commit e90a335c56d1dab9878cd585d27443e1b85c4b20 Author: genxium Date: Tue Sep 20 23:50:01 2022 +0800 Initial commit. diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1578e79 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +* text=auto +* core.ignorecase=false diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d3d839f --- /dev/null +++ b/.gitignore @@ -0,0 +1,134 @@ +battle_srv/test_cases/test_cases +battle_srv/test_cases/tests +*.pid +local +local/* +temp +temp/* +*.rdb +*.rdb.meta + +configs +configs/* +battle_srv/server +battle_srv/main +*.sqlite-journal +frontend/assets/plugin_scripts/conf.js +frontend/assets/plugin_scripts/conf.js.meta +frontend/library +frontend/library/* +.skeema + +*.exe +*.zip + +# logrotate status file +*.status + +# mongodb backup +*.mongobak + +# vim +# +*.sw* + +# OSX +# +.DS_Store +*/.DS_Store +__MACOSX + +# Xcode +# +build/ +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata +*.xccheckout +*.moved-aside +DerivedData +*.hmap +*.ipa +*.xcuserstate +project.xcworkspace + +# Android/IJ +# +*.iml +.idea +.idea/* +android/local.properties +android/build +android/build/* +android/.gradle +android/.gradle/* + +# iOS +# +ios/build +ios/build/* + +# node +# +node_modules/ +./frontend/node_modules/ + +# BUCK +buck-out/ +\.buckd/ +android/app/libs +android/keystores/debug.keystore + +# local logs +*.log +*.log.* + +# crash log +core + +# webpack +frontend/bin + +# Docs +docs +docs/* + +# database data +database/all_data*.sql + +# General asymmetric key files +*.pem + +# Skeema +.skeema +latest_diff_between_live_and_expected_schema.sql + +# nohup.out +*.out +*.pcap + +out +out/* + +*.iml +.gradle +*/.gradle +*/.gradle/* +*/gradle/* +*/build +*/build/* +*/target +*/target/* +*.swp +gradle +gradle/* +*.classpath +*.project + +*~ diff --git a/README.md b/README.md new file mode 100644 index 0000000..47073f9 --- /dev/null +++ b/README.md @@ -0,0 +1,53 @@ +# 0. Preface +If you'd like to play with the backend code seriously, please read the detailed explanation of its important "lifecycle events" in [this note](https://app.yinxiang.com/fx/5c575124-01db-419b-9c02-ec81f78c6ddc). + +There could be some left over wechat-game related code pieces, but they're neither meant to work nor supported anymore. + +# 1. Database Server + +The database product to be used for this project is MySQL 5.7. + +We use [skeema](https://github.com/skeema/skeema) for schematic synchronization under `/database/skeema-repo-root/` which intentionally doesn't contain a `.skeema` file. Please read [this tutorial](https://shimo.im/doc/wQ0LvB0rlZcbHF5V) for more information. + +You can use [this node module (still under development)](https://github.com/genxium/node-mysqldiff-bridge) instead under `Windows10`, other versions of Windows are not yet tested for compatibility. + +The following command(s) +``` +### Optional. +user@proj-root/database/skeema-repo-root> cp .skeema.template .skeema + +### +user@proj-root/database/skeema-repo-root> skeema diff +``` +is recommended to be used for checking difference from your "live MySQL server" to the latest expected schema tracked in git. + +# 2. Building & running + +## 2.1 Golang1.11 +See https://github.com/genxium/Go111ModulePrac for details. + +## 2.2 MySQL +On a product machine, you can install and manage `MySQL` server by [these scripts](https://github.com/genxium/Ubuntu14InitScripts/tree/master/database/mysql). + +## 2.3 Required Config Files + +### 2.3.1 Backend +- It needs `/battle_srv/configs/*` which is generated by `cd /battle_srv && cp -r ./configs.template ./configs` and necessary customization. + +### 2.3.2 Frontend +- It needs CocosCreator v2.2.1 to build. +- A required "CocosCreator plugin `i18n`" is already enclosed in the project, if you have a globally installed "CocosCreator plugin `i18n`"(often located at `$HOME/.CocosCreator/packages/`) they should be OK to co-exist. +- It needs `/frontend/assets/plugin_scripts/conf.js` which is generated by `cd /frontend/assets/plugin_scripts && cp conf.js.template conf.js`. + +## 2.4 Troubleshooting + +### 2.4.1 Redis snapshot writing failure +``` +ErrFatal {"err": "MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error."} +``` + +Just restart your `redis-server` process. + +# 3. Git configs cautions + +Please make sure that you've set `ignorecase = false` in your `[core] section of /.git/config`. diff --git a/battle_srv/Makefile b/battle_srv/Makefile new file mode 100644 index 0000000..925f43e --- /dev/null +++ b/battle_srv/Makefile @@ -0,0 +1,32 @@ +PROJECTNAME=server.exe +ROOT_DIR=. +all: help + +gen-constants: + gojson -pkg common -name constants -input common/constants.json -o common/constants_struct.go + sed -i 's/int64/int/g' common/constants_struct.go + +run-test: build + ServerEnv=TEST ./$(PROJECTNAME) + +run-test-and-hotreload: + ServerEnv=TEST CompileDaemon -log-prefix=false -build="go build" -command="./$(PROJECTNAME)" + +build: + go build -o $(ROOT_DIR)/$(PROJECTNAME) + +run-prod: build-prod + ./$(PROJECTNAME) + +build-prod: + go build -ldflags "-s -w -X main.VERSION=$(shell git rev-parse --short HEAD)-$(shell date "+%Y%m%d-%H:%M:%S")" -o $(ROOT_DIR)/$(PROJECTNAME) + +.PHONY: help + +help: Makefile + @echo + @echo " Choose a command run:" + @echo + @sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /' + @echo + diff --git a/battle_srv/api/req_logger.go b/battle_srv/api/req_logger.go new file mode 100644 index 0000000..517bace --- /dev/null +++ b/battle_srv/api/req_logger.go @@ -0,0 +1,32 @@ +package api + +import ( + "bytes" + "github.com/gin-gonic/gin" + "io" + "io/ioutil" + . "server/common" +) + +func RequestLogger() gin.HandlerFunc { + return func(c *gin.Context) { + buf, _ := ioutil.ReadAll(c.Request.Body) + rdr1 := ioutil.NopCloser(bytes.NewBuffer(buf)) + rdr2 := ioutil.NopCloser(bytes.NewBuffer(buf)) // We have to create a new Buffer, because rdr1 will be read. + + if s := readBody(rdr1); s != "" { + Logger.Debug(s) // Print the request body. + } + + c.Request.Body = rdr2 + c.Next() + } +} + +func readBody(reader io.Reader) string { + buf := new(bytes.Buffer) + buf.ReadFrom(reader) + + s := buf.String() + return s +} diff --git a/battle_srv/api/signal.go b/battle_srv/api/signal.go new file mode 100644 index 0000000..bea83ed --- /dev/null +++ b/battle_srv/api/signal.go @@ -0,0 +1,27 @@ +package api + +import ( + "github.com/gin-gonic/gin" + "net/http" +) + +const RET = "ret" +const PLAYER_ID = "playerId" +const TARGET_PLAYER_ID = "targetPlayerId" +const TOKEN = "token" + +func CErr(c *gin.Context, err error) { + if err != nil { + c.Error(err) + } +} + +func HandleRet() gin.HandlerFunc { + return func(c *gin.Context) { + c.Next() + ret := c.GetInt("ret") + if ret != 0 { + c.JSON(http.StatusOK, gin.H{"ret": ret}) + } + } +} diff --git a/battle_srv/api/v1/player.go b/battle_srv/api/v1/player.go new file mode 100644 index 0000000..9089c9f --- /dev/null +++ b/battle_srv/api/v1/player.go @@ -0,0 +1,723 @@ +package v1 + +import ( + "bytes" + "crypto/sha256" + "encoding/hex" + "encoding/json" + "github.com/gin-gonic/gin" + "github.com/gin-gonic/gin/binding" + "go.uber.org/zap" + "io/ioutil" + "net/http" + "server/api" + . "server/common" + "server/common/utils" + "server/models" + "server/storage" + "strconv" +) + +var Player = playerController{} + +type playerController struct { +} + +type smsCaptchaReq struct { + Num string `json:"phoneNum,omitempty" form:"phoneNum"` + CountryCode string `json:"phoneCountryCode,omitempty" form:"phoneCountryCode"` + Captcha string `json:"smsLoginCaptcha,omitempty" form:"smsLoginCaptcha"` +} + +func (req *smsCaptchaReq) extAuthID() string { + return req.CountryCode + req.Num +} +func (req *smsCaptchaReq) redisKey() string { + return "/cuisine/sms/captcha/" + req.extAuthID() +} + +type wechatShareConfigReq struct { + Url string `form:"url"` +} + +func (p *playerController) GetWechatShareConfig(c *gin.Context) { + var req wechatShareConfigReq + err := c.ShouldBindWith(&req, binding.FormPost) + api.CErr(c, err) + if err != nil || req.Url == "" { + c.Set(api.RET, Constants.RetCode.InvalidRequestParam) + return + } + config, err := utils.WechatIns.GetJsConfig(req.Url) + if err != nil { + Logger.Info("err", zap.Any("", err)) + c.Set(api.RET, Constants.RetCode.WechatServerError) + return + } + resp := struct { + Ret int `json:"ret"` + Config *utils.JsConfig `json:"jsConfig"` + }{Constants.RetCode.Ok, config} + c.JSON(http.StatusOK, resp) +} + +func (p *playerController) SMSCaptchaGet(c *gin.Context) { + var req smsCaptchaReq + err := c.ShouldBindQuery(&req) + api.CErr(c, err) + if err != nil || req.Num == "" || req.CountryCode == "" { + c.Set(api.RET, Constants.RetCode.InvalidRequestParam) + return + } + // Composite a key to access against Redis-server. + redisKey := req.redisKey() + ttl, err := storage.RedisManagerIns.TTL(redisKey).Result() + api.CErr(c, err) + if err != nil { + c.Set(api.RET, Constants.RetCode.UnknownError) + return + } + // Redis剩余时长校验 + if ttl >= ConstVals.Player.CaptchaMaxTTL { + Logger.Info("There's an existing SmsCaptcha record in Redis-server: ", zap.String("key", redisKey), zap.Duration("ttl", ttl)) + c.Set(api.RET, Constants.RetCode.SmsCaptchaRequestedTooFrequently) + return + } + Logger.Info("A new SmsCaptcha record is needed for: ", zap.String("key", redisKey)) + pass := false + var succRet int + if Conf.General.ServerEnv == SERVER_ENV_TEST { + // 测试环境,优先从数据库校验`player.name`,不通过再走机器人magic name校验 + player, err := models.GetPlayerByName(req.Num) + if nil == err && nil != player { + pass = true + succRet = Constants.RetCode.IsTestAcc + } + } + + if !pass { + // 机器人magic name校验,不通过再走手机号校验 + player, err := models.GetPlayerByName(req.Num) + if nil == err && nil != player { + pass = true + succRet = Constants.RetCode.IsBotAcc + } + } + + if !pass { + if RE_PHONE_NUM.MatchString(req.Num) { + succRet = Constants.RetCode.Ok + pass = true + } + // Hardecoded 只验证国内手机号格式 + if req.CountryCode == "86" { + if RE_CHINA_PHONE_NUM.MatchString(req.Num) { + succRet = Constants.RetCode.Ok + pass = true + } else { + succRet = Constants.RetCode.InvalidRequestParam + pass = false + } + } + } + if !pass { + c.Set(api.RET, Constants.RetCode.InvalidRequestParam) + return + } + resp := struct { + Ret int `json:"ret"` + smsCaptchaReq + GetSmsCaptchaRespErrorCode int `json:"getSmsCaptchaRespErrorCode"` + }{Ret: succRet} + var captcha string + if ttl >= 0 { + // 已有未过期的旧验证码记录,续验证码有效期。 + storage.RedisManagerIns.Expire(redisKey, ConstVals.Player.CaptchaExpire) + captcha = storage.RedisManagerIns.Get(redisKey).Val() + if ttl >= ConstVals.Player.CaptchaExpire/4 { + if succRet == Constants.RetCode.Ok { + getSmsCaptchaRespErrorCode := sendSMSViaVendor(req.Num, req.CountryCode, captcha) + if getSmsCaptchaRespErrorCode != 0 { + resp.Ret = Constants.RetCode.GetSmsCaptchaRespErrorCode + resp.GetSmsCaptchaRespErrorCode = getSmsCaptchaRespErrorCode + } + } + } + Logger.Info("Extended ttl of existing SMSCaptcha record in Redis:", zap.String("key", redisKey), zap.String("captcha", captcha)) + } else { + // 校验通过,进行验证码生成处理 + captcha = strconv.Itoa(utils.Rand.Number(1000, 9999)) + if succRet == Constants.RetCode.Ok { + getSmsCaptchaRespErrorCode := sendSMSViaVendor(req.Num, req.CountryCode, captcha) + if getSmsCaptchaRespErrorCode != 0 { + resp.Ret = Constants.RetCode.GetSmsCaptchaRespErrorCode + resp.GetSmsCaptchaRespErrorCode = getSmsCaptchaRespErrorCode + } + } + storage.RedisManagerIns.Set(redisKey, captcha, ConstVals.Player.CaptchaExpire) + Logger.Info("Generated new captcha", zap.String("key", redisKey), zap.String("captcha", captcha)) + } + if succRet == Constants.RetCode.IsTestAcc { + resp.Captcha = captcha + } + if succRet == Constants.RetCode.IsBotAcc { + resp.Captcha = captcha + } + c.JSON(http.StatusOK, resp) +} + +func (p *playerController) SMSCaptchaLogin(c *gin.Context) { + var req smsCaptchaReq + err := c.ShouldBindWith(&req, binding.FormPost) + api.CErr(c, err) + if err != nil || req.Num == "" || req.CountryCode == "" || req.Captcha == "" { + c.Set(api.RET, Constants.RetCode.InvalidRequestParam) + return + } + + redisKey := req.redisKey() + captcha := storage.RedisManagerIns.Get(redisKey).Val() + Logger.Info("Comparing captchas", zap.String("key", redisKey), zap.String("whats-in-redis", captcha), zap.String("whats-from-req", req.Captcha)) + if captcha != req.Captcha { + c.Set(api.RET, Constants.RetCode.SmsCaptchaNotMatch) + return + } + + player, err := p.maybeCreateNewPlayer(req) + api.CErr(c, err) + if err != nil { + c.Set(api.RET, Constants.RetCode.MysqlError) + return + } + now := utils.UnixtimeMilli() + token := utils.TokenGenerator(32) + expiresAt := now + 1000*int64(Constants.Player.IntAuthTokenTTLSeconds) + playerLogin := models.PlayerLogin{ + CreatedAt: now, + FromPublicIP: models.NewNullString(c.ClientIP()), + IntAuthToken: token, + PlayerID: int(player.Id), + DisplayName: models.NewNullString(player.DisplayName), + UpdatedAt: now, + } + err = playerLogin.Insert() + api.CErr(c, err) + if err != nil { + c.Set(api.RET, Constants.RetCode.MysqlError) + return + } + storage.RedisManagerIns.Del(redisKey) + resp := struct { + Ret int `json:"ret"` + Token string `json:"intAuthToken"` + ExpiresAt int64 `json:"expiresAt"` + PlayerID int `json:"playerId"` + DisplayName string `json:"displayName"` + Name string `json:"name"` + }{Constants.RetCode.Ok, token, expiresAt, int(player.Id), player.DisplayName, player.Name} + + c.JSON(http.StatusOK, resp) +} + +type wechatLogin struct { + Authcode string `form:"code"` +} + +func (p *playerController) WechatLogin(c *gin.Context) { + var req wechatLogin + err := c.ShouldBindWith(&req, binding.FormPost) + api.CErr(c, err) + if err != nil || req.Authcode == "" { + c.Set(api.RET, Constants.RetCode.InvalidRequestParam) + return + } + + //baseInfo ResAccessToken 获取用户授权access_token的返回结果 + baseInfo, err := utils.WechatIns.GetOauth2Basic(req.Authcode) + + if err != nil { + Logger.Info("err", zap.Any("", err)) + c.Set(api.RET, Constants.RetCode.WechatServerError) + return + } + + userInfo, err := utils.WechatIns.GetMoreInfo(baseInfo.AccessToken, baseInfo.OpenID) + + if err != nil { + Logger.Info("err", zap.Any("", err)) + c.Set(api.RET, Constants.RetCode.WechatServerError) + return + } + //fserver不会返回openId + userInfo.OpenID = baseInfo.OpenID + + player, err := p.maybeCreatePlayerWechatAuthBinding(userInfo) + api.CErr(c, err) + if err != nil { + c.Set(api.RET, Constants.RetCode.MysqlError) + return + } + + now := utils.UnixtimeMilli() + token := utils.TokenGenerator(32) + expiresAt := now + 1000*int64(Constants.Player.IntAuthTokenTTLSeconds) + playerLogin := models.PlayerLogin{ + CreatedAt: now, + FromPublicIP: models.NewNullString(c.ClientIP()), + IntAuthToken: token, + PlayerID: int(player.Id), + DisplayName: models.NewNullString(player.DisplayName), + UpdatedAt: now, + Avatar: userInfo.HeadImgURL, + } + err = playerLogin.Insert() + api.CErr(c, err) + if err != nil { + c.Set(api.RET, Constants.RetCode.MysqlError) + return + } + + resp := struct { + Ret int `json:"ret"` + Token string `json:"intAuthToken"` + ExpiresAt int64 `json:"expiresAt"` + PlayerID int `json:"playerId"` + DisplayName models.NullString `json:"displayName"` + Avatar string `json:"avatar"` + }{ + Constants.RetCode.Ok, + token, expiresAt, + playerLogin.PlayerID, + playerLogin.DisplayName, + userInfo.HeadImgURL, + } + c.JSON(http.StatusOK, resp) +} + +type wechatGameLogin struct { + Authcode string `form:"code"` + AvatarUrl string `form:"avatarUrl"` + NickName string `form:"nickName"` +} + +func (p *playerController) WechatGameLogin(c *gin.Context) { + var req wechatGameLogin + err := c.ShouldBindWith(&req, binding.FormPost) + if nil != err { + Logger.Error("WechatGameLogin got an invalid request param error", zap.Error(err)) + c.Set(api.RET, Constants.RetCode.InvalidRequestParam) + return + } + if "" == req.Authcode { + Logger.Warn("WechatGameLogin got an invalid request param", zap.Any("req", req)) + c.Set(api.RET, Constants.RetCode.InvalidRequestParam) + return + } + + //baseInfo ResAccessToken 获取用户授权access_token的返回结果 + baseInfo, err := utils.WechatGameIns.GetOauth2Basic(req.Authcode) + + if err != nil { + Logger.Info("err", zap.Any("", err)) + c.Set(api.RET, Constants.RetCode.WechatServerError) + return + } + + Logger.Info("baseInfo", zap.Any(":", baseInfo)) + //crate new userInfo from client userInfo + userInfo := utils.UserInfo{ + Nickname: req.NickName, + HeadImgURL: req.AvatarUrl, + } + + if err != nil { + Logger.Info("err", zap.Any("", err)) + c.Set(api.RET, Constants.RetCode.WechatServerError) + return + } + //fserver不会返回openId + userInfo.OpenID = baseInfo.OpenID + + player, err := p.maybeCreatePlayerWechatGameAuthBinding(userInfo) + api.CErr(c, err) + if err != nil { + c.Set(api.RET, Constants.RetCode.MysqlError) + return + } + + now := utils.UnixtimeMilli() + token := utils.TokenGenerator(32) + expiresAt := now + 1000*int64(Constants.Player.IntAuthTokenTTLSeconds) + playerLogin := models.PlayerLogin{ + CreatedAt: now, + FromPublicIP: models.NewNullString(c.ClientIP()), + IntAuthToken: token, + PlayerID: int(player.Id), + DisplayName: models.NewNullString(player.DisplayName), + UpdatedAt: now, + Avatar: userInfo.HeadImgURL, + } + err = playerLogin.Insert() + api.CErr(c, err) + if err != nil { + c.Set(api.RET, Constants.RetCode.MysqlError) + return + } + + resp := struct { + Ret int `json:"ret"` + Token string `json:"intAuthToken"` + ExpiresAt int64 `json:"expiresAt"` + PlayerID int `json:"playerId"` + DisplayName models.NullString `json:"displayName"` + Avatar string `json:"avatar"` + }{ + Constants.RetCode.Ok, + token, expiresAt, + playerLogin.PlayerID, + playerLogin.DisplayName, + userInfo.HeadImgURL, + } + c.JSON(http.StatusOK, resp) +} + +func (p *playerController) IntAuthTokenLogin(c *gin.Context) { + token := p.getIntAuthToken(c) + if "" == token { + return + } + playerLogin, err := models.GetPlayerLoginByToken(token) + api.CErr(c, err) + if err != nil || playerLogin == nil { + c.Set(api.RET, Constants.RetCode.InvalidToken) + return + } + + //kobako: 从player获取display name等 + player, err := models.GetPlayerById(playerLogin.PlayerID) + if err != nil { + Logger.Error("Get player by id in IntAuthTokenLogin function error: ", zap.Error(err)) + return + } + + expiresAt := playerLogin.UpdatedAt + 1000*int64(Constants.Player.IntAuthTokenTTLSeconds) + resp := struct { + Ret int `json:"ret"` + Token string `json:"intAuthToken"` + ExpiresAt int64 `json:"expiresAt"` + PlayerID int `json:"playerId"` + DisplayName string `json:"displayName"` + Avatar string `json:"avatar"` + Name string `json:"name"` + }{Constants.RetCode.Ok, token, expiresAt, + playerLogin.PlayerID, player.DisplayName, + playerLogin.Avatar, player.Name, + } + c.JSON(http.StatusOK, resp) +} + +func (p *playerController) IntAuthTokenLogout(c *gin.Context) { + token := p.getIntAuthToken(c) + if "" == token { + return + } + err := models.DelPlayerLoginByToken(token) + api.CErr(c, err) + if err != nil { + c.Set(api.RET, Constants.RetCode.UnknownError) + return + } + c.Set(api.RET, Constants.RetCode.Ok) +} + +func (p *playerController) FetchProfile(c *gin.Context) { + targetPlayerId := c.GetInt(api.TARGET_PLAYER_ID) + wallet, err := models.GetPlayerWalletById(targetPlayerId) + if err != nil { + api.CErr(c, err) + c.Set(api.RET, Constants.RetCode.MysqlError) + return + } + player, err := models.GetPlayerById(targetPlayerId) + if err != nil { + api.CErr(c, err) + c.Set(api.RET, Constants.RetCode.MysqlError) + return + } + if wallet == nil || player == nil { + c.Set(api.RET, Constants.RetCode.InvalidRequestParam) + return + } + resp := struct { + Ret int `json:"ret"` + TutorialStage int `json:"tutorialStage"` + Wallet *models.PlayerWallet `json:"wallet"` + }{Constants.RetCode.Ok, player.TutorialStage, wallet} + c.JSON(http.StatusOK, resp) +} + +func (p *playerController) TokenAuth(c *gin.Context) { + var req struct { + Token string `form:"intAuthToken"` + TargetPlayerId int `form:"targetPlayerId"` + } + err := c.ShouldBindWith(&req, binding.FormPost) + if err == nil { + playerLogin, err := models.GetPlayerLoginByToken(req.Token) + api.CErr(c, err) + if err == nil && playerLogin != nil { + c.Set(api.PLAYER_ID, playerLogin.PlayerID) + c.Set(api.TARGET_PLAYER_ID, req.TargetPlayerId) + c.Next() + return + } + } + Logger.Debug("TokenAuth Failed", zap.String("token", req.Token)) + c.Set(api.RET, Constants.RetCode.InvalidToken) + c.Abort() +} + +// 以下是内部私有函数 +func (p *playerController) maybeCreateNewPlayer(req smsCaptchaReq) (*models.Player, error) { + extAuthID := req.extAuthID() + if Conf.General.ServerEnv == SERVER_ENV_TEST { + player, err := models.GetPlayerByName(req.Num) + if err != nil { + Logger.Error("Seeking test env player error:", zap.Error(err)) + return nil, err + } + if player != nil { + Logger.Info("Got a test env player:", zap.Any("phonenum", req.Num), zap.Any("playerId", player.Id)) + return player, nil + } + } else { //正式环境检查是否为bot用户 + botPlayer, err := models.GetPlayerByName(req.Num) + if err != nil { + Logger.Error("Seeking bot player error:", zap.Error(err)) + return nil, err + } + if botPlayer != nil { + Logger.Info("Got a bot player:", zap.Any("phonenum", req.Num), zap.Any("playerId", botPlayer.Id)) + return botPlayer, nil + } + } + + bind, err := models.GetPlayerAuthBinding(Constants.AuthChannel.Sms, extAuthID) + if err != nil { + return nil, err + } + if bind != nil { + player, err := models.GetPlayerById(bind.PlayerID) + if err != nil { + return nil, err + } + if player != nil { + return player, nil + } + } + now := utils.UnixtimeMilli() + player := models.Player{ + CreatedAt: now, + UpdatedAt: now, + } + return p.createNewPlayer(player, extAuthID, int(Constants.AuthChannel.Sms)) + +} + +func (p *playerController) maybeCreatePlayerWechatAuthBinding(userInfo utils.UserInfo) (*models.Player, error) { + bind, err := models.GetPlayerAuthBinding(Constants.AuthChannel.Wechat, userInfo.OpenID) + if err != nil { + return nil, err + } + if bind != nil { + player, err := models.GetPlayerById(bind.PlayerID) + if err != nil { + return nil, err + } + if player != nil { + { //更新玩家姓名及头像 + updateInfo := models.Player{ + Avatar: userInfo.HeadImgURL, + DisplayName: userInfo.Nickname, + } + tx := storage.MySQLManagerIns.MustBegin() + defer tx.Rollback() + ok, err := models.Update(tx, player.Id, &updateInfo) + if err != nil && ok != true { + return nil, err + } else { + tx.Commit() + } + } + return player, nil + } + } + now := utils.UnixtimeMilli() + player := models.Player{ + CreatedAt: now, + UpdatedAt: now, + DisplayName: userInfo.Nickname, + Avatar: userInfo.HeadImgURL, + } + return p.createNewPlayer(player, userInfo.OpenID, int(Constants.AuthChannel.Wechat)) +} + +func (p *playerController) maybeCreatePlayerWechatGameAuthBinding(userInfo utils.UserInfo) (*models.Player, error) { + bind, err := models.GetPlayerAuthBinding(Constants.AuthChannel.WechatGame, userInfo.OpenID) + if err != nil { + return nil, err + } + if bind != nil { + player, err := models.GetPlayerById(bind.PlayerID) + if err != nil { + return nil, err + } + if player != nil { + { //更新玩家姓名及头像 + updateInfo := models.Player{ + Avatar: userInfo.HeadImgURL, + DisplayName: userInfo.Nickname, + } + tx := storage.MySQLManagerIns.MustBegin() + defer tx.Rollback() + ok, err := models.Update(tx, player.Id, &updateInfo) + if err != nil && ok != true { + return nil, err + } else { + tx.Commit() + } + } + return player, nil + } + } + now := utils.UnixtimeMilli() + player := models.Player{ + CreatedAt: now, + UpdatedAt: now, + DisplayName: userInfo.Nickname, + Avatar: userInfo.HeadImgURL, + } + return p.createNewPlayer(player, userInfo.OpenID, int(Constants.AuthChannel.WechatGame)) +} + +func (p *playerController) createNewPlayer(player models.Player, extAuthID string, channel int) (*models.Player, error) { + Logger.Debug("createNewPlayer", zap.String("extAuthID", extAuthID)) + now := utils.UnixtimeMilli() + tx := storage.MySQLManagerIns.MustBegin() + defer tx.Rollback() + err := player.Insert(tx) + if err != nil { + return nil, err + } + playerAuthBinding := models.PlayerAuthBinding{ + CreatedAt: now, + UpdatedAt: now, + Channel: channel, + ExtAuthID: extAuthID, + PlayerID: int(player.Id), + } + err = playerAuthBinding.Insert(tx) + if err != nil { + return nil, err + } + wallet := models.PlayerWallet{ + CreatedAt: now, + UpdatedAt: now, + ID: int(player.Id), + } + err = wallet.Insert(tx) + if err != nil { + return nil, err + } + tx.Commit() + return &player, nil +} + +type intAuthTokenReq struct { + Token string `form:"intAuthToken,omitempty"` +} + +func (p *playerController) getIntAuthToken(c *gin.Context) string { + var req intAuthTokenReq + err := c.ShouldBindWith(&req, binding.FormPost) + api.CErr(c, err) + if err != nil || "" == req.Token { + c.Set(api.RET, Constants.RetCode.InvalidRequestParam) + return "" + } + return req.Token +} + +type tel struct { + Mobile string `json:"mobile"` + Nationcode string `json:"nationcode"` +} + +type captchaReq struct { + Ext string `json:"ext"` + Extend string `json:"extend"` + Params *[2]string `json:"params"` + Sig string `json:"sig"` + Sign string `json:"sign"` + Tel *tel `json:"tel"` + Time int64 `json:"time"` + Tpl_id int `json:"tpl_id"` +} + +func sendSMSViaVendor(mobile string, nationcode string, captchaCode string) int { + tel := &tel{ + Mobile: mobile, + Nationcode: nationcode, + } + var captchaExpireMin string + //短信有效期hardcode + if Conf.General.ServerEnv == SERVER_ENV_TEST { + //测试环境下有效期为20秒 先hardcode了 + captchaExpireMin = "0.5" + } else { + captchaExpireMin = strconv.Itoa(int(ConstVals.Player.CaptchaExpire) / 60000000000) + } + params := [2]string{captchaCode, captchaExpireMin} + appkey := "41a5142feff0b38ade02ea12deee9741" // TODO: Should read from config file! + rand := strconv.Itoa(utils.Rand.Number(1000, 9999)) + now := utils.UnixtimeSec() + + hash := sha256.New() + hash.Write([]byte("appkey=" + appkey + "&random=" + rand + "&time=" + strconv.FormatInt(now, 10) + "&mobile=" + mobile)) + md := hash.Sum(nil) + sig := hex.EncodeToString(md) + + reqData := &captchaReq{ + Ext: "", + Extend: "", + Params: ¶ms, + Sig: sig, + Sign: "洛克互娱", + Tel: tel, + Time: now, + Tpl_id: 207399, + } + reqDataString, err := json.Marshal(reqData) + req := bytes.NewBuffer([]byte(reqDataString)) + if err != nil { + Logger.Info("json marshal", zap.Any("err:", err)) + return -1 + } + resp, err := http.Post("https://yun.tim.qq.com/v5/tlssmssvr/sendsms?sdkappid=1400150185&random="+rand, + "application/json", + req) + if err != nil { + Logger.Info("resp", zap.Any("err:", err)) + } + defer resp.Body.Close() + respBody, err := ioutil.ReadAll(resp.Body) + if err != nil { + Logger.Info("body", zap.Any("response body err:", err)) + } + type bodyStruct struct { + Result int `json:"result"` + } + var body bodyStruct + json.Unmarshal(respBody, &body) + return body.Result +} diff --git a/battle_srv/api/v1/player_test.go b/battle_srv/api/v1/player_test.go new file mode 100644 index 0000000..4d8b153 --- /dev/null +++ b/battle_srv/api/v1/player_test.go @@ -0,0 +1,144 @@ +package v1 + +import ( + "encoding/json" + "net/http" + "net/url" + . "server/common" + "testing" + "time" + + "github.com/hashicorp/go-cleanhttp" + "github.com/jmoiron/sqlx" + _ "github.com/mattn/go-sqlite3" +) + +var httpClient = cleanhttp.DefaultPooledClient() + +func fakeSMSCaptchReq(num string) smsCaptchReq { + if num == "" { + num = "15625296200" + } + return smsCaptchReq{ + Num: num, + CountryCode: "086", + } +} + +type dbTestPlayer struct { + Name string `db:"name"` + MagicPhoneCountryCode string `db:"magic_phone_country_code"` + MagicPhoneNum string `db:"magic_phone_num"` +} + +type smsCaptchaGetResp struct { + Ret int `json:"ret"` + Captcha string `json:"smsLoginCaptcha"` +} + +func init() { + MustParseConfig() + MustParseConstants() +} + +// 添加ServerEnv=TEST可以缩减sleep时间 +// battle_srv$ ServerEnv=TEST go test --count=1 -v server/api/v1 -run SMSCaptchaGet* + +func Test_SMSCaptchaGet_frequentlyAndValidSend(t *testing.T) { + req := fakeSMSCaptchReq("") + resp := mustDoSmsCaptchaGetReq(req, t) + if resp.Ret != Constants.RetCode.Ok { + t.Fail() + } + time.Sleep(time.Second * 1) + resp = mustDoSmsCaptchaGetReq(req, t) + if resp.Ret != Constants.RetCode.SmsCaptchaRequestedTooFrequently { + t.Fail() + } + t.Log("Sleep in a period of sms valid resend seconds") + period := Constants.Player.SmsValidResendPeriodSeconds + time.Sleep(time.Duration(period) * time.Second) + t.Log("Sleep finished") + resp = mustDoSmsCaptchaGetReq(req, t) + if resp.Ret != Constants.RetCode.Ok { + t.Fail() + } +} + +func Test_SMSCaptchaGet_illegalPhone(t *testing.T) { + resp := mustDoSmsCaptchaGetReq(fakeSMSCaptchReq("fake"), t) + if resp.Ret != Constants.RetCode.InvalidRequestParam { + t.Fail() + } +} + +func Test_SMSCaptchaGet_testAcc(t *testing.T) { + player, err := getTestPlayer() + if err == nil && player != nil { + resp := mustDoSmsCaptchaGetReq(fakeSMSCaptchReq(player.Name), t) + if resp.Ret != Constants.RetCode.IsTestAcc { + t.Fail() + } + } else { + t.Skip("请准备test_env.sqlite和先插入测试用户数据") + } +} + +func Test_SMSCaptchaGet_expired(t *testing.T) { + req := fakeSMSCaptchReq("") + resp := mustDoSmsCaptchaGetReq(req, t) + if resp.Ret != Constants.RetCode.Ok { + t.Fail() + } + + t.Log("Sleep in a period of sms expired seconds") + period := Constants.Player.SmsExpiredSeconds + time.Sleep(time.Duration(period) * time.Second) + t.Log("Sleep finished") + + req = fakeSMSCaptchReq("") + resp = mustDoSmsCaptchaGetReq(req, t) + if resp.Ret != Constants.RetCode.Ok { + t.Fail() + } +} + +func mustDoSmsCaptchaGetReq(req smsCaptchReq, t *testing.T) smsCaptchaGetResp { + api := "http://localhost:9992/api/player/v1/SmsCaptcha/get?" + parameters := url.Values{} + parameters.Add("phoneNum", req.Num) + parameters.Add("phoneCountryCode", req.CountryCode) + resp, err := httpClient.Get(api + parameters.Encode()) + if resp != nil { + defer resp.Body.Close() + } + if err != nil { + t.Error("mustDoSmsCaptchaGetReq http err", err) + t.FailNow() + } + if resp.StatusCode != http.StatusOK { + t.Error("code!=200, resp code", resp.StatusCode) + t.FailNow() + } + var respJson smsCaptchaGetResp + err = json.NewDecoder(resp.Body).Decode(&respJson) + if err != nil { + t.Error("mustDoSmsCaptchaGetReq json decode err", err) + t.FailNow() + } + return respJson +} + +func getTestPlayer() (*dbTestPlayer, error) { + db, err := sqlx.Connect("sqlite3", Conf.General.TestEnvSQLitePath) + if err != nil { + return nil, err + } + defer db.Close() + p := new(dbTestPlayer) + err = db.Get(p, "SELECT name, magic_phone_country_code, magic_phone_num FROM test_player limit 1") + if err != nil { + return nil, err + } + return p, err +} diff --git a/battle_srv/check_daemon.sh b/battle_srv/check_daemon.sh new file mode 100644 index 0000000..4638a70 --- /dev/null +++ b/battle_srv/check_daemon.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +basedir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) + +PID_FILE="$basedir/treasure-hunter.pid" +if [ -f $PID_FILE ]; then + pid=$( cat "$PID_FILE" ) + if [ -z $pid ]; then + echo "There's no pid stored in $PID_FILE." + else + ps aux | grep "$pid" + fi +else + echo "There's no PidFile $PID_FILE." +fi diff --git a/battle_srv/common/conf.go b/battle_srv/common/conf.go new file mode 100644 index 0000000..55c4bef --- /dev/null +++ b/battle_srv/common/conf.go @@ -0,0 +1,155 @@ +package common + +import ( + "encoding/json" + "fmt" + "os" + "path/filepath" + "strings" + + "go.uber.org/zap" +) + +// 隐式导入 +var Conf *config + +const ( + APP_NAME = "server" + SERVER_ENV_PROD = "PROD" + SERVER_ENV_TEST = "TEST" +) + +type generalConf struct { + AppRoot string `json:"-"` + ConfDir string `json:"-"` + TestEnvSQLitePath string `json:"-"` + PreConfSQLitePath string `json:"-"` + ServerEnv string `json:"-"` +} + +type mysqlConf struct { + DSN string `json:"-"` + Host string `json:"host"` + Port int `json:"port"` + Dbname string `json:"dbname"` + Username string `json:"username"` + Password string `json:"password"` +} + +type sioConf struct { + HostAndPort string `json:"hostAndPort"` +} + +type botServerConf struct { + SecondsBeforeSummoning int `json:"secondsBeforeSummoning"` + Protocol string `json:"protocol"` + Host string `json:"host"` + Port int `json:"port"` + SymmetricKey string `json:"symmetricKey"` +} + +type redisConf struct { + Dbname int `json:"dbname"` + Host string `json:"host"` + Password string `json:"password"` + Port int `json:"port"` +} + +type config struct { + General *generalConf + MySQL *mysqlConf + Sio *sioConf + Redis *redisConf + BotServer *botServerConf +} + +func MustParseConfig() { + Conf = &config{ + General: new(generalConf), + MySQL: new(mysqlConf), + Sio: new(sioConf), + Redis: new(redisConf), + BotServer: new(botServerConf), + } + execPath, err := os.Executable() + ErrFatal(err) + + pwd, err := os.Getwd() + Logger.Debug("os.GetWd", zap.String("pwd", pwd)) + ErrFatal(err) + + appRoot := pwd + confDir := filepath.Join(appRoot, "configs") + Logger.Debug("conf", zap.String("dir", confDir)) + if isNotExist(confDir) { + appRoot = filepath.Dir(execPath) + confDir = filepath.Join(appRoot, "configs") + Logger.Debug("conf", zap.String("dir", confDir)) + if isNotExist(confDir) { + i := strings.LastIndex(pwd, "battle_srv") + if i == -1 { + Logger.Fatal("无法找到配置目录,cp -rn configs.template configs,并配置相关参数,再启动") + } + appRoot = pwd[:(i + 10)] + confDir = filepath.Join(appRoot, "configs") + Logger.Debug("conf", zap.String("dir", confDir)) + if isNotExist(confDir) { + Logger.Fatal("无法找到配置目录,cp -rn configs.template configs,并配置相关参数,再启动") + } + } + } + Conf.General.AppRoot = appRoot + testEnvSQLitePath := filepath.Join(confDir, "test_env.sqlite") + if !isNotExist(testEnvSQLitePath) { + Conf.General.TestEnvSQLitePath = testEnvSQLitePath + } + preConfSQLitePath := filepath.Join(confDir, "pre_conf_data.sqlite") + if !isNotExist(preConfSQLitePath) { + Conf.General.PreConfSQLitePath = preConfSQLitePath + } + Conf.General.ConfDir = confDir + Conf.General.ServerEnv = os.Getenv("ServerEnv") + + loadJSON("mysql.json", Conf.MySQL) + setMySQLDSNURL(Conf.MySQL) + loadJSON("sio.json", Conf.Sio) + loadJSON("redis.json", Conf.Redis) + loadJSON("bot_server.json", Conf.BotServer) +} + +func setMySQLDSNURL(c *mysqlConf) { + var dsn = fmt.Sprintf("%s:%s@tcp(%s:%d)/%s", + c.Username, c.Password, c.Host, c.Port, c.Dbname) + c.DSN = dsn + +} + +func loadJSON(fp string, v interface{}) { + if !filepath.IsAbs(fp) { + fp = filepath.Join(Conf.General.ConfDir, fp) + } + _, err := os.Stat(fp) + ErrFatal(err) + + fd, err := os.Open(fp) + ErrFatal(err) + defer fd.Close() + Logger.Info("Opened json file successfully.", zap.String("fp", fp)) + err = json.NewDecoder(fd).Decode(v) + ErrFatal(err) + Logger.Info("Loaded json file successfully.", zap.String("fp", fp)) +} + +// Please only use this auxiliary function before server is fully started up, but not afterwards (启动过程可以使用,运行时不准使用). +func ErrFatal(err error) { + if err != nil { + Logger.Fatal("ErrFatal", zap.NamedError("err", err)) + } +} + +func isNotExist(p string) bool { + if _, err := os.Stat(p); err != nil { + return true + } + return false +} diff --git a/battle_srv/common/constants.json b/battle_srv/common/constants.json new file mode 100644 index 0000000..51c4ca0 --- /dev/null +++ b/battle_srv/common/constants.json @@ -0,0 +1,67 @@ +{ + "RET_CODE": { + "__comment__":"基础", + "OK": 9000, + "UNKNOWN_ERROR": 9001, + "INVALID_REQUEST_PARAM": 9002, + "IS_TEST_ACC": 9003, + "MYSQL_ERROR": 9004, + "NONEXISTENT_ACT": 9005, + "LACK_OF_DIAMOND": 9006, + "LACK_OF_GOLD": 9007, + "LACK_OF_ENERGY": 9008, + "NONEXISTENT_ACT_HANDLER": 9009, + "LOCALLY_NO_AVAILABLE_ROOM": 9010, + "LOCALLY_NO_SPECIFIED_ROOM": 9011, + "PLAYER_NOT_ADDABLE_TO_ROOM": 9012, + "PLAYER_NOT_READDABLE_TO_ROOM": 9013, + "PLAYER_NOT_FOUND": 9014, + "PLAYER_CHEATING": 9015, + "WECHAT_SERVER_ERROR": 9016, + "IS_BOT_ACC": 9017, + + "__comment__":"SMS", + "SMS_CAPTCHA_REQUESTED_TOO_FREQUENTLY": 5001, + "SMS_CAPTCHA_NOT_MATCH": 5002, + "INVALID_TOKEN": 2001, + + "DUPLICATED": 2002, + "INCORRECT_HANDLE": 2004, + + "INCORRECT_PASSWORD": 2006, + "INCORRECT_CAPTCHA": 2007, + "INVALID_EMAIL_LITERAL": 2008, + "NO_ASSOCIATED_EMAIL": 2009, + "SEND_EMAIL_TIMEOUT": 2010, + "INCORRECT_PHONE_COUNTRY_CODE": 2011, + "NEW_HANDLE_CONFLICT": 2013, + "FAILED_TO_UPDATE": 2014, + "FAILED_TO_DELETE": 2015, + "FAILED_TO_CREATE": 2016, + "INCORRECT_PHONE_NUMBER": 2018, + "INSUFFICIENT_MEM_TO_ALLOCATE_CONNECTION": 3001, + "PASSWORD_RESET_CODE_GENERATION_PER_EMAIL_TOO_FREQUENTLY": 4000, + "TRADE_CREATION_TOO_FREQUENTLY": 4002, + "MAP_NOT_UNLOCKED": 4003, + + "GET_SMS_CAPTCHA_RESP_ERROR_CODE": 5003, + "NOT_IMPLEMENTED_YET": 65535 + }, + "AUTH_CHANNEL": { + "SMS": 0, + "WECHAT": 1, + "WECHAT_GAME": 2 + }, + "PLAYER": { + "DIAMOND": 1, + "GOLD": 2, + "ENERGY": 3, + "SMS_EXPIRED_SECONDS":120, + "SMS_VALID_RESEND_PERIOD_SECONDS":30, + "INT_AUTH_TOKEN_TTL_SECONDS":604800 + }, + "WS": { + "INTERVAL_TO_PING": 2000, + "WILL_KICK_IF_INACTIVE_FOR": 6000 + } +} diff --git a/battle_srv/common/constants_loader.go b/battle_srv/common/constants_loader.go new file mode 100644 index 0000000..3524cd8 --- /dev/null +++ b/battle_srv/common/constants_loader.go @@ -0,0 +1,38 @@ +package common + +import ( + "path/filepath" + + "github.com/imdario/mergo" + "go.uber.org/zap" +) + +// 隐式导入 +var Constants *constants + +func MustParseConstants() { + fp := filepath.Join(Conf.General.AppRoot, "common/constants.json") + if isNotExist(fp) { + Logger.Fatal("common/constants.json文件不存在") + } + Constants = new(constants) + loadJSON(fp, Constants) + + Logger.Debug("Conf.General.ServerEnv", zap.String("env", Conf.General.ServerEnv)) + if Conf.General.ServerEnv == SERVER_ENV_TEST { + fp = filepath.Join(Conf.General.AppRoot, "common/constants_test.json") + if !isNotExist(fp) { + testConstants := new(constants) + loadJSON(fp, testConstants) + //Logger.Debug(spew.Sdump(Constants)) + //Logger.Debug(spew.Sdump(testConstants)) + err := mergo.Merge(testConstants, Constants) + ErrFatal(err) + Constants = testConstants + //Logger.Debug("mergo.Merge", zap.Error(err)) + //Logger.Debug(spew.Sdump(testConstants)) + } + } + constantsPost() + // Logger.Debug("const", zap.Int("IntAuthTokenTTLSeconds", Constants.Player.IntAuthTokenTTLSeconds)) +} diff --git a/battle_srv/common/constants_struct.go b/battle_srv/common/constants_struct.go new file mode 100644 index 0000000..570e26b --- /dev/null +++ b/battle_srv/common/constants_struct.go @@ -0,0 +1,64 @@ +package common + +type constants struct { + AuthChannel struct { + Sms int `json:"SMS"` + Wechat int `json:"WECHAT"` + WechatGame int `json:"WECHAT_GAME"` + } `json:"AUTH_CHANNEL"` + Player struct { + Diamond int `json:"DIAMOND"` + Energy int `json:"ENERGY"` + Gold int `json:"GOLD"` + IntAuthTokenTTLSeconds int `json:"INT_AUTH_TOKEN_TTL_SECONDS"` + SmsExpiredSeconds int `json:"SMS_EXPIRED_SECONDS"` + SmsValidResendPeriodSeconds int `json:"SMS_VALID_RESEND_PERIOD_SECONDS"` + } `json:"PLAYER"` + RetCode struct { + Duplicated int `json:"DUPLICATED"` + FailedToCreate int `json:"FAILED_TO_CREATE"` + FailedToDelete int `json:"FAILED_TO_DELETE"` + FailedToUpdate int `json:"FAILED_TO_UPDATE"` + IncorrectCaptcha int `json:"INCORRECT_CAPTCHA"` + IncorrectHandle int `json:"INCORRECT_HANDLE"` + IncorrectPassword int `json:"INCORRECT_PASSWORD"` + IncorrectPhoneCountryCode int `json:"INCORRECT_PHONE_COUNTRY_CODE"` + IncorrectPhoneNumber int `json:"INCORRECT_PHONE_NUMBER"` + InsufficientMemToAllocateConnection int `json:"INSUFFICIENT_MEM_TO_ALLOCATE_CONNECTION"` + InvalidEmailLiteral int `json:"INVALID_EMAIL_LITERAL"` + InvalidRequestParam int `json:"INVALID_REQUEST_PARAM"` + InvalidToken int `json:"INVALID_TOKEN"` + IsTestAcc int `json:"IS_TEST_ACC"` + IsBotAcc int `json:"IS_BOT_ACC"` + LackOfDiamond int `json:"LACK_OF_DIAMOND"` + LackOfEnergy int `json:"LACK_OF_ENERGY"` + LackOfGold int `json:"LACK_OF_GOLD"` + MapNotUnlocked int `json:"MAP_NOT_UNLOCKED"` + MysqlError int `json:"MYSQL_ERROR"` + GetSmsCaptchaRespErrorCode int `json:"GET_SMS_CAPTCHA_RESP_ERROR_CODE"` + NewHandleConflict int `json:"NEW_HANDLE_CONFLICT"` + NonexistentAct int `json:"NONEXISTENT_ACT"` + NonexistentActHandler int `json:"NONEXISTENT_ACT_HANDLER"` + LocallyNoAvailableRoom int `json:"LOCALLY_NO_AVAILABLE_ROOM"` + LocallyNoSpecifiedRoom int `json:"LOCALLY_NO_SPECIFIED_ROOM"` + PlayerNotAddableToRoom int `json:"PLAYER_NOT_ADDABLE_TO_ROOM"` + PlayerNotReAddableToRoom int `json:"PLAYER_NOT_READDABLE_TO_ROOM"` + PlayerNotFound int `json:"PLAYER_NOT_FOUND"` + PlayerCheating int `json:"PLAYER_CHEATING"` + NotImplementedYet int `json:"NOT_IMPLEMENTED_YET"` + NoAssociatedEmail int `json:"NO_ASSOCIATED_EMAIL"` + Ok int `json:"OK"` + PasswordResetCodeGenerationPerEmailTooFrequently int `json:"PASSWORD_RESET_CODE_GENERATION_PER_EMAIL_TOO_FREQUENTLY"` + SendEmailTimeout int `json:"SEND_EMAIL_TIMEOUT"` + SmsCaptchaNotMatch int `json:"SMS_CAPTCHA_NOT_MATCH"` + SmsCaptchaRequestedTooFrequently int `json:"SMS_CAPTCHA_REQUESTED_TOO_FREQUENTLY"` + TradeCreationTooFrequently int `json:"TRADE_CREATION_TOO_FREQUENTLY"` + UnknownError int `json:"UNKNOWN_ERROR"` + WechatServerError int `json:"WECHAT_SERVER_ERROR"` + Comment string `json:"__comment__"` + } `json:"RET_CODE"` + Ws struct { + IntervalToPing int `json:"INTERVAL_TO_PING"` + WillKickIfInactiveFor int `json:"WILL_KICK_IF_INACTIVE_FOR"` + } `json:"WS"` +} diff --git a/battle_srv/common/constants_test.json b/battle_srv/common/constants_test.json new file mode 100644 index 0000000..4e2ecab --- /dev/null +++ b/battle_srv/common/constants_test.json @@ -0,0 +1,7 @@ +{ + "PLAYER": { + "SMS_EXPIRED_SECONDS":30, + "SMS_VALID_RESEND_PERIOD_SECONDS":8, + "INT_AUTH_TOKEN_TTL_SECONDS":1800 + } +} diff --git a/battle_srv/common/logger.go b/battle_srv/common/logger.go new file mode 100644 index 0000000..8804ec5 --- /dev/null +++ b/battle_srv/common/logger.go @@ -0,0 +1,23 @@ +package common + +import ( + "go.uber.org/zap" + "go.uber.org/zap/zapcore" +) + +var Logger *zap.Logger +var LoggerConfig zap.Config + +func init() { + LoggerConfig = zap.NewDevelopmentConfig() + LoggerConfig.Level.SetLevel(zap.InfoLevel) + LoggerConfig.Development = false + LoggerConfig.Sampling = &zap.SamplingConfig{ + Initial: 100, + Thereafter: 100, + } + LoggerConfig.EncoderConfig.EncodeLevel = zapcore.CapitalColorLevelEncoder + var err error + Logger, err = LoggerConfig.Build() + ErrFatal(err) +} diff --git a/battle_srv/common/utils/rand.go b/battle_srv/common/utils/rand.go new file mode 100644 index 0000000..6de286d --- /dev/null +++ b/battle_srv/common/utils/rand.go @@ -0,0 +1,35 @@ +package utils + +import ( + crypto_rand "crypto/rand" + "encoding/hex" + "math/rand" + "time" +) + +var Rand *privateRand + +type privateRand struct { + *rand.Rand +} + +func init() { + Rand = &privateRand{rand.New(rand.NewSource(time.Now().UnixNano()))} +} + +func (p *privateRand) Number(numberRange ...int) int { + nr := 0 + if len(numberRange) > 1 { + nr = 1 + nr = p.Intn(numberRange[1]-numberRange[0]) + numberRange[0] + } else { + nr = p.Intn(numberRange[0]) + } + return nr +} + +func TokenGenerator(len int) string { + b := make([]byte, len/2) + crypto_rand.Read(b) + return hex.EncodeToString(b) +} diff --git a/battle_srv/common/utils/time.go b/battle_srv/common/utils/time.go new file mode 100644 index 0000000..23d8b4e --- /dev/null +++ b/battle_srv/common/utils/time.go @@ -0,0 +1,19 @@ +package utils + +import "time" + +func UnixtimeNano() int64 { + return time.Now().UnixNano() +} + +func UnixtimeMicro() int64 { + return time.Now().UnixNano() / 1000 +} + +func UnixtimeMilli() int64 { + return time.Now().UnixNano() / 1000000 +} + +func UnixtimeSec() int64 { + return time.Now().Unix() +} diff --git a/battle_srv/common/utils/wechat.go b/battle_srv/common/utils/wechat.go new file mode 100644 index 0000000..55ed8ea --- /dev/null +++ b/battle_srv/common/utils/wechat.go @@ -0,0 +1,283 @@ +package utils + +import ( + "bytes" + "crypto/sha1" + "encoding/json" + "fmt" + "go.uber.org/zap" + "io" + "io/ioutil" + "math/rand" + "net/http" + . "server/common" + . "server/configs" + "sort" + "time" +) + +var WechatIns *wechat +var WechatGameIns *wechat + +func InitWechat(conf WechatConfig) { + WechatIns = NewWechatIns(&conf, Constants.AuthChannel.Wechat) +} + +func InitWechatGame(conf WechatConfig) { + WechatGameIns = NewWechatIns(&conf, Constants.AuthChannel.WechatGame) +} + +func NewWechatIns(conf *WechatConfig, channel int) *wechat { + newWechat := &wechat{ + config: conf, + channel: channel, + } + return newWechat +} + +const () + +type wechat struct { + config *WechatConfig + channel int +} + +// CommonError 微信返回的通用错误json +type CommonError struct { + ErrCode int64 `json:"errcode"` + ErrMsg string `json:"errmsg"` +} + +// ResAccessToken 获取用户授权access_token的返回结果 +type resAccessToken struct { + CommonError + + AccessToken string `json:"access_token"` + ExpiresIn int64 `json:"expires_in"` + RefreshToken string `json:"refresh_token"` + OpenID string `json:"openid"` + Scope string `json:"scope"` +} + +// Config 返回给用户jssdk配置信息 +type JsConfig struct { + AppID string `json:"app_id"` + Timestamp int64 `json:"timestamp"` + NonceStr string `json:"nonce_str"` + Signature string `json:"signature"` +} + +// resTicket 请求jsapi_tikcet返回结果 +type resTicket struct { + CommonError + + Ticket string `json:"ticket"` + ExpiresIn int64 `json:"expires_in"` +} + +func (w *wechat) GetJsConfig(uri string) (config *JsConfig, err error) { + config = new(JsConfig) + var ticketStr string + ticketStr, err = w.getTicket() + if err != nil { + return + } + nonceStr := randomStr(16) + timestamp := UnixtimeSec() + str := fmt.Sprintf("jsapi_ticket=%s&noncestr=%s×tamp=%d&url=%s", ticketStr, nonceStr, timestamp, uri) + sigStr := signature(str) + + config.AppID = w.config.AppID + config.NonceStr = nonceStr + config.Timestamp = timestamp + config.Signature = sigStr + return +} + +//TODO add cache, getTicket 获取jsapi_ticket +func (w *wechat) getTicket() (ticketStr string, err error) { + var ticket resTicket + ticket, err = w.getTicketFromServer() + if err != nil { + return + } + ticketStr = ticket.Ticket + return +} + +func (w *wechat) GetOauth2Basic(authcode string) (result resAccessToken, err error) { + var accessTokenURL string + if w.channel == Constants.AuthChannel.WechatGame { + accessTokenURL = w.config.ApiProtocol + "://" + w.config.ApiGateway + "/sns/jscode2session?appid=%s&secret=%s&js_code=%s&grant_type=authorization_code" + } + if w.channel == Constants.AuthChannel.Wechat { + accessTokenURL = w.config.ApiProtocol + "://" + w.config.ApiGateway + "/sns/oauth2/access_token?appid=%s&secret=%s&code=%s&grant_type=authorization_code" + } + urlStr := fmt.Sprintf(accessTokenURL, w.config.AppID, w.config.AppSecret, authcode) + Logger.Info("urlStr", zap.Any(":", urlStr)) + response, err := get(urlStr) + if err != nil { + return + } + err = json.Unmarshal(response, &result) + if err != nil { + Logger.Info("GetOauth2Basic marshal error", zap.Any("err", err)) + return + } + if result.ErrCode != 0 { + err = fmt.Errorf("GetOauth2Basic error : errcode=%v , errmsg=%v", result.ErrCode, result.ErrMsg) + return + } + return +} + +//UserInfo 用户授权获取到用户信息 +type UserInfo struct { + CommonError + OpenID string `json:"openid"` + Nickname string `json:"nickname"` + Sex int32 `json:"sex"` + Province string `json:"province"` + City string `json:"city"` + Country string `json:"country"` + HeadImgURL string `json:"headimgurl"` + Privilege []string `json:"privilege"` + Unionid string `json:"unionid"` +} + +func (w *wechat) GetMoreInfo(accessToken string, openId string) (result UserInfo, err error) { + userInfoURL := w.config.ApiProtocol + "://" + w.config.ApiGateway + "/sns/userinfo?appid=%s&access_token=%s&openid=%s&lang=zh_CN" + urlStr := fmt.Sprintf(userInfoURL, w.config.AppID, accessToken, openId) + response, err := get(urlStr) + if err != nil { + return + } + err = json.Unmarshal(response, &result) + if err != nil { + Logger.Info("GetMoreInfo marshal error", zap.Any("err", err)) + return + } + if result.ErrCode != 0 { + err = fmt.Errorf("GetMoreInfo error : errcode=%v , errmsg=%v", result.ErrCode, result.ErrMsg) + return + } + return +} + +//HTTPGet get 请求 +func get(uri string) ([]byte, error) { + response, err := http.Get(uri) + if err != nil { + return nil, err + } + + defer response.Body.Close() + if response.StatusCode != http.StatusOK { + return nil, fmt.Errorf("http get error : uri=%v , statusCode=%v", uri, response.StatusCode) + } + body, err := ioutil.ReadAll(response.Body) + if err != nil { + return nil, err + } + return body, err +} + +//PostJSON post json 数据请求 +func post(uri string, obj interface{}) ([]byte, error) { + jsonData, err := json.Marshal(obj) + if err != nil { + return nil, err + } + + jsonData = bytes.Replace(jsonData, []byte("\\u003c"), []byte("<"), -1) + jsonData = bytes.Replace(jsonData, []byte("\\u003e"), []byte(">"), -1) + jsonData = bytes.Replace(jsonData, []byte("\\u0026"), []byte("&"), -1) + + body := bytes.NewBuffer(jsonData) + response, err := http.Post(uri, "application/json;charset=utf-8", body) + if err != nil { + return nil, err + } + defer response.Body.Close() + + if response.StatusCode != http.StatusOK { + return nil, fmt.Errorf("http get error : uri=%v , statusCode=%v", uri, response.StatusCode) + } + return ioutil.ReadAll(response.Body) +} + +//Signature sha1签名 +func signature(params ...string) string { + sort.Strings(params) + h := sha1.New() + for _, s := range params { + io.WriteString(h, s) + } + return fmt.Sprintf("%x", h.Sum(nil)) +} + +//RandomStr 随机生成字符串 +func randomStr(length int) string { + str := "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" + bytes := []byte(str) + result := []byte{} + r := rand.New(rand.NewSource(time.Now().UnixNano())) + for i := 0; i < length; i++ { + result = append(result, bytes[r.Intn(len(bytes))]) + } + return string(result) +} + +//getTicketFromServer 强制从服务器中获取ticket +func (w *wechat) getTicketFromServer() (ticket resTicket, err error) { + var accessToken string + accessToken, err = w.getAccessTokenFromServer() + if err != nil { + return + } + + getTicketURL := w.config.ApiProtocol + "://" + w.config.ApiGateway + "/cgi-bin/ticket/getticket?access_token=%s&type=jsapi" + var response []byte + url := fmt.Sprintf(getTicketURL, accessToken) + response, err = get(url) + err = json.Unmarshal(response, &ticket) + if err != nil { + return + } + if ticket.ErrCode != 0 { + err = fmt.Errorf("getTicket Error : errcode=%d , errmsg=%s", ticket.ErrCode, ticket.ErrMsg) + return + } + + //jsAPITicketCacheKey := fmt.Sprintf("jsapi_ticket_%s", w.config.AppID) + //expires := ticket.ExpiresIn - 1500 + //set + //err = js.Cache.Set(jsAPITicketCacheKey, ticket.Ticket, time.Duration(expires)*time.Second) + return +} + +//GetAccessTokenFromServer 强制从微信服务器获取token +func (w *wechat) getAccessTokenFromServer() (accessToken string, err error) { + AccessTokenURL := w.config.ApiProtocol + "://" + w.config.ApiGateway + "/cgi-bin/token" + url := fmt.Sprintf("%s?grant_type=client_credential&appid=%s&secret=%s", AccessTokenURL, w.config.AppID, w.config.AppSecret) + var body []byte + body, err = get(url) + if err != nil { + return + } + var r resAccessToken + err = json.Unmarshal(body, &r) + if err != nil { + return + } + if r.ErrMsg != "" { + err = fmt.Errorf("get access_token error : errcode=%v , errormsg=%v", r.ErrCode, r.ErrMsg) + return + } + + //accessTokenCacheKey := fmt.Sprintf("access_token_%s", w.config.AppID) + //expires := r.ExpiresIn - 1500 + //set to redis err = ctx.Cache.Set(accessTokenCacheKey, r.AccessToken, time.Duration(expires)*time.Second) + accessToken = r.AccessToken + return +} diff --git a/battle_srv/common/vals.go b/battle_srv/common/vals.go new file mode 100644 index 0000000..55f0b39 --- /dev/null +++ b/battle_srv/common/vals.go @@ -0,0 +1,31 @@ +package common + +import ( + "regexp" + "time" +) + +var ( + RE_PHONE_NUM = regexp.MustCompile(`^\+?[0-9]{8,14}$`) + RE_SMS_CAPTCHA_CODE = regexp.MustCompile(`^[0-9]{4}$`) + RE_CHINA_PHONE_NUM = regexp.MustCompile(`^(13[0-9]|14[5|7]|15[0|1|2|3|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\d{8}$`) +) + +// 隐式导入 +var ConstVals = &struct { + Player struct { + CaptchaExpire time.Duration + CaptchaMaxTTL time.Duration + } + Ws struct { + WillKickIfInactiveFor time.Duration + } +}{} + +func constantsPost() { + ConstVals.Player.CaptchaExpire = time.Duration(Constants.Player.SmsExpiredSeconds) * time.Second + ConstVals.Player.CaptchaMaxTTL = ConstVals.Player.CaptchaExpire - + time.Duration(Constants.Player.SmsValidResendPeriodSeconds)*time.Second + + ConstVals.Ws.WillKickIfInactiveFor = time.Duration(Constants.Ws.WillKickIfInactiveFor) * time.Millisecond +} diff --git a/battle_srv/configs.template/bot_server.json b/battle_srv/configs.template/bot_server.json new file mode 100644 index 0000000..cf60684 --- /dev/null +++ b/battle_srv/configs.template/bot_server.json @@ -0,0 +1,7 @@ +{ + "secondsBeforeSummoning": 10, + "protocol": "http", + "host": "localhost", + "port": 15351, + "symmetricKey": "" +} diff --git a/battle_srv/configs.template/mysql.json b/battle_srv/configs.template/mysql.json new file mode 100644 index 0000000..8dfde7a --- /dev/null +++ b/battle_srv/configs.template/mysql.json @@ -0,0 +1,7 @@ +{ + "host": "localhost", + "port": 3306, + "dbname": "tsrht", + "username": "root", + "password": "root" +} diff --git a/battle_srv/configs.template/pre_conf_data.sqlite b/battle_srv/configs.template/pre_conf_data.sqlite new file mode 100644 index 0000000..6c77100 Binary files /dev/null and b/battle_srv/configs.template/pre_conf_data.sqlite differ diff --git a/battle_srv/configs.template/redis.json b/battle_srv/configs.template/redis.json new file mode 100644 index 0000000..e1d0f1f --- /dev/null +++ b/battle_srv/configs.template/redis.json @@ -0,0 +1,6 @@ +{ + "host": "localhost", + "port": 6379, + "dbname": 0, + "password": "" +} diff --git a/battle_srv/configs.template/sio.json b/battle_srv/configs.template/sio.json new file mode 100644 index 0000000..68118bf --- /dev/null +++ b/battle_srv/configs.template/sio.json @@ -0,0 +1,3 @@ +{ + "hostAndPort": "0.0.0.0:9992" +} diff --git a/battle_srv/configs.template/test_env.sqlite b/battle_srv/configs.template/test_env.sqlite new file mode 100644 index 0000000..6c77100 Binary files /dev/null and b/battle_srv/configs.template/test_env.sqlite differ diff --git a/battle_srv/configs.template/wechat.go b/battle_srv/configs.template/wechat.go new file mode 100644 index 0000000..6986a59 --- /dev/null +++ b/battle_srv/configs.template/wechat.go @@ -0,0 +1,33 @@ +package configs + +type WechatConfig struct { + ApiProtocol string + ApiGateway string + AppID string + AppSecret string +} + +// Fserver +var WechatConfigIns = WechatConfig{ + ApiProtocol: "http", + ApiGateway: "119.29.236.44:8089", + AppID: "wx5432dc1d6164d4e", + AppSecret: "secret1", +} + +/* +// Production +var WechatConfigIns = WechatConfig { + ApiProtocol: "https", + ApiGateway: "api.weixin.qq.com", + AppID: "wxe7063ab415266544", + AppSecret: "secret1", +} +*/ + +var WechatGameConfigIns = WechatConfig{ + ApiProtocol: "https", + ApiGateway: "api.weixin.qq.com", + AppID: "wxf497c910a2a25edc", + AppSecret: "secret1", +} diff --git a/battle_srv/env_tools/load_pre_conf.go b/battle_srv/env_tools/load_pre_conf.go new file mode 100644 index 0000000..d797942 --- /dev/null +++ b/battle_srv/env_tools/load_pre_conf.go @@ -0,0 +1,144 @@ +package env_tools + +import ( + sq "github.com/Masterminds/squirrel" + "github.com/jmoiron/sqlx" + _ "github.com/mattn/go-sqlite3" + "go.uber.org/zap" + . "server/common" + "server/common/utils" + "server/models" + "server/storage" +) + +func LoadPreConf() { + Logger.Info(`Merging PreConfSQLite data into MySQL`, + zap.String("PreConfSQLitePath", Conf.General.PreConfSQLitePath)) + db, err := sqlx.Connect("sqlite3", Conf.General.PreConfSQLitePath) + ErrFatal(err) + defer db.Close() + + loadPreConfToMysql(db) + + // --kobako + maybeCreateNewPlayerFromBotTable(db, "bot_player") +} + +type dbBotPlayer struct { + Name string `db:"name"` + MagicPhoneCountryCode string `db:"magic_phone_country_code"` + MagicPhoneNum string `db:"magic_phone_num"` + DisplayName string `db:"display_name"` +} + +func loadPreConfToMysql(db *sqlx.DB) { + tbs := []string{} + loadSqlite(db, tbs) +} + +func loadSqlite(db *sqlx.DB, tbs []string) { + for _, v := range tbs { + result, err := storage.MySQLManagerIns.Exec("truncate " + v) + ErrFatal(err) + Logger.Info("truncate", zap.Any("truncate "+v, result)) + query, args, err := sq.Select("*").From(v).ToSql() + if err != nil { + Logger.Info("loadSql ToSql error", zap.Any("err", err)) + } + rows, err := db.Queryx(query, args...) + if err != nil { + Logger.Info("loadSql query error", zap.Any("err", err)) + } + createMysqlData(rows, v) + } +} + +func createMysqlData(rows *sqlx.Rows, v string) { + tx := storage.MySQLManagerIns.MustBegin() + defer Logger.Info("Loaded table " + v + " from PreConfSQLite successfully.") + switch v { + // TODO + } + err := tx.Commit() + if err != nil { + defer tx.Rollback() + Logger.Info(v+" load", zap.Any("tx.commit error", err)) + } +} + +//加上tableName参数, 用于pre_conf_data.sqlite里bot_player表的复用 --kobako +func maybeCreateNewPlayerFromBotTable(db *sqlx.DB, tableName string) { + var ls []*dbBotPlayer + err := db.Select(&ls, "SELECT name, magic_phone_country_code, magic_phone_num, display_name FROM "+tableName) + ErrFatal(err) + names := make([]string, len(ls), len(ls)) + for i, v := range ls { + names[i] = v.Name + } + sql := "SELECT name FROM `player` WHERE name in (?)" + query, args, err := sqlx.In(sql, names) + ErrFatal(err) + query = storage.MySQLManagerIns.Rebind(query) + // existNames := make([]string, len(ls), len(ls)) + var existPlayers []*models.Player + err = storage.MySQLManagerIns.Select(&existPlayers, query, args...) + ErrFatal(err) + + for _, botPlayer := range ls { + var flag bool + for _, v := range existPlayers { + if botPlayer.Name == v.Name { + // 已有数据,合并处理 + flag = true + break + } + } + if !flag { + // 找不到,新增 + Logger.Debug("create", zap.Any(tableName, botPlayer)) + err := createNewBotPlayer(botPlayer) + if err != nil { + Logger.Warn("createNewPlayer from"+tableName, zap.NamedError("createNewPlayerErr", err)) + } + } + } +} + +func createNewBotPlayer(p *dbBotPlayer) error { + tx := storage.MySQLManagerIns.MustBegin() + defer tx.Rollback() + now := utils.UnixtimeMilli() + player := models.Player{ + CreatedAt: now, + UpdatedAt: now, + Name: p.Name, + DisplayName: p.DisplayName, + } + err := player.Insert(tx) + if err != nil { + return err + } + playerAuthBinding := models.PlayerAuthBinding{ + CreatedAt: now, + UpdatedAt: now, + Channel: int(Constants.AuthChannel.Sms), + ExtAuthID: p.MagicPhoneCountryCode + p.MagicPhoneNum, + PlayerID: int(player.Id), + } + err = playerAuthBinding.Insert(tx) + if err != nil { + return err + } + + wallet := models.PlayerWallet{ + CreatedAt: now, + UpdatedAt: now, + ID: int(player.Id), + } + err = wallet.Insert(tx) + if err != nil { + return err + } + tx.Commit() + return nil +} diff --git a/battle_srv/env_tools/test_env_db.go b/battle_srv/env_tools/test_env_db.go new file mode 100644 index 0000000..c6afec7 --- /dev/null +++ b/battle_srv/env_tools/test_env_db.go @@ -0,0 +1,102 @@ +package env_tools + +import ( + . "server/common" + "server/common/utils" + "server/models" + "server/storage" + + "github.com/jmoiron/sqlx" + _ "github.com/mattn/go-sqlite3" + "go.uber.org/zap" +) + +func MergeTestPlayerAccounts() { + fp := Conf.General.TestEnvSQLitePath + Logger.Info(`Initializing TestPlayerAccounts in runtime MySQLServer from SQLite file:`, zap.String("fp", fp)) + db, err := sqlx.Connect("sqlite3", fp) + ErrFatal(err) + defer db.Close() + maybeCreateNewPlayer(db, "test_player") +} + +type dbTestPlayer struct { + Name string `db:"name"` + MagicPhoneCountryCode string `db:"magic_phone_country_code"` + MagicPhoneNum string `db:"magic_phone_num"` +} + +func maybeCreateNewPlayer(db *sqlx.DB, tableName string) { + var ls []*dbTestPlayer + err := db.Select(&ls, "SELECT name, magic_phone_country_code, magic_phone_num FROM "+tableName) + ErrFatal(err) + names := make([]string, len(ls), len(ls)) + for i, v := range ls { + names[i] = v.Name + } + sql := "SELECT name FROM `player` WHERE name in (?)" + query, args, err := sqlx.In(sql, names) + ErrFatal(err) + query = storage.MySQLManagerIns.Rebind(query) + // existNames := make([]string, len(ls), len(ls)) + var existPlayers []*models.Player + err = storage.MySQLManagerIns.Select(&existPlayers, query, args...) + ErrFatal(err) + + for _, testPlayer := range ls { + var flag bool + for _, v := range existPlayers { + if testPlayer.Name == v.Name { + // 已有数据,合并处理 + flag = true + break + } + } + if !flag { + // 找不到,新增 + Logger.Debug("create", zap.Any(tableName, testPlayer)) + err := createNewPlayer(testPlayer) + if err != nil { + Logger.Warn("createNewPlayer from"+tableName, zap.NamedError("createNewPlayerErr", err)) + } + } + } +} + +func createNewPlayer(p *dbTestPlayer) error { + tx := storage.MySQLManagerIns.MustBegin() + defer tx.Rollback() + now := utils.UnixtimeMilli() + player := models.Player{ + CreatedAt: now, + UpdatedAt: now, + Name: p.Name, + } + err := player.Insert(tx) + if err != nil { + return err + } + playerAuthBinding := models.PlayerAuthBinding{ + CreatedAt: now, + UpdatedAt: now, + Channel: int(Constants.AuthChannel.Sms), + ExtAuthID: p.MagicPhoneCountryCode + p.MagicPhoneNum, + PlayerID: int(player.Id), + } + err = playerAuthBinding.Insert(tx) + if err != nil { + return err + } + + wallet := models.PlayerWallet{ + CreatedAt: now, + UpdatedAt: now, + ID: int(player.Id), + } + err = wallet.Insert(tx) + if err != nil { + return err + } + tx.Commit() + return nil +} diff --git a/battle_srv/go.mod b/battle_srv/go.mod new file mode 100644 index 0000000..5ab0e6d --- /dev/null +++ b/battle_srv/go.mod @@ -0,0 +1,37 @@ +module server + +require ( + github.com/ByteArena/box2d v1.0.2 + github.com/ChimeraCoder/gojson v1.0.0 // indirect + github.com/Masterminds/squirrel v0.0.0-20180815162352-8a7e65843414 + github.com/davecgh/go-spew v1.1.1 + github.com/fatih/color v1.7.0 // indirect + github.com/gin-contrib/cors v0.0.0-20180514151808-6f0a820f94be + github.com/gin-contrib/sse v0.0.0-20170109093832-22d885f9ecc7 // indirect + github.com/gin-gonic/gin v1.3.0 + github.com/githubnemo/CompileDaemon v1.0.0 // indirect + github.com/go-redis/redis v6.13.2+incompatible + github.com/go-sql-driver/mysql v1.4.0 + github.com/golang/protobuf v1.5.2 + github.com/google/go-cmp v0.5.9 // indirect + github.com/gorilla/websocket v1.2.0 + github.com/hashicorp/go-cleanhttp v0.0.0-20171218145408-d5fe4b57a186 + github.com/howeyc/fsnotify v0.9.0 // indirect + github.com/imdario/mergo v0.3.6 + github.com/jmoiron/sqlx v0.0.0-20180614180643-0dae4fefe7c0 + github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect + github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect + github.com/logrusorgru/aurora v0.0.0-20181002194514-a7b3b318ed4e + github.com/mattn/go-colorable v0.0.9 // indirect + github.com/mattn/go-isatty v0.0.3 // indirect + github.com/mattn/go-sqlite3 v1.9.0 + github.com/robfig/cron v0.0.0-20180505203441-b41be1df6967 + github.com/thoas/go-funk v0.0.0-20180716193722-1060394a7713 + github.com/ugorji/go v1.1.1 // indirect + go.uber.org/atomic v1.3.2 // indirect + go.uber.org/multierr v1.1.0 // indirect + go.uber.org/zap v1.9.1 + google.golang.org/protobuf v1.28.1 + gopkg.in/go-playground/validator.v8 v8.18.2 // indirect + gopkg.in/yaml.v2 v2.2.1 // indirect +) diff --git a/battle_srv/go.sum b/battle_srv/go.sum new file mode 100644 index 0000000..3990203 --- /dev/null +++ b/battle_srv/go.sum @@ -0,0 +1,84 @@ +github.com/ByteArena/box2d v1.0.2 h1:f7f9KEQWhCs1n516DMLzi5w6u0MeeE78Mes4fWMcj9k= +github.com/ByteArena/box2d v1.0.2/go.mod h1:LzEuxY9iCz+tskfWCY3o0ywYBRafDDugdSj+/YGI6sE= +github.com/ChimeraCoder/gojson v1.0.0 h1:gAYKGTV+xfQ4+l/4C/nazPbiQDUidG0G3ukAJnE7LNE= +github.com/ChimeraCoder/gojson v1.0.0/go.mod h1:nYbTQlu6hv8PETM15J927yM0zGj3njIldp72UT1MqSw= +github.com/Masterminds/squirrel v0.0.0-20180815162352-8a7e65843414 h1:VHdYPA0V0YgL97gdjHevN6IVPRX+fOoNMqcYvUAzwNU= +github.com/Masterminds/squirrel v0.0.0-20180815162352-8a7e65843414/go.mod h1:xnKTFzjGUiZtiOagBsfnvomW+nJg2usB1ZpordQWqNM= +github.com/Pallinder/go-randomdata v0.0.0-20180616180521-15df0648130a h1:0OnS8GR4uI3nau+f/juCZlAq+zCrsHXRJlENrUQ4eU8= +github.com/Pallinder/go-randomdata v0.0.0-20180616180521-15df0648130a/go.mod h1:yHmJgulpD2Nfrm0cR9tI/+oAgRqCQQixsA8HyRZfV9Y= +github.com/Tarliton/collision2d v0.0.0-20160527013055-f7a088279920 h1:0IrTIOtqYxunLFS7/NZtdHDXifo0sjOnw2y2EhvDIFE= +github.com/Tarliton/collision2d v0.0.0-20160527013055-f7a088279920/go.mod h1:xQkVqGFqY6zzdXxydhfUfJQfmSIAyx0XavFZgQK0F5o= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= +github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/gin-contrib/cors v0.0.0-20180514151808-6f0a820f94be h1:2dYuM6B1e0D4RetEP5sHh4OZkBAvNiLPaqB0h+y6BJU= +github.com/gin-contrib/cors v0.0.0-20180514151808-6f0a820f94be/go.mod h1:cw+u9IsAkC16e42NtYYVCLsHYXE98nB3M7Dr9mLSeH4= +github.com/gin-contrib/sse v0.0.0-20170109093832-22d885f9ecc7 h1:AzN37oI0cOS+cougNAV9szl6CVoj2RYwzS3DpUQNtlY= +github.com/gin-contrib/sse v0.0.0-20170109093832-22d885f9ecc7/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s= +github.com/gin-gonic/gin v1.3.0 h1:kCmZyPklC0gVdL728E6Aj20uYBJV93nj/TkwBTKhFbs= +github.com/gin-gonic/gin v1.3.0/go.mod h1:7cKuhb5qV2ggCFctp2fJQ+ErvciLZrIeoOSOm6mUr7Y= +github.com/githubnemo/CompileDaemon v1.0.0 h1:F4nrVyPOxva6gJIw320fwfaFaPl8ZuEk95RZOy9Q4eM= +github.com/githubnemo/CompileDaemon v1.0.0/go.mod h1:lE3EXX1td33uhlkFLp+ImWY9qBaoRcDeA3neh4m8ic0= +github.com/go-redis/redis v6.13.2+incompatible h1:kfEWSpgBs4XmuzGg7nYPqhQejjzU9eKdIL0PmE2TtRY= +github.com/go-redis/redis v6.13.2+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA= +github.com/go-sql-driver/mysql v1.4.0 h1:7LxgVwFb2hIQtMm87NdgAVfXjnt4OePseqT1tKx+opk= +github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= +github.com/golang/protobuf v1.1.0 h1:0iH4Ffd/meGoXqF2lSAhZHt8X+cPgkfn/cb6Cce5Vpc= +github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/googollee/go-engine.io v0.0.0-20180611083002-3c3145340e67 h1:CTWsAFYrbWv+NEyoIG+Q5XGZPOEhJ66cuT2QKsz8PgU= +github.com/googollee/go-engine.io v0.0.0-20180611083002-3c3145340e67/go.mod h1:MBpz1MS3P4HtRcBpQU4HcjvWXZ9q+JWacMEh2/BFYbg= +github.com/googollee/go-socket.io v0.0.0-20180611075005-f12da5711bc6 h1:jyykn2uqd82u413JcoyghmxJakOdbdl8PJ8JAG4JVCQ= +github.com/googollee/go-socket.io v0.0.0-20180611075005-f12da5711bc6/go.mod h1:ftBGBMhSYToR5oV4ImIPKvAIsNaTkLC+tTvoNafqxlQ= +github.com/gorilla/websocket v1.2.0 h1:VJtLvh6VQym50czpZzx07z/kw9EgAxI3x1ZB8taTMQQ= +github.com/gorilla/websocket v1.2.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/hashicorp/go-cleanhttp v0.0.0-20171218145408-d5fe4b57a186 h1:URgjUo+bs1KwatoNbwG0uCO4dHN4r1jsp4a5AGgHRjo= +github.com/hashicorp/go-cleanhttp v0.0.0-20171218145408-d5fe4b57a186/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/howeyc/fsnotify v0.9.0 h1:0gtV5JmOKH4A8SsFxG2BczSeXWWPvcMT0euZt5gDAxY= +github.com/howeyc/fsnotify v0.9.0/go.mod h1:41HzSPxBGeFRQKEEwgh49TRw/nKBsYZ2cF1OzPjSJsA= +github.com/imdario/mergo v0.3.6 h1:xTNEAn+kxVO7dTZGu0CegyqKZmoWFI0rF8UxjlB2d28= +github.com/imdario/mergo v0.3.6/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= +github.com/jmoiron/sqlx v0.0.0-20180614180643-0dae4fefe7c0 h1:5B0uxl2lzNRVkJVg+uGHxWtRt4C0Wjc6kJKo5XYx8xE= +github.com/jmoiron/sqlx v0.0.0-20180614180643-0dae4fefe7c0/go.mod h1:IiEW3SEiiErVyFdH8NTuWjSifiEQKUoyK3LNqr2kCHU= +github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 h1:SOEGU9fKiNWd/HOJuq6+3iTQz8KNCLtVX6idSoTLdUw= +github.com/lann/builder v0.0.0-20180802200727-47ae307949d0/go.mod h1:dXGbAdH5GtBTC4WfIxhKZfyBF/HBFgRZSWwZ9g/He9o= +github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 h1:P6pPBnrTSX3DEVR4fDembhRWSsG5rVo6hYhAB/ADZrk= +github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0/go.mod h1:vmVJ0l/dxyfGW6FmdpVm2joNMFikkuWg0EoCKLGUMNw= +github.com/logrusorgru/aurora v0.0.0-20181002194514-a7b3b318ed4e h1:9MlwzLdW7QSDrhDjFlsEYmxpFyIoXmYRon3dt0io31k= +github.com/logrusorgru/aurora v0.0.0-20181002194514-a7b3b318ed4e/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4= +github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4= +github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= +github.com/mattn/go-isatty v0.0.3 h1:ns/ykhmWi7G9O+8a448SecJU3nSMBXJfqQkl0upE1jI= +github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/mattn/go-sqlite3 v1.9.0 h1:pDRiWfl+++eC2FEFRy6jXmQlvp4Yh3z1MJKg4UeYM/4= +github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= +github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88= +github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= +github.com/robfig/cron v0.0.0-20180505203441-b41be1df6967 h1:x7xEyJDP7Hv3LVgvWhzioQqbC/KtuUhTigKlH/8ehhE= +github.com/robfig/cron v0.0.0-20180505203441-b41be1df6967/go.mod h1:JGuDeoQd7Z6yL4zQhZ3OPEVHB7fL6Ka6skscFHfmt2k= +github.com/thoas/go-funk v0.0.0-20180716193722-1060394a7713 h1:knaxjm6QMbUMNvuaSnJZmw0gRX4V/79JVUQiziJGM84= +github.com/thoas/go-funk v0.0.0-20180716193722-1060394a7713/go.mod h1:mlR+dHGb+4YgXkf13rkQTuzrneeHANxOm6+ZnEV9HsA= +github.com/ugorji/go v1.1.1 h1:gmervu+jDMvXTbcHQ0pd2wee85nEoE0BsVyEuzkfK8w= +github.com/ugorji/go v1.1.1/go.mod h1:hnLbHMwcvSihnDhEfx2/BzKp2xb0Y+ErdfYcrs9tkJQ= +go.uber.org/atomic v1.3.2 h1:2Oa65PReHzfn29GpvgsYwloV9AVFHPDk8tYxt2c2tr4= +go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/multierr v1.1.0 h1:HoEmRHQPVSqub6w2z2d2EOVs2fjyFRGyofhKuyDq0QI= +go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= +go.uber.org/zap v1.9.1 h1:XCJQEf3W6eZaVwhRBof6ImoYGJSITeKWsyeh3HFu/5o= +go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= +google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/go-playground/validator.v8 v8.18.2 h1:lFB4DoMU6B626w8ny76MV7VX6W2VHct2GVOI3xgiMrQ= +gopkg.in/go-playground/validator.v8 v8.18.2/go.mod h1:RX2a/7Ha8BgOhfk7j780h4/u/RRjR0eouCJSH80/M2Y= +gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/battle_srv/logrotate/treasure-hunter b/battle_srv/logrotate/treasure-hunter new file mode 100644 index 0000000..de366f8 --- /dev/null +++ b/battle_srv/logrotate/treasure-hunter @@ -0,0 +1,16 @@ +# This file should be put as "/etc/logrotate.d/treasure-hunter". +# Manual usage Example +# - logrotate -f /etc/logrotate.d/treasure-hunter + +/var/log/treasure-hunter.log { + rotate 12 + size 32M + hourly + missingok + notifempty + compress + delaycompress + copytruncate + create 0640 ubuntu ubuntu + su ubuntu ubuntu +} diff --git a/battle_srv/main.go b/battle_srv/main.go new file mode 100644 index 0000000..ce2aacf --- /dev/null +++ b/battle_srv/main.go @@ -0,0 +1,117 @@ +package main + +import ( + "context" + "fmt" + "net/http" + "os" + "os/signal" + "path/filepath" + "server/api" + "server/api/v1" + . "server/common" + "server/common/utils" + "server/configs" + "server/env_tools" + "server/models" + "server/storage" + "server/ws" + "syscall" + "time" + + "github.com/gin-contrib/cors" + "github.com/gin-gonic/gin" + "github.com/robfig/cron" + "go.uber.org/zap" +) + +func main() { + MustParseConfig() + MustParseConstants() + storage.Init() + env_tools.LoadPreConf() + utils.InitWechat(configs.WechatConfigIns) + utils.InitWechatGame(configs.WechatGameConfigIns) + if Conf.General.ServerEnv == SERVER_ENV_TEST { + env_tools.MergeTestPlayerAccounts() + } + models.InitRoomHeapManager() + startScheduler() + router := gin.Default() + setRouter(router) + + srv := &http.Server{ + Addr: fmt.Sprintf("%s", Conf.Sio.HostAndPort), + Handler: router, + } + /* + * To disable "Keep-Alive" of http/1.0 clients, thus avoid confusing results when inspecting leaks by `netstat`. + * + * -- YFLu + */ + srv.SetKeepAlivesEnabled(false) + go func() { + if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed { + Logger.Fatal("Error launching the service:", zap.Error(err)) + } + Logger.Info("Listening and serving HTTP on", zap.Any("Conf.Sio.HostAndPort", Conf.Sio.HostAndPort)) + }() + var gracefulStop = make(chan os.Signal) + signal.Notify(gracefulStop, syscall.SIGTERM) + signal.Notify(gracefulStop, syscall.SIGINT) + sig := <-gracefulStop + Logger.Info("Shutdown Server ...") + Logger.Info("caught sig", zap.Any("sig", sig)) + Logger.Info("Wait for 5 second to finish processing") + clean() + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + defer cancel() + if err := srv.Shutdown(ctx); err != nil { + Logger.Fatal("Server Shutdown:", zap.Error(err)) + } + Logger.Info("Server exiting") + os.Exit(0) +} + +func clean() { + Logger.Info("About to clean up the resources occupied by this server-process.") + if storage.MySQLManagerIns != nil { + storage.MySQLManagerIns.Close() + } + if Logger != nil { + Logger.Sync() + } +} + +func setRouter(router *gin.Engine) { + f := func(c *gin.Context) { + c.JSON(http.StatusOK, gin.H{"ping": "pong"}) + } + router.Use(cors.Default()) + router.StaticFS("/asset", http.Dir(filepath.Join(Conf.General.AppRoot, "asset"))) + router.GET("/ping", f) + router.GET("/tsrht", ws.Serve) + + apiRouter := router.Group("/api") + { + apiRouter.Use(api.HandleRet(), api.RequestLogger()) + apiRouter.POST("/player/v1/IntAuthToken/login", v1.Player.IntAuthTokenLogin) + apiRouter.POST("/player/v1/IntAuthToken/logout", v1.Player.IntAuthTokenLogout) + apiRouter.GET("/player/v1/SmsCaptcha/get", v1.Player.SMSCaptchaGet) + apiRouter.POST("/player/v1/SmsCaptcha/login", v1.Player.SMSCaptchaLogin) + apiRouter.POST("/player/v1/wechat/login", v1.Player.WechatLogin) + apiRouter.POST("/player/v1/wechat/jsconfig", v1.Player.GetWechatShareConfig) + apiRouter.POST("/player/v1/wechatGame/login", v1.Player.WechatGameLogin) + + authRouter := func(method string, url string, handler gin.HandlerFunc) { + apiRouter.Handle(method, url, v1.Player.TokenAuth, handler) + } + authRouter(http.MethodPost, "/player/v1/profile/fetch", v1.Player.FetchProfile) + } +} + +func startScheduler() { + c := cron.New() + //c.AddFunc("*/1 * * * * *", FuncName) + c.Start() +} diff --git a/battle_srv/models/barrier.go b/battle_srv/models/barrier.go new file mode 100644 index 0000000..9b3a73c --- /dev/null +++ b/battle_srv/models/barrier.go @@ -0,0 +1,13 @@ +package models + +import ( + "github.com/ByteArena/box2d" +) + +type Barrier struct { + X float64 + Y float64 + Type uint32 + Boundary *Polygon2D + CollidableBody *box2d.B2Body +} diff --git a/battle_srv/models/bullet.go b/battle_srv/models/bullet.go new file mode 100644 index 0000000..6936d5c --- /dev/null +++ b/battle_srv/models/bullet.go @@ -0,0 +1,19 @@ +package models + +import ( + "github.com/ByteArena/box2d" +) + +type Bullet struct { + LocalIdInBattle int32 `json:"-"` + LinearSpeed float64 `json:"-"` + X float64 `json:"-"` + Y float64 `json:"-"` + Removed bool `json:"-"` + Dir *Direction `json:"-"` + StartAtPoint *Vec2D `json:"-"` + EndAtPoint *Vec2D `json:"-"` + DamageBoundary *Polygon2D `json:"-"` + CollidableBody *box2d.B2Body `json:"-"` + RemovedAtFrameId int32 `json:"-"` +} diff --git a/battle_srv/models/helper.go b/battle_srv/models/helper.go new file mode 100644 index 0000000..5e51382 --- /dev/null +++ b/battle_srv/models/helper.go @@ -0,0 +1,81 @@ +package models + +import ( + "database/sql" + . "server/common" + "server/storage" + + sq "github.com/Masterminds/squirrel" + "github.com/jmoiron/sqlx" + "go.uber.org/zap" +) + +func exist(t string, cond sq.Eq) (bool, error) { + c, err := getCount(t, cond) + if err != nil { + return false, err + } + return c >= 1, nil +} + +func getCount(t string, cond sq.Eq) (int, error) { + query, args, err := sq.Select("count(1)").From(t).Where(cond).ToSql() + if err != nil { + return 0, err + } + //Logger.Debug("getCount", zap.String("sql", query), zap.Any("args", args)) + var c int + err = storage.MySQLManagerIns.Get(&c, query, args...) + return c, err +} + +func insert(t string, cols []string, vs []interface{}) (sql.Result, error) { + query, args, err := sq.Insert(t).Columns(cols...).Values(vs...).ToSql() + Logger.Debug("txInsert", zap.String("sql", query)) + if err != nil { + return nil, err + } + result, err := storage.MySQLManagerIns.Exec(query, args...) + return result, err +} + +func txInsert(tx *sqlx.Tx, t string, cols []string, vs []interface{}) (sql.Result, error) { + query, args, err := sq.Insert(t).Columns(cols...).Values(vs...).ToSql() + //Logger.Debug("txInsert", zap.String("sql", query)) + if err != nil { + return nil, err + } + result, err := tx.Exec(query, args...) + return result, err +} + +func getFields(t string, fields []string, cond sq.Eq, dest interface{}) error { + query, args, err := sq.Select(fields...).From(t).Where(cond).Limit(1).ToSql() + Logger.Debug("getFields", zap.String("sql", query), zap.Any("args", args)) + if err != nil { + return err + } + err = storage.MySQLManagerIns.Get(dest, query, args...) + return err +} + +func getObj(t string, cond sq.Eq, dest interface{}) error { + query, args, err := sq.Select("*").From(t).Where(cond).Limit(1).ToSql() + Logger.Debug("getObj", zap.String("sql", query), zap.Any("args", args)) + if err != nil { + return err + } + err = storage.MySQLManagerIns.Get(dest, query, args...) + return err +} + +func getList(t string, cond sq.Eq, dest interface{}) error { + query, args, err := sq.Select("*").From(t).Where(cond).ToSql() + Logger.Debug("getList", zap.String("sql", query), zap.Any("args", args)) + if err != nil { + return err + } + err = storage.MySQLManagerIns.Select(dest, query, args...) + //Logger.Debug("getList", zap.Error(err)) + return err +} diff --git a/battle_srv/models/in_range_player_collection.go b/battle_srv/models/in_range_player_collection.go new file mode 100644 index 0000000..8d53202 --- /dev/null +++ b/battle_srv/models/in_range_player_collection.go @@ -0,0 +1,164 @@ +package models + +import ( + "fmt" + . "github.com/logrusorgru/aurora" +) + +type InRangePlayerCollection struct { + MaxSize int `json:"-"` + CurrentSize int `json:"-"` + CurrentNodePointer *InRangePlayerNode `json:"-"` + InRangePlayerMap map[int32]*InRangePlayerNode `json:"-"` +} + +func (p *InRangePlayerCollection) Init(maxSize int) *InRangePlayerCollection { + p = &InRangePlayerCollection{ + MaxSize: maxSize, + CurrentSize: 0, + CurrentNodePointer: nil, + InRangePlayerMap: make(map[int32]*InRangePlayerNode), + } + return p +} + +func (p *InRangePlayerCollection) Print() { + fmt.Println(Cyan(fmt.Sprintf("{ \n MaxSize: %d, \n CurrentSize: %d, \n }", p.MaxSize, p.CurrentSize))) +} + +func (p *InRangePlayerCollection) AppendPlayer(player *Player) *InRangePlayerNode { + if nil != p.InRangePlayerMap[player.Id] { //如果该玩家已存在返回nil + return nil + } else { + //p.CurrentSize + size := p.CurrentSize + 1 + if size > p.MaxSize { //超出守护塔的承载范围 + fmt.Println(Red(fmt.Sprintf("Error: InRangePlayerCollection overflow, MaxSize: %d, NowSize: %d", p.MaxSize, size))) + return nil + } + p.CurrentSize = size + + node := InRangePlayerNode{ + Prev: nil, + Next: nil, + player: player, + } + + p.InRangePlayerMap[player.Id] = &node + + { //p.CurrentNodePointer + if p.CurrentNodePointer == nil { //刚init好的情况 + p.CurrentNodePointer = &node + } else { //加到最后面相当于循环链表prepend + p.CurrentNodePointer.PrependNode(&node) + } + } + + return &node + } +} + +func (p *InRangePlayerCollection) RemovePlayerById(playerId int32) { + nodePointer := p.InRangePlayerMap[playerId] + + delete(p.InRangePlayerMap, playerId) + + { //p.CurrentNodePointer + if p.CurrentNodePointer == nodePointer { //如果正准备攻击这个玩家,将指针移动到Next + p.CurrentNodePointer = nodePointer.Next + } + } + + //Remove from the linked list + nodePointer.RemoveFromLink() + + p.CurrentSize = p.CurrentSize - 1 +} + +func (p *InRangePlayerCollection) NextPlayerToAttack() *InRangePlayerNode { + if p.CurrentNodePointer.Next != nil { + p.CurrentNodePointer = p.CurrentNodePointer.Next + } else { + //继续攻击当前玩家 + } + return p.CurrentNodePointer +} + +//TODO: 完成重构 + +/// Doubly circular linked list Implement +type InRangePlayerNode struct { + Prev *InRangePlayerNode + Next *InRangePlayerNode + player *Player +} + +func (node *InRangePlayerNode) AppendNode(newNode *InRangePlayerNode) *InRangePlayerNode { + if node == nil { + return newNode + } else if node.Next == nil && node.Prev == nil { + node.Prev = newNode + node.Next = newNode + newNode.Prev = node + newNode.Next = node + return node + } else { + oldNext := node.Next + node.Next = newNode + newNode.Next = oldNext + oldNext.Prev = newNode + newNode.Prev = node + return node + } +} + +func (node *InRangePlayerNode) PrependNode(newNode *InRangePlayerNode) *InRangePlayerNode { + if node == nil { //没有节点的情况 + return newNode + } else if node.Next == nil && node.Prev == nil { //单个节点的情况 + node.Prev = newNode + node.Next = newNode + newNode.Prev = node + newNode.Next = node + return node + } else { + oldPrev := node.Prev + node.Prev = newNode + newNode.Prev = oldPrev + oldPrev.Next = newNode + newNode.Next = node + return node + } +} + +func (node *InRangePlayerNode) RemoveFromLink() { + if node == nil { + return + } else if node.Next == nil && node.Prev == nil { + node = nil //Wait for GC + } else { + prev := node.Prev + next := node.Next + prev.Next = next + next.Prev = prev + node = nil + } +} + +func (node *InRangePlayerNode) Print() { + if node == nil { + fmt.Println("No player in range") + } else if node.Next == nil && node.Prev == nil { + fmt.Println(Red(node.player.Id)) + } else { + now := node.Next + fmt.Printf("%d ", Red(node.player.Id)) + for node != now { + fmt.Printf("%d ", Green(now.player.Id)) + now = now.Next + } + fmt.Println("") + } +} + +/// End Doubly circular linked list Implement diff --git a/battle_srv/models/math.go b/battle_srv/models/math.go new file mode 100644 index 0000000..37e8f5b --- /dev/null +++ b/battle_srv/models/math.go @@ -0,0 +1,132 @@ +package models + +import ( + "fmt" + "github.com/ByteArena/box2d" + "math" +) + +// Use type `float64` for json unmarshalling of numbers. +type Direction struct { + Dx int32 `json:"dx,omitempty"` + Dy int32 `json:"dy,omitempty"` +} + +type Vec2D struct { + X float64 `json:"x,omitempty"` + Y float64 `json:"y,omitempty"` +} + +func CreateVec2DFromB2Vec2(b2V2 box2d.B2Vec2) *Vec2D { + return &Vec2D{ + X: b2V2.X, + Y: b2V2.Y, + } +} + +func (v2 *Vec2D) ToB2Vec2() box2d.B2Vec2 { + return box2d.MakeB2Vec2(v2.X, v2.Y) +} + +type Polygon2D struct { + Anchor *Vec2D `json:"-"` // This "Polygon2D.Anchor" is used to be assigned to "B2BodyDef.Position", which in turn is used as the position of the FIRST POINT of the polygon. + Points []*Vec2D `json:"-"` + + /* + When used to represent a "polyline directly drawn in a `Tmx file`", we can initialize both "Anchor" and "Points" simultaneously. + + Yet when used to represent a "polyline drawn in a `Tsx file`", we have to first initialize "Points w.r.t. center of the tile-rectangle", and then "Anchor(initially nil) of the tile positioned in the `Tmx file`". + + Refer to https://shimo.im/docs/SmLJJhXm2C8XMzZT for more information. + */ + + /* + [WARNING] Used to cache "`TileWidth & TileHeight` of a Tsx file" only. + */ + TileWidth int + TileHeight int + + /* + [WARNING] Used to cache "`Width & TileHeight` of an object in Tmx file" only. + */ + TmxObjectWidth float64 + TmxObjectHeight float64 +} + +func MoveDynamicBody(body *box2d.B2Body, pToTargetPos *box2d.B2Vec2, inSeconds float64) { + if body.GetType() != box2d.B2BodyType.B2_dynamicBody { + return + } + body.SetTransform(*pToTargetPos, 0.0) + body.SetLinearVelocity(box2d.MakeB2Vec2(0.0, 0.0)) + body.SetAngularVelocity(0.0) +} + +func PrettyPrintFixture(fix *box2d.B2Fixture) { + fmt.Printf("\t\tfriction:\t%v\n", fix.M_friction) + fmt.Printf("\t\trestitution:\t%v\n", fix.M_restitution) + fmt.Printf("\t\tdensity:\t%v\n", fix.M_density) + fmt.Printf("\t\tisSensor:\t%v\n", fix.M_isSensor) + fmt.Printf("\t\tfilter.categoryBits:\t%d\n", fix.M_filter.CategoryBits) + fmt.Printf("\t\tfilter.maskBits:\t%d\n", fix.M_filter.MaskBits) + fmt.Printf("\t\tfilter.groupIndex:\t%d\n", fix.M_filter.GroupIndex) + + switch fix.M_shape.GetType() { + case box2d.B2Shape_Type.E_circle: + { + s := fix.M_shape.(*box2d.B2CircleShape) + fmt.Printf("\t\tb2CircleShape shape: {\n") + fmt.Printf("\t\t\tradius:\t%v\n", s.M_radius) + fmt.Printf("\t\t\toffset:\t%v\n", s.M_p) + fmt.Printf("\t\t}\n") + } + break + + case box2d.B2Shape_Type.E_polygon: + { + s := fix.M_shape.(*box2d.B2PolygonShape) + fmt.Printf("\t\tb2PolygonShape shape: {\n") + for i := 0; i < s.M_count; i++ { + fmt.Printf("\t\t\t%v\n", s.M_vertices[i]) + } + fmt.Printf("\t\t}\n") + } + break + + default: + break + } +} + +func PrettyPrintBody(body *box2d.B2Body) { + bodyIndex := body.M_islandIndex + + fmt.Printf("{\n") + fmt.Printf("\tHeapRAM addr:\t%p\n", body) + fmt.Printf("\ttype:\t%d\n", body.M_type) + fmt.Printf("\tposition:\t%v\n", body.GetPosition()) + fmt.Printf("\tangle:\t%v\n", body.M_sweep.A) + fmt.Printf("\tlinearVelocity:\t%v\n", body.GetLinearVelocity()) + fmt.Printf("\tangularVelocity:\t%v\n", body.GetAngularVelocity()) + fmt.Printf("\tlinearDamping:\t%v\n", body.M_linearDamping) + fmt.Printf("\tangularDamping:\t%v\n", body.M_angularDamping) + fmt.Printf("\tallowSleep:\t%d\n", body.M_flags&box2d.B2Body_Flags.E_autoSleepFlag) + fmt.Printf("\tawake:\t%d\n", body.M_flags&box2d.B2Body_Flags.E_awakeFlag) + fmt.Printf("\tfixedRotation:\t%d\n", body.M_flags&box2d.B2Body_Flags.E_fixedRotationFlag) + fmt.Printf("\tbullet:\t%d\n", body.M_flags&box2d.B2Body_Flags.E_bulletFlag) + fmt.Printf("\tactive:\t%d\n", body.M_flags&box2d.B2Body_Flags.E_activeFlag) + fmt.Printf("\tgravityScale:\t%v\n", body.M_gravityScale) + fmt.Printf("\tislandIndex:\t%v\n", bodyIndex) + fmt.Printf("\tfixtures: {\n") + for f := body.M_fixtureList; f != nil; f = f.M_next { + PrettyPrintFixture(f) + } + fmt.Printf("\t}\n") + fmt.Printf("}\n") +} + +func Distance(pt1 *Vec2D, pt2 *Vec2D) float64 { + dx := pt1.X - pt2.X + dy := pt1.Y - pt2.Y + return math.Sqrt(dx*dx + dy*dy) +} diff --git a/battle_srv/models/pb_type_convert.go b/battle_srv/models/pb_type_convert.go new file mode 100644 index 0000000..73360cb --- /dev/null +++ b/battle_srv/models/pb_type_convert.go @@ -0,0 +1,203 @@ +package models + +import ( + pb "server/pb_output" +) + +func toPbVec2D(modelInstance *Vec2D) *pb.Vec2D { + toRet := &pb.Vec2D{ + X: modelInstance.X, + Y: modelInstance.Y, + } + return toRet +} + +func toPbPolygon2D(modelInstance *Polygon2D) *pb.Polygon2D { + toRet := &pb.Polygon2D{ + Anchor: toPbVec2D(modelInstance.Anchor), + Points: make([]*pb.Vec2D, len(modelInstance.Points)), + } + for index, p := range modelInstance.Points { + toRet.Points[index] = toPbVec2D(p) + } + return toRet +} + +func toPbVec2DList(modelInstance *Vec2DList) *pb.Vec2DList { + toRet := &pb.Vec2DList{ + Vec2DList: make([]*pb.Vec2D, len(*modelInstance)), + } + for k, v := range *modelInstance { + toRet.Vec2DList[k] = toPbVec2D(v) + } + return toRet +} + +func toPbPolygon2DList(modelInstance *Polygon2DList) *pb.Polygon2DList { + toRet := &pb.Polygon2DList{ + Polygon2DList: make([]*pb.Polygon2D, len(*modelInstance)), + } + for k, v := range *modelInstance { + toRet.Polygon2DList[k] = toPbPolygon2D(v) + } + return toRet +} + +func ToPbStrToBattleColliderInfo(intervalToPing int32, willKickIfInactiveFor int32, boundRoomId int32, stageName string, modelInstance1 StrToVec2DListMap, modelInstance2 StrToPolygon2DListMap, stageDiscreteW int32, stageDiscreteH int32, stageTileW int32, stageTileH int32) *pb.BattleColliderInfo { + toRet := &pb.BattleColliderInfo{ + IntervalToPing: intervalToPing, + WillKickIfInactiveFor: willKickIfInactiveFor, + BoundRoomId: boundRoomId, + StageName: stageName, + StrToVec2DListMap: make(map[string]*pb.Vec2DList, 0), + StrToPolygon2DListMap: make(map[string]*pb.Polygon2DList, 0), + StageDiscreteW: stageDiscreteW, + StageDiscreteH: stageDiscreteH, + StageTileW: stageTileW, + StageTileH: stageTileH, + } + for k, v := range modelInstance1 { + toRet.StrToVec2DListMap[k] = toPbVec2DList(v) + } + for k, v := range modelInstance2 { + toRet.StrToPolygon2DListMap[k] = toPbPolygon2DList(v) + } + return toRet +} + +func toPbPlayers(modelInstances map[int32]*Player) map[int32]*pb.Player { + toRet := make(map[int32]*pb.Player, 0) + if nil == modelInstances { + return toRet + } + + for k, last := range modelInstances { + toRet[k] = &pb.Player{ + Id: last.Id, + X: last.X, + Y: last.Y, + Dir: &pb.Direction{ + Dx: last.Dir.Dx, + Dy: last.Dir.Dy, + }, + Speed: last.Speed, + BattleState: last.BattleState, + Score: last.Score, + Removed: last.Removed, + JoinIndex: last.JoinIndex, + } + } + + return toRet +} + +func toPbTreasures(modelInstances map[int32]*Treasure) map[int32]*pb.Treasure { + toRet := make(map[int32]*pb.Treasure, 0) + if nil == modelInstances { + return toRet + } + + for k, last := range modelInstances { + toRet[k] = &pb.Treasure{ + Id: last.Id, + LocalIdInBattle: last.LocalIdInBattle, + Score: last.Score, + X: last.X, + Y: last.Y, + Removed: last.Removed, + Type: last.Type, + } + } + + return toRet +} + +func toPbTraps(modelInstances map[int32]*Trap) map[int32]*pb.Trap { + toRet := make(map[int32]*pb.Trap, 0) + if nil == modelInstances { + return toRet + } + + for k, last := range modelInstances { + toRet[k] = &pb.Trap{ + Id: last.Id, + LocalIdInBattle: last.LocalIdInBattle, + X: last.X, + Y: last.Y, + Removed: last.Removed, + Type: last.Type, + } + } + + return toRet +} + +func toPbBullets(modelInstances map[int32]*Bullet) map[int32]*pb.Bullet { + toRet := make(map[int32]*pb.Bullet, 0) + if nil == modelInstances { + return toRet + } + + for k, last := range modelInstances { + if nil == last.StartAtPoint || nil == last.EndAtPoint { + continue + } + toRet[k] = &pb.Bullet{ + LocalIdInBattle: last.LocalIdInBattle, + LinearSpeed: last.LinearSpeed, + X: last.X, + Y: last.Y, + Removed: last.Removed, + StartAtPoint: &pb.Vec2D{ + X: last.StartAtPoint.X, + Y: last.StartAtPoint.Y, + }, + EndAtPoint: &pb.Vec2D{ + X: last.EndAtPoint.X, + Y: last.EndAtPoint.Y, + }, + } + } + + return toRet +} + +func toPbSpeedShoes(modelInstances map[int32]*SpeedShoe) map[int32]*pb.SpeedShoe { + toRet := make(map[int32]*pb.SpeedShoe, 0) + if nil == modelInstances { + return toRet + } + + for k, last := range modelInstances { + toRet[k] = &pb.SpeedShoe{ + Id: last.Id, + LocalIdInBattle: last.LocalIdInBattle, + X: last.X, + Y: last.Y, + Removed: last.Removed, + Type: last.Type, + } + } + + return toRet +} + +func toPbGuardTowers(modelInstances map[int32]*GuardTower) map[int32]*pb.GuardTower { + toRet := make(map[int32]*pb.GuardTower, 0) + if nil == modelInstances { + return toRet + } + + for k, last := range modelInstances { + toRet[k] = &pb.GuardTower{ + Id: last.Id, + LocalIdInBattle: last.LocalIdInBattle, + X: last.X, + Y: last.Y, + Removed: last.Removed, + Type: last.Type, + } + } + + return toRet +} diff --git a/battle_srv/models/player.go b/battle_srv/models/player.go new file mode 100644 index 0000000..3c4e137 --- /dev/null +++ b/battle_srv/models/player.go @@ -0,0 +1,142 @@ +package models + +import ( + "database/sql" + "fmt" + "github.com/ByteArena/box2d" + sq "github.com/Masterminds/squirrel" + "github.com/jmoiron/sqlx" +) + +type PlayerBattleState struct { + ADDED_PENDING_BATTLE_COLLIDER_ACK int32 + READDED_PENDING_BATTLE_COLLIDER_ACK int32 + ACTIVE int32 + DISCONNECTED int32 + LOST int32 + EXPELLED_DURING_GAME int32 + EXPELLED_IN_DISMISSAL int32 +} + +var PlayerBattleStateIns PlayerBattleState + +func InitPlayerBattleStateIns() { + PlayerBattleStateIns = PlayerBattleState{ + ADDED_PENDING_BATTLE_COLLIDER_ACK: 0, + READDED_PENDING_BATTLE_COLLIDER_ACK: 1, + ACTIVE: 2, + DISCONNECTED: 3, + LOST: 4, + EXPELLED_DURING_GAME: 5, + EXPELLED_IN_DISMISSAL: 6, + } +} + +type Player struct { + Id int32 `json:"id,omitempty" db:"id"` + X float64 `json:"x,omitempty"` + Y float64 `json:"y,omitempty"` + Dir *Direction `json:"dir,omitempty"` + Speed int32 `json:"speed,omitempty"` + BattleState int32 `json:"battleState,omitempty"` + LastMoveGmtMillis int32 `json:"lastMoveGmtMillis,omitempty"` + Score int32 `json:"score,omitempty"` + Removed bool `json:"removed,omitempty"` + JoinIndex int32 + + Name string `json:"name,omitempty" db:"name"` + DisplayName string `json:"displayName,omitempty" db:"display_name"` + Avatar string `json:"avatar,omitempty"` + + FrozenAtGmtMillis int64 `json:"-" db:"-"` + AddSpeedAtGmtMillis int64 `json:"-" db:"-"` + CreatedAt int64 `json:"-" db:"created_at"` + UpdatedAt int64 `json:"-" db:"updated_at"` + DeletedAt NullInt64 `json:"-" db:"deleted_at"` + TutorialStage int `json:"-" db:"tutorial_stage"` + CollidableBody *box2d.B2Body `json:"-"` + AckingFrameId int32 `json:"ackingFrameId"` + AckingInputFrameId int32 `json:"-"` + LastSentInputFrameId int32 `json:"-"` +} + +func ExistPlayerByName(name string) (bool, error) { + return exist("player", sq.Eq{"name": name, "deleted_at": nil}) +} + +func GetPlayerByName(name string) (*Player, error) { + return getPlayer(sq.Eq{"name": name, "deleted_at": nil}) +} + +func GetPlayerById(id int) (*Player, error) { + return getPlayer(sq.Eq{"id": id, "deleted_at": nil}) +} + +func getPlayer(cond sq.Eq) (*Player, error) { + var p Player + err := getObj("player", cond, &p) + if err == sql.ErrNoRows { + return nil, nil + } + p.Dir = &Direction{ + Dx: 0, + Dy: 0, + } + return &p, nil +} + +func (p *Player) Insert(tx *sqlx.Tx) error { + result, err := txInsert(tx, "player", []string{"name", "display_name", "created_at", "updated_at", "avatar"}, + []interface{}{p.Name, p.DisplayName, p.CreatedAt, p.UpdatedAt, p.Avatar}) + if err != nil { + return err + } + id, err := result.LastInsertId() + if err != nil { + return err + } + p.Id = int32(id) + return nil +} + +func Update(tx *sqlx.Tx, id int32, p *Player) (bool, error) { + query, args, err := sq.Update("player"). + Set("display_name", p.DisplayName). + Set("avatar", p.Avatar). + Where(sq.Eq{"id": id}).ToSql() + + fmt.Println(query) + + if err != nil { + return false, err + } + result, err := tx.Exec(query, args...) + if err != nil { + fmt.Println("ERRRRRRR: ") + fmt.Println(err) + return false, err + } + rowsAffected, err := result.RowsAffected() + if err != nil { + return false, err + } + return rowsAffected >= 1, nil +} + +func UpdatePlayerTutorialStage(tx *sqlx.Tx, id int) (bool, error) { + query, args, err := sq.Update("player"). + Set("tutorial_stage", 1). + Where(sq.Eq{"tutorial_stage": 0, "id": id}).ToSql() + if err != nil { + return false, err + } + result, err := tx.Exec(query, args...) + if err != nil { + return false, err + } + rowsAffected, err := result.RowsAffected() + if err != nil { + return false, err + } + return rowsAffected >= 1, nil +} diff --git a/battle_srv/models/player_auth_binding.go b/battle_srv/models/player_auth_binding.go new file mode 100644 index 0000000..8363ac1 --- /dev/null +++ b/battle_srv/models/player_auth_binding.go @@ -0,0 +1,35 @@ +package models + +import ( + "database/sql" + + sq "github.com/Masterminds/squirrel" + "github.com/jmoiron/sqlx" +) + +type PlayerAuthBinding struct { + Channel int `db:"channel"` + CreatedAt int64 `db:"created_at"` + DeletedAt NullInt64 `db:"deleted_at"` + ExtAuthID string `db:"ext_auth_id"` + PlayerID int `db:"player_id"` + UpdatedAt int64 `db:"updated_at"` +} + +func (p *PlayerAuthBinding) Insert(tx *sqlx.Tx) error { + _, err := txInsert(tx, "player_auth_binding", []string{"channel", "created_at", "ext_auth_id", + "player_id", "updated_at"}, + []interface{}{p.Channel, p.CreatedAt, p.ExtAuthID, p.PlayerID, p.UpdatedAt}) + return err +} + +func GetPlayerAuthBinding(channel int, extAuthID string) (*PlayerAuthBinding, error) { + var p PlayerAuthBinding + err := getObj("player_auth_binding", + sq.Eq{"channel": channel, "ext_auth_id": extAuthID, "deleted_at": nil}, + &p) + if err == sql.ErrNoRows { + return nil, nil + } + return &p, nil +} diff --git a/battle_srv/models/player_login.go b/battle_srv/models/player_login.go new file mode 100644 index 0000000..96f4ea8 --- /dev/null +++ b/battle_srv/models/player_login.go @@ -0,0 +1,110 @@ +package models + +import ( + "database/sql" + . "server/common" + "server/common/utils" + "server/storage" + + sq "github.com/Masterminds/squirrel" +) + +type PlayerLogin struct { + CreatedAt int64 `db:"created_at"` + DeletedAt NullInt64 `db:"deleted_at"` + DisplayName NullString `db:"display_name"` + Avatar string `db:"avatar"` + FromPublicIP NullString `db:"from_public_ip"` + ID int `db:"id"` + IntAuthToken string `db:"int_auth_token"` + PlayerID int `db:"player_id"` + UpdatedAt int64 `db:"updated_at"` +} + +func (p *PlayerLogin) Insert() error { + result, err := insert("player_login", []string{"created_at", "display_name", + "from_public_ip", "int_auth_token", "player_id", "updated_at", "avatar"}, + []interface{}{p.CreatedAt, p.DisplayName, p.FromPublicIP, p.IntAuthToken, + p.PlayerID, p.UpdatedAt, p.Avatar}) + if err != nil { + return err + } + id, err := result.LastInsertId() + if err != nil { + return err + } + p.ID = int(id) + return nil +} + +func GetPlayerLoginByToken(token string) (*PlayerLogin, error) { + var p PlayerLogin + err := getObj("player_login", + sq.Eq{"int_auth_token": token, "deleted_at": nil}, + &p) + if err == sql.ErrNoRows { + return nil, nil + } + return &p, nil +} + +func GetPlayerLoginByPlayerId(playerId int) (*PlayerLogin, error) { + var p PlayerLogin + err := getObj("player_login", + sq.Eq{"player_id": playerId, "deleted_at": nil}, + &p) + if err == sql.ErrNoRows { + return nil, nil + } + return &p, nil +} + +func GetPlayerIdByToken(token string) (int, error) { + var p PlayerLogin + err := getFields("player_login", []string{"player_id"}, + sq.Eq{"int_auth_token": token, "deleted_at": nil}, + &p) + if err == sql.ErrNoRows { + return 0, nil + } + return p.PlayerID, nil +} + +// TODO 封装到helper +func DelPlayerLoginByToken(token string) error { + query, args, err := sq.Update("player_login").Set("deleted_at", utils.UnixtimeMilli()). + Where(sq.Eq{"int_auth_token": token}).ToSql() + if err != nil { + return err + } + //Logger.Debug(query, args) + _, err = storage.MySQLManagerIns.Exec(query, args...) + if err == sql.ErrNoRows { + return nil + } + if err != nil { + return err + } + return nil +} + +func EnsuredPlayerLoginByToken(id int, token string) (bool, error) { + return exist("player_login", sq.Eq{"int_auth_token": token, "deleted_at": nil, "player_id": id}) +} + +func EnsuredPlayerLoginById(id int) (bool, error) { + return exist("player_login", sq.Eq{"player_id": id, "deleted_at": nil}) +} + +func CleanExpiredPlayerLoginToken() error { + now := utils.UnixtimeMilli() + max := now - int64(Constants.Player.IntAuthTokenTTLSeconds*1000) + + query, args, err := sq.Update("player_login").Set("deleted_at", now). + Where(sq.LtOrEq{"created_at": max}).ToSql() + if err != nil { + return err + } + _, err = storage.MySQLManagerIns.Exec(query, args...) + return err +} diff --git a/battle_srv/models/player_wallet.go b/battle_srv/models/player_wallet.go new file mode 100644 index 0000000..23421f2 --- /dev/null +++ b/battle_srv/models/player_wallet.go @@ -0,0 +1,129 @@ +package models + +import ( + "database/sql" + "errors" + . "server/common" + "server/common/utils" + + sq "github.com/Masterminds/squirrel" + "github.com/jmoiron/sqlx" + "go.uber.org/zap" +) + +type PlayerWallet struct { + CreatedAt int64 `json:"-" db:"created_at"` + DeletedAt NullInt64 `json:"-" db:"deleted_at"` + Gem int `json:"gem" db:"gem"` + ID int `json:"-" db:"id"` + UpdatedAt int64 `json:"-" db:"updated_at"` +} + +func (p *PlayerWallet) Insert(tx *sqlx.Tx) error { + _, err := txInsert(tx, "player_wallet", []string{"id", "created_at", "updated_at"}, + []interface{}{p.ID, p.CreatedAt, p.UpdatedAt}) + return err +} + +func GetPlayerWalletById(id int) (*PlayerWallet, error) { + var p PlayerWallet + err := getObj("player_wallet", sq.Eq{"id": id, "deleted_at": nil}, &p) + if err == sql.ErrNoRows { + return nil, nil + } + return &p, nil +} + +func CostPlayerWallet(tx *sqlx.Tx, id int, currency int, val int) (int, error) { + var column string + switch currency { + case Constants.Player.Diamond: + column = "diamond" + case Constants.Player.Energy: + column = "energy" + case Constants.Player.Gold: + column = "gold" + } + if column == "" { + Logger.Debug("CostPlayerWallet Error Currency", + zap.Int("currency", currency), zap.Int("val", val)) + return Constants.RetCode.MysqlError, errors.New("error currency") + } + + now := utils.UnixtimeMilli() + query, args, err := sq.Update("player_wallet"). + Set(column, sq.Expr(column+"-?", val)).Set("updated_at", now). + Where(sq.Eq{"id": id, "deleted_at": nil}). + Where(sq.GtOrEq{column: val}).ToSql() + + Logger.Debug("CostPlayerWallet", zap.String("sql", query), zap.Any("args", args)) + if err != nil { + return Constants.RetCode.MysqlError, err + } + result, err := tx.Exec(query, args...) + if err != nil { + return Constants.RetCode.MysqlError, err + } + rowsAffected, err := result.RowsAffected() + if err != nil { + return Constants.RetCode.MysqlError, err + } + ok := rowsAffected >= 1 + Logger.Debug("CostPlayerWallet", zap.Int64("rowsAffected", rowsAffected), + zap.Bool("cost", ok)) + if !ok { + var ret int + switch currency { + case Constants.Player.Diamond: + ret = Constants.RetCode.LackOfDiamond + case Constants.Player.Energy: + ret = Constants.RetCode.LackOfEnergy + case Constants.Player.Gold: + ret = Constants.RetCode.LackOfGold + } + return ret, nil + } + return 0, nil +} + +func AddPlayerWallet(tx *sqlx.Tx, id int, currency int, val int) (int, error) { + var column string + switch currency { + case Constants.Player.Diamond: + column = "diamond" + case Constants.Player.Energy: + column = "energy" + case Constants.Player.Gold: + column = "gold" + } + if column == "" { + Logger.Debug("CostPlayerWallet Error Currency", + zap.Int("currency", currency), zap.Int("val", val)) + return Constants.RetCode.MysqlError, errors.New("error currency") + } + + now := utils.UnixtimeMilli() + query, args, err := sq.Update("player_wallet"). + Set(column, sq.Expr(column+"+?", val)).Set("updated_at", now). + Where(sq.Eq{"id": id, "deleted_at": nil}).ToSql() + + Logger.Debug("AddPlayerWallet", zap.String("sql", query), zap.Any("args", args)) + if err != nil { + return Constants.RetCode.MysqlError, err + } + result, err := tx.Exec(query, args...) + if err != nil { + return Constants.RetCode.MysqlError, err + } + rowsAffected, err := result.RowsAffected() + if err != nil { + return Constants.RetCode.MysqlError, err + } + ok := rowsAffected >= 1 + Logger.Debug("AddPlayerWallet", zap.Int64("rowsAffected", rowsAffected), + zap.Bool("add", ok)) + if !ok { + return Constants.RetCode.UnknownError, nil + } + return 0, nil +} diff --git a/battle_srv/models/pumpkin.go b/battle_srv/models/pumpkin.go new file mode 100644 index 0000000..7868387 --- /dev/null +++ b/battle_srv/models/pumpkin.go @@ -0,0 +1,14 @@ +package models + +import "github.com/ByteArena/box2d" + +type Pumpkin struct { + LocalIdInBattle int32 `json:"localIdInBattle,omitempty"` + LinearSpeed float64 `json:"linearSpeed,omitempty"` + X float64 `json:"x,omitempty"` + Y float64 `json:"y,omitempty"` + Removed bool `json:"removed,omitempty"` + Dir *Direction `json:"-"` + CollidableBody *box2d.B2Body `json:"-"` + RemovedAtFrameId int32 `json:"-"` +} diff --git a/battle_srv/models/ringbuf.go b/battle_srv/models/ringbuf.go new file mode 100644 index 0000000..5d2d82d --- /dev/null +++ b/battle_srv/models/ringbuf.go @@ -0,0 +1,73 @@ +package models + +type RingBuffer struct { + Ed int32 // write index + St int32 // read index + EdFrameId int32 + StFrameId int32 + N int32 + Cnt int32 // the count of valid elements in the buffer, used mainly to distinguish what "st == ed" means for "Pop" and "Get" methods + Eles []interface{} +} + +func NewRingBuffer(n int32) *RingBuffer { + return &RingBuffer{ + Ed: 0, + St: 0, + N: n, + Cnt: 0, + Eles: make([]interface{}, n), + } +} + +func (rb *RingBuffer) Put(pItem interface{}) { + rb.Eles[rb.Ed] = pItem + rb.EdFrameId++ + rb.Cnt++ + rb.Ed++ + if rb.Ed >= rb.N { + rb.Ed -= rb.N // Deliberately not using "%" operator for performance concern + } +} + +func (rb *RingBuffer) Pop() interface{} { + if 0 == rb.Cnt { + return nil + } + pItem := rb.Eles[rb.St] + rb.StFrameId++ + rb.Cnt-- + rb.St++ + if rb.St >= rb.N { + rb.St -= rb.N + } + return pItem +} + +func (rb *RingBuffer) GetByOffset(offsetFromSt int32) interface{} { + if 0 == rb.Cnt { + return nil + } + arrIdx := rb.St + offsetFromSt + if rb.St < rb.Ed { + // case#1: 0...st...ed...N-1 + if rb.St <= arrIdx && arrIdx < rb.Ed { + return rb.Eles[arrIdx] + } + } else { + // if rb.St >= rb.Ed + // case#2: 0...ed...st...N-1 + if arrIdx >= rb.N { + arrIdx -= rb.N + } + if arrIdx >= rb.St || arrIdx < rb.Ed { + return rb.Eles[arrIdx] + } + } + + return nil +} + +func (rb *RingBuffer) GetByFrameId(frameId int32) interface{} { + return rb.GetByOffset(frameId - rb.StFrameId) +} diff --git a/battle_srv/models/room.go b/battle_srv/models/room.go new file mode 100644 index 0000000..d30261c --- /dev/null +++ b/battle_srv/models/room.go @@ -0,0 +1,1450 @@ +package models + +import ( + "encoding/xml" + "fmt" + "strings" + "github.com/ByteArena/box2d" + "github.com/golang/protobuf/proto" + "github.com/gorilla/websocket" + "go.uber.org/zap" + "io/ioutil" + "math/rand" + "os" + "path/filepath" + . "server/common" + "server/common/utils" + pb "server/pb_output" + "sync" + "sync/atomic" + "time" +) + +const ( + UPSYNC_MSG_ACT_HB_PING = int32(1) + UPSYNC_MSG_ACT_PLAYER_CMD = int32(2) + UPSYNC_MSG_ACT_PLAYER_COLLIDER_ACK = int32(3) + + DOWNSYNC_MSG_ACT_HB_REQ = int32(1) + DOWNSYNC_MSG_ACT_INPUT_BATCH = int32(2) + DOWNSYNC_MSG_ACT_ROOM_FRAME = int32(3) +) + +const ( + MAGIC_REMOVED_AT_FRAME_ID_PERMANENT_REMOVAL_MARGIN = 5 + MAGIC_ROOM_DOWNSYNC_FRAME_ID_BATTLE_READY_TO_START = -99 + MAGIC_ROOM_DOWNSYNC_FRAME_ID_PLAYER_ADDED_AND_ACKED = -98 + MAGIC_ROOM_DOWNSYNC_FRAME_ID_PLAYER_READDED_AND_ACKED = -97 + + MAGIC_JOIN_INDEX_DEFAULT = 0 + MAGIC_JOIN_INDEX_INVALID = -1 +) + +const ( + // You can equivalently use the `GroupIndex` approach, but the more complicated and general purpose approach is used deliberately here. Reference http://www.aurelienribon.com/post/2011-07-box2d-tutorial-collision-filtering. + COLLISION_CATEGORY_CONTROLLED_PLAYER = (1 << 1) + COLLISION_CATEGORY_TREASURE = (1 << 2) + COLLISION_CATEGORY_TRAP = (1 << 3) + COLLISION_CATEGORY_TRAP_BULLET = (1 << 4) + COLLISION_CATEGORY_BARRIER = (1 << 5) + COLLISION_CATEGORY_PUMPKIN = (1 << 6) + COLLISION_CATEGORY_SPEED_SHOES = (1 << 7) + + COLLISION_MASK_FOR_CONTROLLED_PLAYER = (COLLISION_CATEGORY_TREASURE | COLLISION_CATEGORY_TRAP | COLLISION_CATEGORY_TRAP_BULLET | COLLISION_CATEGORY_SPEED_SHOES) + COLLISION_MASK_FOR_TREASURE = (COLLISION_CATEGORY_CONTROLLED_PLAYER) + COLLISION_MASK_FOR_TRAP = (COLLISION_CATEGORY_CONTROLLED_PLAYER) + COLLISION_MASK_FOR_TRAP_BULLET = (COLLISION_CATEGORY_CONTROLLED_PLAYER) + COLLISION_MASK_FOR_BARRIER = (COLLISION_CATEGORY_PUMPKIN) + COLLISION_MASK_FOR_PUMPKIN = (COLLISION_CATEGORY_BARRIER) + COLLISION_MASK_FOR_SPEED_SHOES = (COLLISION_CATEGORY_CONTROLLED_PLAYER) +) + +var DIRECTION_DECODER = [][]int32{ + {0, 0}, + {0, +1}, + {0, -1}, + {+2, 0}, + {-2, 0}, + {+2, +1}, + {-2, -1}, + {+2, -1}, + {-2, +1}, + {+2, 0}, + {-2, 0}, + {0, +1}, + {0, -1}, +} + +type RoomBattleState struct { + IDLE int32 + WAITING int32 + PREPARE int32 + IN_BATTLE int32 + STOPPING_BATTLE_FOR_SETTLEMENT int32 + IN_SETTLEMENT int32 + IN_DISMISSAL int32 +} + +type BattleStartCbType func() +type SignalToCloseConnCbType func(customRetCode int, customRetMsg string) + +// A single instance containing only "named constant integers" to be shared by all threads. +var RoomBattleStateIns RoomBattleState + +func InitRoomBattleStateIns() { + RoomBattleStateIns = RoomBattleState{ + IDLE: 0, + WAITING: -1, + PREPARE: 10000000, + IN_BATTLE: 10000001, + STOPPING_BATTLE_FOR_SETTLEMENT: 10000002, + IN_SETTLEMENT: 10000003, + IN_DISMISSAL: 10000004, + } +} + +func calRoomScore(inRoomPlayerCount int32, roomPlayerCnt int, currentRoomBattleState int32) float32 { + x := float32(inRoomPlayerCount) / float32(roomPlayerCnt) + d := (x - 0.5) + d2 := d * d + return -7.8125*d2 + 5.0 - float32(currentRoomBattleState) +} + +type Room struct { + Id int32 + Capacity int + Players map[int32]*Player + /** + * The following `PlayerDownsyncSessionDict` is NOT individually put + * under `type Player struct` for a reason. + * + * Upon each connection establishment, a new instance `player Player` is created for the given `playerId`. + + * To be specific, if + * - that `playerId == 42` accidentally reconnects in just several milliseconds after a passive disconnection, e.g. due to bad wireless signal strength, and + * - that `type Player struct` contains a `DownsyncSession` field + * + * , then we might have to + * - clean up `previousPlayerInstance.DownsyncSession` + * - initialize `currentPlayerInstance.DownsyncSession` + * + * to avoid chaotic flaws. + * + * Moreover, during the invocation of `PlayerSignalToCloseDict`, the `Player` instance is supposed to be deallocated (though not synchronously). + */ + PlayerDownsyncSessionDict map[int32]*websocket.Conn + PlayerSignalToCloseDict map[int32]SignalToCloseConnCbType + Score float32 + State int32 + Index int + Tick int32 + ServerFPS int32 + BattleDurationNanos int64 + EffectivePlayerCount int32 + DismissalWaitGroup sync.WaitGroup + Treasures map[int32]*Treasure + Traps map[int32]*Trap + GuardTowers map[int32]*GuardTower + Bullets map[int32]*Bullet + SpeedShoes map[int32]*SpeedShoe + Barriers map[int32]*Barrier + Pumpkins map[int32]*Pumpkin + AccumulatedLocalIdForBullets int32 + CollidableWorld *box2d.B2World + AllPlayerInputsBuffer *RingBuffer + LastAllConfirmedInputFrameId int32 + LastAllConfirmedInputFrameIdWithChange int32 + LastAllConfirmedInputList []uint64 + InputDelayFrames int32 + InputScaleFrames uint32 // inputDelayedAndScaledFrameId = ((originalFrameId - InputDelayFrames) >> InputScaleFrames) + JoinIndexBooleanArr []bool + + StageName string + StageDiscreteW int32 + StageDiscreteH int32 + StageTileW int32 + StageTileH int32 + RawBattleStrToVec2DListMap StrToVec2DListMap + RawBattleStrToPolygon2DListMap StrToPolygon2DListMap +} + +func (pR *Room) onTreasurePickedUp(contactingPlayer *Player, contactingTreasure *Treasure) { + if _, existent := pR.Treasures[contactingTreasure.LocalIdInBattle]; existent { + Logger.Info("Player has picked up treasure:", zap.Any("roomId", pR.Id), zap.Any("contactingPlayer.Id", contactingPlayer.Id), zap.Any("contactingTreasure.LocalIdInBattle", contactingTreasure.LocalIdInBattle)) + pR.CollidableWorld.DestroyBody(contactingTreasure.CollidableBody) + pR.Treasures[contactingTreasure.LocalIdInBattle] = &Treasure{Removed: true} + pR.Players[contactingPlayer.Id].Score += contactingTreasure.Score + } +} + +const ( + PLAYER_DEFAULT_SPEED = 200 // Hardcoded + ADD_SPEED = 100 // Hardcoded +) + +func (pR *Room) onSpeedShoePickedUp(contactingPlayer *Player, contactingSpeedShoe *SpeedShoe, nowMillis int64) { + if _, existent := pR.SpeedShoes[contactingSpeedShoe.LocalIdInBattle]; existent && contactingPlayer.AddSpeedAtGmtMillis == -1 { + Logger.Info("Player has picked up a SpeedShoe:", zap.Any("roomId", pR.Id), zap.Any("contactingPlayer.Id", contactingPlayer.Id), zap.Any("contactingSpeedShoe.LocalIdInBattle", contactingSpeedShoe.LocalIdInBattle)) + pR.CollidableWorld.DestroyBody(contactingSpeedShoe.CollidableBody) + pR.SpeedShoes[contactingSpeedShoe.LocalIdInBattle] = &SpeedShoe{ + Removed: true, + RemovedAtFrameId: pR.Tick, + } + pR.Players[contactingPlayer.Id].Speed += ADD_SPEED + pR.Players[contactingPlayer.Id].AddSpeedAtGmtMillis = nowMillis + } +} + +func (pR *Room) onBulletCrashed(contactingPlayer *Player, contactingBullet *Bullet, nowMillis int64, maxMillisToFreezePerPlayer int64) { + if _, existent := pR.Bullets[contactingBullet.LocalIdInBattle]; existent { + pR.CollidableWorld.DestroyBody(contactingBullet.CollidableBody) + pR.Bullets[contactingBullet.LocalIdInBattle] = &Bullet{ + Removed: true, + RemovedAtFrameId: pR.Tick, + } + + if contactingPlayer != nil { + if maxMillisToFreezePerPlayer > (nowMillis - pR.Players[contactingPlayer.Id].FrozenAtGmtMillis) { + // Deliberately doing nothing. -- YFLu, 2019-09-04. + } else { + pR.Players[contactingPlayer.Id].Speed = 0 + pR.Players[contactingPlayer.Id].FrozenAtGmtMillis = nowMillis + pR.Players[contactingPlayer.Id].AddSpeedAtGmtMillis = -1 + //Logger.Info("Player has picked up bullet:", zap.Any("roomId", pR.Id), zap.Any("contactingPlayer.Id", contactingPlayer.Id), zap.Any("contactingBullet.LocalIdInBattle", contactingBullet.LocalIdInBattle), zap.Any("pR.Players[contactingPlayer.Id].Speed", pR.Players[contactingPlayer.Id].Speed)) + } + } + } +} + +func (pR *Room) onPumpkinEncounterPlayer(pumpkin *Pumpkin, player *Player) { + Logger.Info("pumpkin has caught the player: ", zap.Any("pumpkinId", pumpkin.LocalIdInBattle), zap.Any("playerId", player.Id)) +} + +func (pR *Room) updateScore() { + pR.Score = calRoomScore(pR.EffectivePlayerCount, pR.Capacity, pR.State) +} + +func (pR *Room) AddPlayerIfPossible(pPlayerFromDbInit *Player, session *websocket.Conn, signalToCloseConnOfThisPlayer SignalToCloseConnCbType) bool { + playerId := pPlayerFromDbInit.Id + // TODO: Any thread-safety concern for accessing "pR" here? + if RoomBattleStateIns.IDLE != pR.State && RoomBattleStateIns.WAITING != pR.State { + Logger.Warn("AddPlayerIfPossible error, roomState:", zap.Any("playerId", playerId), zap.Any("roomId", pR.Id), zap.Any("roomState", pR.State), zap.Any("roomEffectivePlayerCount", pR.EffectivePlayerCount)) + return false + } + if _, existent := pR.Players[playerId]; existent { + Logger.Warn("AddPlayerIfPossible error, existing in the room.PlayersDict:", zap.Any("playerId", playerId), zap.Any("roomId", pR.Id), zap.Any("roomState", pR.State), zap.Any("roomEffectivePlayerCount", pR.EffectivePlayerCount)) + return false + } + + defer pR.onPlayerAdded(playerId) + pPlayerFromDbInit.AckingFrameId = 0 + pPlayerFromDbInit.AckingInputFrameId = -1 + pPlayerFromDbInit.LastSentInputFrameId = -1 + pPlayerFromDbInit.BattleState = PlayerBattleStateIns.ADDED_PENDING_BATTLE_COLLIDER_ACK + pPlayerFromDbInit.FrozenAtGmtMillis = -1 // Hardcoded temporarily. + pPlayerFromDbInit.Speed = PLAYER_DEFAULT_SPEED // Hardcoded temporarily. + pPlayerFromDbInit.AddSpeedAtGmtMillis = -1 // Hardcoded temporarily. + + pR.Players[playerId] = pPlayerFromDbInit + pR.PlayerDownsyncSessionDict[playerId] = session + pR.PlayerSignalToCloseDict[playerId] = signalToCloseConnOfThisPlayer + return true +} + +func (pR *Room) ReAddPlayerIfPossible(pTmpPlayerInstance *Player, session *websocket.Conn, signalToCloseConnOfThisPlayer SignalToCloseConnCbType) bool { + playerId := pTmpPlayerInstance.Id + // TODO: Any thread-safety concern for accessing "pR" and "pEffectiveInRoomPlayerInstance" here? + if RoomBattleStateIns.PREPARE != pR.State && RoomBattleStateIns.WAITING != pR.State && RoomBattleStateIns.IN_BATTLE != pR.State && RoomBattleStateIns.IN_SETTLEMENT != pR.State && RoomBattleStateIns.IN_DISMISSAL != pR.State { + Logger.Warn("ReAddPlayerIfPossible error due to roomState:", zap.Any("playerId", playerId), zap.Any("roomId", pR.Id), zap.Any("roomState", pR.State), zap.Any("roomEffectivePlayerCount", pR.EffectivePlayerCount)) + return false + } + if _, existent := pR.Players[playerId]; !existent { + Logger.Warn("ReAddPlayerIfPossible error due to player nonexistent for room:", zap.Any("playerId", playerId), zap.Any("roomId", pR.Id), zap.Any("roomState", pR.State), zap.Any("roomEffectivePlayerCount", pR.EffectivePlayerCount)) + return false + } + /* + * WARNING: The "pTmpPlayerInstance *Player" used here is a temporarily constructed + * instance from "/battle_srv/ws/serve.go", which is NOT the same as "pR.Players[pTmpPlayerInstance.Id]". + * -- YFLu + */ + defer pR.onPlayerReAdded(playerId) + pR.PlayerDownsyncSessionDict[playerId] = session + pR.PlayerSignalToCloseDict[playerId] = signalToCloseConnOfThisPlayer + pEffectiveInRoomPlayerInstance := pR.Players[playerId] + pEffectiveInRoomPlayerInstance.AckingFrameId = 0 + pEffectiveInRoomPlayerInstance.AckingInputFrameId = -1 + pEffectiveInRoomPlayerInstance.LastSentInputFrameId = -1 + pEffectiveInRoomPlayerInstance.BattleState = PlayerBattleStateIns.READDED_PENDING_BATTLE_COLLIDER_ACK + + Logger.Warn("ReAddPlayerIfPossible finished.", zap.Any("roomId", pR.Id), zap.Any("playerId", playerId), zap.Any("roomState", pR.State), zap.Any("roomEffectivePlayerCount", pR.EffectivePlayerCount), zap.Any("player AckingFrameId", pEffectiveInRoomPlayerInstance.AckingFrameId), zap.Any("player AckingInputFrameId", pEffectiveInRoomPlayerInstance.AckingInputFrameId)) + return true +} + +func (pR *Room) refreshColliders() { + /* + "BarrierCollider"s are NOT added to the "colliders in B2World of the current battle", thus NOT involved in server-side collision detection! + + -- YFLu, 2019-09-04 + */ + gravity := box2d.MakeB2Vec2(0.0, 0.0) + world := box2d.MakeB2World(gravity) + world.SetContactFilter(&box2d.B2ContactFilter{}) + pR.CollidableWorld = &world + + Logger.Info("Begins `refreshColliders` for players:", zap.Any("roomId", pR.Id)) + for _, player := range pR.Players { + var bdDef box2d.B2BodyDef + colliderOffset := box2d.MakeB2Vec2(0, 0) // Matching that of client-side setting. + bdDef = box2d.MakeB2BodyDef() + bdDef.Type = box2d.B2BodyType.B2_dynamicBody + bdDef.Position.Set(player.X+colliderOffset.X, player.Y+colliderOffset.Y) + + b2Body := pR.CollidableWorld.CreateBody(&bdDef) + + b2CircleShape := box2d.MakeB2CircleShape() + b2CircleShape.M_radius = 32 // Matching that of client-side setting. + + fd := box2d.MakeB2FixtureDef() + fd.Shape = &b2CircleShape + fd.Filter.CategoryBits = COLLISION_CATEGORY_CONTROLLED_PLAYER + fd.Filter.MaskBits = COLLISION_MASK_FOR_CONTROLLED_PLAYER + fd.Density = 0.0 + b2Body.CreateFixtureFromDef(&fd) + + player.CollidableBody = b2Body + b2Body.SetUserData(player) + } + Logger.Info("Ends `refreshColliders` for players:", zap.Any("roomId", pR.Id)) + + Logger.Info("Begins `refreshColliders` for treasures:", zap.Any("roomId", pR.Id)) + for _, treasure := range pR.Treasures { + var bdDef box2d.B2BodyDef + bdDef.Type = box2d.B2BodyType.B2_dynamicBody + bdDef = box2d.MakeB2BodyDef() + bdDef.Position.Set(treasure.PickupBoundary.Anchor.X, treasure.PickupBoundary.Anchor.Y) + + b2Body := pR.CollidableWorld.CreateBody(&bdDef) + + pointsCount := len(treasure.PickupBoundary.Points) + + b2Vertices := make([]box2d.B2Vec2, pointsCount) + for vIndex, v2 := range treasure.PickupBoundary.Points { + b2Vertices[vIndex] = v2.ToB2Vec2() + } + + b2PolygonShape := box2d.MakeB2PolygonShape() + b2PolygonShape.Set(b2Vertices, pointsCount) + + fd := box2d.MakeB2FixtureDef() + fd.Shape = &b2PolygonShape + fd.Filter.CategoryBits = COLLISION_CATEGORY_TREASURE + fd.Filter.MaskBits = COLLISION_MASK_FOR_TREASURE + fd.Density = 0.0 + b2Body.CreateFixtureFromDef(&fd) + + treasure.CollidableBody = b2Body + b2Body.SetUserData(treasure) + } + Logger.Info("Ends `refreshColliders` for treasures:", zap.Any("roomId", pR.Id)) + + Logger.Info("Begins `refreshColliders` for towers:", zap.Any("roomId", pR.Id)) + for _, tower := range pR.GuardTowers { + // Logger.Info("Begins `refreshColliders` for single tower:", zap.Any("k-th", k), zap.Any("tower.LocalIdInBattle", tower.LocalIdInBattle), zap.Any("tower.X", tower.X), zap.Any("tower.Y", tower.Y), zap.Any("tower.PickupBoundary", tower.PickupBoundary), zap.Any("tower.PickupBoundary.Points", tower.PickupBoundary.Points), zap.Any("tower.WidthInB2World", tower.WidthInB2World), zap.Any("tower.HeightInB2World", tower.HeightInB2World), zap.Any("roomId", pR.Id)) + var bdDef box2d.B2BodyDef + bdDef.Type = box2d.B2BodyType.B2_dynamicBody + bdDef = box2d.MakeB2BodyDef() + bdDef.Position.Set(tower.PickupBoundary.Anchor.X, tower.PickupBoundary.Anchor.Y) + + b2Body := pR.CollidableWorld.CreateBody(&bdDef) + // Logger.Info("Checks#1 `refreshColliders` for single tower:", zap.Any("k-th", k), zap.Any("tower", tower), zap.Any("roomId", pR.Id)) + + pointsCount := len(tower.PickupBoundary.Points) + + b2Vertices := make([]box2d.B2Vec2, pointsCount) + for vIndex, v2 := range tower.PickupBoundary.Points { + b2Vertices[vIndex] = v2.ToB2Vec2() + } + // Logger.Info("Checks#2 `refreshColliders` for single tower:", zap.Any("k-th", k), zap.Any("tower", tower), zap.Any("roomId", pR.Id)) + + b2PolygonShape := box2d.MakeB2PolygonShape() + // Logger.Info("Checks#3 `refreshColliders` for single tower:", zap.Any("k-th", k), zap.Any("tower", tower), zap.Any("roomId", pR.Id)) + b2PolygonShape.Set(b2Vertices, pointsCount) + // Logger.Info("Checks#4 `refreshColliders` for single tower:", zap.Any("k-th", k), zap.Any("tower", tower), zap.Any("roomId", pR.Id)) + + fd := box2d.MakeB2FixtureDef() + fd.Shape = &b2PolygonShape + fd.Filter.CategoryBits = COLLISION_CATEGORY_TRAP + fd.Filter.MaskBits = COLLISION_MASK_FOR_TRAP + fd.Density = 0.0 + b2Body.CreateFixtureFromDef(&fd) + // Logger.Info("Checks#5 `refreshColliders` for single tower:", zap.Any("k-th", k), zap.Any("tower", tower), zap.Any("roomId", pR.Id)) + + tower.CollidableBody = b2Body + b2Body.SetUserData(tower) + // Logger.Info("Ends `refreshColliders` for single tower:", zap.Any("k-th", k), zap.Any("tower", tower), zap.Any("roomId", pR.Id)) + } + Logger.Info("Ends `refreshColliders` for towers:", zap.Any("roomId", pR.Id)) + + listener := RoomBattleContactListener{ + name: "TreasureHunterX", + room: pR, + } + /* + * Setting a "ContactListener" for "pR.CollidableWorld" + * will only trigger corresponding callbacks in the + * SAME GOROUTINE of "pR.CollidableWorld.Step(...)" according + * to "https://github.com/ByteArena/box2d/blob/master/DynamicsB2World.go" and + * "https://github.com/ByteArena/box2d/blob/master/DynamicsB2Contact.go". + * + * The invocation-chain involves "Step -> SolveTOI -> B2ContactUpdate -> [BeginContact, EndContact, PreSolve]". + */ + pR.CollidableWorld.SetContactListener(listener) +} + +func calculateDiffFrame(currentFrame *pb.RoomDownsyncFrame, lastFrame *pb.RoomDownsyncFrame) *pb.RoomDownsyncFrame { + if lastFrame == nil { + return currentFrame + } + diffFrame := &pb.RoomDownsyncFrame{ + Id: currentFrame.Id, + RefFrameId: lastFrame.Id, + Players: currentFrame.Players, + SentAt: currentFrame.SentAt, + CountdownNanos: currentFrame.CountdownNanos, + Bullets: currentFrame.Bullets, + Treasures: make(map[int32]*pb.Treasure, 0), + Traps: make(map[int32]*pb.Trap, 0), + SpeedShoes: make(map[int32]*pb.SpeedShoe, 0), + GuardTowers: make(map[int32]*pb.GuardTower, 0), + } + + for k, last := range lastFrame.Treasures { + if last.Removed { + diffFrame.Treasures[k] = last + continue + } + curr, ok := currentFrame.Treasures[k] + if !ok { + diffFrame.Treasures[k] = &pb.Treasure{Removed: true} + Logger.Info("A treasure is removed.", zap.Any("diffFrame.id", diffFrame.Id), zap.Any("treasure.LocalIdInBattle", curr.LocalIdInBattle)) + continue + } + if ok, v := diffTreasure(last, curr); ok { + diffFrame.Treasures[k] = v + } + } + + for k, last := range lastFrame.Bullets { + curr, ok := currentFrame.Bullets[k] + /* + * The use of 'bullet.RemovedAtFrameId' implies that you SHOULDN'T create a record '&Bullet{Removed: true}' here after it's already deleted from 'room.Bullets'. Same applies for `Traps` and `SpeedShoes`. + * + * -- YFLu + */ + if false == ok { + diffFrame.Bullets[k] = &pb.Bullet{Removed: true} + // Logger.Info("A bullet is removed.", zap.Any("diffFrame.id", diffFrame.Id), zap.Any("bullet.LocalIdInBattle", lastFrame.Bullets[k].LocalIdInBattle)) + continue + } + if ok, v := diffBullet(last, curr); ok { + diffFrame.Bullets[k] = v + } + } + + for k, last := range lastFrame.Traps { + curr, ok := currentFrame.Traps[k] + if false == ok { + continue + } + if ok, v := diffTrap(last, curr); ok { + diffFrame.Traps[k] = v + } + } + + for k, last := range lastFrame.SpeedShoes { + curr, ok := currentFrame.SpeedShoes[k] + if false == ok { + continue + } + if ok, v := diffSpeedShoe(last, curr); ok { + diffFrame.SpeedShoes[k] = v + } + } + + return diffFrame +} + +func diffTreasure(last *pb.Treasure, curr *pb.Treasure) (bool, *pb.Treasure) { + treature := &pb.Treasure{} + t := false + if last.Score != curr.Score { + treature.Score = curr.Score + t = true + } + if last.X != curr.X { + treature.X = curr.X + t = true + } + if last.Y != curr.Y { + treature.Y = curr.Y + t = true + } + return t, treature +} + +func diffTrap(last *pb.Trap, curr *pb.Trap) (bool, *pb.Trap) { + trap := &pb.Trap{} + t := false + if last.X != curr.X { + trap.X = curr.X + t = true + } + if last.Y != curr.Y { + trap.Y = curr.Y + t = true + } + return t, trap +} + +func diffSpeedShoe(last *pb.SpeedShoe, curr *pb.SpeedShoe) (bool, *pb.SpeedShoe) { + speedShoe := &pb.SpeedShoe{} + t := false + if last.X != curr.X { + speedShoe.X = curr.X + t = true + } + if last.Y != curr.Y { + speedShoe.Y = curr.Y + t = true + } + return t, speedShoe +} + +func diffBullet(last *pb.Bullet, curr *pb.Bullet) (bool, *pb.Bullet) { + t := true + return t, curr +} + +func (pR *Room) ChooseStage() error { + /* + * We use the verb "refresh" here to imply that upon invocation of this function, all colliders will be recovered if they were destroyed in the previous battle. + * + * -- YFLu, 2019-09-04 + */ + pwd, err := os.Getwd() + ErrFatal(err) + + rand.Seed(time.Now().Unix()) + stageNameList := []string{"pacman" /*, "richsoil"*/} + chosenStageIndex := rand.Int() % len(stageNameList) // Hardcoded temporarily. -- YFLu + + pR.StageName = stageNameList[chosenStageIndex] + + relativePathForAllStages := "../frontend/assets/resources/map" + relativePathForChosenStage := fmt.Sprintf("%s/%s", relativePathForAllStages, pR.StageName) + + pTmxMapIns := &TmxMap{} + + absDirPathContainingDirectlyTmxFile := filepath.Join(pwd, relativePathForChosenStage) + absTmxFilePath := fmt.Sprintf("%s/map.tmx", absDirPathContainingDirectlyTmxFile) + if !filepath.IsAbs(absTmxFilePath) { + panic("Tmx filepath must be absolute!") + } + + byteArr, err := ioutil.ReadFile(absTmxFilePath) + if nil != err { + panic(err) + } + err = xml.Unmarshal(byteArr, pTmxMapIns) + if nil != err { + panic(err) + } + + // Obtain the content of `gidBoundariesMapInB2World`. + gidBoundariesMapInB2World := make(map[int]StrToPolygon2DListMap, 0) + for _, tileset := range pTmxMapIns.Tilesets { + relativeTsxFilePath := fmt.Sprintf("%s/%s", filepath.Join(pwd, relativePathForChosenStage), tileset.Source) // Note that "TmxTileset.Source" can be a string of "relative path". + absTsxFilePath, err := filepath.Abs(relativeTsxFilePath) + if nil != err { + panic(err) + } + if !filepath.IsAbs(absTsxFilePath) { + panic("Filepath must be absolute!") + } + + byteArrOfTsxFile, err := ioutil.ReadFile(absTsxFilePath) + if nil != err { + panic(err) + } + + DeserializeTsxToColliderDict(pTmxMapIns, byteArrOfTsxFile, int(tileset.FirstGid), gidBoundariesMapInB2World) + } + + stageDiscreteW, stageDiscreteH, stageTileW, stageTileH, toRetStrToVec2DListMap, toRetStrToPolygon2DListMap, err := ParseTmxLayersAndGroups(pTmxMapIns, gidBoundariesMapInB2World) + if nil != err { + panic(err) + } + + pR.StageDiscreteW = stageDiscreteW + pR.StageDiscreteH = stageDiscreteH + pR.StageTileW = stageTileW + pR.StageTileH = stageTileH + pR.RawBattleStrToVec2DListMap = toRetStrToVec2DListMap + pR.RawBattleStrToPolygon2DListMap = toRetStrToPolygon2DListMap + + // Refresh "Treasure" data for RoomDownsyncFrame. + lowScoreTreasurePolygon2DList := *(toRetStrToPolygon2DListMap["LowScoreTreasure"]) + highScoreTreasurePolygon2DList := *(toRetStrToPolygon2DListMap["HighScoreTreasure"]) + + var treasureLocalIdInBattle int32 = 0 + for _, polygon2D := range lowScoreTreasurePolygon2DList { + /* + // For debug-printing only. + + Logger.Info("ChooseStage printing polygon2D for lowScoreTreasurePolygon2DList", zap.Any("treasureLocalIdInBattle", treasureLocalIdInBattle), zap.Any("polygon2D.Anchor", polygon2D.Anchor), zap.Any("polygon2D.Points", polygon2D.Points)) + */ + + theTreasure := &Treasure{ + Id: 0, + LocalIdInBattle: treasureLocalIdInBattle, + Score: LOW_SCORE_TREASURE_SCORE, + Type: LOW_SCORE_TREASURE_TYPE, + X: polygon2D.Anchor.X, + Y: polygon2D.Anchor.Y, + PickupBoundary: polygon2D, + } + + pR.Treasures[theTreasure.LocalIdInBattle] = theTreasure + treasureLocalIdInBattle++ + } + + for _, polygon2D := range highScoreTreasurePolygon2DList { + /* + // For debug-printing only. + + Logger.Info("ChooseStage printing polygon2D for highScoreTreasurePolygon2DList", zap.Any("treasureLocalIdInBattle", treasureLocalIdInBattle), zap.Any("polygon2D.Anchor", polygon2D.Anchor), zap.Any("polygon2D.Points", polygon2D.Points)) + */ + theTreasure := &Treasure{ + Id: 0, + LocalIdInBattle: treasureLocalIdInBattle, + Score: HIGH_SCORE_TREASURE_SCORE, + Type: HIGH_SCORE_TREASURE_TYPE, + X: polygon2D.Anchor.X, + Y: polygon2D.Anchor.Y, + PickupBoundary: polygon2D, + } + + pR.Treasures[theTreasure.LocalIdInBattle] = theTreasure + + treasureLocalIdInBattle++ + } + + // Refresh "GuardTower" data for RoomDownsyncFrame. + guardTowerPolygon2DList := *(toRetStrToPolygon2DListMap["GuardTower"]) + var guardTowerLocalIdInBattle int32 = 0 + for _, polygon2D := range guardTowerPolygon2DList { + /* + // For debug-printing only. + + Logger.Info("ChooseStage printing polygon2D for guardTowerPolygon2DList", zap.Any("guardTowerLocalIdInBattle", guardTowerLocalIdInBattle), zap.Any("polygon2D.Anchor", polygon2D.Anchor), zap.Any("polygon2D.Points", polygon2D.Points), zap.Any("pR.GuardTowers", pR.GuardTowers)) + */ + + var inRangePlayers InRangePlayerCollection + pInRangePlayers := &inRangePlayers + pInRangePlayers = pInRangePlayers.Init(10) + theGuardTower := &GuardTower{ + Id: 0, + LocalIdInBattle: guardTowerLocalIdInBattle, + X: polygon2D.Anchor.X, + Y: polygon2D.Anchor.Y, + PickupBoundary: polygon2D, + InRangePlayers: pInRangePlayers, + LastAttackTick: utils.UnixtimeNano(), + WidthInB2World: float64(polygon2D.TmxObjectWidth), + HeightInB2World: float64(polygon2D.TmxObjectHeight), + } + + pR.GuardTowers[theGuardTower.LocalIdInBattle] = theGuardTower + + guardTowerLocalIdInBattle++ + } + + return nil +} + +func (pR *Room) ConvertToInputFrameId(originalFrameId int32, inputDelayFrames int32) int32 { + if originalFrameId < inputDelayFrames { + return 0 + } + return ((originalFrameId - inputDelayFrames) >> pR.InputScaleFrames) +} + +func (pR *Room) EncodeUpsyncCmd(upsyncCmd *pb.InputFrameUpsync) uint64 { + var ret uint64 = 0 + // There're 13 possible directions, occupying the first 4 bits, no need to shift + ret += uint64(upsyncCmd.EncodedDir) + return ret +} + +func (pR *Room) CanPopSt(refLowerInputFrameId int32) bool { + rb := pR.AllPlayerInputsBuffer + if rb.Cnt <= 0 { + return false + } + if rb.StFrameId <= refLowerInputFrameId { + // already delayed too much + return true + } + + return false +} + +func (pR *Room) AllPlayerInputsBufferString() string { + s := make([]string, 0) + s = append(s, fmt.Sprintf("{lastAllConfirmedInputFrameId: %v, lastAllConfirmedInputFrameIdWithChange: %v}", pR.LastAllConfirmedInputFrameId, pR.LastAllConfirmedInputFrameIdWithChange)) + for playerId, player := range pR.Players { + s = append(s, fmt.Sprintf("{playerId: %v, ackingFrameId: %v, ackingInputFrameId: %v, lastSentInputFrameId: %v}", playerId, player.AckingFrameId, player.AckingInputFrameId, player.LastSentInputFrameId)) + } + for i := pR.AllPlayerInputsBuffer.StFrameId; i < pR.AllPlayerInputsBuffer.EdFrameId; i++ { + tmp := pR.AllPlayerInputsBuffer.GetByFrameId(i) + if nil == tmp { + break + } + f := tmp.(*pb.InputFrameDownsync) + s = append(s, fmt.Sprintf("{inputFrameId: %v, inputList: %v, confirmedList: %v}", f.InputFrameId, f.InputList, f.ConfirmedList)) + } + + return strings.Join(s, "\n") +} + +func (pR *Room) StartBattle() { + if RoomBattleStateIns.WAITING != pR.State { + Logger.Warn("[StartBattle] Battle not started after all players' battle state checked!", zap.Any("roomId", pR.Id), zap.Any("roomState", pR.State)) + return + } + + // Always instantiates a new channel and let the old one die out due to not being retained by any root reference. + nanosPerFrame := 1000000000 / int64(pR.ServerFPS) + pR.Tick = 0 + + // Refresh "Colliders" for server-side contact listening of B2World. + pR.refreshColliders() + + /** + * Will be triggered from a goroutine which executes the critical `Room.AddPlayerIfPossible`, thus the `battleMainLoop` should be detached. + * All of the consecutive stages, e.g. settlement, dismissal, should share the same goroutine with `battleMainLoop`. + */ + battleMainLoop := func() { + defer func() { + if r := recover(); r != nil { + Logger.Error("battleMainLoop, recovery spot#1, recovered from: ", zap.Any("roomId", pR.Id), zap.Any("panic", r)) + } + Logger.Info("The `battleMainLoop` is stopped for:", zap.Any("roomId", pR.Id)) + pR.onBattleStoppedForSettlement() + }() + + battleMainLoopStartedNanos := utils.UnixtimeNano() + var totalElapsedNanos int64 + totalElapsedNanos = 0 + + // inputFrameIdDownsyncToleranceFrameCnt := int32(1) + + Logger.Info("The `battleMainLoop` is started for:", zap.Any("roomId", pR.Id)) + for { + pR.Tick++ // It's important to increment "pR.Tick" here such that the "InputFrameDownsync.InputFrameId" is most advanced + if 1 == pR.Tick { + // The legacy frontend code needs this "kickoffFrame" to remove the "ready to start 3-2-1" panel + kickoffFrame := pb.RoomDownsyncFrame{ + Id: pR.Tick, + RefFrameId: 0, // Hardcoded for now. + Players: toPbPlayers(pR.Players), + Treasures: toPbTreasures(pR.Treasures), + Traps: toPbTraps(pR.Traps), + Bullets: toPbBullets(pR.Bullets), + SpeedShoes: toPbSpeedShoes(pR.SpeedShoes), + GuardTowers: toPbGuardTowers(pR.GuardTowers), + SentAt: utils.UnixtimeMilli(), + CountdownNanos: (pR.BattleDurationNanos - totalElapsedNanos), + } + for playerId, player := range pR.Players { + if swapped := atomic.CompareAndSwapInt32(&player.BattleState, PlayerBattleStateIns.ACTIVE, PlayerBattleStateIns.ACTIVE); !swapped { + /* + [WARNING] DON'T send anything into "DedicatedForwardingChanForPlayer" if the player is disconnected, because it could jam the channel and cause significant delay upon "battle recovery for reconnected player". + */ + continue + } + pR.sendSafely(kickoffFrame, playerId) + } + } + + if totalElapsedNanos > pR.BattleDurationNanos { + Logger.Info(fmt.Sprintf("The `battleMainLoop` is stopped:\n%v", pR.AllPlayerInputsBufferString())) + pR.StopBattleForSettlement() + } + + if swapped := atomic.CompareAndSwapInt32(&pR.State, RoomBattleStateIns.IN_BATTLE, RoomBattleStateIns.IN_BATTLE); !swapped { + return + } + stCalculation := utils.UnixtimeNano() + + refInputFrameId := int32(999999999) // Hardcoded as a max reference. + for playerId, _ := range pR.Players { + thatId := atomic.LoadInt32(&(pR.Players[playerId].AckingInputFrameId)) + if thatId > refInputFrameId { + continue + } + refInputFrameId = thatId + } + + for pR.CanPopSt(refInputFrameId) { + // _ = pR.AllPlayerInputsBuffer.Pop() + f := pR.AllPlayerInputsBuffer.Pop().(*pb.InputFrameDownsync) + if pR.inputFrameIdDebuggable(f.InputFrameId) { + // Popping of an "inputFrame" would be AFTER its being all being confirmed, because it requires the "inputFrame" to be all acked + Logger.Info("inputFrame lifecycle#5[popped]:", zap.Any("roomId", pR.Id), zap.Any("refInputFrameId", refInputFrameId), zap.Any("inputFrameId", f.InputFrameId), zap.Any("StFrameId", pR.AllPlayerInputsBuffer.StFrameId), zap.Any("EdFrameId", pR.AllPlayerInputsBuffer.EdFrameId)) + } + } + + lastAllConfirmedInputFrameIdWithChange := atomic.LoadInt32(&(pR.LastAllConfirmedInputFrameIdWithChange)) + for playerId, player := range pR.Players { + if swapped := atomic.CompareAndSwapInt32(&player.BattleState, PlayerBattleStateIns.ACTIVE, PlayerBattleStateIns.ACTIVE); !swapped { + /* + [WARNING] DON'T send anything into "DedicatedForwardingChanForPlayer" if the player is disconnected, because it could jam the channel and cause significant delay upon "battle recovery for reconnected player". + */ + continue + } + + toSendInputFrames := make([]*pb.InputFrameDownsync, 0, pR.AllPlayerInputsBuffer.Cnt) + // [WARNING] Websocket is TCP-based, thus no need to re-send a previously sent inputFrame to a same player! + anchorInputFrameId := atomic.LoadInt32(&(pR.Players[playerId].LastSentInputFrameId)) + candidateToSendInputFrameId := anchorInputFrameId + 1 + + // [WARNING] EDGE CASE HERE: Upon initialization, all of "lastAllConfirmedInputFrameId", "lastAllConfirmedInputFrameIdWithChange" and "anchorInputFrameId" are "-1", thus "candidateToSendInputFrameId" starts with "0", however "inputFrameId: 0" might not have been all confirmed! + debugSendingInputFrameId := int32(-1) + + // TODO: If a buffered "inputFrame" is inserted but has been non-all-confirmed for a long time, e.g. inserted at "inputFrameId=42" but still non-all-confirmed at "inputFrameId=980", the server should mark that of "inputFrameId=42" as well as send it to the unconfirmed players with an extra "RoomDownsyncFrame" for their FORCE RESET OF REFERENCE STATE + for candidateToSendInputFrameId <= lastAllConfirmedInputFrameIdWithChange { + tmp := pR.AllPlayerInputsBuffer.GetByFrameId(candidateToSendInputFrameId) + if nil == tmp { + break + } + f := tmp.(*pb.InputFrameDownsync) + if pR.inputFrameIdDebuggable(candidateToSendInputFrameId) { + debugSendingInputFrameId = candidateToSendInputFrameId + Logger.Info("inputFrame lifecycle#3[sending]:", zap.Any("roomId", pR.Id), zap.Any("refInputFrameId", refInputFrameId), zap.Any("playerId", playerId), zap.Any("playerAnchorInputFrameId", anchorInputFrameId), zap.Any("playerAckingInputFrameId", player.AckingInputFrameId), zap.Any("inputFrameId", candidateToSendInputFrameId), zap.Any("inputFrameId-doublecheck", f.InputFrameId), zap.Any("StFrameId", pR.AllPlayerInputsBuffer.StFrameId), zap.Any("EdFrameId", pR.AllPlayerInputsBuffer.EdFrameId), zap.Any("ConfirmedList", f.ConfirmedList)) + } + toSendInputFrames = append(toSendInputFrames, f) + candidateToSendInputFrameId++ + } + + if 0 >= len(toSendInputFrames) { + continue + } + + pR.sendSafely(toSendInputFrames, playerId) + atomic.StoreInt32(&(pR.Players[playerId].LastSentInputFrameId), candidateToSendInputFrameId-1) + if -1 != debugSendingInputFrameId { + Logger.Info("inputFrame lifecycle#4[sent]:", zap.Any("roomId", pR.Id), zap.Any("refInputFrameId", refInputFrameId), zap.Any("playerId", playerId), zap.Any("playerAckingInputFrameId", player.AckingInputFrameId), zap.Any("inputFrameId", debugSendingInputFrameId), zap.Any("StFrameId", pR.AllPlayerInputsBuffer.StFrameId), zap.Any("EdFrameId", pR.AllPlayerInputsBuffer.EdFrameId)) + } + } + + /* + if swapped := atomic.CompareAndSwapInt32(&(pR.LastAllConfirmedInputFrameIdWithChange), lastAllConfirmedInputFrameIdWithChange, -1); !swapped { + // "OnBattleCmdReceived" might be updating "pR.LastAllConfirmedInputFrameIdWithChange" simultaneously, don't update here if the old value is no longer valid + Logger.Warn("pR.LastAllConfirmedInputFrameIdWithChange NOT UPDATED:", zap.Any("roomId", pR.Id), zap.Any("refInputFrameId", refInputFrameId), zap.Any("StFrameId", pR.AllPlayerInputsBuffer.StFrameId), zap.Any("EdFrameId", pR.AllPlayerInputsBuffer.EdFrameId)) + } + */ + now := utils.UnixtimeNano() + elapsedInCalculation := now - stCalculation + totalElapsedNanos = (now - battleMainLoopStartedNanos) + // Logger.Info("Elapsed time statistics:", zap.Any("roomId", pR.Id), zap.Any("elapsedInCalculation", elapsedInCalculation), zap.Any("totalElapsedNanos", totalElapsedNanos)) + time.Sleep(time.Duration(nanosPerFrame - elapsedInCalculation)) + } + } + + pR.onBattlePrepare(func() { + pR.onBattleStarted() // NOTE: Deliberately not using `defer`. + go battleMainLoop() + }) +} + +func (pR *Room) OnBattleCmdReceived(pReq *pb.WsReq) { + if swapped := atomic.CompareAndSwapInt32(&pR.State, RoomBattleStateIns.IN_BATTLE, RoomBattleStateIns.IN_BATTLE); !swapped { + return + } + + playerId := pReq.PlayerId + indiceInJoinIndexBooleanArr := uint32(pReq.JoinIndex - 1) + inputFrameUpsyncBatch := pReq.InputFrameUpsyncBatch + ackingFrameId := pReq.AckingFrameId + ackingInputFrameId := pReq.AckingInputFrameId + + for _, inputFrameUpsync := range inputFrameUpsyncBatch { + if _, existent := pR.Players[playerId]; !existent { + Logger.Warn("upcmd player doesn't exist:", zap.Any("roomId", pR.Id), zap.Any("playerId", playerId)) + return + } + + if swapped := atomic.CompareAndSwapInt32(&(pR.Players[playerId].AckingFrameId), pR.Players[playerId].AckingFrameId, ackingFrameId); !swapped { + panic(fmt.Sprintf("Failed to update AckingFrameId to %v for roomId=%v, playerId=%v", ackingFrameId, pR.Id, playerId)) + } + + if swapped := atomic.CompareAndSwapInt32(&(pR.Players[playerId].AckingInputFrameId), pR.Players[playerId].AckingInputFrameId, ackingInputFrameId); !swapped { + panic(fmt.Sprintf("Failed to update AckingInputFrameId to %v for roomId=%v, playerId=%v", ackingInputFrameId, pR.Id, playerId)) + } + clientInputFrameId := inputFrameUpsync.InputFrameId + if clientInputFrameId < pR.AllPlayerInputsBuffer.StFrameId { + Logger.Warn("Obsolete inputFrameUpsync:", zap.Any("roomId", pR.Id), zap.Any("playerId", playerId), zap.Any("clientInputFrameId", clientInputFrameId), zap.Any("StFrameId", pR.AllPlayerInputsBuffer.StFrameId), zap.Any("EdFrameId", pR.AllPlayerInputsBuffer.EdFrameId)) + return + } + + var joinMask uint64 = (1 << indiceInJoinIndexBooleanArr) + encodedInput := pR.EncodeUpsyncCmd(inputFrameUpsync) + + if clientInputFrameId >= pR.AllPlayerInputsBuffer.EdFrameId { + // The outer-if branching is for reducing an extra get-and-set operation, which is now placed in the else-branch. + for clientInputFrameId >= pR.AllPlayerInputsBuffer.EdFrameId { + newInputList := make([]uint64, len(pR.Players)) + newInputList[indiceInJoinIndexBooleanArr] = encodedInput + pR.AllPlayerInputsBuffer.Put(&pb.InputFrameDownsync{ + InputFrameId: pR.AllPlayerInputsBuffer.EdFrameId, + InputList: newInputList, + ConfirmedList: joinMask, // by now only the current player has confirmed this input frame + }) + if pR.inputFrameIdDebuggable(clientInputFrameId) { + Logger.Info("inputFrame lifecycle#1[inserted]", zap.Any("roomId", pR.Id), zap.Any("playerId", playerId), zap.Any("inputFrameId", clientInputFrameId), zap.Any("EdFrameId", pR.AllPlayerInputsBuffer.EdFrameId)) + } + } + } else { + tmp2 := pR.AllPlayerInputsBuffer.GetByFrameId(clientInputFrameId) + if nil == tmp2 { + // This shouldn't happen due to the previous 2 checks + Logger.Warn("Mysterious error getting an input frame:", zap.Any("roomId", pR.Id), zap.Any("playerId", playerId), zap.Any("clientInputFrameId", clientInputFrameId), zap.Any("StFrameId", pR.AllPlayerInputsBuffer.StFrameId), zap.Any("EdFrameId", pR.AllPlayerInputsBuffer.EdFrameId)) + return + } + inputFrameDownsync := tmp2.(*pb.InputFrameDownsync) + oldConfirmedList := inputFrameDownsync.ConfirmedList + if (oldConfirmedList & joinMask) > 0 { + Logger.Warn("Cmd already confirmed but getting set attempt:", zap.Any("roomId", pR.Id), zap.Any("playerId", playerId), zap.Any("clientInputFrameId", clientInputFrameId), zap.Any("StFrameId", pR.AllPlayerInputsBuffer.StFrameId), zap.Any("EdFrameId", pR.AllPlayerInputsBuffer.EdFrameId)) + return + } + + // In Golang 1.12, there's no "compare-and-swap primitive" on a custom struct (or it's pointer, unless it's an unsafe pointer https://pkg.go.dev/sync/atomic@go1.12#CompareAndSwapPointer). Although CAS on custom struct is possible in Golang 1.19 https://pkg.go.dev/sync/atomic@go1.19.1#Value.CompareAndSwap, using a single word is still faster whenever possible. + if swapped := atomic.CompareAndSwapUint64(&inputFrameDownsync.InputList[indiceInJoinIndexBooleanArr], uint64(0), encodedInput); !swapped { + if encodedInput > 0 { + Logger.Warn("Failed input CAS:", zap.Any("roomId", pR.Id), zap.Any("playerId", playerId), zap.Any("clientInputFrameId", clientInputFrameId)) + } + return + } + + newConfirmedList := (oldConfirmedList | joinMask) + if swapped := atomic.CompareAndSwapUint64(&(inputFrameDownsync.ConfirmedList), oldConfirmedList, newConfirmedList); !swapped { + if encodedInput > 0 { + Logger.Warn("Failed confirm CAS:", zap.Any("roomId", pR.Id), zap.Any("playerId", playerId), zap.Any("clientInputFrameId", clientInputFrameId)) + } + return + } + + totPlayerCnt := uint32(len(pR.Players)) + allConfirmedMask := uint64((1 << totPlayerCnt) - 1) // TODO: What if a player is disconnected backthen? + if allConfirmedMask == newConfirmedList { + if false == pR.equalInputLists(inputFrameDownsync.InputList, pR.LastAllConfirmedInputList) { + atomic.StoreInt32(&(pR.LastAllConfirmedInputFrameIdWithChange), clientInputFrameId) // [WARNING] Different from the CAS in "battleMainLoop", it's safe to just update "pR.LastAllConfirmedInputFrameIdWithChange" here, because only monotonic increment is possible here! + Logger.Info("Key inputFrame change", zap.Any("roomId", pR.Id), zap.Any("inputFrameId", clientInputFrameId), zap.Any("lastInputFrameId", pR.LastAllConfirmedInputFrameId), zap.Any("StFrameId", pR.AllPlayerInputsBuffer.StFrameId), zap.Any("EdFrameId", pR.AllPlayerInputsBuffer.EdFrameId), zap.Any("newInputList", inputFrameDownsync.InputList), zap.Any("lastInputList", pR.LastAllConfirmedInputList)) + } + atomic.StoreInt32(&(pR.LastAllConfirmedInputFrameId), clientInputFrameId) // [WARNING] It's IMPORTANT that "pR.LastAllConfirmedInputFrameId" is NOT NECESSARILY CONSECUTIVE, i.e. if one of the players disconnects and reconnects within a considerable amount of frame delays! + for i,v := range inputFrameDownsync.InputList { + // To avoid potential misuse of pointers + pR.LastAllConfirmedInputList[i] = v + } + if pR.inputFrameIdDebuggable(clientInputFrameId) { + Logger.Info("inputFrame lifecycle#2[allconfirmed]", zap.Any("roomId", pR.Id), zap.Any("playerId", playerId), zap.Any("inputFrameId", clientInputFrameId), zap.Any("StFrameId", pR.AllPlayerInputsBuffer.StFrameId), zap.Any("EdFrameId", pR.AllPlayerInputsBuffer.EdFrameId)) + } + } + } + } +} + +func (pR *Room) equalInputLists(lhs []uint64, rhs []uint64) bool { + if len(lhs) != len(rhs) { + return false + } + for i, _ := range lhs { + if lhs[i] != rhs[i] { + return false + } + } + return true +} + +func (pR *Room) StopBattleForSettlement() { + if RoomBattleStateIns.IN_BATTLE != pR.State { + return + } + pR.State = RoomBattleStateIns.STOPPING_BATTLE_FOR_SETTLEMENT + Logger.Info("Stopping the `battleMainLoop` for:", zap.Any("roomId", pR.Id)) + pR.Tick++ + for playerId, _ := range pR.Players { + assembledFrame := pb.RoomDownsyncFrame{ + Id: pR.Tick, + RefFrameId: 0, // Hardcoded for now. + Players: toPbPlayers(pR.Players), + SentAt: utils.UnixtimeMilli(), + CountdownNanos: -1, // TODO: Replace this magic constant! + Treasures: toPbTreasures(pR.Treasures), + Traps: toPbTraps(pR.Traps), + } + pR.sendSafely(assembledFrame, playerId) + } + // Note that `pR.onBattleStoppedForSettlement` will be called by `battleMainLoop`. +} + +func (pR *Room) onBattleStarted() { + if RoomBattleStateIns.PREPARE != pR.State { + return + } + pR.State = RoomBattleStateIns.IN_BATTLE + pR.updateScore() +} + +func (pR *Room) onBattlePrepare(cb BattleStartCbType) { + if RoomBattleStateIns.WAITING != pR.State { + Logger.Warn("[onBattlePrepare] Battle not started after all players' battle state checked!", zap.Any("roomId", pR.Id), zap.Any("roomState", pR.State)) + return + } + pR.State = RoomBattleStateIns.PREPARE + Logger.Info("Battle state transitted to RoomBattleStateIns.PREPARE for:", zap.Any("roomId", pR.Id)) + + playerMetas := make(map[int32]*pb.PlayerMeta, 0) + for _, player := range pR.Players { + playerMetas[player.Id] = &pb.PlayerMeta{ + Id: player.Id, + Name: player.Name, + DisplayName: player.DisplayName, + Avatar: player.Avatar, + JoinIndex: player.JoinIndex, + } + } + + battleReadyToStartFrame := pb.RoomDownsyncFrame{ + Id: pR.Tick, + Players: toPbPlayers(pR.Players), + SentAt: utils.UnixtimeMilli(), + RefFrameId: MAGIC_ROOM_DOWNSYNC_FRAME_ID_BATTLE_READY_TO_START, + PlayerMetas: playerMetas, + CountdownNanos: pR.BattleDurationNanos, + } + + Logger.Info("Sending out frame for RoomBattleState.PREPARE ", zap.Any("battleReadyToStartFrame", battleReadyToStartFrame)) + for _, player := range pR.Players { + pR.sendSafely(battleReadyToStartFrame, player.Id) + } + + battlePreparationNanos := int64(6000000000) + preparationLoop := func() { + defer func() { + Logger.Info("The `preparationLoop` is stopped for:", zap.Any("roomId", pR.Id)) + cb() + }() + preparationLoopStartedNanos := utils.UnixtimeNano() + totalElapsedNanos := int64(0) + for { + if totalElapsedNanos > battlePreparationNanos { + break + } + now := utils.UnixtimeNano() + totalElapsedNanos = (now - preparationLoopStartedNanos) + time.Sleep(time.Duration(battlePreparationNanos - totalElapsedNanos)) + } + } + go preparationLoop() +} + +func (pR *Room) onBattleStoppedForSettlement() { + if RoomBattleStateIns.STOPPING_BATTLE_FOR_SETTLEMENT != pR.State { + return + } + defer func() { + pR.onSettlementCompleted() + }() + pR.State = RoomBattleStateIns.IN_SETTLEMENT + Logger.Info("The room is in settlement:", zap.Any("roomId", pR.Id)) + // TODO: Some settlement labor. +} + +func (pR *Room) onSettlementCompleted() { + pR.Dismiss() +} + +func (pR *Room) Dismiss() { + if RoomBattleStateIns.IN_SETTLEMENT != pR.State { + return + } + pR.State = RoomBattleStateIns.IN_DISMISSAL + if 0 < len(pR.Players) { + Logger.Info("The room is in dismissal:", zap.Any("roomId", pR.Id)) + for playerId, _ := range pR.Players { + Logger.Info("Adding 1 to pR.DismissalWaitGroup:", zap.Any("roomId", pR.Id), zap.Any("playerId", playerId)) + pR.DismissalWaitGroup.Add(1) + pR.expelPlayerForDismissal(playerId) + pR.DismissalWaitGroup.Done() + Logger.Info("Decremented 1 to pR.DismissalWaitGroup:", zap.Any("roomId", pR.Id), zap.Any("playerId", playerId)) + } + pR.DismissalWaitGroup.Wait() + } + pR.onDismissed() +} + +func (pR *Room) onDismissed() { + + // Always instantiates new HeapRAM blocks and let the old blocks die out due to not being retained by any root reference. + pR.Players = make(map[int32]*Player) + pR.Treasures = make(map[int32]*Treasure) + pR.Traps = make(map[int32]*Trap) + pR.GuardTowers = make(map[int32]*GuardTower) + pR.Bullets = make(map[int32]*Bullet) + pR.SpeedShoes = make(map[int32]*SpeedShoe) + pR.PlayerDownsyncSessionDict = make(map[int32]*websocket.Conn) + pR.PlayerSignalToCloseDict = make(map[int32]SignalToCloseConnCbType) + + pR.LastAllConfirmedInputFrameId = -1 + pR.LastAllConfirmedInputFrameIdWithChange = -1 + pR.LastAllConfirmedInputList = make([]uint64, pR.Capacity) + + for indice, _ := range pR.JoinIndexBooleanArr { + pR.JoinIndexBooleanArr[indice] = false + } + pR.AllPlayerInputsBuffer = NewRingBuffer(1024) + + pR.ChooseStage() + pR.EffectivePlayerCount = 0 + + // [WARNING] It's deliberately ordered such that "pR.State = RoomBattleStateIns.IDLE" is put AFTER all the refreshing operations above. + pR.State = RoomBattleStateIns.IDLE + pR.updateScore() + + Logger.Info("The room is completely dismissed:", zap.Any("roomId", pR.Id)) +} + +func (pR *Room) Unicast(toPlayerId int32, msg interface{}) { + // TODO +} + +func (pR *Room) Broadcast(msg interface{}) { + // TODO +} + +func (pR *Room) expelPlayerDuringGame(playerId int32) { + defer pR.onPlayerExpelledDuringGame(playerId) +} + +func (pR *Room) expelPlayerForDismissal(playerId int32) { + pR.onPlayerExpelledForDismissal(playerId) +} + +func (pR *Room) onPlayerExpelledDuringGame(playerId int32) { + pR.onPlayerLost(playerId) +} + +func (pR *Room) onPlayerExpelledForDismissal(playerId int32) { + pR.onPlayerLost(playerId) + + Logger.Info("onPlayerExpelledForDismissal:", zap.Any("playerId", playerId), zap.Any("roomId", pR.Id), zap.Any("nowRoomBattleState", pR.State), zap.Any("nowRoomEffectivePlayerCount", pR.EffectivePlayerCount)) +} + +func (pR *Room) OnPlayerDisconnected(playerId int32) { + defer func() { + if r := recover(); r != nil { + Logger.Error("Room OnPlayerDisconnected, recovery spot#1, recovered from: ", zap.Any("playerId", playerId), zap.Any("roomId", pR.Id), zap.Any("panic", r)) + } + }() + + if _, existent := pR.Players[playerId]; existent { + switch pR.Players[playerId].BattleState { + case PlayerBattleStateIns.DISCONNECTED: + case PlayerBattleStateIns.LOST: + case PlayerBattleStateIns.EXPELLED_DURING_GAME: + case PlayerBattleStateIns.EXPELLED_IN_DISMISSAL: + Logger.Info("Room OnPlayerDisconnected[early return #1]:", zap.Any("playerId", playerId), zap.Any("playerBattleState", pR.Players[playerId].BattleState), zap.Any("roomId", pR.Id), zap.Any("nowRoomBattleState", pR.State), zap.Any("nowRoomEffectivePlayerCount", pR.EffectivePlayerCount)) + return + } + } else { + // Not even the "pR.Players[playerId]" exists. + Logger.Info("Room OnPlayerDisconnected[early return #2]:", zap.Any("playerId", playerId), zap.Any("roomId", pR.Id), zap.Any("nowRoomBattleState", pR.State), zap.Any("nowRoomEffectivePlayerCount", pR.EffectivePlayerCount)) + return + } + + switch pR.State { + case RoomBattleStateIns.WAITING: + pR.onPlayerLost(playerId) + delete(pR.Players, playerId) // Note that this statement MUST be put AFTER `pR.onPlayerLost(...)` to avoid nil pointer exception. + if 0 == pR.EffectivePlayerCount { + pR.State = RoomBattleStateIns.IDLE + } + pR.updateScore() + Logger.Info("Player disconnected while room is at RoomBattleStateIns.WAITING:", zap.Any("playerId", playerId), zap.Any("roomId", pR.Id), zap.Any("nowRoomBattleState", pR.State), zap.Any("nowRoomEffectivePlayerCount", pR.EffectivePlayerCount)) + default: + pR.Players[playerId].BattleState = PlayerBattleStateIns.DISCONNECTED + pR.clearPlayerNetworkSession(playerId) // Still need clear the network session pointers, because "OnPlayerDisconnected" is only triggered from "signalToCloseConnOfThisPlayer" in "ws/serve.go", when the same player reconnects the network session pointers will be re-assigned + Logger.Info("Player disconnected from room:", zap.Any("playerId", playerId), zap.Any("playerBattleState", pR.Players[playerId].BattleState), zap.Any("roomId", pR.Id), zap.Any("nowRoomBattleState", pR.State), zap.Any("nowRoomEffectivePlayerCount", pR.EffectivePlayerCount)) + } +} + +func (pR *Room) onPlayerLost(playerId int32) { + defer func() { + if r := recover(); r != nil { + Logger.Error("Room OnPlayerLost, recovery spot, recovered from: ", zap.Any("playerId", playerId), zap.Any("roomId", pR.Id), zap.Any("panic", r)) + } + }() + if player, existent := pR.Players[playerId]; existent { + player.BattleState = PlayerBattleStateIns.LOST + pR.clearPlayerNetworkSession(playerId) + pR.EffectivePlayerCount-- + indiceInJoinIndexBooleanArr := int(player.JoinIndex - 1) + if (0 <= indiceInJoinIndexBooleanArr) && (indiceInJoinIndexBooleanArr < len(pR.JoinIndexBooleanArr)) { + pR.JoinIndexBooleanArr[indiceInJoinIndexBooleanArr] = false + } else { + Logger.Warn("Room OnPlayerLost, pR.JoinIndexBooleanArr is out of range: ", zap.Any("playerId", playerId), zap.Any("roomId", pR.Id), zap.Any("indiceInJoinIndexBooleanArr", indiceInJoinIndexBooleanArr), zap.Any("len(pR.JoinIndexBooleanArr)", len(pR.JoinIndexBooleanArr))) + } + player.JoinIndex = MAGIC_JOIN_INDEX_INVALID + Logger.Info("Room OnPlayerLost: ", zap.Any("playerId", playerId), zap.Any("roomId", pR.Id), zap.Any("resulted pR.JoinIndexBooleanArr", pR.JoinIndexBooleanArr)) + } +} + +func (pR *Room) clearPlayerNetworkSession(playerId int32) { + if _, y := pR.PlayerDownsyncSessionDict[playerId]; y { + Logger.Info("sending termination symbol for:", zap.Any("playerId", playerId), zap.Any("roomId", pR.Id)) + delete(pR.PlayerDownsyncSessionDict, playerId) + delete(pR.PlayerSignalToCloseDict, playerId) + } +} + +func (pR *Room) onPlayerAdded(playerId int32) { + pR.EffectivePlayerCount++ + + if 1 == pR.EffectivePlayerCount { + pR.State = RoomBattleStateIns.WAITING + } + + for index, value := range pR.JoinIndexBooleanArr { + if false == value { + pR.Players[playerId].JoinIndex = int32(index) + 1 + pR.JoinIndexBooleanArr[index] = true + + // Lazily assign the initial position of "Player" for "RoomDownsyncFrame". + playerPosList := *(pR.RawBattleStrToVec2DListMap["PlayerStartingPos"]) + if index > len(playerPosList) { + panic(fmt.Sprintf("onPlayerAdded error, index >= len(playerPosList), roomId=%v, playerId=%v, roomState=%v, roomEffectivePlayerCount=%v", pR.Id, playerId, pR.State, pR.EffectivePlayerCount)) + } + playerPos := playerPosList[index] + + if nil == playerPos { + panic(fmt.Sprintf("onPlayerAdded error, nil == playerPos, roomId=%v, playerId=%v, roomState=%v, roomEffectivePlayerCount=%v", pR.Id, playerId, pR.State, pR.EffectivePlayerCount)) + } + pR.Players[playerId].X = playerPos.X + pR.Players[playerId].Y = playerPos.Y + + break + } + } + + pR.updateScore() + Logger.Info("onPlayerAdded:", zap.Any("playerId", playerId), zap.Any("roomId", pR.Id), zap.Any("joinIndex", pR.Players[playerId].JoinIndex), zap.Any("EffectivePlayerCount", pR.EffectivePlayerCount), zap.Any("resulted pR.JoinIndexBooleanArr", pR.JoinIndexBooleanArr), zap.Any("RoomBattleState", pR.State)) +} + +func (pR *Room) onPlayerReAdded(playerId int32) { + /* + * [WARNING] + * + * If a player quits at "RoomBattleState.WAITING", then his/her re-joining will always invoke `AddPlayerIfPossible(...)`. Therefore, this + * function will only be invoked for players who quit the battle at ">RoomBattleState.WAITING" and re-join at "RoomBattleState.IN_BATTLE", during which the `pR.JoinIndexBooleanArr` doesn't change. + */ + Logger.Info("Room got `onPlayerReAdded` invoked,", zap.Any("roomId", pR.Id), zap.Any("playerId", playerId), zap.Any("resulted pR.JoinIndexBooleanArr", pR.JoinIndexBooleanArr)) + + pR.updateScore() +} + +func (pR *Room) OnPlayerBattleColliderAcked(playerId int32) bool { + pPlayer, ok := pR.Players[playerId] + if false == ok { + return false + } + + playerMetas := make(map[int32]*pb.PlayerMeta, 0) + for _, player := range pR.Players { + playerMetas[player.Id] = &pb.PlayerMeta{ + Id: player.Id, + Name: player.Name, + DisplayName: player.DisplayName, + Avatar: player.Avatar, + JoinIndex: player.JoinIndex, + } + } + + var playerAckedFrame pb.RoomDownsyncFrame + + switch pPlayer.BattleState { + case PlayerBattleStateIns.ADDED_PENDING_BATTLE_COLLIDER_ACK: + playerAckedFrame = pb.RoomDownsyncFrame{ + Id: pR.Tick, + Players: toPbPlayers(pR.Players), + SentAt: utils.UnixtimeMilli(), + RefFrameId: MAGIC_ROOM_DOWNSYNC_FRAME_ID_PLAYER_ADDED_AND_ACKED, + PlayerMetas: playerMetas, + } + case PlayerBattleStateIns.READDED_PENDING_BATTLE_COLLIDER_ACK: + playerAckedFrame = pb.RoomDownsyncFrame{ + Id: pR.Tick, + Players: toPbPlayers(pR.Players), + SentAt: utils.UnixtimeMilli(), + RefFrameId: MAGIC_ROOM_DOWNSYNC_FRAME_ID_PLAYER_READDED_AND_ACKED, + PlayerMetas: playerMetas, + } + default: + } + + for _, player := range pR.Players { + /* + [WARNING] + This `playerAckedFrame` is the first ever "RoomDownsyncFrame" for every "PersistentSessionClient on the frontend", and it goes right after each "BattleColliderInfo". + + By making use of the sequential nature of each ws session, all later "RoomDownsyncFrame"s generated after `pRoom.StartBattle()` will be put behind this `playerAckedFrame`. + */ + pR.sendSafely(playerAckedFrame, player.Id) + } + + pPlayer.BattleState = PlayerBattleStateIns.ACTIVE + Logger.Info("OnPlayerBattleColliderAcked", zap.Any("roomId", pR.Id), zap.Any("roomState", pR.State), zap.Any("playerId", playerId), zap.Any("capacity", pR.Capacity), zap.Any("len(players)", len(pR.Players))) + + if pR.Capacity == len(pR.Players) { + allAcked := true + for _, p := range pR.Players { + if PlayerBattleStateIns.ACTIVE != p.BattleState { + Logger.Info("unexpectedly got an inactive player", zap.Any("roomId", pR.Id), zap.Any("playerId", p.Id), zap.Any("battleState", p.BattleState)) + allAcked = false + break + } + } + if true == allAcked { + pR.StartBattle() // WON'T run if the battle state is not in WAITING. + } + } + + pR.updateScore() + return true +} + +func (pR *Room) sendSafely(s interface{}, playerId int32) { + defer func() { + if r := recover(); r != nil { + pR.PlayerSignalToCloseDict[playerId](Constants.RetCode.UnknownError, fmt.Sprintf("%v", r)) + } + }() + + var resp *pb.WsResp = nil + + switch v := s.(type) { + case pb.RoomDownsyncFrame: + roomDownsyncFrame := s.(pb.RoomDownsyncFrame) + resp = &pb.WsResp{ + Ret: int32(Constants.RetCode.Ok), + EchoedMsgId: int32(0), + Act: DOWNSYNC_MSG_ACT_ROOM_FRAME, + Rdf: &roomDownsyncFrame, + } + case []*pb.InputFrameDownsync: + toSendFrames := s.([]*pb.InputFrameDownsync) + resp = &pb.WsResp{ + Ret: int32(Constants.RetCode.Ok), + EchoedMsgId: int32(0), + Act: DOWNSYNC_MSG_ACT_INPUT_BATCH, + InputFrameDownsyncBatch: toSendFrames, + } + default: + panic(fmt.Sprintf("Unknown downsync message type, roomId=%v, playerId=%v, roomState=%v, v=%v", pR.Id, playerId, v)) + } + + theBytes, marshalErr := proto.Marshal(resp) + if nil != marshalErr { + panic(fmt.Sprintf("Error marshaling downsync message: roomId=%v, playerId=%v, roomState=%v, roomEffectivePlayerCount=%v", pR.Id, playerId, pR.State, pR.EffectivePlayerCount)) + } + + if err := pR.PlayerDownsyncSessionDict[playerId].WriteMessage(websocket.BinaryMessage, theBytes); nil != err { + panic(fmt.Sprintf("Error sending downsync message: roomId=%v, playerId=%v, roomState=%v, roomEffectivePlayerCount=%v", pR.Id, playerId, pR.State, pR.EffectivePlayerCount)) + } +} + +func (pR *Room) inputFrameIdDebuggable(inputFrameId int32) bool { + return 0 == (inputFrameId % 10) +} + +type RoomBattleContactListener struct { + name string + room *Room +} + +// Implementing the GolangBox2d contact listeners [begins]. +/** + * Note that the execution of these listeners is within the SAME GOROUTINE as that of "`battleMainLoop` in the same room". + * See the comments in `Room.refreshContactListener()` for details. + */ +func (l RoomBattleContactListener) BeginContact(contact box2d.B2ContactInterface) { + var pTower *GuardTower + var pPlayer *Player + + switch v := contact.GetNodeA().Other.GetUserData().(type) { + case *GuardTower: + pTower = v + case *Player: + pPlayer = v + default: + // + } + + switch v := contact.GetNodeB().Other.GetUserData().(type) { + case *GuardTower: + pTower = v + case *Player: + pPlayer = v + default: + } + + if pTower != nil && pPlayer != nil { + pTower.InRangePlayers.AppendPlayer(pPlayer) + } +} + +func (l RoomBattleContactListener) EndContact(contact box2d.B2ContactInterface) { + var pTower *GuardTower + var pPlayer *Player + + switch v := contact.GetNodeA().Other.GetUserData().(type) { + case *GuardTower: + pTower = v + case *Player: + pPlayer = v + default: + } + + switch v := contact.GetNodeB().Other.GetUserData().(type) { + case *GuardTower: + pTower = v + case *Player: + pPlayer = v + default: + } + + if pTower != nil && pPlayer != nil { + pTower.InRangePlayers.RemovePlayerById(pPlayer.Id) + } +} + +func (l RoomBattleContactListener) PreSolve(contact box2d.B2ContactInterface, oldManifold box2d.B2Manifold) { + //fmt.Printf("I am PreSolve %s\n", l.name); +} + +func (l RoomBattleContactListener) PostSolve(contact box2d.B2ContactInterface, impulse *box2d.B2ContactImpulse) { + //fmt.Printf("PostSolve %s\n", l.name); +} + +// Implementing the GolangBox2d contact listeners [ends]. diff --git a/battle_srv/models/room_heap_manager.go b/battle_srv/models/room_heap_manager.go new file mode 100644 index 0000000..e9f4a12 --- /dev/null +++ b/battle_srv/models/room_heap_manager.go @@ -0,0 +1,138 @@ +package models + +import ( + "container/heap" + "fmt" + "github.com/gorilla/websocket" + "go.uber.org/zap" + . "server/common" + "sync" +) + +// Reference https://github.com/genxium/GoStructPrac. +type RoomHeap []*Room +type RoomMap map[int32]*Room + +var ( + // NOTE: For the package exported instances of non-primitive types to be accessed as singletons, they must be of pointer types. + RoomHeapMux *sync.Mutex + RoomHeapManagerIns *RoomHeap + RoomMapManagerIns *RoomMap +) + +func (pPq *RoomHeap) PrintInOrder() { + pq := *pPq + fmt.Printf("The RoomHeap instance now contains:\n") + for i := 0; i < len(pq); i++ { + fmt.Printf("{index: %d, roomID: %d, score: %.2f} ", i, pq[i].Id, pq[i].Score) + } + fmt.Printf("\n") +} + +func (pq RoomHeap) Len() int { return len(pq) } + +func (pq RoomHeap) Less(i, j int) bool { + return pq[i].Score > pq[j].Score +} + +func (pq *RoomHeap) Swap(i, j int) { + (*pq)[i], (*pq)[j] = (*pq)[j], (*pq)[i] + (*pq)[i].Index = i + (*pq)[j].Index = j +} + +func (pq *RoomHeap) Push(pItem interface{}) { + // NOTE: Must take input param type `*Room` here. + n := len(*pq) + pItem.(*Room).Index = n + *pq = append(*pq, pItem.(*Room)) +} + +func (pq *RoomHeap) Pop() interface{} { + old := *pq + n := len(old) + if n == 0 { + return nil + } + pItem := old[n-1] + if pItem.Score <= float32(0.0) { + return nil + } + pItem.Index = -1 // for safety + *pq = old[0 : n-1] + // NOTE: Must return instance which is directly castable to type `*Room` here. + return pItem +} + +func (pq *RoomHeap) update(pItem *Room, Score float32) { + // NOTE: Must use type `*Room` here. + heap.Fix(pq, pItem.Index) +} + +func (pq *RoomHeap) Update(pItem *Room, Score float32) { + pq.update(pItem, Score) +} + +func PrintRoomMap() { + fmt.Printf("The RoomMap instance now contains:\n") + for _, pR := range *RoomMapManagerIns { + fmt.Printf("{roomID: %d, score: %.2f} ", pR.Id, pR.Score) + } + fmt.Printf("\n") +} + +func InitRoomHeapManager() { + RoomHeapMux = new(sync.Mutex) + // Init "pseudo class constants". + InitRoomBattleStateIns() + InitPlayerBattleStateIns() + initialCountOfRooms := 32 + pq := make(RoomHeap, initialCountOfRooms) + roomMap := make(RoomMap, initialCountOfRooms) + + for i := 0; i < initialCountOfRooms; i++ { + roomCapacity := 2 + joinIndexBooleanArr := make([]bool, roomCapacity) + for index, _ := range joinIndexBooleanArr { + joinIndexBooleanArr[index] = false + } + currentRoomBattleState := RoomBattleStateIns.IDLE + pq[i] = &Room{ + Id: int32(i + 1), + Players: make(map[int32]*Player), + PlayerDownsyncSessionDict: make(map[int32]*websocket.Conn), + PlayerSignalToCloseDict: make(map[int32]SignalToCloseConnCbType), + Capacity: roomCapacity, + Score: calRoomScore(0, roomCapacity, currentRoomBattleState), + State: currentRoomBattleState, + Index: i, + Tick: 0, + EffectivePlayerCount: 0, + //BattleDurationNanos: int64(5 * 1000 * 1000 * 1000), + BattleDurationNanos: int64(30 * 1000 * 1000 * 1000), + ServerFPS: 60, + Treasures: make(map[int32]*Treasure), + Traps: make(map[int32]*Trap), + GuardTowers: make(map[int32]*GuardTower), + Bullets: make(map[int32]*Bullet), + SpeedShoes: make(map[int32]*SpeedShoe), + Barriers: make(map[int32]*Barrier), + Pumpkins: make(map[int32]*Pumpkin), + AccumulatedLocalIdForBullets: 0, + AllPlayerInputsBuffer: NewRingBuffer(1024), + LastAllConfirmedInputFrameId: -1, + LastAllConfirmedInputFrameIdWithChange: -1, + LastAllConfirmedInputList: make([]uint64, roomCapacity), + InputDelayFrames: 4, + InputScaleFrames: 2, + JoinIndexBooleanArr: joinIndexBooleanArr, + } + roomMap[pq[i].Id] = pq[i] + pq[i].ChooseStage() + } + heap.Init(&pq) + RoomHeapManagerIns = &pq + RoomMapManagerIns = &roomMap + Logger.Info("The RoomHeapManagerIns has been initialized:", zap.Any("addr", fmt.Sprintf("%p", RoomHeapManagerIns)), zap.Any("size", len(*RoomHeapManagerIns))) + Logger.Info("The RoomMapManagerIns has been initialized:", zap.Any("size", len(*RoomMapManagerIns))) +} diff --git a/battle_srv/models/speed_shoe.go b/battle_srv/models/speed_shoe.go new file mode 100644 index 0000000..a2db919 --- /dev/null +++ b/battle_srv/models/speed_shoe.go @@ -0,0 +1,17 @@ +package models + +import ( + "github.com/ByteArena/box2d" +) + +type SpeedShoe struct { + Id int32 `json:"id,omitempty"` + LocalIdInBattle int32 `json:"localIdInBattle,omitempty"` + X float64 `json:"x,omitempty"` + Y float64 `json:"y,omitempty"` + Removed bool `json:"removed,omitempty"` + Type int32 `json:"type,omitempty"` + PickupBoundary *Polygon2D `json:"-"` + CollidableBody *box2d.B2Body `json:"-"` + RemovedAtFrameId int32 `json:"-"` +} diff --git a/battle_srv/models/tiled_map.go b/battle_srv/models/tiled_map.go new file mode 100644 index 0000000..da46afe --- /dev/null +++ b/battle_srv/models/tiled_map.go @@ -0,0 +1,537 @@ +package models + +import ( + "bytes" + "compress/zlib" + "encoding/base64" + "encoding/xml" + "errors" + "fmt" + "github.com/ByteArena/box2d" + "go.uber.org/zap" + "io/ioutil" + "math" + . "server/common" + "strconv" + "strings" +) + +const ( + LOW_SCORE_TREASURE_TYPE = 1 + HIGH_SCORE_TREASURE_TYPE = 2 + + SPEED_SHOES_TYPE = 3 + + LOW_SCORE_TREASURE_SCORE = 100 + HIGH_SCORE_TREASURE_SCORE = 200 + + FLIPPED_HORIZONTALLY_FLAG uint32 = 0x80000000 + FLIPPED_VERTICALLY_FLAG uint32 = 0x40000000 + FLIPPED_DIAGONALLY_FLAG uint32 = 0x20000000 +) + +// For either a "*.tmx" or "*.tsx" file. [begins] +type TmxOrTsxProperty struct { + Name string `xml:"name,attr"` + Value string `xml:"value,attr"` +} + +type TmxOrTsxProperties struct { + Property []*TmxOrTsxProperty `xml:"property"` +} + +type TmxOrTsxPolyline struct { + Points string `xml:"points,attr"` +} + +type TmxOrTsxObject struct { + Id int `xml:"id,attr"` + Gid *int `xml:"gid,attr"` + X float64 `xml:"x,attr"` + Y float64 `xml:"y,attr"` + Properties *TmxOrTsxProperties `xml:"properties"` + Polyline *TmxOrTsxPolyline `xml:"polyline"` + Width *float64 `xml:"width,attr"` + Height *float64 `xml:"height,attr"` +} + +type TmxOrTsxObjectGroup struct { + Draworder string `xml:"draworder,attr"` + Name string `xml:"name,attr"` + Objects []*TmxOrTsxObject `xml:"object"` +} + +type TmxOrTsxImage struct { + Source string `xml:"source,attr"` + Width int `xml:"width,attr"` + Height int `xml:"height,attr"` +} + +// For either a "*.tmx" or "*.tsx" file. [ends] + +// Within a "*.tsx" file. [begins] +type Tsx struct { + Name string `xml:"name,attr"` + TileWidth int `xml:"tilewidth,attr"` + TileHeight int `xml:"tileheight,attr"` + TileCount int `xml:"tilecount,attr"` + Columns int `xml:"columns,attr"` + Image []*TmxOrTsxImage `xml:"image"` + Tiles []*TsxTile `xml:"tile"` +} + +type TsxTile struct { + Id int `xml:"id,attr"` + ObjectGroup *TmxOrTsxObjectGroup `xml:"objectgroup"` + Properties *TmxOrTsxProperties `xml:"properties"` +} + +// Within a "*.tsx" file. [ends] + +// Within a "*.tmx" file. [begins] +type TmxLayerDecodedTileData struct { + Id uint32 + Tileset *TmxTileset + FlipHorizontal bool + FlipVertical bool + FlipDiagonal bool +} + +type TmxLayerEncodedData struct { + Encoding string `xml:"encoding,attr"` + Compression string `xml:"compression,attr"` + Value string `xml:",chardata"` +} + +type TmxLayer struct { + Name string `xml:"name,attr"` + Width int `xml:"width,attr"` + Height int `xml:"height,attr"` + Data *TmxLayerEncodedData `xml:"data"` + Tile []*TmxLayerDecodedTileData +} + +type TmxTileset struct { + FirstGid uint32 `xml:"firstgid,attr"` + Name string `xml:"name,attr"` + TileWidth int `xml:"tilewidth,attr"` + TileHeight int `xml:"tileheight,attr"` + Images []*TmxOrTsxImage `xml:"image"` + Source string `xml:"source,attr"` +} + +type TmxMap struct { + Version string `xml:"version,attr"` + Orientation string `xml:"orientation,attr"` + Width int `xml:"width,attr"` + Height int `xml:"height,attr"` + TileWidth int `xml:"tilewidth,attr"` + TileHeight int `xml:"tileheight,attr"` + Properties []*TmxOrTsxProperties `xml:"properties"` + Tilesets []*TmxTileset `xml:"tileset"` + Layers []*TmxLayer `xml:"layer"` + ObjectGroups []*TmxOrTsxObjectGroup `xml:"objectgroup"` +} + +// Within a "*.tmx" file. [ends] + +func (d *TmxLayerEncodedData) decodeBase64() ([]byte, error) { + r := bytes.NewReader([]byte(strings.TrimSpace(d.Value))) + decr := base64.NewDecoder(base64.StdEncoding, r) + if d.Compression == "zlib" { + rclose, err := zlib.NewReader(decr) + if err != nil { + Logger.Error("tmx data decode zlib error: ", zap.Any("encoding", d.Encoding), zap.Any("compression", d.Compression), zap.Any("value", d.Value)) + return nil, err + } + return ioutil.ReadAll(rclose) + } + Logger.Error("tmx data decode invalid compression: ", zap.Any("encoding", d.Encoding), zap.Any("compression", d.Compression), zap.Any("value", d.Value)) + return nil, errors.New("Invalid compression.") +} + +func (l *TmxLayer) decodeBase64() ([]uint32, error) { + databytes, err := l.Data.decodeBase64() + if err != nil { + return nil, err + } + if l.Width == 0 || l.Height == 0 { + return nil, errors.New("Zero width or height.") + } + if len(databytes) != l.Height*l.Width*4 { + Logger.Error("TmxLayer decodeBase64 invalid data bytes:", zap.Any("width", l.Width), zap.Any("height", l.Height), zap.Any("data lenght", len(databytes))) + return nil, errors.New("Data length error.") + } + dindex := 0 + gids := make([]uint32, l.Height*l.Width) + for h := 0; h < l.Height; h++ { + for w := 0; w < l.Width; w++ { + gid := uint32(databytes[dindex]) | + uint32(databytes[dindex+1])<<8 | + uint32(databytes[dindex+2])<<16 | + uint32(databytes[dindex+3])<<24 + dindex += 4 + gids[h*l.Width+w] = gid + } + } + return gids, nil +} + +type Vec2DList []*Vec2D +type Polygon2DList []*Polygon2D +type StrToVec2DListMap map[string]*Vec2DList // Note that it's deliberately NOT using "map[string]Vec2DList", for the easy of passing return value to "models/room.go". +type StrToPolygon2DListMap map[string]*Polygon2DList // Note that it's deliberately NOT using "map[string]Polygon2DList", for the easy of passing return value to "models/room.go". + +func TmxPolylineToPolygon2DInB2World(pTmxMapIns *TmxMap, singleObjInTmxFile *TmxOrTsxObject, targetPolyline *TmxOrTsxPolyline) (*Polygon2D, error) { + if nil == targetPolyline { + return nil, nil + } + + singleValueArray := strings.Split(targetPolyline.Points, " ") + pointsCount := len(singleValueArray) + + if pointsCount >= box2d.B2_maxPolygonVertices { + return nil, errors.New(fmt.Sprintf("During `TmxPolylineToPolygon2DInB2World`, you have a polygon with pointsCount == %v, exceeding or equal to box2d.B2_maxPolygonVertices == %v, of polyines [%v]", pointsCount, box2d.B2_maxPolygonVertices, singleValueArray)) + } + + theUntransformedAnchor := &Vec2D{ + X: singleObjInTmxFile.X, + Y: singleObjInTmxFile.Y, + } + theTransformedAnchor := pTmxMapIns.continuousObjLayerOffsetToContinuousMapNodePos(theUntransformedAnchor) + thePolygon2DFromPolyline := &Polygon2D{ + Anchor: &theTransformedAnchor, + Points: make([]*Vec2D, len(singleValueArray)), + } + + for k, value := range singleValueArray { + thePolygon2DFromPolyline.Points[k] = &Vec2D{} + for kk, v := range strings.Split(value, ",") { + coordinateValue, err := strconv.ParseFloat(v, 64) + if nil != err { + panic(err) + } + if 0 == (kk % 2) { + thePolygon2DFromPolyline.Points[k].X = (coordinateValue) + } else { + thePolygon2DFromPolyline.Points[k].Y = (coordinateValue) + } + } + + // Transform to B2World space coordinate. + tmp := &Vec2D{ + X: thePolygon2DFromPolyline.Points[k].X, + Y: thePolygon2DFromPolyline.Points[k].Y, + } + transformedTmp := pTmxMapIns.continuousObjLayerVecToContinuousMapNodeVec(tmp) + thePolygon2DFromPolyline.Points[k].X = transformedTmp.X + thePolygon2DFromPolyline.Points[k].Y = transformedTmp.Y + } + + return thePolygon2DFromPolyline, nil +} + +func TsxPolylineToOffsetsWrtTileCenterInB2World(pTmxMapIns *TmxMap, singleObjInTsxFile *TmxOrTsxObject, targetPolyline *TmxOrTsxPolyline, pTsxIns *Tsx) (*Polygon2D, error) { + if nil == targetPolyline { + return nil, nil + } + var factorHalf float64 = 0.5 + offsetFromTopLeftInTileLocalCoordX := singleObjInTsxFile.X + offsetFromTopLeftInTileLocalCoordY := singleObjInTsxFile.Y + + singleValueArray := strings.Split(targetPolyline.Points, " ") + pointsCount := len(singleValueArray) + + if pointsCount >= box2d.B2_maxPolygonVertices { + return nil, errors.New(fmt.Sprintf("During `TsxPolylineToOffsetsWrtTileCenterInB2World`, you have a polygon with pointsCount == %v, exceeding or equal to box2d.B2_maxPolygonVertices == %v", pointsCount, box2d.B2_maxPolygonVertices)) + } + + thePolygon2DFromPolyline := &Polygon2D{ + Anchor: nil, + Points: make([]*Vec2D, pointsCount), + TileWidth: pTsxIns.TileWidth, + TileHeight: pTsxIns.TileHeight, + } + + /* + [WARNING] In this case, the "Treasure"s and "GuardTower"s are put into Tmx file as "ImageObject"s, of each the "ProportionalAnchor" is (0.5, 0). Therefore we calculate that "thePolygon2DFromPolyline.Points" are "offsets(in B2World) w.r.t. the BottomCenter". See https://shimo.im/docs/SmLJJhXm2C8XMzZT for details. + */ + + for k, value := range singleValueArray { + thePolygon2DFromPolyline.Points[k] = &Vec2D{} + for kk, v := range strings.Split(value, ",") { + coordinateValue, err := strconv.ParseFloat(v, 64) + if nil != err { + panic(err) + } + if 0 == (kk % 2) { + // W.r.t. center. + thePolygon2DFromPolyline.Points[k].X = (coordinateValue + offsetFromTopLeftInTileLocalCoordX) - factorHalf*float64(pTsxIns.TileWidth) + } else { + // W.r.t. bottom. + thePolygon2DFromPolyline.Points[k].Y = float64(pTsxIns.TileHeight) - (coordinateValue + offsetFromTopLeftInTileLocalCoordY) + } + } + + // No need to transform for B2World space coordinate because the marks in a Tsx file is already rectilinear. + } + + return thePolygon2DFromPolyline, nil +} + +func DeserializeTsxToColliderDict(pTmxMapIns *TmxMap, byteArrOfTsxFile []byte, firstGid int, gidBoundariesMapInB2World map[int]StrToPolygon2DListMap) error { + pTsxIns := &Tsx{} + err := xml.Unmarshal(byteArrOfTsxFile, pTsxIns) + if nil != err { + panic(err) + } + /* + // For debug-printing only. -- YFLu, 2019-09-04. + + reserializedTmxMap, err := pTmxMapIns.ToXML() + if nil != err { + panic(err) + } + */ + + for _, tile := range pTsxIns.Tiles { + globalGid := (firstGid + int(tile.Id)) + /** + Per tile xml str could be + + ``` + + + + + + + + + + + ``` + , we currently REQUIRE that "`an object of a tile` with ONE OR MORE polylines must come with a single corresponding '', and viceversa". + + Refer to https://shimo.im/docs/SmLJJhXm2C8XMzZT for how we theoretically fit a "Polyline in Tsx" into a "Polygon2D" and then into the corresponding "B2BodyDef & B2Body in the `world of colliding bodies`". + */ + + theObjGroup := tile.ObjectGroup + if nil == theObjGroup { + continue + } + for _, singleObj := range theObjGroup.Objects { + if nil == singleObj.Polyline { + // Temporarily omit those non-polyline-containing objects. + continue + } + if nil == singleObj.Properties.Property || "boundary_type" != singleObj.Properties.Property[0].Name { + continue + } + + key := singleObj.Properties.Property[0].Value + + var theStrToPolygon2DListMap StrToPolygon2DListMap + if existingStrToPolygon2DListMap, ok := gidBoundariesMapInB2World[globalGid]; ok { + theStrToPolygon2DListMap = existingStrToPolygon2DListMap + } else { + gidBoundariesMapInB2World[globalGid] = make(StrToPolygon2DListMap, 0) + theStrToPolygon2DListMap = gidBoundariesMapInB2World[globalGid] + } + + var pThePolygon2DList *Polygon2DList + if _, ok := theStrToPolygon2DListMap[key]; ok { + pThePolygon2DList = theStrToPolygon2DListMap[key] + } else { + thePolygon2DList := make(Polygon2DList, 0) + theStrToPolygon2DListMap[key] = &thePolygon2DList + pThePolygon2DList = theStrToPolygon2DListMap[key] + } + + thePolygon2DFromPolyline, err := TsxPolylineToOffsetsWrtTileCenterInB2World(pTmxMapIns, singleObj, singleObj.Polyline, pTsxIns) + if nil != err { + panic(err) + } + *pThePolygon2DList = append(*pThePolygon2DList, thePolygon2DFromPolyline) + } + } + return nil +} + +func ParseTmxLayersAndGroups(pTmxMapIns *TmxMap, gidBoundariesMapInB2World map[int]StrToPolygon2DListMap) (int32, int32, int32, int32, StrToVec2DListMap, StrToPolygon2DListMap, error) { + toRetStrToVec2DListMap := make(StrToVec2DListMap, 0) + toRetStrToPolygon2DListMap := make(StrToPolygon2DListMap, 0) + /* + Note that both + - "Vec2D"s of "toRetStrToVec2DListMap", and + - "Polygon2D"s of "toRetStrToPolygon2DListMap" + + are already transformed into the "coordinate of B2World". + + -- YFLu + */ + + for _, objGroup := range pTmxMapIns.ObjectGroups { + switch objGroup.Name { + case "PlayerStartingPos": + var pTheVec2DListToCache *Vec2DList + _, ok := toRetStrToVec2DListMap[objGroup.Name] + if false == ok { + theVec2DListToCache := make(Vec2DList, 0) + toRetStrToVec2DListMap[objGroup.Name] = &theVec2DListToCache + pTheVec2DListToCache = toRetStrToVec2DListMap[objGroup.Name] + } else { + pTheVec2DListToCache = toRetStrToVec2DListMap[objGroup.Name] + } + for _, singleObjInTmxFile := range objGroup.Objects { + theUntransformedPos := &Vec2D{ + X: singleObjInTmxFile.X, + Y: singleObjInTmxFile.Y, + } + thePosInWorld := pTmxMapIns.continuousObjLayerOffsetToContinuousMapNodePos(theUntransformedPos) + *pTheVec2DListToCache = append(*pTheVec2DListToCache, &thePosInWorld) + } + case "Pumpkin", "SpeedShoe": + case "Barrier": + /* + Note that in this case, the "Polygon2D.Anchor" of each "TmxOrTsxObject" is located exactly in an overlapping with "Polygon2D.Points[0]" w.r.t. B2World. + + -- YFLu + */ + var pThePolygon2DListToCache *Polygon2DList + _, ok := toRetStrToPolygon2DListMap[objGroup.Name] + if false == ok { + thePolygon2DListToCache := make(Polygon2DList, 0) + toRetStrToPolygon2DListMap[objGroup.Name] = &thePolygon2DListToCache + pThePolygon2DListToCache = toRetStrToPolygon2DListMap[objGroup.Name] + } else { + pThePolygon2DListToCache = toRetStrToPolygon2DListMap[objGroup.Name] + } + + for _, singleObjInTmxFile := range objGroup.Objects { + if nil == singleObjInTmxFile.Polyline { + continue + } + if nil == singleObjInTmxFile.Properties.Property || "boundary_type" != singleObjInTmxFile.Properties.Property[0].Name || "barrier" != singleObjInTmxFile.Properties.Property[0].Value { + continue + } + + thePolygon2DInWorld, err := TmxPolylineToPolygon2DInB2World(pTmxMapIns, singleObjInTmxFile, singleObjInTmxFile.Polyline) + if nil != err { + panic(err) + } + *pThePolygon2DListToCache = append(*pThePolygon2DListToCache, thePolygon2DInWorld) + } + case "LowScoreTreasure", "GuardTower", "HighScoreTreasure": + /* + Note that in this case, the "Polygon2D.Anchor" of each "TmxOrTsxObject" ISN'T located exactly in an overlapping with "Polygon2D.Points[0]" w.r.t. B2World, refer to "https://shimo.im/docs/SmLJJhXm2C8XMzZT" for details. + + -- YFLu + */ + for _, singleObjInTmxFile := range objGroup.Objects { + if nil == singleObjInTmxFile.Gid { + continue + } + theGlobalGid := singleObjInTmxFile.Gid + theStrToPolygon2DListMap, ok := gidBoundariesMapInB2World[*theGlobalGid] + if false == ok { + continue + } + + pThePolygon2DList, ok := theStrToPolygon2DListMap[objGroup.Name] + if false == ok { + continue + } + + var pThePolygon2DListToCache *Polygon2DList + _, ok = toRetStrToPolygon2DListMap[objGroup.Name] + if false == ok { + thePolygon2DListToCache := make(Polygon2DList, 0) + toRetStrToPolygon2DListMap[objGroup.Name] = &thePolygon2DListToCache + pThePolygon2DListToCache = toRetStrToPolygon2DListMap[objGroup.Name] + } else { + pThePolygon2DListToCache = toRetStrToPolygon2DListMap[objGroup.Name] + } + + for _, thePolygon2D := range *pThePolygon2DList { + theUntransformedBottomCenterAsAnchor := &Vec2D{ + X: singleObjInTmxFile.X, + Y: singleObjInTmxFile.Y, + } + + theTransformedBottomCenterAsAnchor := pTmxMapIns.continuousObjLayerOffsetToContinuousMapNodePos(theUntransformedBottomCenterAsAnchor) + + thePolygon2DInWorld := &Polygon2D{ + Anchor: &theTransformedBottomCenterAsAnchor, + Points: make([]*Vec2D, len(thePolygon2D.Points)), + TileWidth: thePolygon2D.TileWidth, + TileHeight: thePolygon2D.TileHeight, + } + if nil != singleObjInTmxFile.Width && nil != singleObjInTmxFile.Height { + thePolygon2DInWorld.TmxObjectWidth = *singleObjInTmxFile.Width + thePolygon2DInWorld.TmxObjectHeight = *singleObjInTmxFile.Height + } + for kk, p := range thePolygon2D.Points { + // [WARNING] It's intentionally recreating a copy of "Vec2D" here. + thePolygon2DInWorld.Points[kk] = &Vec2D{ + X: p.X, + Y: p.Y, + } + } + *pThePolygon2DListToCache = append(*pThePolygon2DListToCache, thePolygon2DInWorld) + } + } + default: + } + } + return int32(pTmxMapIns.Width), int32(pTmxMapIns.Height), int32(pTmxMapIns.TileWidth), int32(pTmxMapIns.TileHeight), toRetStrToVec2DListMap, toRetStrToPolygon2DListMap, nil +} + +func (pTmxMap *TmxMap) ToXML() (string, error) { + ret, err := xml.Marshal(pTmxMap) + return string(ret[:]), err +} + +type TileRectilinearSize struct { + Width float64 + Height float64 +} + +func (pTmxMapIns *TmxMap) continuousObjLayerVecToContinuousMapNodeVec(continuousObjLayerVec *Vec2D) Vec2D { + var tileRectilinearSize TileRectilinearSize + tileRectilinearSize.Width = float64(pTmxMapIns.TileWidth) + tileRectilinearSize.Height = float64(pTmxMapIns.TileHeight) + tileSizeUnifiedLength := math.Sqrt(tileRectilinearSize.Width*tileRectilinearSize.Width*0.25 + tileRectilinearSize.Height*tileRectilinearSize.Height*0.25) + isometricObjectLayerPointOffsetScaleFactor := (tileSizeUnifiedLength / tileRectilinearSize.Height) + cosineThetaRadian := (tileRectilinearSize.Width * 0.5) / tileSizeUnifiedLength + sineThetaRadian := (tileRectilinearSize.Height * 0.5) / tileSizeUnifiedLength + + transMat := [...][2]float64{ + {isometricObjectLayerPointOffsetScaleFactor * cosineThetaRadian, -isometricObjectLayerPointOffsetScaleFactor * cosineThetaRadian}, + {-isometricObjectLayerPointOffsetScaleFactor * sineThetaRadian, -isometricObjectLayerPointOffsetScaleFactor * sineThetaRadian}, + } + convertedVecX := transMat[0][0]*continuousObjLayerVec.X + transMat[0][1]*continuousObjLayerVec.Y + convertedVecY := transMat[1][0]*continuousObjLayerVec.X + transMat[1][1]*continuousObjLayerVec.Y + converted := Vec2D{ + X: convertedVecX, + Y: convertedVecY, + } + return converted +} + +func (pTmxMapIns *TmxMap) continuousObjLayerOffsetToContinuousMapNodePos(continuousObjLayerOffset *Vec2D) Vec2D { + layerOffset := Vec2D{ + X: 0, + Y: float64(pTmxMapIns.Height*pTmxMapIns.TileHeight) * 0.5, + } + + calibratedVec := continuousObjLayerOffset + convertedVec := pTmxMapIns.continuousObjLayerVecToContinuousMapNodeVec(calibratedVec) + + toRet := Vec2D{ + X: layerOffset.X + convertedVec.X, + Y: layerOffset.Y + convertedVec.Y, + } + + return toRet +} diff --git a/battle_srv/models/trap.go b/battle_srv/models/trap.go new file mode 100644 index 0000000..0474a02 --- /dev/null +++ b/battle_srv/models/trap.go @@ -0,0 +1,39 @@ +package models + +import ( + "github.com/ByteArena/box2d" +) + +type Trap struct { + Id int32 `json:"id,omitempty"` + LocalIdInBattle int32 `json:"localIdInBattle,omitempty"` + Type int32 `json:"type,omitempty"` + X float64 `json:"x,omitempty"` + Y float64 `json:"y,omitempty"` + Removed bool `json:"removed,omitempty"` + PickupBoundary *Polygon2D `json:"-"` + TrapBullets []*Bullet `json:"-"` + CollidableBody *box2d.B2Body `json:"-"` + RemovedAtFrameId int32 `json:"-"` +} + +type GuardTower struct { + Id int32 `json:"id,omitempty"` + LocalIdInBattle int32 `json:"localIdInBattle,omitempty"` + Type int32 `json:"type,omitempty"` + X float64 `json:"x,omitempty"` + Y float64 `json:"y,omitempty"` + Removed bool `json:"removed,omitempty"` + PickupBoundary *Polygon2D `json:"-"` + TrapBullets []*Bullet `json:"-"` + CollidableBody *box2d.B2Body `json:"-"` + RemovedAtFrameId int32 `json:"-"` + + InRangePlayers *InRangePlayerCollection `json:"-"` + LastAttackTick int64 `json:"-"` + + TileWidth float64 `json:"-"` + TileHeight float64 `json:"-"` + WidthInB2World float64 `json:"-"` + HeightInB2World float64 `json:"-"` +} diff --git a/battle_srv/models/treasure.go b/battle_srv/models/treasure.go new file mode 100644 index 0000000..95f3704 --- /dev/null +++ b/battle_srv/models/treasure.go @@ -0,0 +1,18 @@ +package models + +import ( + "github.com/ByteArena/box2d" +) + +type Treasure struct { + Id int32 `json:"id,omitempty"` + LocalIdInBattle int32 `json:"localIdInBattle,omitempty"` + Score int32 `json:"score,omitempty"` + X float64 `json:"x,omitempty"` + Y float64 `json:"y,omitempty"` + Removed bool `json:"removed,omitempty"` + Type int32 `json:"type,omitempty"` + + PickupBoundary *Polygon2D `json:"-"` + CollidableBody *box2d.B2Body `json:"-"` +} diff --git a/battle_srv/models/type.go b/battle_srv/models/type.go new file mode 100644 index 0000000..7b24bbd --- /dev/null +++ b/battle_srv/models/type.go @@ -0,0 +1,74 @@ +package models + +import ( + "database/sql" + "encoding/json" +) + +type NullInt64 struct { + sql.NullInt64 +} + +func NewNullInt64(s int64) NullInt64 { + ns := NullInt64{} + ns.Int64 = s + ns.Valid = true + return ns +} + +func (v NullInt64) MarshalJSON() ([]byte, error) { + if v.Valid { + return json.Marshal(v.Int64) + } else { + return json.Marshal(nil) + } +} + +func (v *NullInt64) UnmarshalJSON(data []byte) error { + var s *int64 + //Logger.Debugf("%s\n", data) + if err := json.Unmarshal(data, &s); err != nil { + return err + } + if s != nil { + v.Valid = true + v.Int64 = *s + } else { + v.Valid = false + } + return nil +} + +type NullString struct { + sql.NullString +} + +func NewNullString(s string) NullString { + ns := NullString{} + ns.String = s + ns.Valid = true + return ns +} + +func (v NullString) MarshalJSON() ([]byte, error) { + if v.Valid { + return json.Marshal(v.String) + } else { + return json.Marshal(nil) + } +} + +func (v *NullString) UnmarshalJSON(data []byte) error { + var s *string + //Logger.Debugf("%s\n", data) + if err := json.Unmarshal(data, &s); err != nil { + return err + } + if s != nil { + v.Valid = true + v.String = *s + } else { + v.Valid = false + } + return nil +} diff --git a/battle_srv/pb_output/room_downsync_frame.pb.go b/battle_srv/pb_output/room_downsync_frame.pb.go new file mode 100644 index 0000000..86432fc --- /dev/null +++ b/battle_srv/pb_output/room_downsync_frame.pb.go @@ -0,0 +1,2283 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.1 +// protoc v3.21.4 +// source: room_downsync_frame.proto + +package __ + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Direction struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Dx int32 `protobuf:"varint,1,opt,name=dx,proto3" json:"dx,omitempty"` + Dy int32 `protobuf:"varint,2,opt,name=dy,proto3" json:"dy,omitempty"` +} + +func (x *Direction) Reset() { + *x = Direction{} + if protoimpl.UnsafeEnabled { + mi := &file_room_downsync_frame_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Direction) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Direction) ProtoMessage() {} + +func (x *Direction) ProtoReflect() protoreflect.Message { + mi := &file_room_downsync_frame_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Direction.ProtoReflect.Descriptor instead. +func (*Direction) Descriptor() ([]byte, []int) { + return file_room_downsync_frame_proto_rawDescGZIP(), []int{0} +} + +func (x *Direction) GetDx() int32 { + if x != nil { + return x.Dx + } + return 0 +} + +func (x *Direction) GetDy() int32 { + if x != nil { + return x.Dy + } + return 0 +} + +type Vec2D struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + X float64 `protobuf:"fixed64,1,opt,name=x,proto3" json:"x,omitempty"` + Y float64 `protobuf:"fixed64,2,opt,name=y,proto3" json:"y,omitempty"` +} + +func (x *Vec2D) Reset() { + *x = Vec2D{} + if protoimpl.UnsafeEnabled { + mi := &file_room_downsync_frame_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Vec2D) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Vec2D) ProtoMessage() {} + +func (x *Vec2D) ProtoReflect() protoreflect.Message { + mi := &file_room_downsync_frame_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Vec2D.ProtoReflect.Descriptor instead. +func (*Vec2D) Descriptor() ([]byte, []int) { + return file_room_downsync_frame_proto_rawDescGZIP(), []int{1} +} + +func (x *Vec2D) GetX() float64 { + if x != nil { + return x.X + } + return 0 +} + +func (x *Vec2D) GetY() float64 { + if x != nil { + return x.Y + } + return 0 +} + +type Polygon2D struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Anchor *Vec2D `protobuf:"bytes,1,opt,name=Anchor,proto3" json:"Anchor,omitempty"` + Points []*Vec2D `protobuf:"bytes,2,rep,name=Points,proto3" json:"Points,omitempty"` +} + +func (x *Polygon2D) Reset() { + *x = Polygon2D{} + if protoimpl.UnsafeEnabled { + mi := &file_room_downsync_frame_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Polygon2D) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Polygon2D) ProtoMessage() {} + +func (x *Polygon2D) ProtoReflect() protoreflect.Message { + mi := &file_room_downsync_frame_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Polygon2D.ProtoReflect.Descriptor instead. +func (*Polygon2D) Descriptor() ([]byte, []int) { + return file_room_downsync_frame_proto_rawDescGZIP(), []int{2} +} + +func (x *Polygon2D) GetAnchor() *Vec2D { + if x != nil { + return x.Anchor + } + return nil +} + +func (x *Polygon2D) GetPoints() []*Vec2D { + if x != nil { + return x.Points + } + return nil +} + +type Vec2DList struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Vec2DList []*Vec2D `protobuf:"bytes,1,rep,name=vec2DList,proto3" json:"vec2DList,omitempty"` +} + +func (x *Vec2DList) Reset() { + *x = Vec2DList{} + if protoimpl.UnsafeEnabled { + mi := &file_room_downsync_frame_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Vec2DList) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Vec2DList) ProtoMessage() {} + +func (x *Vec2DList) ProtoReflect() protoreflect.Message { + mi := &file_room_downsync_frame_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Vec2DList.ProtoReflect.Descriptor instead. +func (*Vec2DList) Descriptor() ([]byte, []int) { + return file_room_downsync_frame_proto_rawDescGZIP(), []int{3} +} + +func (x *Vec2DList) GetVec2DList() []*Vec2D { + if x != nil { + return x.Vec2DList + } + return nil +} + +type Polygon2DList struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Polygon2DList []*Polygon2D `protobuf:"bytes,1,rep,name=polygon2DList,proto3" json:"polygon2DList,omitempty"` +} + +func (x *Polygon2DList) Reset() { + *x = Polygon2DList{} + if protoimpl.UnsafeEnabled { + mi := &file_room_downsync_frame_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Polygon2DList) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Polygon2DList) ProtoMessage() {} + +func (x *Polygon2DList) ProtoReflect() protoreflect.Message { + mi := &file_room_downsync_frame_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Polygon2DList.ProtoReflect.Descriptor instead. +func (*Polygon2DList) Descriptor() ([]byte, []int) { + return file_room_downsync_frame_proto_rawDescGZIP(), []int{4} +} + +func (x *Polygon2DList) GetPolygon2DList() []*Polygon2D { + if x != nil { + return x.Polygon2DList + } + return nil +} + +type BattleColliderInfo struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + IntervalToPing int32 `protobuf:"varint,1,opt,name=intervalToPing,proto3" json:"intervalToPing,omitempty"` + WillKickIfInactiveFor int32 `protobuf:"varint,2,opt,name=willKickIfInactiveFor,proto3" json:"willKickIfInactiveFor,omitempty"` + BoundRoomId int32 `protobuf:"varint,3,opt,name=boundRoomId,proto3" json:"boundRoomId,omitempty"` + StageName string `protobuf:"bytes,4,opt,name=stageName,proto3" json:"stageName,omitempty"` + StrToVec2DListMap map[string]*Vec2DList `protobuf:"bytes,5,rep,name=strToVec2DListMap,proto3" json:"strToVec2DListMap,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + StrToPolygon2DListMap map[string]*Polygon2DList `protobuf:"bytes,6,rep,name=strToPolygon2DListMap,proto3" json:"strToPolygon2DListMap,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + StageDiscreteW int32 `protobuf:"varint,7,opt,name=StageDiscreteW,proto3" json:"StageDiscreteW,omitempty"` + StageDiscreteH int32 `protobuf:"varint,8,opt,name=StageDiscreteH,proto3" json:"StageDiscreteH,omitempty"` + StageTileW int32 `protobuf:"varint,9,opt,name=StageTileW,proto3" json:"StageTileW,omitempty"` + StageTileH int32 `protobuf:"varint,10,opt,name=StageTileH,proto3" json:"StageTileH,omitempty"` +} + +func (x *BattleColliderInfo) Reset() { + *x = BattleColliderInfo{} + if protoimpl.UnsafeEnabled { + mi := &file_room_downsync_frame_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *BattleColliderInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BattleColliderInfo) ProtoMessage() {} + +func (x *BattleColliderInfo) ProtoReflect() protoreflect.Message { + mi := &file_room_downsync_frame_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use BattleColliderInfo.ProtoReflect.Descriptor instead. +func (*BattleColliderInfo) Descriptor() ([]byte, []int) { + return file_room_downsync_frame_proto_rawDescGZIP(), []int{5} +} + +func (x *BattleColliderInfo) GetIntervalToPing() int32 { + if x != nil { + return x.IntervalToPing + } + return 0 +} + +func (x *BattleColliderInfo) GetWillKickIfInactiveFor() int32 { + if x != nil { + return x.WillKickIfInactiveFor + } + return 0 +} + +func (x *BattleColliderInfo) GetBoundRoomId() int32 { + if x != nil { + return x.BoundRoomId + } + return 0 +} + +func (x *BattleColliderInfo) GetStageName() string { + if x != nil { + return x.StageName + } + return "" +} + +func (x *BattleColliderInfo) GetStrToVec2DListMap() map[string]*Vec2DList { + if x != nil { + return x.StrToVec2DListMap + } + return nil +} + +func (x *BattleColliderInfo) GetStrToPolygon2DListMap() map[string]*Polygon2DList { + if x != nil { + return x.StrToPolygon2DListMap + } + return nil +} + +func (x *BattleColliderInfo) GetStageDiscreteW() int32 { + if x != nil { + return x.StageDiscreteW + } + return 0 +} + +func (x *BattleColliderInfo) GetStageDiscreteH() int32 { + if x != nil { + return x.StageDiscreteH + } + return 0 +} + +func (x *BattleColliderInfo) GetStageTileW() int32 { + if x != nil { + return x.StageTileW + } + return 0 +} + +func (x *BattleColliderInfo) GetStageTileH() int32 { + if x != nil { + return x.StageTileH + } + return 0 +} + +type Player struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + X float64 `protobuf:"fixed64,2,opt,name=x,proto3" json:"x,omitempty"` + Y float64 `protobuf:"fixed64,3,opt,name=y,proto3" json:"y,omitempty"` + Dir *Direction `protobuf:"bytes,4,opt,name=dir,proto3" json:"dir,omitempty"` + Speed int32 `protobuf:"varint,5,opt,name=speed,proto3" json:"speed,omitempty"` + BattleState int32 `protobuf:"varint,6,opt,name=battleState,proto3" json:"battleState,omitempty"` + LastMoveGmtMillis int32 `protobuf:"varint,7,opt,name=lastMoveGmtMillis,proto3" json:"lastMoveGmtMillis,omitempty"` + Score int32 `protobuf:"varint,10,opt,name=score,proto3" json:"score,omitempty"` + Removed bool `protobuf:"varint,11,opt,name=removed,proto3" json:"removed,omitempty"` + JoinIndex int32 `protobuf:"varint,12,opt,name=joinIndex,proto3" json:"joinIndex,omitempty"` +} + +func (x *Player) Reset() { + *x = Player{} + if protoimpl.UnsafeEnabled { + mi := &file_room_downsync_frame_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Player) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Player) ProtoMessage() {} + +func (x *Player) ProtoReflect() protoreflect.Message { + mi := &file_room_downsync_frame_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Player.ProtoReflect.Descriptor instead. +func (*Player) Descriptor() ([]byte, []int) { + return file_room_downsync_frame_proto_rawDescGZIP(), []int{6} +} + +func (x *Player) GetId() int32 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *Player) GetX() float64 { + if x != nil { + return x.X + } + return 0 +} + +func (x *Player) GetY() float64 { + if x != nil { + return x.Y + } + return 0 +} + +func (x *Player) GetDir() *Direction { + if x != nil { + return x.Dir + } + return nil +} + +func (x *Player) GetSpeed() int32 { + if x != nil { + return x.Speed + } + return 0 +} + +func (x *Player) GetBattleState() int32 { + if x != nil { + return x.BattleState + } + return 0 +} + +func (x *Player) GetLastMoveGmtMillis() int32 { + if x != nil { + return x.LastMoveGmtMillis + } + return 0 +} + +func (x *Player) GetScore() int32 { + if x != nil { + return x.Score + } + return 0 +} + +func (x *Player) GetRemoved() bool { + if x != nil { + return x.Removed + } + return false +} + +func (x *Player) GetJoinIndex() int32 { + if x != nil { + return x.JoinIndex + } + return 0 +} + +type PlayerMeta struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + DisplayName string `protobuf:"bytes,3,opt,name=displayName,proto3" json:"displayName,omitempty"` + Avatar string `protobuf:"bytes,4,opt,name=avatar,proto3" json:"avatar,omitempty"` + JoinIndex int32 `protobuf:"varint,5,opt,name=joinIndex,proto3" json:"joinIndex,omitempty"` +} + +func (x *PlayerMeta) Reset() { + *x = PlayerMeta{} + if protoimpl.UnsafeEnabled { + mi := &file_room_downsync_frame_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PlayerMeta) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PlayerMeta) ProtoMessage() {} + +func (x *PlayerMeta) ProtoReflect() protoreflect.Message { + mi := &file_room_downsync_frame_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PlayerMeta.ProtoReflect.Descriptor instead. +func (*PlayerMeta) Descriptor() ([]byte, []int) { + return file_room_downsync_frame_proto_rawDescGZIP(), []int{7} +} + +func (x *PlayerMeta) GetId() int32 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *PlayerMeta) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *PlayerMeta) GetDisplayName() string { + if x != nil { + return x.DisplayName + } + return "" +} + +func (x *PlayerMeta) GetAvatar() string { + if x != nil { + return x.Avatar + } + return "" +} + +func (x *PlayerMeta) GetJoinIndex() int32 { + if x != nil { + return x.JoinIndex + } + return 0 +} + +type Treasure struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + LocalIdInBattle int32 `protobuf:"varint,2,opt,name=localIdInBattle,proto3" json:"localIdInBattle,omitempty"` + Score int32 `protobuf:"varint,3,opt,name=score,proto3" json:"score,omitempty"` + X float64 `protobuf:"fixed64,4,opt,name=x,proto3" json:"x,omitempty"` + Y float64 `protobuf:"fixed64,5,opt,name=y,proto3" json:"y,omitempty"` + Removed bool `protobuf:"varint,6,opt,name=removed,proto3" json:"removed,omitempty"` + Type int32 `protobuf:"varint,7,opt,name=type,proto3" json:"type,omitempty"` +} + +func (x *Treasure) Reset() { + *x = Treasure{} + if protoimpl.UnsafeEnabled { + mi := &file_room_downsync_frame_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Treasure) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Treasure) ProtoMessage() {} + +func (x *Treasure) ProtoReflect() protoreflect.Message { + mi := &file_room_downsync_frame_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Treasure.ProtoReflect.Descriptor instead. +func (*Treasure) Descriptor() ([]byte, []int) { + return file_room_downsync_frame_proto_rawDescGZIP(), []int{8} +} + +func (x *Treasure) GetId() int32 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *Treasure) GetLocalIdInBattle() int32 { + if x != nil { + return x.LocalIdInBattle + } + return 0 +} + +func (x *Treasure) GetScore() int32 { + if x != nil { + return x.Score + } + return 0 +} + +func (x *Treasure) GetX() float64 { + if x != nil { + return x.X + } + return 0 +} + +func (x *Treasure) GetY() float64 { + if x != nil { + return x.Y + } + return 0 +} + +func (x *Treasure) GetRemoved() bool { + if x != nil { + return x.Removed + } + return false +} + +func (x *Treasure) GetType() int32 { + if x != nil { + return x.Type + } + return 0 +} + +type Bullet struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + LocalIdInBattle int32 `protobuf:"varint,1,opt,name=localIdInBattle,proto3" json:"localIdInBattle,omitempty"` + LinearSpeed float64 `protobuf:"fixed64,2,opt,name=linearSpeed,proto3" json:"linearSpeed,omitempty"` + X float64 `protobuf:"fixed64,3,opt,name=x,proto3" json:"x,omitempty"` + Y float64 `protobuf:"fixed64,4,opt,name=y,proto3" json:"y,omitempty"` + Removed bool `protobuf:"varint,5,opt,name=removed,proto3" json:"removed,omitempty"` + StartAtPoint *Vec2D `protobuf:"bytes,6,opt,name=startAtPoint,proto3" json:"startAtPoint,omitempty"` + EndAtPoint *Vec2D `protobuf:"bytes,7,opt,name=endAtPoint,proto3" json:"endAtPoint,omitempty"` +} + +func (x *Bullet) Reset() { + *x = Bullet{} + if protoimpl.UnsafeEnabled { + mi := &file_room_downsync_frame_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Bullet) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Bullet) ProtoMessage() {} + +func (x *Bullet) ProtoReflect() protoreflect.Message { + mi := &file_room_downsync_frame_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Bullet.ProtoReflect.Descriptor instead. +func (*Bullet) Descriptor() ([]byte, []int) { + return file_room_downsync_frame_proto_rawDescGZIP(), []int{9} +} + +func (x *Bullet) GetLocalIdInBattle() int32 { + if x != nil { + return x.LocalIdInBattle + } + return 0 +} + +func (x *Bullet) GetLinearSpeed() float64 { + if x != nil { + return x.LinearSpeed + } + return 0 +} + +func (x *Bullet) GetX() float64 { + if x != nil { + return x.X + } + return 0 +} + +func (x *Bullet) GetY() float64 { + if x != nil { + return x.Y + } + return 0 +} + +func (x *Bullet) GetRemoved() bool { + if x != nil { + return x.Removed + } + return false +} + +func (x *Bullet) GetStartAtPoint() *Vec2D { + if x != nil { + return x.StartAtPoint + } + return nil +} + +func (x *Bullet) GetEndAtPoint() *Vec2D { + if x != nil { + return x.EndAtPoint + } + return nil +} + +type Trap struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + LocalIdInBattle int32 `protobuf:"varint,2,opt,name=localIdInBattle,proto3" json:"localIdInBattle,omitempty"` + Type int32 `protobuf:"varint,3,opt,name=type,proto3" json:"type,omitempty"` + X float64 `protobuf:"fixed64,4,opt,name=x,proto3" json:"x,omitempty"` + Y float64 `protobuf:"fixed64,5,opt,name=y,proto3" json:"y,omitempty"` + Removed bool `protobuf:"varint,6,opt,name=removed,proto3" json:"removed,omitempty"` +} + +func (x *Trap) Reset() { + *x = Trap{} + if protoimpl.UnsafeEnabled { + mi := &file_room_downsync_frame_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Trap) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Trap) ProtoMessage() {} + +func (x *Trap) ProtoReflect() protoreflect.Message { + mi := &file_room_downsync_frame_proto_msgTypes[10] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Trap.ProtoReflect.Descriptor instead. +func (*Trap) Descriptor() ([]byte, []int) { + return file_room_downsync_frame_proto_rawDescGZIP(), []int{10} +} + +func (x *Trap) GetId() int32 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *Trap) GetLocalIdInBattle() int32 { + if x != nil { + return x.LocalIdInBattle + } + return 0 +} + +func (x *Trap) GetType() int32 { + if x != nil { + return x.Type + } + return 0 +} + +func (x *Trap) GetX() float64 { + if x != nil { + return x.X + } + return 0 +} + +func (x *Trap) GetY() float64 { + if x != nil { + return x.Y + } + return 0 +} + +func (x *Trap) GetRemoved() bool { + if x != nil { + return x.Removed + } + return false +} + +type SpeedShoe struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + LocalIdInBattle int32 `protobuf:"varint,2,opt,name=localIdInBattle,proto3" json:"localIdInBattle,omitempty"` + X float64 `protobuf:"fixed64,3,opt,name=x,proto3" json:"x,omitempty"` + Y float64 `protobuf:"fixed64,4,opt,name=y,proto3" json:"y,omitempty"` + Removed bool `protobuf:"varint,5,opt,name=removed,proto3" json:"removed,omitempty"` + Type int32 `protobuf:"varint,6,opt,name=type,proto3" json:"type,omitempty"` +} + +func (x *SpeedShoe) Reset() { + *x = SpeedShoe{} + if protoimpl.UnsafeEnabled { + mi := &file_room_downsync_frame_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SpeedShoe) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SpeedShoe) ProtoMessage() {} + +func (x *SpeedShoe) ProtoReflect() protoreflect.Message { + mi := &file_room_downsync_frame_proto_msgTypes[11] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SpeedShoe.ProtoReflect.Descriptor instead. +func (*SpeedShoe) Descriptor() ([]byte, []int) { + return file_room_downsync_frame_proto_rawDescGZIP(), []int{11} +} + +func (x *SpeedShoe) GetId() int32 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *SpeedShoe) GetLocalIdInBattle() int32 { + if x != nil { + return x.LocalIdInBattle + } + return 0 +} + +func (x *SpeedShoe) GetX() float64 { + if x != nil { + return x.X + } + return 0 +} + +func (x *SpeedShoe) GetY() float64 { + if x != nil { + return x.Y + } + return 0 +} + +func (x *SpeedShoe) GetRemoved() bool { + if x != nil { + return x.Removed + } + return false +} + +func (x *SpeedShoe) GetType() int32 { + if x != nil { + return x.Type + } + return 0 +} + +type Pumpkin struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + LocalIdInBattle int32 `protobuf:"varint,1,opt,name=localIdInBattle,proto3" json:"localIdInBattle,omitempty"` + LinearSpeed float64 `protobuf:"fixed64,2,opt,name=linearSpeed,proto3" json:"linearSpeed,omitempty"` + X float64 `protobuf:"fixed64,3,opt,name=x,proto3" json:"x,omitempty"` + Y float64 `protobuf:"fixed64,4,opt,name=y,proto3" json:"y,omitempty"` + Removed bool `protobuf:"varint,5,opt,name=removed,proto3" json:"removed,omitempty"` +} + +func (x *Pumpkin) Reset() { + *x = Pumpkin{} + if protoimpl.UnsafeEnabled { + mi := &file_room_downsync_frame_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Pumpkin) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Pumpkin) ProtoMessage() {} + +func (x *Pumpkin) ProtoReflect() protoreflect.Message { + mi := &file_room_downsync_frame_proto_msgTypes[12] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Pumpkin.ProtoReflect.Descriptor instead. +func (*Pumpkin) Descriptor() ([]byte, []int) { + return file_room_downsync_frame_proto_rawDescGZIP(), []int{12} +} + +func (x *Pumpkin) GetLocalIdInBattle() int32 { + if x != nil { + return x.LocalIdInBattle + } + return 0 +} + +func (x *Pumpkin) GetLinearSpeed() float64 { + if x != nil { + return x.LinearSpeed + } + return 0 +} + +func (x *Pumpkin) GetX() float64 { + if x != nil { + return x.X + } + return 0 +} + +func (x *Pumpkin) GetY() float64 { + if x != nil { + return x.Y + } + return 0 +} + +func (x *Pumpkin) GetRemoved() bool { + if x != nil { + return x.Removed + } + return false +} + +type GuardTower struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + LocalIdInBattle int32 `protobuf:"varint,2,opt,name=localIdInBattle,proto3" json:"localIdInBattle,omitempty"` + Type int32 `protobuf:"varint,3,opt,name=type,proto3" json:"type,omitempty"` + X float64 `protobuf:"fixed64,4,opt,name=x,proto3" json:"x,omitempty"` + Y float64 `protobuf:"fixed64,5,opt,name=y,proto3" json:"y,omitempty"` + Removed bool `protobuf:"varint,6,opt,name=removed,proto3" json:"removed,omitempty"` +} + +func (x *GuardTower) Reset() { + *x = GuardTower{} + if protoimpl.UnsafeEnabled { + mi := &file_room_downsync_frame_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GuardTower) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GuardTower) ProtoMessage() {} + +func (x *GuardTower) ProtoReflect() protoreflect.Message { + mi := &file_room_downsync_frame_proto_msgTypes[13] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GuardTower.ProtoReflect.Descriptor instead. +func (*GuardTower) Descriptor() ([]byte, []int) { + return file_room_downsync_frame_proto_rawDescGZIP(), []int{13} +} + +func (x *GuardTower) GetId() int32 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *GuardTower) GetLocalIdInBattle() int32 { + if x != nil { + return x.LocalIdInBattle + } + return 0 +} + +func (x *GuardTower) GetType() int32 { + if x != nil { + return x.Type + } + return 0 +} + +func (x *GuardTower) GetX() float64 { + if x != nil { + return x.X + } + return 0 +} + +func (x *GuardTower) GetY() float64 { + if x != nil { + return x.Y + } + return 0 +} + +func (x *GuardTower) GetRemoved() bool { + if x != nil { + return x.Removed + } + return false +} + +type RoomDownsyncFrame struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + RefFrameId int32 `protobuf:"varint,2,opt,name=refFrameId,proto3" json:"refFrameId,omitempty"` + Players map[int32]*Player `protobuf:"bytes,3,rep,name=players,proto3" json:"players,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + SentAt int64 `protobuf:"varint,4,opt,name=sentAt,proto3" json:"sentAt,omitempty"` + CountdownNanos int64 `protobuf:"varint,5,opt,name=countdownNanos,proto3" json:"countdownNanos,omitempty"` + Treasures map[int32]*Treasure `protobuf:"bytes,6,rep,name=treasures,proto3" json:"treasures,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + Traps map[int32]*Trap `protobuf:"bytes,7,rep,name=traps,proto3" json:"traps,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + Bullets map[int32]*Bullet `protobuf:"bytes,8,rep,name=bullets,proto3" json:"bullets,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + SpeedShoes map[int32]*SpeedShoe `protobuf:"bytes,9,rep,name=speedShoes,proto3" json:"speedShoes,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + Pumpkin map[int32]*Pumpkin `protobuf:"bytes,10,rep,name=pumpkin,proto3" json:"pumpkin,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + GuardTowers map[int32]*GuardTower `protobuf:"bytes,11,rep,name=guardTowers,proto3" json:"guardTowers,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + PlayerMetas map[int32]*PlayerMeta `protobuf:"bytes,12,rep,name=playerMetas,proto3" json:"playerMetas,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (x *RoomDownsyncFrame) Reset() { + *x = RoomDownsyncFrame{} + if protoimpl.UnsafeEnabled { + mi := &file_room_downsync_frame_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RoomDownsyncFrame) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RoomDownsyncFrame) ProtoMessage() {} + +func (x *RoomDownsyncFrame) ProtoReflect() protoreflect.Message { + mi := &file_room_downsync_frame_proto_msgTypes[14] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RoomDownsyncFrame.ProtoReflect.Descriptor instead. +func (*RoomDownsyncFrame) Descriptor() ([]byte, []int) { + return file_room_downsync_frame_proto_rawDescGZIP(), []int{14} +} + +func (x *RoomDownsyncFrame) GetId() int32 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *RoomDownsyncFrame) GetRefFrameId() int32 { + if x != nil { + return x.RefFrameId + } + return 0 +} + +func (x *RoomDownsyncFrame) GetPlayers() map[int32]*Player { + if x != nil { + return x.Players + } + return nil +} + +func (x *RoomDownsyncFrame) GetSentAt() int64 { + if x != nil { + return x.SentAt + } + return 0 +} + +func (x *RoomDownsyncFrame) GetCountdownNanos() int64 { + if x != nil { + return x.CountdownNanos + } + return 0 +} + +func (x *RoomDownsyncFrame) GetTreasures() map[int32]*Treasure { + if x != nil { + return x.Treasures + } + return nil +} + +func (x *RoomDownsyncFrame) GetTraps() map[int32]*Trap { + if x != nil { + return x.Traps + } + return nil +} + +func (x *RoomDownsyncFrame) GetBullets() map[int32]*Bullet { + if x != nil { + return x.Bullets + } + return nil +} + +func (x *RoomDownsyncFrame) GetSpeedShoes() map[int32]*SpeedShoe { + if x != nil { + return x.SpeedShoes + } + return nil +} + +func (x *RoomDownsyncFrame) GetPumpkin() map[int32]*Pumpkin { + if x != nil { + return x.Pumpkin + } + return nil +} + +func (x *RoomDownsyncFrame) GetGuardTowers() map[int32]*GuardTower { + if x != nil { + return x.GuardTowers + } + return nil +} + +func (x *RoomDownsyncFrame) GetPlayerMetas() map[int32]*PlayerMeta { + if x != nil { + return x.PlayerMetas + } + return nil +} + +type InputFrameUpsync struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + InputFrameId int32 `protobuf:"varint,1,opt,name=inputFrameId,proto3" json:"inputFrameId,omitempty"` + EncodedDir int32 `protobuf:"varint,6,opt,name=encodedDir,proto3" json:"encodedDir,omitempty"` +} + +func (x *InputFrameUpsync) Reset() { + *x = InputFrameUpsync{} + if protoimpl.UnsafeEnabled { + mi := &file_room_downsync_frame_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *InputFrameUpsync) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*InputFrameUpsync) ProtoMessage() {} + +func (x *InputFrameUpsync) ProtoReflect() protoreflect.Message { + mi := &file_room_downsync_frame_proto_msgTypes[15] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use InputFrameUpsync.ProtoReflect.Descriptor instead. +func (*InputFrameUpsync) Descriptor() ([]byte, []int) { + return file_room_downsync_frame_proto_rawDescGZIP(), []int{15} +} + +func (x *InputFrameUpsync) GetInputFrameId() int32 { + if x != nil { + return x.InputFrameId + } + return 0 +} + +func (x *InputFrameUpsync) GetEncodedDir() int32 { + if x != nil { + return x.EncodedDir + } + return 0 +} + +type InputFrameDownsync struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + InputFrameId int32 `protobuf:"varint,1,opt,name=inputFrameId,proto3" json:"inputFrameId,omitempty"` + InputList []uint64 `protobuf:"varint,2,rep,packed,name=inputList,proto3" json:"inputList,omitempty"` // Indexed by "joinIndex", we try to compress the "single player input" into 1 word (64-bit for 64-bit Golang runtime) because atomic compare-and-swap only works on 1 word. Although CAS on custom struct is possible in Golang 1.19 https://pkg.go.dev/sync/atomic@go1.19.1#Value.CompareAndSwap, using a single word is still faster whenever possible. + ConfirmedList uint64 `protobuf:"varint,3,opt,name=confirmedList,proto3" json:"confirmedList,omitempty"` // Indexed by "joinIndex", same compression concern as above +} + +func (x *InputFrameDownsync) Reset() { + *x = InputFrameDownsync{} + if protoimpl.UnsafeEnabled { + mi := &file_room_downsync_frame_proto_msgTypes[16] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *InputFrameDownsync) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*InputFrameDownsync) ProtoMessage() {} + +func (x *InputFrameDownsync) ProtoReflect() protoreflect.Message { + mi := &file_room_downsync_frame_proto_msgTypes[16] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use InputFrameDownsync.ProtoReflect.Descriptor instead. +func (*InputFrameDownsync) Descriptor() ([]byte, []int) { + return file_room_downsync_frame_proto_rawDescGZIP(), []int{16} +} + +func (x *InputFrameDownsync) GetInputFrameId() int32 { + if x != nil { + return x.InputFrameId + } + return 0 +} + +func (x *InputFrameDownsync) GetInputList() []uint64 { + if x != nil { + return x.InputList + } + return nil +} + +func (x *InputFrameDownsync) GetConfirmedList() uint64 { + if x != nil { + return x.ConfirmedList + } + return 0 +} + +type HeartbeatUpsync struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ClientTimestamp int64 `protobuf:"varint,1,opt,name=clientTimestamp,proto3" json:"clientTimestamp,omitempty"` +} + +func (x *HeartbeatUpsync) Reset() { + *x = HeartbeatUpsync{} + if protoimpl.UnsafeEnabled { + mi := &file_room_downsync_frame_proto_msgTypes[17] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *HeartbeatUpsync) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*HeartbeatUpsync) ProtoMessage() {} + +func (x *HeartbeatUpsync) ProtoReflect() protoreflect.Message { + mi := &file_room_downsync_frame_proto_msgTypes[17] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use HeartbeatUpsync.ProtoReflect.Descriptor instead. +func (*HeartbeatUpsync) Descriptor() ([]byte, []int) { + return file_room_downsync_frame_proto_rawDescGZIP(), []int{17} +} + +func (x *HeartbeatUpsync) GetClientTimestamp() int64 { + if x != nil { + return x.ClientTimestamp + } + return 0 +} + +type WsReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + MsgId int32 `protobuf:"varint,1,opt,name=msgId,proto3" json:"msgId,omitempty"` + PlayerId int32 `protobuf:"varint,2,opt,name=playerId,proto3" json:"playerId,omitempty"` + Act int32 `protobuf:"varint,3,opt,name=act,proto3" json:"act,omitempty"` + JoinIndex int32 `protobuf:"varint,4,opt,name=joinIndex,proto3" json:"joinIndex,omitempty"` + AckingFrameId int32 `protobuf:"varint,5,opt,name=ackingFrameId,proto3" json:"ackingFrameId,omitempty"` + AckingInputFrameId int32 `protobuf:"varint,6,opt,name=ackingInputFrameId,proto3" json:"ackingInputFrameId,omitempty"` + InputFrameUpsyncBatch []*InputFrameUpsync `protobuf:"bytes,7,rep,name=inputFrameUpsyncBatch,proto3" json:"inputFrameUpsyncBatch,omitempty"` + Hb *HeartbeatUpsync `protobuf:"bytes,8,opt,name=hb,proto3" json:"hb,omitempty"` +} + +func (x *WsReq) Reset() { + *x = WsReq{} + if protoimpl.UnsafeEnabled { + mi := &file_room_downsync_frame_proto_msgTypes[18] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *WsReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*WsReq) ProtoMessage() {} + +func (x *WsReq) ProtoReflect() protoreflect.Message { + mi := &file_room_downsync_frame_proto_msgTypes[18] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use WsReq.ProtoReflect.Descriptor instead. +func (*WsReq) Descriptor() ([]byte, []int) { + return file_room_downsync_frame_proto_rawDescGZIP(), []int{18} +} + +func (x *WsReq) GetMsgId() int32 { + if x != nil { + return x.MsgId + } + return 0 +} + +func (x *WsReq) GetPlayerId() int32 { + if x != nil { + return x.PlayerId + } + return 0 +} + +func (x *WsReq) GetAct() int32 { + if x != nil { + return x.Act + } + return 0 +} + +func (x *WsReq) GetJoinIndex() int32 { + if x != nil { + return x.JoinIndex + } + return 0 +} + +func (x *WsReq) GetAckingFrameId() int32 { + if x != nil { + return x.AckingFrameId + } + return 0 +} + +func (x *WsReq) GetAckingInputFrameId() int32 { + if x != nil { + return x.AckingInputFrameId + } + return 0 +} + +func (x *WsReq) GetInputFrameUpsyncBatch() []*InputFrameUpsync { + if x != nil { + return x.InputFrameUpsyncBatch + } + return nil +} + +func (x *WsReq) GetHb() *HeartbeatUpsync { + if x != nil { + return x.Hb + } + return nil +} + +type WsResp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Ret int32 `protobuf:"varint,1,opt,name=ret,proto3" json:"ret,omitempty"` + EchoedMsgId int32 `protobuf:"varint,2,opt,name=echoedMsgId,proto3" json:"echoedMsgId,omitempty"` + Act int32 `protobuf:"varint,3,opt,name=act,proto3" json:"act,omitempty"` + Rdf *RoomDownsyncFrame `protobuf:"bytes,4,opt,name=rdf,proto3" json:"rdf,omitempty"` + InputFrameDownsyncBatch []*InputFrameDownsync `protobuf:"bytes,5,rep,name=inputFrameDownsyncBatch,proto3" json:"inputFrameDownsyncBatch,omitempty"` + BciFrame *BattleColliderInfo `protobuf:"bytes,6,opt,name=bciFrame,proto3" json:"bciFrame,omitempty"` +} + +func (x *WsResp) Reset() { + *x = WsResp{} + if protoimpl.UnsafeEnabled { + mi := &file_room_downsync_frame_proto_msgTypes[19] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *WsResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*WsResp) ProtoMessage() {} + +func (x *WsResp) ProtoReflect() protoreflect.Message { + mi := &file_room_downsync_frame_proto_msgTypes[19] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use WsResp.ProtoReflect.Descriptor instead. +func (*WsResp) Descriptor() ([]byte, []int) { + return file_room_downsync_frame_proto_rawDescGZIP(), []int{19} +} + +func (x *WsResp) GetRet() int32 { + if x != nil { + return x.Ret + } + return 0 +} + +func (x *WsResp) GetEchoedMsgId() int32 { + if x != nil { + return x.EchoedMsgId + } + return 0 +} + +func (x *WsResp) GetAct() int32 { + if x != nil { + return x.Act + } + return 0 +} + +func (x *WsResp) GetRdf() *RoomDownsyncFrame { + if x != nil { + return x.Rdf + } + return nil +} + +func (x *WsResp) GetInputFrameDownsyncBatch() []*InputFrameDownsync { + if x != nil { + return x.InputFrameDownsyncBatch + } + return nil +} + +func (x *WsResp) GetBciFrame() *BattleColliderInfo { + if x != nil { + return x.BciFrame + } + return nil +} + +var File_room_downsync_frame_proto protoreflect.FileDescriptor + +var file_room_downsync_frame_proto_rawDesc = []byte{ + 0x0a, 0x19, 0x72, 0x6f, 0x6f, 0x6d, 0x5f, 0x64, 0x6f, 0x77, 0x6e, 0x73, 0x79, 0x6e, 0x63, 0x5f, + 0x66, 0x72, 0x61, 0x6d, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0f, 0x74, 0x72, 0x65, + 0x61, 0x73, 0x75, 0x72, 0x65, 0x68, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x78, 0x22, 0x2b, 0x0a, 0x09, + 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x0e, 0x0a, 0x02, 0x64, 0x78, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x64, 0x78, 0x12, 0x0e, 0x0a, 0x02, 0x64, 0x79, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x64, 0x79, 0x22, 0x23, 0x0a, 0x05, 0x56, 0x65, 0x63, + 0x32, 0x44, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x01, 0x52, 0x01, 0x78, + 0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x01, 0x52, 0x01, 0x79, 0x22, 0x6b, + 0x0a, 0x09, 0x50, 0x6f, 0x6c, 0x79, 0x67, 0x6f, 0x6e, 0x32, 0x44, 0x12, 0x2e, 0x0a, 0x06, 0x41, + 0x6e, 0x63, 0x68, 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x74, 0x72, + 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x68, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x78, 0x2e, 0x56, 0x65, + 0x63, 0x32, 0x44, 0x52, 0x06, 0x41, 0x6e, 0x63, 0x68, 0x6f, 0x72, 0x12, 0x2e, 0x0a, 0x06, 0x50, + 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x74, 0x72, + 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x68, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x78, 0x2e, 0x56, 0x65, + 0x63, 0x32, 0x44, 0x52, 0x06, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x22, 0x41, 0x0a, 0x09, 0x56, + 0x65, 0x63, 0x32, 0x44, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x34, 0x0a, 0x09, 0x76, 0x65, 0x63, 0x32, + 0x44, 0x4c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x74, 0x72, + 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x68, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x78, 0x2e, 0x56, 0x65, + 0x63, 0x32, 0x44, 0x52, 0x09, 0x76, 0x65, 0x63, 0x32, 0x44, 0x4c, 0x69, 0x73, 0x74, 0x22, 0x51, + 0x0a, 0x0d, 0x50, 0x6f, 0x6c, 0x79, 0x67, 0x6f, 0x6e, 0x32, 0x44, 0x4c, 0x69, 0x73, 0x74, 0x12, + 0x40, 0x0a, 0x0d, 0x70, 0x6f, 0x6c, 0x79, 0x67, 0x6f, 0x6e, 0x32, 0x44, 0x4c, 0x69, 0x73, 0x74, + 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, + 0x65, 0x68, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x78, 0x2e, 0x50, 0x6f, 0x6c, 0x79, 0x67, 0x6f, 0x6e, + 0x32, 0x44, 0x52, 0x0d, 0x70, 0x6f, 0x6c, 0x79, 0x67, 0x6f, 0x6e, 0x32, 0x44, 0x4c, 0x69, 0x73, + 0x74, 0x22, 0xee, 0x05, 0x0a, 0x12, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x43, 0x6f, 0x6c, 0x6c, + 0x69, 0x64, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x26, 0x0a, 0x0e, 0x69, 0x6e, 0x74, 0x65, + 0x72, 0x76, 0x61, 0x6c, 0x54, 0x6f, 0x50, 0x69, 0x6e, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x0e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x54, 0x6f, 0x50, 0x69, 0x6e, 0x67, + 0x12, 0x34, 0x0a, 0x15, 0x77, 0x69, 0x6c, 0x6c, 0x4b, 0x69, 0x63, 0x6b, 0x49, 0x66, 0x49, 0x6e, + 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x46, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x15, 0x77, 0x69, 0x6c, 0x6c, 0x4b, 0x69, 0x63, 0x6b, 0x49, 0x66, 0x49, 0x6e, 0x61, 0x63, 0x74, + 0x69, 0x76, 0x65, 0x46, 0x6f, 0x72, 0x12, 0x20, 0x0a, 0x0b, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, + 0x6f, 0x6f, 0x6d, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x62, 0x6f, 0x75, + 0x6e, 0x64, 0x52, 0x6f, 0x6f, 0x6d, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x74, 0x61, 0x67, + 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, + 0x67, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x68, 0x0a, 0x11, 0x73, 0x74, 0x72, 0x54, 0x6f, 0x56, + 0x65, 0x63, 0x32, 0x44, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x61, 0x70, 0x18, 0x05, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x3a, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x68, 0x75, 0x6e, 0x74, + 0x65, 0x72, 0x78, 0x2e, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x43, 0x6f, 0x6c, 0x6c, 0x69, 0x64, + 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x53, 0x74, 0x72, 0x54, 0x6f, 0x56, 0x65, 0x63, 0x32, + 0x44, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x61, 0x70, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x11, 0x73, + 0x74, 0x72, 0x54, 0x6f, 0x56, 0x65, 0x63, 0x32, 0x44, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x61, 0x70, + 0x12, 0x74, 0x0a, 0x15, 0x73, 0x74, 0x72, 0x54, 0x6f, 0x50, 0x6f, 0x6c, 0x79, 0x67, 0x6f, 0x6e, + 0x32, 0x44, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x61, 0x70, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x3e, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x68, 0x75, 0x6e, 0x74, 0x65, 0x72, + 0x78, 0x2e, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x43, 0x6f, 0x6c, 0x6c, 0x69, 0x64, 0x65, 0x72, + 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x53, 0x74, 0x72, 0x54, 0x6f, 0x50, 0x6f, 0x6c, 0x79, 0x67, 0x6f, + 0x6e, 0x32, 0x44, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x61, 0x70, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, + 0x15, 0x73, 0x74, 0x72, 0x54, 0x6f, 0x50, 0x6f, 0x6c, 0x79, 0x67, 0x6f, 0x6e, 0x32, 0x44, 0x4c, + 0x69, 0x73, 0x74, 0x4d, 0x61, 0x70, 0x12, 0x26, 0x0a, 0x0e, 0x53, 0x74, 0x61, 0x67, 0x65, 0x44, + 0x69, 0x73, 0x63, 0x72, 0x65, 0x74, 0x65, 0x57, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0e, + 0x53, 0x74, 0x61, 0x67, 0x65, 0x44, 0x69, 0x73, 0x63, 0x72, 0x65, 0x74, 0x65, 0x57, 0x12, 0x26, + 0x0a, 0x0e, 0x53, 0x74, 0x61, 0x67, 0x65, 0x44, 0x69, 0x73, 0x63, 0x72, 0x65, 0x74, 0x65, 0x48, + 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0e, 0x53, 0x74, 0x61, 0x67, 0x65, 0x44, 0x69, 0x73, + 0x63, 0x72, 0x65, 0x74, 0x65, 0x48, 0x12, 0x1e, 0x0a, 0x0a, 0x53, 0x74, 0x61, 0x67, 0x65, 0x54, + 0x69, 0x6c, 0x65, 0x57, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x53, 0x74, 0x61, 0x67, + 0x65, 0x54, 0x69, 0x6c, 0x65, 0x57, 0x12, 0x1e, 0x0a, 0x0a, 0x53, 0x74, 0x61, 0x67, 0x65, 0x54, + 0x69, 0x6c, 0x65, 0x48, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x53, 0x74, 0x61, 0x67, + 0x65, 0x54, 0x69, 0x6c, 0x65, 0x48, 0x1a, 0x60, 0x0a, 0x16, 0x53, 0x74, 0x72, 0x54, 0x6f, 0x56, + 0x65, 0x63, 0x32, 0x44, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x61, 0x70, 0x45, 0x6e, 0x74, 0x72, 0x79, + 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, + 0x65, 0x79, 0x12, 0x30, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x1a, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x68, 0x75, 0x6e, 0x74, + 0x65, 0x72, 0x78, 0x2e, 0x56, 0x65, 0x63, 0x32, 0x44, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x05, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x68, 0x0a, 0x1a, 0x53, 0x74, 0x72, 0x54, + 0x6f, 0x50, 0x6f, 0x6c, 0x79, 0x67, 0x6f, 0x6e, 0x32, 0x44, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x61, + 0x70, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x34, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, + 0x72, 0x65, 0x68, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x78, 0x2e, 0x50, 0x6f, 0x6c, 0x79, 0x67, 0x6f, + 0x6e, 0x32, 0x44, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, + 0x38, 0x01, 0x22, 0x96, 0x02, 0x0a, 0x06, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x12, 0x0e, 0x0a, + 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x69, 0x64, 0x12, 0x0c, 0x0a, + 0x01, 0x78, 0x18, 0x02, 0x20, 0x01, 0x28, 0x01, 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x01, 0x52, 0x01, 0x79, 0x12, 0x2c, 0x0a, 0x03, 0x64, 0x69, 0x72, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, + 0x65, 0x68, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x78, 0x2e, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, + 0x6f, 0x6e, 0x52, 0x03, 0x64, 0x69, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x70, 0x65, 0x65, 0x64, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x73, 0x70, 0x65, 0x65, 0x64, 0x12, 0x20, 0x0a, + 0x0b, 0x62, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x18, 0x06, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x0b, 0x62, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, + 0x2c, 0x0a, 0x11, 0x6c, 0x61, 0x73, 0x74, 0x4d, 0x6f, 0x76, 0x65, 0x47, 0x6d, 0x74, 0x4d, 0x69, + 0x6c, 0x6c, 0x69, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x11, 0x6c, 0x61, 0x73, 0x74, + 0x4d, 0x6f, 0x76, 0x65, 0x47, 0x6d, 0x74, 0x4d, 0x69, 0x6c, 0x6c, 0x69, 0x73, 0x12, 0x14, 0x0a, + 0x05, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x73, 0x63, + 0x6f, 0x72, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x64, 0x18, 0x0b, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x64, 0x12, 0x1c, 0x0a, + 0x09, 0x6a, 0x6f, 0x69, 0x6e, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x09, 0x6a, 0x6f, 0x69, 0x6e, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x22, 0x88, 0x01, 0x0a, 0x0a, + 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x4d, 0x65, 0x74, 0x61, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, + 0x0a, 0x0b, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x4e, 0x61, 0x6d, 0x65, + 0x12, 0x16, 0x0a, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x12, 0x1c, 0x0a, 0x09, 0x6a, 0x6f, 0x69, 0x6e, + 0x49, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x6a, 0x6f, 0x69, + 0x6e, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x22, 0xa4, 0x01, 0x0a, 0x08, 0x54, 0x72, 0x65, 0x61, 0x73, + 0x75, 0x72, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x02, 0x69, 0x64, 0x12, 0x28, 0x0a, 0x0f, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x49, 0x64, 0x49, 0x6e, + 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0f, 0x6c, 0x6f, + 0x63, 0x61, 0x6c, 0x49, 0x64, 0x49, 0x6e, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x12, 0x14, 0x0a, + 0x05, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x73, 0x63, + 0x6f, 0x72, 0x65, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x04, 0x20, 0x01, 0x28, 0x01, 0x52, 0x01, + 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x01, 0x52, 0x01, 0x79, 0x12, + 0x18, 0x0a, 0x07, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, + 0x52, 0x07, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, + 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0xfe, 0x01, + 0x0a, 0x06, 0x42, 0x75, 0x6c, 0x6c, 0x65, 0x74, 0x12, 0x28, 0x0a, 0x0f, 0x6c, 0x6f, 0x63, 0x61, + 0x6c, 0x49, 0x64, 0x49, 0x6e, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x0f, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x49, 0x64, 0x49, 0x6e, 0x42, 0x61, 0x74, 0x74, + 0x6c, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x6c, 0x69, 0x6e, 0x65, 0x61, 0x72, 0x53, 0x70, 0x65, 0x65, + 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x01, 0x52, 0x0b, 0x6c, 0x69, 0x6e, 0x65, 0x61, 0x72, 0x53, + 0x70, 0x65, 0x65, 0x64, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x03, 0x20, 0x01, 0x28, 0x01, 0x52, + 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x01, 0x52, 0x01, 0x79, + 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x08, 0x52, 0x07, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x64, 0x12, 0x3a, 0x0a, 0x0c, 0x73, 0x74, + 0x61, 0x72, 0x74, 0x41, 0x74, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x16, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x68, 0x75, 0x6e, 0x74, 0x65, + 0x72, 0x78, 0x2e, 0x56, 0x65, 0x63, 0x32, 0x44, 0x52, 0x0c, 0x73, 0x74, 0x61, 0x72, 0x74, 0x41, + 0x74, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x36, 0x0a, 0x0a, 0x65, 0x6e, 0x64, 0x41, 0x74, 0x50, + 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x74, 0x72, 0x65, + 0x61, 0x73, 0x75, 0x72, 0x65, 0x68, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x78, 0x2e, 0x56, 0x65, 0x63, + 0x32, 0x44, 0x52, 0x0a, 0x65, 0x6e, 0x64, 0x41, 0x74, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x22, 0x8a, + 0x01, 0x0a, 0x04, 0x54, 0x72, 0x61, 0x70, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x02, 0x69, 0x64, 0x12, 0x28, 0x0a, 0x0f, 0x6c, 0x6f, 0x63, 0x61, 0x6c, + 0x49, 0x64, 0x49, 0x6e, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x0f, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x49, 0x64, 0x49, 0x6e, 0x42, 0x61, 0x74, 0x74, 0x6c, + 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x04, 0x20, 0x01, 0x28, 0x01, + 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x01, 0x52, 0x01, + 0x79, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x64, 0x18, 0x06, 0x20, 0x01, + 0x28, 0x08, 0x52, 0x07, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x64, 0x22, 0x8f, 0x01, 0x0a, 0x09, + 0x53, 0x70, 0x65, 0x65, 0x64, 0x53, 0x68, 0x6f, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x69, 0x64, 0x12, 0x28, 0x0a, 0x0f, 0x6c, 0x6f, 0x63, + 0x61, 0x6c, 0x49, 0x64, 0x49, 0x6e, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x0f, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x49, 0x64, 0x49, 0x6e, 0x42, 0x61, 0x74, + 0x74, 0x6c, 0x65, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x03, 0x20, 0x01, 0x28, 0x01, 0x52, 0x01, + 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x01, 0x52, 0x01, 0x79, 0x12, + 0x18, 0x0a, 0x07, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, + 0x52, 0x07, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, + 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0x8b, 0x01, + 0x0a, 0x07, 0x50, 0x75, 0x6d, 0x70, 0x6b, 0x69, 0x6e, 0x12, 0x28, 0x0a, 0x0f, 0x6c, 0x6f, 0x63, + 0x61, 0x6c, 0x49, 0x64, 0x49, 0x6e, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x0f, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x49, 0x64, 0x49, 0x6e, 0x42, 0x61, 0x74, + 0x74, 0x6c, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x6c, 0x69, 0x6e, 0x65, 0x61, 0x72, 0x53, 0x70, 0x65, + 0x65, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x01, 0x52, 0x0b, 0x6c, 0x69, 0x6e, 0x65, 0x61, 0x72, + 0x53, 0x70, 0x65, 0x65, 0x64, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x03, 0x20, 0x01, 0x28, 0x01, + 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x01, 0x52, 0x01, + 0x79, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x64, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x08, 0x52, 0x07, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x64, 0x22, 0x90, 0x01, 0x0a, 0x0a, + 0x47, 0x75, 0x61, 0x72, 0x64, 0x54, 0x6f, 0x77, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x69, 0x64, 0x12, 0x28, 0x0a, 0x0f, 0x6c, 0x6f, + 0x63, 0x61, 0x6c, 0x49, 0x64, 0x49, 0x6e, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x0f, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x49, 0x64, 0x49, 0x6e, 0x42, 0x61, + 0x74, 0x74, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x01, 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x01, 0x52, 0x01, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x64, 0x18, + 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x64, 0x22, 0xbb, + 0x0b, 0x0a, 0x11, 0x52, 0x6f, 0x6f, 0x6d, 0x44, 0x6f, 0x77, 0x6e, 0x73, 0x79, 0x6e, 0x63, 0x46, + 0x72, 0x61, 0x6d, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x02, 0x69, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x72, 0x65, 0x66, 0x46, 0x72, 0x61, 0x6d, 0x65, + 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x72, 0x65, 0x66, 0x46, 0x72, 0x61, + 0x6d, 0x65, 0x49, 0x64, 0x12, 0x49, 0x0a, 0x07, 0x70, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x73, 0x18, + 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2f, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, + 0x68, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x78, 0x2e, 0x52, 0x6f, 0x6f, 0x6d, 0x44, 0x6f, 0x77, 0x6e, + 0x73, 0x79, 0x6e, 0x63, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x2e, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, + 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x07, 0x70, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x73, 0x12, + 0x16, 0x0a, 0x06, 0x73, 0x65, 0x6e, 0x74, 0x41, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, + 0x06, 0x73, 0x65, 0x6e, 0x74, 0x41, 0x74, 0x12, 0x26, 0x0a, 0x0e, 0x63, 0x6f, 0x75, 0x6e, 0x74, + 0x64, 0x6f, 0x77, 0x6e, 0x4e, 0x61, 0x6e, 0x6f, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, + 0x0e, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x64, 0x6f, 0x77, 0x6e, 0x4e, 0x61, 0x6e, 0x6f, 0x73, 0x12, + 0x4f, 0x0a, 0x09, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x73, 0x18, 0x06, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x31, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x68, 0x75, 0x6e, + 0x74, 0x65, 0x72, 0x78, 0x2e, 0x52, 0x6f, 0x6f, 0x6d, 0x44, 0x6f, 0x77, 0x6e, 0x73, 0x79, 0x6e, + 0x63, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x2e, 0x54, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x73, + 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x09, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x73, + 0x12, 0x43, 0x0a, 0x05, 0x74, 0x72, 0x61, 0x70, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x2d, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x68, 0x75, 0x6e, 0x74, 0x65, 0x72, + 0x78, 0x2e, 0x52, 0x6f, 0x6f, 0x6d, 0x44, 0x6f, 0x77, 0x6e, 0x73, 0x79, 0x6e, 0x63, 0x46, 0x72, + 0x61, 0x6d, 0x65, 0x2e, 0x54, 0x72, 0x61, 0x70, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x05, + 0x74, 0x72, 0x61, 0x70, 0x73, 0x12, 0x49, 0x0a, 0x07, 0x62, 0x75, 0x6c, 0x6c, 0x65, 0x74, 0x73, + 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2f, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, + 0x65, 0x68, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x78, 0x2e, 0x52, 0x6f, 0x6f, 0x6d, 0x44, 0x6f, 0x77, + 0x6e, 0x73, 0x79, 0x6e, 0x63, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x2e, 0x42, 0x75, 0x6c, 0x6c, 0x65, + 0x74, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x07, 0x62, 0x75, 0x6c, 0x6c, 0x65, 0x74, 0x73, + 0x12, 0x52, 0x0a, 0x0a, 0x73, 0x70, 0x65, 0x65, 0x64, 0x53, 0x68, 0x6f, 0x65, 0x73, 0x18, 0x09, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x68, + 0x75, 0x6e, 0x74, 0x65, 0x72, 0x78, 0x2e, 0x52, 0x6f, 0x6f, 0x6d, 0x44, 0x6f, 0x77, 0x6e, 0x73, + 0x79, 0x6e, 0x63, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x2e, 0x53, 0x70, 0x65, 0x65, 0x64, 0x53, 0x68, + 0x6f, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x73, 0x70, 0x65, 0x65, 0x64, 0x53, + 0x68, 0x6f, 0x65, 0x73, 0x12, 0x49, 0x0a, 0x07, 0x70, 0x75, 0x6d, 0x70, 0x6b, 0x69, 0x6e, 0x18, + 0x0a, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2f, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, + 0x68, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x78, 0x2e, 0x52, 0x6f, 0x6f, 0x6d, 0x44, 0x6f, 0x77, 0x6e, + 0x73, 0x79, 0x6e, 0x63, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x2e, 0x50, 0x75, 0x6d, 0x70, 0x6b, 0x69, + 0x6e, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x07, 0x70, 0x75, 0x6d, 0x70, 0x6b, 0x69, 0x6e, 0x12, + 0x55, 0x0a, 0x0b, 0x67, 0x75, 0x61, 0x72, 0x64, 0x54, 0x6f, 0x77, 0x65, 0x72, 0x73, 0x18, 0x0b, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x33, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x68, + 0x75, 0x6e, 0x74, 0x65, 0x72, 0x78, 0x2e, 0x52, 0x6f, 0x6f, 0x6d, 0x44, 0x6f, 0x77, 0x6e, 0x73, + 0x79, 0x6e, 0x63, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x2e, 0x47, 0x75, 0x61, 0x72, 0x64, 0x54, 0x6f, + 0x77, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0b, 0x67, 0x75, 0x61, 0x72, 0x64, + 0x54, 0x6f, 0x77, 0x65, 0x72, 0x73, 0x12, 0x55, 0x0a, 0x0b, 0x70, 0x6c, 0x61, 0x79, 0x65, 0x72, + 0x4d, 0x65, 0x74, 0x61, 0x73, 0x18, 0x0c, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x33, 0x2e, 0x74, 0x72, + 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x68, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x78, 0x2e, 0x52, 0x6f, + 0x6f, 0x6d, 0x44, 0x6f, 0x77, 0x6e, 0x73, 0x79, 0x6e, 0x63, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x2e, + 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x4d, 0x65, 0x74, 0x61, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, + 0x52, 0x0b, 0x70, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x4d, 0x65, 0x74, 0x61, 0x73, 0x1a, 0x53, 0x0a, + 0x0c, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, + 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, + 0x2d, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, + 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x68, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x78, + 0x2e, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, + 0x38, 0x01, 0x1a, 0x57, 0x0a, 0x0e, 0x54, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x73, 0x45, + 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x2f, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, + 0x68, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x78, 0x2e, 0x54, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, + 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x4f, 0x0a, 0x0a, 0x54, + 0x72, 0x61, 0x70, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x2b, 0x0a, 0x05, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x74, 0x72, 0x65, + 0x61, 0x73, 0x75, 0x72, 0x65, 0x68, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x78, 0x2e, 0x54, 0x72, 0x61, + 0x70, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x53, 0x0a, 0x0c, + 0x42, 0x75, 0x6c, 0x6c, 0x65, 0x74, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, + 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x2d, + 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, + 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x68, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x78, 0x2e, + 0x42, 0x75, 0x6c, 0x6c, 0x65, 0x74, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, + 0x01, 0x1a, 0x59, 0x0a, 0x0f, 0x53, 0x70, 0x65, 0x65, 0x64, 0x53, 0x68, 0x6f, 0x65, 0x73, 0x45, + 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x30, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, + 0x68, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x78, 0x2e, 0x53, 0x70, 0x65, 0x65, 0x64, 0x53, 0x68, 0x6f, + 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x54, 0x0a, 0x0c, + 0x50, 0x75, 0x6d, 0x70, 0x6b, 0x69, 0x6e, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, + 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x2e, + 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, + 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x68, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x78, 0x2e, + 0x50, 0x75, 0x6d, 0x70, 0x6b, 0x69, 0x6e, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, + 0x38, 0x01, 0x1a, 0x5b, 0x0a, 0x10, 0x47, 0x75, 0x61, 0x72, 0x64, 0x54, 0x6f, 0x77, 0x65, 0x72, + 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x31, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, + 0x72, 0x65, 0x68, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x78, 0x2e, 0x47, 0x75, 0x61, 0x72, 0x64, 0x54, + 0x6f, 0x77, 0x65, 0x72, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, + 0x5b, 0x0a, 0x10, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x4d, 0x65, 0x74, 0x61, 0x73, 0x45, 0x6e, + 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x31, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x68, + 0x75, 0x6e, 0x74, 0x65, 0x72, 0x78, 0x2e, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x4d, 0x65, 0x74, + 0x61, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x56, 0x0a, 0x10, + 0x49, 0x6e, 0x70, 0x75, 0x74, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x55, 0x70, 0x73, 0x79, 0x6e, 0x63, + 0x12, 0x22, 0x0a, 0x0c, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x49, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x46, 0x72, 0x61, + 0x6d, 0x65, 0x49, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x65, 0x6e, 0x63, 0x6f, 0x64, 0x65, 0x64, 0x44, + 0x69, 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x65, 0x6e, 0x63, 0x6f, 0x64, 0x65, + 0x64, 0x44, 0x69, 0x72, 0x22, 0x7c, 0x0a, 0x12, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x46, 0x72, 0x61, + 0x6d, 0x65, 0x44, 0x6f, 0x77, 0x6e, 0x73, 0x79, 0x6e, 0x63, 0x12, 0x22, 0x0a, 0x0c, 0x69, 0x6e, + 0x70, 0x75, 0x74, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x0c, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x49, 0x64, 0x12, 0x1c, + 0x0a, 0x09, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x18, 0x02, 0x20, 0x03, 0x28, + 0x04, 0x52, 0x09, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x24, 0x0a, 0x0d, + 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x72, 0x6d, 0x65, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x04, 0x52, 0x0d, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x72, 0x6d, 0x65, 0x64, 0x4c, 0x69, + 0x73, 0x74, 0x22, 0x3b, 0x0a, 0x0f, 0x48, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x55, + 0x70, 0x73, 0x79, 0x6e, 0x63, 0x12, 0x28, 0x0a, 0x0f, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x54, + 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0f, + 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x22, + 0xca, 0x02, 0x0a, 0x05, 0x57, 0x73, 0x52, 0x65, 0x71, 0x12, 0x14, 0x0a, 0x05, 0x6d, 0x73, 0x67, + 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x6d, 0x73, 0x67, 0x49, 0x64, 0x12, + 0x1a, 0x0a, 0x08, 0x70, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x08, 0x70, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x49, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x61, + 0x63, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x61, 0x63, 0x74, 0x12, 0x1c, 0x0a, + 0x09, 0x6a, 0x6f, 0x69, 0x6e, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x09, 0x6a, 0x6f, 0x69, 0x6e, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x24, 0x0a, 0x0d, 0x61, + 0x63, 0x6b, 0x69, 0x6e, 0x67, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x49, 0x64, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x0d, 0x61, 0x63, 0x6b, 0x69, 0x6e, 0x67, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x49, + 0x64, 0x12, 0x2e, 0x0a, 0x12, 0x61, 0x63, 0x6b, 0x69, 0x6e, 0x67, 0x49, 0x6e, 0x70, 0x75, 0x74, + 0x46, 0x72, 0x61, 0x6d, 0x65, 0x49, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x12, 0x61, + 0x63, 0x6b, 0x69, 0x6e, 0x67, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x49, + 0x64, 0x12, 0x57, 0x0a, 0x15, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x55, + 0x70, 0x73, 0x79, 0x6e, 0x63, 0x42, 0x61, 0x74, 0x63, 0x68, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x21, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x68, 0x75, 0x6e, 0x74, 0x65, + 0x72, 0x78, 0x2e, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x55, 0x70, 0x73, + 0x79, 0x6e, 0x63, 0x52, 0x15, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x55, + 0x70, 0x73, 0x79, 0x6e, 0x63, 0x42, 0x61, 0x74, 0x63, 0x68, 0x12, 0x30, 0x0a, 0x02, 0x68, 0x62, + 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, + 0x65, 0x68, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x78, 0x2e, 0x48, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, + 0x61, 0x74, 0x55, 0x70, 0x73, 0x79, 0x6e, 0x63, 0x52, 0x02, 0x68, 0x62, 0x22, 0xa4, 0x02, 0x0a, + 0x06, 0x57, 0x73, 0x52, 0x65, 0x73, 0x70, 0x12, 0x10, 0x0a, 0x03, 0x72, 0x65, 0x74, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x72, 0x65, 0x74, 0x12, 0x20, 0x0a, 0x0b, 0x65, 0x63, 0x68, + 0x6f, 0x65, 0x64, 0x4d, 0x73, 0x67, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, + 0x65, 0x63, 0x68, 0x6f, 0x65, 0x64, 0x4d, 0x73, 0x67, 0x49, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x61, + 0x63, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x61, 0x63, 0x74, 0x12, 0x34, 0x0a, + 0x03, 0x72, 0x64, 0x66, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x74, 0x72, 0x65, + 0x61, 0x73, 0x75, 0x72, 0x65, 0x68, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x78, 0x2e, 0x52, 0x6f, 0x6f, + 0x6d, 0x44, 0x6f, 0x77, 0x6e, 0x73, 0x79, 0x6e, 0x63, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x52, 0x03, + 0x72, 0x64, 0x66, 0x12, 0x5d, 0x0a, 0x17, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x46, 0x72, 0x61, 0x6d, + 0x65, 0x44, 0x6f, 0x77, 0x6e, 0x73, 0x79, 0x6e, 0x63, 0x42, 0x61, 0x74, 0x63, 0x68, 0x18, 0x05, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x68, + 0x75, 0x6e, 0x74, 0x65, 0x72, 0x78, 0x2e, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x46, 0x72, 0x61, 0x6d, + 0x65, 0x44, 0x6f, 0x77, 0x6e, 0x73, 0x79, 0x6e, 0x63, 0x52, 0x17, 0x69, 0x6e, 0x70, 0x75, 0x74, + 0x46, 0x72, 0x61, 0x6d, 0x65, 0x44, 0x6f, 0x77, 0x6e, 0x73, 0x79, 0x6e, 0x63, 0x42, 0x61, 0x74, + 0x63, 0x68, 0x12, 0x3f, 0x0a, 0x08, 0x62, 0x63, 0x69, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x18, 0x06, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x68, + 0x75, 0x6e, 0x74, 0x65, 0x72, 0x78, 0x2e, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x43, 0x6f, 0x6c, + 0x6c, 0x69, 0x64, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x08, 0x62, 0x63, 0x69, 0x46, 0x72, + 0x61, 0x6d, 0x65, 0x42, 0x03, 0x5a, 0x01, 0x2e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_room_downsync_frame_proto_rawDescOnce sync.Once + file_room_downsync_frame_proto_rawDescData = file_room_downsync_frame_proto_rawDesc +) + +func file_room_downsync_frame_proto_rawDescGZIP() []byte { + file_room_downsync_frame_proto_rawDescOnce.Do(func() { + file_room_downsync_frame_proto_rawDescData = protoimpl.X.CompressGZIP(file_room_downsync_frame_proto_rawDescData) + }) + return file_room_downsync_frame_proto_rawDescData +} + +var file_room_downsync_frame_proto_msgTypes = make([]protoimpl.MessageInfo, 30) +var file_room_downsync_frame_proto_goTypes = []interface{}{ + (*Direction)(nil), // 0: treasurehunterx.Direction + (*Vec2D)(nil), // 1: treasurehunterx.Vec2D + (*Polygon2D)(nil), // 2: treasurehunterx.Polygon2D + (*Vec2DList)(nil), // 3: treasurehunterx.Vec2DList + (*Polygon2DList)(nil), // 4: treasurehunterx.Polygon2DList + (*BattleColliderInfo)(nil), // 5: treasurehunterx.BattleColliderInfo + (*Player)(nil), // 6: treasurehunterx.Player + (*PlayerMeta)(nil), // 7: treasurehunterx.PlayerMeta + (*Treasure)(nil), // 8: treasurehunterx.Treasure + (*Bullet)(nil), // 9: treasurehunterx.Bullet + (*Trap)(nil), // 10: treasurehunterx.Trap + (*SpeedShoe)(nil), // 11: treasurehunterx.SpeedShoe + (*Pumpkin)(nil), // 12: treasurehunterx.Pumpkin + (*GuardTower)(nil), // 13: treasurehunterx.GuardTower + (*RoomDownsyncFrame)(nil), // 14: treasurehunterx.RoomDownsyncFrame + (*InputFrameUpsync)(nil), // 15: treasurehunterx.InputFrameUpsync + (*InputFrameDownsync)(nil), // 16: treasurehunterx.InputFrameDownsync + (*HeartbeatUpsync)(nil), // 17: treasurehunterx.HeartbeatUpsync + (*WsReq)(nil), // 18: treasurehunterx.WsReq + (*WsResp)(nil), // 19: treasurehunterx.WsResp + nil, // 20: treasurehunterx.BattleColliderInfo.StrToVec2DListMapEntry + nil, // 21: treasurehunterx.BattleColliderInfo.StrToPolygon2DListMapEntry + nil, // 22: treasurehunterx.RoomDownsyncFrame.PlayersEntry + nil, // 23: treasurehunterx.RoomDownsyncFrame.TreasuresEntry + nil, // 24: treasurehunterx.RoomDownsyncFrame.TrapsEntry + nil, // 25: treasurehunterx.RoomDownsyncFrame.BulletsEntry + nil, // 26: treasurehunterx.RoomDownsyncFrame.SpeedShoesEntry + nil, // 27: treasurehunterx.RoomDownsyncFrame.PumpkinEntry + nil, // 28: treasurehunterx.RoomDownsyncFrame.GuardTowersEntry + nil, // 29: treasurehunterx.RoomDownsyncFrame.PlayerMetasEntry +} +var file_room_downsync_frame_proto_depIdxs = []int32{ + 1, // 0: treasurehunterx.Polygon2D.Anchor:type_name -> treasurehunterx.Vec2D + 1, // 1: treasurehunterx.Polygon2D.Points:type_name -> treasurehunterx.Vec2D + 1, // 2: treasurehunterx.Vec2DList.vec2DList:type_name -> treasurehunterx.Vec2D + 2, // 3: treasurehunterx.Polygon2DList.polygon2DList:type_name -> treasurehunterx.Polygon2D + 20, // 4: treasurehunterx.BattleColliderInfo.strToVec2DListMap:type_name -> treasurehunterx.BattleColliderInfo.StrToVec2DListMapEntry + 21, // 5: treasurehunterx.BattleColliderInfo.strToPolygon2DListMap:type_name -> treasurehunterx.BattleColliderInfo.StrToPolygon2DListMapEntry + 0, // 6: treasurehunterx.Player.dir:type_name -> treasurehunterx.Direction + 1, // 7: treasurehunterx.Bullet.startAtPoint:type_name -> treasurehunterx.Vec2D + 1, // 8: treasurehunterx.Bullet.endAtPoint:type_name -> treasurehunterx.Vec2D + 22, // 9: treasurehunterx.RoomDownsyncFrame.players:type_name -> treasurehunterx.RoomDownsyncFrame.PlayersEntry + 23, // 10: treasurehunterx.RoomDownsyncFrame.treasures:type_name -> treasurehunterx.RoomDownsyncFrame.TreasuresEntry + 24, // 11: treasurehunterx.RoomDownsyncFrame.traps:type_name -> treasurehunterx.RoomDownsyncFrame.TrapsEntry + 25, // 12: treasurehunterx.RoomDownsyncFrame.bullets:type_name -> treasurehunterx.RoomDownsyncFrame.BulletsEntry + 26, // 13: treasurehunterx.RoomDownsyncFrame.speedShoes:type_name -> treasurehunterx.RoomDownsyncFrame.SpeedShoesEntry + 27, // 14: treasurehunterx.RoomDownsyncFrame.pumpkin:type_name -> treasurehunterx.RoomDownsyncFrame.PumpkinEntry + 28, // 15: treasurehunterx.RoomDownsyncFrame.guardTowers:type_name -> treasurehunterx.RoomDownsyncFrame.GuardTowersEntry + 29, // 16: treasurehunterx.RoomDownsyncFrame.playerMetas:type_name -> treasurehunterx.RoomDownsyncFrame.PlayerMetasEntry + 15, // 17: treasurehunterx.WsReq.inputFrameUpsyncBatch:type_name -> treasurehunterx.InputFrameUpsync + 17, // 18: treasurehunterx.WsReq.hb:type_name -> treasurehunterx.HeartbeatUpsync + 14, // 19: treasurehunterx.WsResp.rdf:type_name -> treasurehunterx.RoomDownsyncFrame + 16, // 20: treasurehunterx.WsResp.inputFrameDownsyncBatch:type_name -> treasurehunterx.InputFrameDownsync + 5, // 21: treasurehunterx.WsResp.bciFrame:type_name -> treasurehunterx.BattleColliderInfo + 3, // 22: treasurehunterx.BattleColliderInfo.StrToVec2DListMapEntry.value:type_name -> treasurehunterx.Vec2DList + 4, // 23: treasurehunterx.BattleColliderInfo.StrToPolygon2DListMapEntry.value:type_name -> treasurehunterx.Polygon2DList + 6, // 24: treasurehunterx.RoomDownsyncFrame.PlayersEntry.value:type_name -> treasurehunterx.Player + 8, // 25: treasurehunterx.RoomDownsyncFrame.TreasuresEntry.value:type_name -> treasurehunterx.Treasure + 10, // 26: treasurehunterx.RoomDownsyncFrame.TrapsEntry.value:type_name -> treasurehunterx.Trap + 9, // 27: treasurehunterx.RoomDownsyncFrame.BulletsEntry.value:type_name -> treasurehunterx.Bullet + 11, // 28: treasurehunterx.RoomDownsyncFrame.SpeedShoesEntry.value:type_name -> treasurehunterx.SpeedShoe + 12, // 29: treasurehunterx.RoomDownsyncFrame.PumpkinEntry.value:type_name -> treasurehunterx.Pumpkin + 13, // 30: treasurehunterx.RoomDownsyncFrame.GuardTowersEntry.value:type_name -> treasurehunterx.GuardTower + 7, // 31: treasurehunterx.RoomDownsyncFrame.PlayerMetasEntry.value:type_name -> treasurehunterx.PlayerMeta + 32, // [32:32] is the sub-list for method output_type + 32, // [32:32] is the sub-list for method input_type + 32, // [32:32] is the sub-list for extension type_name + 32, // [32:32] is the sub-list for extension extendee + 0, // [0:32] is the sub-list for field type_name +} + +func init() { file_room_downsync_frame_proto_init() } +func file_room_downsync_frame_proto_init() { + if File_room_downsync_frame_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_room_downsync_frame_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Direction); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_room_downsync_frame_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Vec2D); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_room_downsync_frame_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Polygon2D); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_room_downsync_frame_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Vec2DList); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_room_downsync_frame_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Polygon2DList); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_room_downsync_frame_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*BattleColliderInfo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_room_downsync_frame_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Player); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_room_downsync_frame_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PlayerMeta); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_room_downsync_frame_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Treasure); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_room_downsync_frame_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Bullet); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_room_downsync_frame_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Trap); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_room_downsync_frame_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SpeedShoe); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_room_downsync_frame_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Pumpkin); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_room_downsync_frame_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GuardTower); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_room_downsync_frame_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RoomDownsyncFrame); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_room_downsync_frame_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*InputFrameUpsync); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_room_downsync_frame_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*InputFrameDownsync); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_room_downsync_frame_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*HeartbeatUpsync); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_room_downsync_frame_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*WsReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_room_downsync_frame_proto_msgTypes[19].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*WsResp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_room_downsync_frame_proto_rawDesc, + NumEnums: 0, + NumMessages: 30, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_room_downsync_frame_proto_goTypes, + DependencyIndexes: file_room_downsync_frame_proto_depIdxs, + MessageInfos: file_room_downsync_frame_proto_msgTypes, + }.Build() + File_room_downsync_frame_proto = out.File + file_room_downsync_frame_proto_rawDesc = nil + file_room_downsync_frame_proto_goTypes = nil + file_room_downsync_frame_proto_depIdxs = nil +} diff --git a/battle_srv/scheduler/player.go b/battle_srv/scheduler/player.go new file mode 100644 index 0000000..906e1f4 --- /dev/null +++ b/battle_srv/scheduler/player.go @@ -0,0 +1,16 @@ +package scheduler + +import ( + . "server/common" + "server/models" + + "go.uber.org/zap" +) + +func HandleExpiredPlayerLoginToken() { + Logger.Debug("HandleExpiredPlayerLoginToken start") + err := models.CleanExpiredPlayerLoginToken() + if err != nil { + Logger.Debug("HandleExpiredPlayerLoginToken", zap.Error(err)) + } +} diff --git a/battle_srv/start_daemon.sh b/battle_srv/start_daemon.sh new file mode 100644 index 0000000..67670cd --- /dev/null +++ b/battle_srv/start_daemon.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +if [ $# -ne 1 ]; then + echo "Usage: $0 [TEST|PROD]" + exit 1 +fi + +basedir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) + +OS_USER=$USER +ServerEnv=$1 +LOG_PATH="/var/log/treasure-hunter.log" + +# Make sure that the following "PidFile" is "git ignored". +PID_FILE="$basedir/treasure-hunter.pid" + +sudo su - root -c "touch $LOG_PATH" +sudo su - root -c "chown $OS_USER:$OS_USER $LOG_PATH" + +ServerEnv=$ServerEnv $basedir/server >$LOG_PATH 2>&1 & +echo $! > $PID_FILE diff --git a/battle_srv/stop_daemon.sh b/battle_srv/stop_daemon.sh new file mode 100644 index 0000000..2043b2a --- /dev/null +++ b/battle_srv/stop_daemon.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +basedir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) + +PID_FILE="$basedir/treasure-hunter.pid" +if [ -f $PID_FILE ]; then + pid=$( cat "$PID_FILE" ) + if [ -z $pid ]; then + echo "There's no pid stored in $PID_FILE." + else + echo "Killing process of id $pid." + kill $pid + echo "Removing PidFile $PID_FILE." + rm $PID_FILE + fi +else + echo "There's no PidFile $PID_FILE." +fi diff --git a/battle_srv/storage/init.go b/battle_srv/storage/init.go new file mode 100644 index 0000000..f6c5b5a --- /dev/null +++ b/battle_srv/storage/init.go @@ -0,0 +1,6 @@ +package storage + +func Init() { + initMySQL() + initRedis() +} diff --git a/battle_srv/storage/mysql_manager.go b/battle_srv/storage/mysql_manager.go new file mode 100644 index 0000000..9cca7f2 --- /dev/null +++ b/battle_srv/storage/mysql_manager.go @@ -0,0 +1,22 @@ +package storage + +import ( + . "server/common" + + _ "github.com/go-sql-driver/mysql" + "github.com/jmoiron/sqlx" + "go.uber.org/zap" +) + +var ( + MySQLManagerIns *sqlx.DB +) + +func initMySQL() { + var err error + MySQLManagerIns, err = sqlx.Connect("mysql", Conf.MySQL.DSN+"?charset=utf8mb4") + ErrFatal(err) + err = MySQLManagerIns.Ping() + ErrFatal(err) + Logger.Info("MySQLManagerIns", zap.Any("mysql", MySQLManagerIns)) +} diff --git a/battle_srv/storage/redis_manager.go b/battle_srv/storage/redis_manager.go new file mode 100644 index 0000000..1458a7d --- /dev/null +++ b/battle_srv/storage/redis_manager.go @@ -0,0 +1,25 @@ +package storage + +import ( + "fmt" + . "server/common" + + "github.com/go-redis/redis" + _ "github.com/go-sql-driver/mysql" + "go.uber.org/zap" +) + +var ( + RedisManagerIns *redis.Client +) + +func initRedis() { + RedisManagerIns = redis.NewClient(&redis.Options{ + Addr: fmt.Sprintf("%s:%d", Conf.Redis.Host, Conf.Redis.Port), + Password: Conf.Redis.Password, // no password set + DB: Conf.Redis.Dbname, // use default DB + }) + pong, err := RedisManagerIns.Ping().Result() + ErrFatal(err) + Logger.Info("Redis", zap.String("ping", pong)) +} diff --git a/battle_srv/test_cases/Makefile b/battle_srv/test_cases/Makefile new file mode 100644 index 0000000..72179e8 --- /dev/null +++ b/battle_srv/test_cases/Makefile @@ -0,0 +1,9 @@ +PROJECTNAME=tests +ROOT_DIR=$(shell pwd) +all: help + +run-test: build + GOPATH=$(GOPATH):$(ROOT_DIR)/.. ServerEnv=TEST ./$(PROJECTNAME) + +build: + go build -o $(ROOT_DIR)/$(PROJECTNAME) ./tests.go diff --git a/battle_srv/test_cases/tests.go b/battle_srv/test_cases/tests.go new file mode 100644 index 0000000..a276a06 --- /dev/null +++ b/battle_srv/test_cases/tests.go @@ -0,0 +1,79 @@ +package main + +import ( + "fmt" + "io/ioutil" + "os" + "path/filepath" + . "server/common" + "server/models" +) + +var relativePath string + +func loadTMX(fp string, pTmxMapIns *models.TmxMap) { + if !filepath.IsAbs(fp) { + panic("Tmx filepath must be absolute!") + } + + byteArr, err := ioutil.ReadFile(fp) + ErrFatal(err) + models.DeserializeToTmxMapIns(byteArr, pTmxMapIns) + for _, info := range pTmxMapIns.TreasuresInfo { + fmt.Printf("treasuresInfo: %v\n", info) + } + for _, info := range pTmxMapIns.HighTreasuresInfo { + fmt.Printf("treasuresInfo: %v\n", info) + } +} + +func loadTSX(fp string, pTsxIns *models.Tsx) { + if !filepath.IsAbs(fp) { + panic("Tmx filepath must be absolute!") + } + + byteArr, err := ioutil.ReadFile(fp) + ErrFatal(err) + models.DeserializeToTsxIns(byteArr, pTsxIns) + for _, Pos := range pTsxIns.TrapPolyLineList { + fmt.Printf("%v\n", Pos) + } +} + +func getTMXInfo() { + relativePath = "../frontend/assets/resources/map/treasurehunter.tmx" + execPath, err := os.Executable() + ErrFatal(err) + + pwd, err := os.Getwd() + ErrFatal(err) + + fmt.Printf("execPath = %v, pwd = %s, returning...\n", execPath, pwd) + + tmxMapIns := models.TmxMap{} + pTmxMapIns := &tmxMapIns + fp := filepath.Join(pwd, relativePath) + fmt.Printf("fp == %v\n", fp) + loadTMX(fp, pTmxMapIns) +} + +func getTSXInfo() { + + relativePath = "../frontend/assets/resources/map/tile_1.tsx" + execPath, err := os.Executable() + ErrFatal(err) + + pwd, err := os.Getwd() + ErrFatal(err) + + fmt.Printf("execPath = %v, pwd = %s, returning...\n", execPath, pwd) + tsxIns := models.Tsx{} + pTsxIns := &tsxIns + fp := filepath.Join(pwd, relativePath) + fmt.Printf("fp == %v\n", fp) + loadTSX(fp, pTsxIns) +} + +func main() { + getTSXInfo() +} diff --git a/battle_srv/ws/serve.go b/battle_srv/ws/serve.go new file mode 100644 index 0000000..0f3e9fb --- /dev/null +++ b/battle_srv/ws/serve.go @@ -0,0 +1,378 @@ +package ws + +import ( + "container/heap" + "fmt" + "github.com/gin-gonic/gin" + "github.com/golang/protobuf/proto" + "github.com/gorilla/websocket" + "go.uber.org/zap" + "net/http" + . "server/common" + "server/models" + pb "server/pb_output" + "strconv" + "sync/atomic" + "time" +) + +const ( + READ_BUF_SIZE = 8 * 1024 + WRITE_BUF_SIZE = 8 * 1024 +) + +var upgrader = websocket.Upgrader{ + ReadBufferSize: READ_BUF_SIZE, + WriteBufferSize: WRITE_BUF_SIZE, + CheckOrigin: func(r *http.Request) bool { + Logger.Debug("origin", zap.Any("origin", r.Header.Get("Origin"))) + return true + }, +} + +func startOrFeedHeartbeatWatchdog(conn *websocket.Conn) bool { + if nil == conn { + return false + } + conn.SetReadDeadline(time.Now().Add(time.Millisecond * (ConstVals.Ws.WillKickIfInactiveFor))) + return true +} + +func Serve(c *gin.Context) { + token, ok := c.GetQuery("intAuthToken") + if !ok { + c.AbortWithStatus(http.StatusBadRequest) + return + } + Logger.Info("Finding PlayerLogin record for ws authentication:", zap.Any("intAuthToken", token)) + boundRoomId := 0 + expectRoomId := 0 + var err error + if boundRoomIdStr, hasBoundRoomId := c.GetQuery("boundRoomId"); hasBoundRoomId { + boundRoomId, err = strconv.Atoi(boundRoomIdStr) + if err != nil { + // TODO: Abort with specific message. + c.AbortWithStatus(http.StatusBadRequest) + return + } + Logger.Info("Finding PlayerLogin record for ws authentication:", zap.Any("intAuthToken", token), zap.Any("boundRoomId", boundRoomId)) + } + if expectRoomIdStr, hasExpectRoomId := c.GetQuery("expectedRoomId"); hasExpectRoomId { + expectRoomId, err = strconv.Atoi(expectRoomIdStr) + if err != nil { + c.AbortWithStatus(http.StatusBadRequest) + return + } + Logger.Info("Finding PlayerLogin record for ws authentication:", zap.Any("intAuthToken", token), zap.Any("expectedRoomId", expectRoomId)) + } + + // TODO: Wrap the following 2 stmts by sql transaction! + playerId, err := models.GetPlayerIdByToken(token) + if err != nil || playerId == 0 { + // TODO: Abort with specific message. + Logger.Info("PlayerLogin record not found for ws authentication:", zap.Any("intAuthToken", token)) + c.AbortWithStatus(http.StatusBadRequest) + return + } + + Logger.Info("PlayerLogin record has been found for ws authentication:", zap.Any("playerId", playerId)) + + conn, err := upgrader.Upgrade(c.Writer, c.Request, nil) + if err != nil { + Logger.Error("upgrade:", zap.Error(err), zap.Any("playerId", playerId)) + c.AbortWithStatus(http.StatusBadRequest) + return + } + Logger.Debug("ConstVals.Ws.WillKickIfInactiveFor", zap.Duration("v", ConstVals.Ws.WillKickIfInactiveFor)) + /** + * WARNING: After successfully upgraded to use the "persistent connection" of http1.1/websocket protocol, you CANNOT overwrite the http1.0 resp status by `c.AbortWithStatus(...)` any more! + */ + + connHasBeenSignaledToClose := int32(0) + pConnHasBeenSignaledToClose := &connHasBeenSignaledToClose + + var pRoom *models.Room = nil + signalToCloseConnOfThisPlayer := func(customRetCode int, customRetMsg string) { + if swapped := atomic.CompareAndSwapInt32(pConnHasBeenSignaledToClose, 0, 1); !swapped { + return + } + Logger.Warn("signalToCloseConnOfThisPlayer:", zap.Any("playerId", playerId), zap.Any("customRetCode", customRetCode), zap.Any("customRetMsg", customRetMsg)) + if nil != pRoom { + pRoom.OnPlayerDisconnected(int32(playerId)) + } + defer func() { + if r := recover(); r != nil { + Logger.Warn("Recovered from: ", zap.Any("panic", r)) + } + }() + /** + * References + * - https://tools.ietf.org/html/rfc6455 + * - https://godoc.org/github.com/gorilla/websocket#hdr-Control_Messages + * - https://godoc.org/github.com/gorilla/websocket#FormatCloseMessage + * - https://godoc.org/github.com/gorilla/websocket#Conn.WriteControl + * - https://godoc.org/github.com/gorilla/websocket#hdr-Concurrency + * - "The Close and WriteControl methods can be called concurrently with all other methods." + */ + + /** + * References for the "WebsocketStdCloseCode"s. Note that we're using some "CustomCloseCode"s here as well. + * + * - https://tools.ietf.org/html/rfc6455#section-7.4 + * - https://godoc.org/github.com/gorilla/websocket#pkg-constants. + */ + closeMessage := websocket.FormatCloseMessage(customRetCode, customRetMsg) + err := conn.WriteControl(websocket.CloseMessage, closeMessage, time.Now().Add(time.Millisecond*(ConstVals.Ws.WillKickIfInactiveFor))) + if err != nil { + Logger.Error("Unable to send the CloseFrame control message to player(client-side):", zap.Any("playerId", playerId), zap.Error(err)) + } + + time.AfterFunc(3*time.Second, func() { + // To actually terminates the underlying TCP connection which might be in `CLOSE_WAIT` state if inspected by `netstat`. + conn.Close() + }) + } + + onReceivedCloseMessageFromClient := func(code int, text string) error { + Logger.Warn("Triggered `onReceivedCloseMessageFromClient`:", zap.Any("code", code), zap.Any("playerId", playerId), zap.Any("message", text)) + signalToCloseConnOfThisPlayer(code, text) + return nil + } + + /** + * - "SetCloseHandler sets the handler for close messages received from the peer." + * + * - "The default close handler sends a close message back to the peer." + * + * - "The connection read methods return a CloseError when a close message is received. Most applications should handle close messages as part of their normal error handling. Applications should only set a close handler when the application must perform some action before sending a close message back to the peer." + * + * from reference https://godoc.org/github.com/gorilla/websocket#Conn.SetCloseHandler. + */ + conn.SetCloseHandler(onReceivedCloseMessageFromClient) + + pPlayer, err := models.GetPlayerById(playerId) + + if nil != err || nil == pPlayer { + // TODO: Abort with specific message. + signalToCloseConnOfThisPlayer(Constants.RetCode.PlayerNotFound, "") + } + + Logger.Info("Player has logged in and its profile is found from persistent storage:", zap.Any("playerId", playerId), zap.Any("play", pPlayer)) + + // Find a room to join. + Logger.Info("About to acquire RoomHeapMux for player:", zap.Any("playerId", playerId)) + (*(models.RoomHeapMux)).Lock() + defer func() { + (*(models.RoomHeapMux)).Unlock() + Logger.Info("Released RoomHeapMux for player:", zap.Any("playerId", playerId)) + }() + defer func() { + if r := recover(); r != nil { + Logger.Error("Recovered from: ", zap.Any("panic", r)) + signalToCloseConnOfThisPlayer(Constants.RetCode.UnknownError, "") + } + }() + Logger.Info("Acquired RoomHeapMux for player:", zap.Any("playerId", playerId)) + // Logger.Info("The RoomHeapManagerIns has:", zap.Any("addr", fmt.Sprintf("%p", models.RoomHeapManagerIns)), zap.Any("size", len(*(models.RoomHeapManagerIns)))) + playerSuccessfullyAddedToRoom := false + if 0 < boundRoomId { + if tmpPRoom, existent := (*models.RoomMapManagerIns)[int32(boundRoomId)]; existent { + pRoom = tmpPRoom + Logger.Info("Successfully got:\n", zap.Any("roomId", pRoom.Id), zap.Any("playerId", playerId), zap.Any("forBoundRoomId", boundRoomId)) + res := pRoom.ReAddPlayerIfPossible(pPlayer, conn, signalToCloseConnOfThisPlayer) + if !res { + Logger.Warn("Failed to get:\n", zap.Any("roomId", pRoom.Id), zap.Any("playerId", playerId), zap.Any("forBoundRoomId", boundRoomId)) + } else { + playerSuccessfullyAddedToRoom = true + } + } + } + + if 0 < expectRoomId { + if tmpRoom, existent := (*models.RoomMapManagerIns)[int32(expectRoomId)]; existent { + pRoom = tmpRoom + Logger.Info("Successfully got:\n", zap.Any("roomId", pRoom.Id), zap.Any("playerId", playerId), zap.Any("forExpectedRoomId", expectRoomId)) + + if pRoom.ReAddPlayerIfPossible(pPlayer, conn, signalToCloseConnOfThisPlayer) { + playerSuccessfullyAddedToRoom = true + } else if pRoom.AddPlayerIfPossible(pPlayer, conn, signalToCloseConnOfThisPlayer) { + playerSuccessfullyAddedToRoom = true + } else { + Logger.Warn("Failed to get:\n", zap.Any("roomId", pRoom.Id), zap.Any("playerId", playerId), zap.Any("forExpectedRoomId", expectRoomId)) + playerSuccessfullyAddedToRoom = false + } + + } + } + + if false == playerSuccessfullyAddedToRoom { + defer func() { + if pRoom != nil { + heap.Push(models.RoomHeapManagerIns, pRoom) + (models.RoomHeapManagerIns).Update(pRoom, pRoom.Score) + } + (models.RoomHeapManagerIns).PrintInOrder() + }() + tmpRoom, ok := heap.Pop(models.RoomHeapManagerIns).(*models.Room) + if !ok { + signalToCloseConnOfThisPlayer(Constants.RetCode.LocallyNoAvailableRoom, fmt.Sprintf("Cannot pop a (*Room) for playerId == %v!", playerId)) + } else { + pRoom = tmpRoom + Logger.Info("Successfully popped:\n", zap.Any("roomId", pRoom.Id), zap.Any("playerId", playerId)) + res := pRoom.AddPlayerIfPossible(pPlayer, conn, signalToCloseConnOfThisPlayer) + if !res { + signalToCloseConnOfThisPlayer(Constants.RetCode.PlayerNotAddableToRoom, fmt.Sprintf("AddPlayerIfPossible returns false for roomId == %v, playerId == %v!", pRoom.Id, playerId)) + } + } + } + + if swapped := atomic.CompareAndSwapInt32(pConnHasBeenSignaledToClose, 1, 1); swapped { + return + } + + if pThePlayer, ok := pRoom.Players[int32(playerId)]; ok && (models.PlayerBattleStateIns.ADDED_PENDING_BATTLE_COLLIDER_ACK == pThePlayer.BattleState || models.PlayerBattleStateIns.READDED_PENDING_BATTLE_COLLIDER_ACK == pThePlayer.BattleState) { + defer func() { + timeoutSeconds := time.Duration(5) * time.Second + time.AfterFunc(timeoutSeconds, func() { + if models.PlayerBattleStateIns.ADDED_PENDING_BATTLE_COLLIDER_ACK == pThePlayer.BattleState || models.PlayerBattleStateIns.READDED_PENDING_BATTLE_COLLIDER_ACK == pThePlayer.BattleState { + signalToCloseConnOfThisPlayer(Constants.RetCode.UnknownError, fmt.Sprintf("The expected Ack for BattleColliderInfo is not received in %s, for playerId == %v!", timeoutSeconds, playerId)) + } + }) + }() + + playerBattleColliderInfo := models.ToPbStrToBattleColliderInfo(int32(Constants.Ws.IntervalToPing), int32(Constants.Ws.WillKickIfInactiveFor), pRoom.Id, pRoom.StageName, pRoom.RawBattleStrToVec2DListMap, pRoom.RawBattleStrToPolygon2DListMap, pRoom.StageDiscreteW, pRoom.StageDiscreteH, pRoom.StageTileW, pRoom.StageTileH) + + resp := &pb.WsResp{ + Ret: int32(Constants.RetCode.Ok), + EchoedMsgId: int32(0), + Act: models.DOWNSYNC_MSG_ACT_HB_REQ, + BciFrame: playerBattleColliderInfo, + } + + // Logger.Info("Sending downsync HeartbeatRequirements:", zap.Any("roomId", pRoom.Id), zap.Any("playerId", playerId), zap.Any("resp", resp)) + + theBytes, marshalErr := proto.Marshal(resp) + if nil != marshalErr { + Logger.Error("Error marshalling HeartbeatRequirements:", zap.Any("the error", marshalErr), zap.Any("roomId", pRoom.Id), zap.Any("playerId", playerId)) + signalToCloseConnOfThisPlayer(Constants.RetCode.UnknownError, fmt.Sprintf("Error marshalling HeartbeatRequirements, playerId == %v and roomId == %v!", playerId, pRoom.Id)) + } + + if err := conn.WriteMessage(websocket.BinaryMessage, theBytes); nil != err { + Logger.Error("HeartbeatRequirements resp not written:", zap.Any("roomId", pRoom.Id), zap.Any("playerId", playerId), zap.Error(err)) + signalToCloseConnOfThisPlayer(Constants.RetCode.UnknownError, fmt.Sprintf("HeartbeatRequirements resp not written to roomId=%v, playerId == %v!", pRoom.Id, playerId)) + } + } + + /* + TODO + + Is there a way to EXPLICITLY make this "receivingLoopAgainstPlayer/conn.ReadXXX(...)" edge-triggered or yield/park otherwise? For example a C-style equivalent would be as follows. + + ``` + receivingLoopAgainstPlayer := func() error { + defer func() { + if r := recover(); r != nil { + Logger.Warn("Goroutine `receivingLoopAgainstPlayer`, recovery spot#1, recovered from: ", zap.Any("panic", r)) + } + Logger.Info("Goroutine `receivingLoopAgainstPlayer` is stopped for:", zap.Any("playerId", playerId), zap.Any("roomId", pRoom.Id)) + }() + + // Set O_NONBLOCK on "fdOfThisConn". + int flags = fcntl(fdOfThisConn, F_GETFL, 0); + fcntl(fdOfThisConn, F_SETFL, flags | O_NONBLOCK); + + int ep_fd = epoll_create1(0); + epoll_event ev; + ev.data.fd = fdOfThisConn; + ev.events = (EPOLLIN | EPOLLET | CUSTOM_SIGNAL_TO_CLOSE); // Is this possible? + epoll_ctl(ep_fd, EPOLL_CTL_ADD, fdOfThisConn, &ev); + epoll_event *evs = (epoll_event*)calloc(MAXEVENTS, sizeof(epoll_event)); + + bool localAwarenessOfSignaledToClose = false; + + while(true) { + if (true == localAwarenessOfSignaledToClose) { + return; + } + + // Would yield the current KernelThread and park it to a "queue" for later being unparked from the same "queue", thus resumed running. See http://web.stanford.edu/~hhli/CS110Notes/CS110NotesCollection/Topic%204%20Networking%20(5).html for more information. However, multiple "goroutine"s might share a same KernelThread and could be an issue for yielding. + int n = epoll_wait(ep_fd, evs, MAXEVENTS, -1); + + for (int i = 0; i < n; ++i) { + if (evs[i].data.fd == fdOfThisConn) { + if ( + (evs[i].events & EPOLLERR) || + (evs[i].events & EPOLLHUP) || + (evs[i].events & CUSTOM_SIGNAL_TO_CLOSE) + ) { + signalToCloseConnOfThisPlayer(Constants.RetCode.UnknownError, "") + localAwarenessOfSignaledToClose = true; + break; + } + int nbytes = 0; + while(nbytes = recv(fdOfThisConn, buff, sizeof(buff)) && 0 < nbytes) { + ... + } + // Now that "0 == nbytes" or "EWOULDBLOCK == nbytes" or other errors came up. + continue; + } + } + } + } + + ``` + -- YFLu, 2020-07-03 + */ + + // Starts the receiving loop against the client-side + receivingLoopAgainstPlayer := func() error { + defer func() { + if r := recover(); r != nil { + Logger.Warn("Goroutine `receivingLoopAgainstPlayer`, recovery spot#1, recovered from: ", zap.Any("panic", r)) + } + Logger.Info("Goroutine `receivingLoopAgainstPlayer` is stopped for:", zap.Any("playerId", playerId), zap.Any("roomId", pRoom.Id)) + }() + for { + if swapped := atomic.CompareAndSwapInt32(pConnHasBeenSignaledToClose, 1, 1); swapped { + return nil + } + + // Tries to receive from client-side in a non-blocking manner. + _, bytes, err := conn.ReadMessage() + if nil != err { + Logger.Error("About to `signalToCloseConnOfThisPlayer`", zap.Any("roomId", pRoom.Id), zap.Any("playerId", playerId), zap.Error(err)) + signalToCloseConnOfThisPlayer(Constants.RetCode.UnknownError, "") + return nil + } + + pReq := new(pb.WsReq) + unmarshalErr := proto.Unmarshal(bytes, pReq) + if nil != unmarshalErr { + Logger.Error("About to `signalToCloseConnOfThisPlayer`", zap.Any("roomId", pRoom.Id), zap.Any("playerId", playerId), zap.Error(unmarshalErr)) + signalToCloseConnOfThisPlayer(Constants.RetCode.UnknownError, "") + } + + // Logger.Info("Received request message from client", zap.Any("roomId", pRoom.Id), zap.Any("playerId", playerId), zap.Any("pReq", pReq)) + + switch pReq.Act { + case models.UPSYNC_MSG_ACT_HB_PING: + startOrFeedHeartbeatWatchdog(conn) + case models.UPSYNC_MSG_ACT_PLAYER_CMD: + startOrFeedHeartbeatWatchdog(conn) + pRoom.OnBattleCmdReceived(pReq) + case models.UPSYNC_MSG_ACT_PLAYER_COLLIDER_ACK: + res := pRoom.OnPlayerBattleColliderAcked(int32(playerId)) + if false == res { + Logger.Error("About to `signalToCloseConnOfThisPlayer`", zap.Any("roomId", pRoom.Id), zap.Any("playerId", playerId), zap.Error(err)) + signalToCloseConnOfThisPlayer(Constants.RetCode.UnknownError, "") + return nil + } + default: + } + } + return nil + } + + startOrFeedHeartbeatWatchdog(conn) + go receivingLoopAgainstPlayer() +} diff --git a/database/skeema-repo-root/.skeema.template b/database/skeema-repo-root/.skeema.template new file mode 100644 index 0000000..43ff06c --- /dev/null +++ b/database/skeema-repo-root/.skeema.template @@ -0,0 +1,15 @@ +[production] +socket=/tmp/mysql.sock # Depending on the live MySQL server version and host OS, this "socket path" might vary. For example on "Ubuntu14.04/16.04", it's possible to find it via grepping "socket" of "/etc/my.cnf" or "/etc/mysql/". +user=root +host=localhost +schema=tsrht + +[development] +socket=/tmp/mysql.sock # Alternative for "Ubuntu16.04 + MySQL5.7" could be "/var/run/mysqld/mysqld.sock". +user=root +host=localhost +allow-unsafe +skip-alter-wrapper +skip-alter-algorithm +skip-alter-lock +schema=tsrht_test diff --git a/database/skeema-repo-root/player.sql b/database/skeema-repo-root/player.sql new file mode 100644 index 0000000..e67b41c --- /dev/null +++ b/database/skeema-repo-root/player.sql @@ -0,0 +1,32 @@ + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `player` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(32) NOT NULL, + `display_name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `created_at` bigint(20) unsigned NOT NULL, + `updated_at` bigint(20) unsigned NOT NULL, + `deleted_at` bigint(20) unsigned DEFAULT NULL, + `tutorial_stage` smallint(5) unsigned NOT NULL DEFAULT '0', + `avatar` varchar(256) DEFAULT '', + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + diff --git a/database/skeema-repo-root/player_auth_binding.sql b/database/skeema-repo-root/player_auth_binding.sql new file mode 100644 index 0000000..e0430ab --- /dev/null +++ b/database/skeema-repo-root/player_auth_binding.sql @@ -0,0 +1,30 @@ + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `player_auth_binding` ( + `channel` int(11) unsigned NOT NULL, + `player_id` int(10) unsigned NOT NULL, + `ext_auth_id` varchar(64) NOT NULL, + `created_at` bigint(20) unsigned NOT NULL, + `updated_at` bigint(20) unsigned NOT NULL, + `deleted_at` bigint(20) unsigned DEFAULT NULL, + PRIMARY KEY (`player_id`,`channel`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + diff --git a/database/skeema-repo-root/player_login.sql b/database/skeema-repo-root/player_login.sql new file mode 100644 index 0000000..4f45df4 --- /dev/null +++ b/database/skeema-repo-root/player_login.sql @@ -0,0 +1,33 @@ + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `player_login` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `int_auth_token` varchar(64) NOT NULL, + `player_id` int(11) unsigned NOT NULL, + `display_name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `from_public_ip` varchar(32) DEFAULT NULL, + `created_at` bigint(20) unsigned NOT NULL, + `updated_at` bigint(20) unsigned NOT NULL, + `deleted_at` bigint(20) unsigned DEFAULT NULL, + `avatar` varchar(256) DEFAULT '', + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=206 DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + diff --git a/database/skeema-repo-root/player_wallet.sql b/database/skeema-repo-root/player_wallet.sql new file mode 100644 index 0000000..4cec11e --- /dev/null +++ b/database/skeema-repo-root/player_wallet.sql @@ -0,0 +1,29 @@ + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `player_wallet` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `gem` int(11) unsigned NOT NULL DEFAULT '0', + `created_at` bigint(20) unsigned NOT NULL, + `updated_at` bigint(20) unsigned NOT NULL, + `deleted_at` bigint(20) unsigned DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + diff --git a/frontend/assets/plugin_scripts.meta b/frontend/assets/plugin_scripts.meta new file mode 100644 index 0000000..a29a805 --- /dev/null +++ b/frontend/assets/plugin_scripts.meta @@ -0,0 +1,5 @@ +{ + "ver": "1.0.1", + "uuid": "a351f972-c36f-48ae-b978-30512b7e8b6b", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/plugin_scripts/NetworkDoctor.js b/frontend/assets/plugin_scripts/NetworkDoctor.js new file mode 100644 index 0000000..7c07733 --- /dev/null +++ b/frontend/assets/plugin_scripts/NetworkDoctor.js @@ -0,0 +1,66 @@ +function NetworkDoctor(serverFps, clientUpsyncFps) { + this.serverFps = serverFps; + this.clientUpsyncFps = clientUpsyncFps; + this.millisPerServerFrame = parseInt(1000 / this.serverFps); + this._tooLongSinceLastFrameDiffReceivedThreshold = (this.millisPerServerFrame << 6); + + this.setupFps = function(fps) { + this.serverFps = this.clientUpsyncFps = fps; + this.millisPerServerFrame = parseInt(1000 / this.serverFps); + this._tooLongSinceLastFrameDiffReceivedThreshold = (this.millisPerServerFrame << 6); + } + + this._lastFrameDiffRecvTime = null; + this._tooLongSinceLastFrameDiffReceived = function() { + if (undefined === this._lastFrameDiffRecvTime || null === this._lastFrameDiffRecvTime) return false; + return (this._tooLongSinceLastFrameDiffReceivedThreshold <= (Date.now() - this._lastFrameDiffRecvTime)); + }; + + this._consecutiveALittleLongFrameDiffReceivedIntervalCount = 0; + this._consecutiveALittleLongFrameDiffReceivedIntervalCountThreshold = 120; + + this.onNewFrameDiffReceived = function(frameDiff) { + var now = Date.now(); + if (undefined !== this._lastFrameDiffRecvTime && null !== this._lastFrameDiffRecvTime) { + var intervalFromLastFrameDiff = (now - this._lastFrameDiffRecvTime); + if ((this.millisPerServerFrame << 5) < intervalFromLastFrameDiff) { + ++this._consecutiveALittleLongFrameDiffReceivedIntervalCount; + console.log('Medium delay, intervalFromLastFrameDiff is', intervalFromLastFrameDiff); + } else { + this._consecutiveALittleLongFrameDiffReceivedIntervalCount = 0; + } + } + this._lastFrameDiffRecvTime = now; + }; + + this._networkComplaintPrefix = "\nNetwork is not good >_<\n"; + + this.generateNetworkComplaint = function(excludeTypeConstantALittleLongFrameDiffReceivedInterval, excludeTypeTooLongSinceLastFrameDiffReceived) { + if (this.hasBattleStopped) return null; + var shouldComplain = false; + var ret = this._networkComplaintPrefix; + if (true != excludeTypeConstantALittleLongFrameDiffReceivedInterval && this._consecutiveALittleLongFrameDiffReceivedIntervalCountThreshold <= this._consecutiveALittleLongFrameDiffReceivedIntervalCount) { + this._consecutiveALittleLongFrameDiffReceivedIntervalCount = 0; + ret += "\nConstantly having a little long recv interval.\n"; + shouldComplain = true; + } + if (true != excludeTypeTooLongSinceLastFrameDiffReceived && this._tooLongSinceLastFrameDiffReceived()) { + ret += "\nToo long since last received frameDiff.\n"; + shouldComplain = true; + } + return (shouldComplain ? ret : null); + }; + + this.hasBattleStopped = false; + this.onBattleStopped = function() { + this.hasBattleStopped = true; + }; + + this.isClientSessionConnected = function() { + if (!window.game) return false; + if (!window.game.clientSession) return false; + return window.game.clientSession.connected; + }; +} + +window.NetworkDoctor = NetworkDoctor; diff --git a/frontend/assets/plugin_scripts/NetworkDoctor.js.meta b/frontend/assets/plugin_scripts/NetworkDoctor.js.meta new file mode 100644 index 0000000..ed88779 --- /dev/null +++ b/frontend/assets/plugin_scripts/NetworkDoctor.js.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.5", + "uuid": "477c07c3-0d50-4d55-96f0-6eaf9f25e2da", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/plugin_scripts/NetworkUtils.js b/frontend/assets/plugin_scripts/NetworkUtils.js new file mode 100644 index 0000000..aa04660 --- /dev/null +++ b/frontend/assets/plugin_scripts/NetworkUtils.js @@ -0,0 +1,585 @@ +'use strict'; + +function _typeof6(obj) { + if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { + _typeof6 = function _typeof6(obj) { + return typeof obj; + }; + } else { + _typeof6 = function _typeof6(obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; + }; + } + return _typeof6(obj); +} + +function _typeof5(obj) { + if (typeof Symbol === "function" && _typeof6(Symbol.iterator) === "symbol") { + _typeof5 = function _typeof5(obj) { + return _typeof6(obj); + }; + } else { + _typeof5 = function _typeof5(obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof6(obj); + }; + } + + return _typeof5(obj); +} + +function _typeof4(obj) { + if (typeof Symbol === "function" && _typeof5(Symbol.iterator) === "symbol") { + _typeof4 = function _typeof4(obj) { + return _typeof5(obj); + }; + } else { + _typeof4 = function _typeof4(obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof5(obj); + }; + } + + return _typeof4(obj); +} + +function _typeof3(obj) { + if (typeof Symbol === "function" && _typeof4(Symbol.iterator) === "symbol") { + _typeof3 = function _typeof3(obj) { + return _typeof4(obj); + }; + } else { + _typeof3 = function _typeof3(obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof4(obj); + }; + } + + return _typeof3(obj); +} + +function _typeof2(obj) { + if (typeof Symbol === "function" && _typeof3(Symbol.iterator) === "symbol") { + _typeof2 = function _typeof2(obj) { + return _typeof3(obj); + }; + } else { + _typeof2 = function _typeof2(obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof3(obj); + }; + } + + return _typeof2(obj); +} + +function _typeof(obj) { + if (typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol") { + _typeof = function _typeof(obj) { + return _typeof2(obj); + }; + } else { + _typeof = function _typeof(obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof2(obj); + }; + } + + return _typeof(obj); +} + +var NetworkUtils = NetworkUtils || {}; +window.NetworkUtils = NetworkUtils; +NetworkUtils.ArrayProto = Array.prototype; +NetworkUtils.ObjProto = Object.prototype; +NetworkUtils.hasOwn = NetworkUtils.ObjProto.hasOwnProperty; +NetworkUtils.toString = NetworkUtils.ObjProto.toString; +NetworkUtils.nativeForEach = NetworkUtils.ArrayProto.forEach; +NetworkUtils.slice = NetworkUtils.ArrayProto.slice; +NetworkUtils.nativeKeys = Object.keys; +NetworkUtils.nativeIsArray = Array.isArray; + +NetworkUtils.isFunction = function(o) { + return typeof o == "function" || false; +}; + +NetworkUtils.isObject = function(o) { + var type = typeof o === 'undefined' ? 'undefined' : _typeof(o); + return type === 'function' || type === 'object' && !!o; +}; + +NetworkUtils.isArray = NetworkUtils.nativeIsArray || function(obj) { + return NetworkUtils.toString.call(obj) === '[object Array]'; +}; + +NetworkUtils.isString = function(o) { + return typeof o === 'string'; +}; + +NetworkUtils.isNotEmptyString = function(s) { + return NetworkUtils.isString(s) && s !== ''; +}; + +NetworkUtils.each = function(o, fn, ctx) { + if (o == null) return; + + if (NetworkUtils.nativeForEach && o.forEach === NetworkUtils.nativeForEach) { + o.forEach(fn, ctx); + } else if (o.length === +o.length) { + for (var i = 0, l = o.length; i < l; i++) { + if (i in o && fn.call(ctx, o[i], i, o) === {}) return; + } + } else { + for (var key in o) { + if (NetworkUtils.hasOwn.call(o, key)) { + if (fn.call(ctx, o[key], key, o) === {}) return; + } + } + } +}; + +NetworkUtils.numFormat = function(num) { + if (num > 9999) { + return Math.floor(num / 1000).toString() + 'K'; + } else { + return num.toString(); + } +}; //1000=>1,000 + + +NetworkUtils.numberFmt = function(num) { + if (!/^(\+|-)?(\d+)(\.\d+)?$/.test(num)) { + return num; + } + + var a = RegExp.$1, + b = RegExp.$2, + c = RegExp.$3, + re = new RegExp(); + re.compile("(\\d)(\\d{3})(,|$)"); + + while (re.test(b)) { + b = b.replace(re, "$1,$2$3"); + } + + return a + "" + b + "" + c; +}; //1,000=>1000 + + +NetworkUtils.fmtNumber = function(str) { + if (!NetworkUtils.isNotEmptyString(str)) return 0; + return parseInt(str.replace(/,/g, ''), 10); +}; + +NetworkUtils.defaults = function(obj) { + NetworkUtils.each(NetworkUtils.slice.call(arguments, 1), function(o) { + for (var k in o) { + if (obj[k] == null) + obj[k] = o[k]; + } + }); + return obj; +}; + +NetworkUtils.keys = function(obj) { + if (!NetworkUtils.isObject(obj)) return []; + if (NetworkUtils.nativeKeys) return NetworkUtils.nativeKeys(obj); + var keys = []; + + for (var key in obj) { + if (NetworkUtils.hasOwn.call(obj, key)) keys.push(key); + } + + return keys; +}; + +NetworkUtils.values = function(obj) { + var keys = NetworkUtils.keys(obj); + var length = keys.length; + var values = Array(length); + + for (var i = 0; i < length; i++) { + values[i] = obj[keys[i]]; + } + + return values; +}; + +NetworkUtils.noop = function() {}; + +NetworkUtils.cutstr = function(str, len) { + var temp, + icount = 0, + patrn = /[^\x00-\xff]/, + strre = ""; + + for (var i = 0; i < str.length; i++) { + if (icount < len - 1) { + temp = str.substr(i, 1); + + if (patrn.exec(temp) == null) { + icount = icount + 1; + } else { + icount = icount + 2; + } + + strre += temp; + } else { + break; + } + } + + if (str == strre) { + return strre; + } else { + return strre + "..."; + } +}; + +NetworkUtils.clamp = function(n, min, max) { + if (n < min) return min; + if (n > max) return max; + return n; +}; + +NetworkUtils.Progress = {}; +NetworkUtils.Progress.settings = { + minimum: 0.1, + trickle: true, + trickleRate: 0.3, + trickleSpeed: 100 +}; +NetworkUtils.Progress.status = null; + +NetworkUtils.Progress.set = function(n) { + var progress = NetworkUtils.Progress; + n = NetworkUtils.clamp(n, progress.settings.minimum, 1); + progress.status = n; + progress.cb(progress.status); + return this; +}; + +NetworkUtils.Progress.inc = function(amount) { + var progress = NetworkUtils.Progress, + n = progress.status; + + if (!n) { + return progress.start(); + } else { + amount = (1 - n) * NetworkUtils.clamp(Math.random() * n, 0.1, 0.95); + n = NetworkUtils.clamp(n + amount, 0, 0.994); + return progress.set(n); + } +}; + +NetworkUtils.Progress.trickle = function() { + var progress = NetworkUtils.Progress; + return progress.inc(Math.random() * progress.settings.trickleRate); +}; + +NetworkUtils.Progress.start = function(cb) { + var progress = NetworkUtils.Progress; + progress.cb = cb || NetworkUtils.noop; + if (!progress.status) progress.set(0); + + var _timer = function timer() { + if (progress.status === 1) { + clearTimeout(_timer); + _timer = null; + return; + } + + progress.trickle(); + work(); + }; + + var work = function work() { + setTimeout(_timer, progress.settings.trickleSpeed); + }; + + if (progress.settings.trickle) work(); + return this; +}; + +NetworkUtils.Progress.done = function() { + var progress = NetworkUtils.Progress; + return progress.inc(0.3 + 0.5 * Math.random()).set(1); +}; + +NetworkUtils.decode = decodeURIComponent; +NetworkUtils.encode = encodeURIComponent; + +NetworkUtils.formData = function(o) { + var kvps = [], + regEx = /%20/g; + + for (var k in o) { + if (!o[k]) continue; + kvps.push(NetworkUtils.encode(k).replace(regEx, "+") + "=" + NetworkUtils.encode(o[k].toString()).replace(regEx, "+")); + } + + return kvps.join('&'); +}; + +NetworkUtils.ajax = function(o) { + var xhr = cc.loader.getXMLHttpRequest(); + o = Object.assign({ + type: "GET", + data: null, + dataType: 'json', + progress: null, + contentType: "application/x-www-form-urlencoded" + }, o); + if (o.progress) NetworkUtils.Progress.start(o.progress); + + xhr.onreadystatechange = function() { + if (xhr.readyState == 4) { + if (xhr.status < 300) { + var res; + + if (o.dataType == 'json') { + if (xhr.responseText) { + res = window.JSON ? window.JSON.parse(xhr.responseText) : eval(xhr.responseText); + } + } else { + res = xhr.responseText; + } + + if (!!res) o.success(res); + if (o.progress) NetworkUtils.Progress.done(); + } else { + if (o.error) o.error(xhr, xhr.status, xhr.statusText); + } + } + }; //if("withCredentials" in xhr) xhr.withCredentials = true; + + + var url = o.url, + data = null; + var isPost = o.type === "POST" || o.type === "PUT"; + + if (o.data) { + if (!isPost) { + url += "?" + NetworkUtils.formData(o.data); + data = null; + } else if (isPost && _typeof(o.data) === 'object') { + data = NetworkUtils.formData(o.data); + } else { + data = o.data; + } + } + + xhr.open(o.type, url, true); + + if (isPost) { + xhr.setRequestHeader("Content-Type", o.contentType); + } + + xhr.timeout = 3000; + + xhr.ontimeout = function() { + // XMLHttpRequest 超时 + if ('function' === typeof o.timeout) { + o.timeout(); + } + }; + xhr.onerror = function() { + if ('function' === typeof o.error) { + o.error(); + } + + } + xhr.send(data); + return xhr; +}; + +NetworkUtils.get = function(url, data, success, error) { + if (NetworkUtils.isFunction(data)) { + error = success; + success = data; + data = {}; + } + + NetworkUtils.ajax({ + url: url, + type: "GET", + data: data, + success: success, + error: error || NetworkUtils.noop + }); +}; + +NetworkUtils.post = function(url, data, success, error, timeout) { + if (NetworkUtils.isFunction(data)) { + error = success; + success = data; + data = {}; + } + + NetworkUtils.ajax({ + url: url, + type: "POST", + data: data, + success: success, + error: error || NetworkUtils.noop, + timeout: timeout + }); +}; + +NetworkUtils.now = Date.now || function() { + return new Date().getTime(); +}; + +NetworkUtils.same = function(s) { + return s; +}; + +NetworkUtils.parseCookieString = function(text) { + var cookies = {}; + + if (NetworkUtils.isString(text) && text.length > 0) { + var cookieParts = text.split(/;\s/g); + var cookieName; + var cookieValue; + var cookieNameValue; + + for (var i = 0, len = cookieParts.length; i < len; i++) { + // Check for normally-formatted cookie (name-value) + cookieNameValue = cookieParts[i].match(/([^=]+)=/i); + + if (cookieNameValue instanceof Array) { + try { + cookieName = NetworkUtils.decode(cookieNameValue[1]); + cookieValue = cookieParts[i].substring(cookieNameValue[1].length + 1); + } catch (ex) { // Intentionally ignore the cookie - + // the encoding is wrong + } + } else { + // Means the cookie does not have an =", so treat it as + // a boolean flag + cookieName = NetworkUtils.decode(cookieParts[i]); + cookieValue = ''; + } + + if (cookieName) { + cookies[cookieName] = cookieValue; + } + } + } + + return cookies; +}; + +NetworkUtils.getCookie = function(name) { + if (!NetworkUtils.isNotEmptyString(name)) { + throw new TypeError('Cookie name must be a non-empty string'); + } + + var cookies = NetworkUtils.parseCookieString(document.cookie); + return cookies[name]; +}; + +NetworkUtils.setCookie = function(name, value, options) { + if (!NetworkUtils.isNotEmptyString(name)) { + throw new TypeError('Cookie name must be a non-empty string'); + } + + options = options || {}; + var expires = options['expires']; + var domain = options['domain']; + var path = options['path']; + + if (!options['raw']) { + value = NetworkUtils.encode(String(value)); + } + + var text = name + '=' + value; // expires + + var date = expires; + + if (typeof date === 'number') { + date = new Date(); + date.setDate(date.getDate() + expires); + } + + if (date instanceof Date) { + text += '; expires=' + date.toUTCString(); + } // domain + + + if (NetworkUtils.isNotEmptyString(domain)) { + text += '; domain=' + domain; + } // path + + + if (NetworkUtils.isNotEmptyString(path)) { + text += '; path=' + path; + } // secure + + + if (options['secure']) { + text += '; secure'; + } + + document.cookie = text; + return text; +}; + +NetworkUtils.removeCookie = function(name, options) { + options = options || {}; + options['expires'] = new Date(0); + return NetworkUtils.setCookie(name, '', options); +}; + +NetworkUtils.dragNode = function(node) { + var isMoving = false, + size = cc.director.getVisibleSize(), + touchLoc = void 0, + oldPos = void 0, + moveToPos = void 0; + node.on(cc.Node.EventType.TOUCH_START, function(event) { + var touches = event.getTouches(); + touchLoc = touches[0].getLocation(); + oldPos = node.position; + }); + node.on(cc.Node.EventType.TOUCH_MOVE, function(event) { + var touches = event.getTouches(); + moveToPos = touches[0].getLocation(); + isMoving = true; + }); + node.on(cc.Node.EventType.TOUCH_END, function(event) { + isMoving = false; + }); + return function() { + if (!isMoving) return; + var x = oldPos.x + moveToPos.x - touchLoc.x; + var xEdge = node.width * node.anchorX / 2; + + if (Math.abs(x) < xEdge) { + node.x = x; + } else { + node.x = x > 0 ? xEdge : -xEdge; + isMoving = false; + } + + if (node.height > size.height) { + var y = oldPos.y + moveToPos.y - touchLoc.y; + var yEdge = (node.height - size.height) / 2; + + if (Math.abs(y) < yEdge) { + node.y = y; + } else { + node.y = y > 0 ? yEdge : -yEdge; + isMoving = false; + } + } + }; +}; + +NetworkUtils.getQueryVariable = function(key) { + var query = cc.sys.platform == cc.sys.WECHAT_GAME ? '' : window.location.search.substring(1), + vars = query.split('&'); + + for (var i = 0, l = vars.length; i < l; i++) { + var pair = vars[i].split('='); + + if (decodeURIComponent(pair[0]) === key) { + return decodeURIComponent(pair[1]); + } + } +}; diff --git a/frontend/assets/plugin_scripts/NetworkUtils.js.meta b/frontend/assets/plugin_scripts/NetworkUtils.js.meta new file mode 100644 index 0000000..6c0d37e --- /dev/null +++ b/frontend/assets/plugin_scripts/NetworkUtils.js.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.5", + "uuid": "c116dddb-470e-47de-af9b-560adb7c78fb", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/plugin_scripts/auxiliaries.js b/frontend/assets/plugin_scripts/auxiliaries.js new file mode 100644 index 0000000..b91f16f --- /dev/null +++ b/frontend/assets/plugin_scripts/auxiliaries.js @@ -0,0 +1,200 @@ +"use strict"; + +window.getQueryParamDict = function() { + // Kindly note that only the first occurrence of duplicated keys will be picked up. + var query = cc.sys.platform == cc.sys.WECHAT_GAME ? '' : window.location.search.substring(1); + var kvPairs = query.split('&'); + var toRet = {}; + for (var i = 0; i < kvPairs.length; ++i) { + var kAndV = kvPairs[i].split('='); + if (undefined === kAndV || null === kAndV || 2 != kAndV.length) return; + var k = kAndV[0]; + var v = decodeURIComponent(kAndV[1]); + toRet[k] = v; + } + return toRet; +} + +let IS_USING_WKWECHAT_KERNEL = null; +window.isUsingWebkitWechatKernel = function() { + if (null == IS_USING_WKWECHAT_KERNEL) { + // The extraction of `browserType` might take a considerable amount of time in mobile browser kernels. + IS_USING_WKWECHAT_KERNEL = (cc.sys.BROWSER_TYPE_WECHAT == cc.sys.browserType); + } + return IS_USING_WKWECHAT_KERNEL; +}; + +let IS_USING_X5_BLINK_KERNEL = null; +window.isUsingX5BlinkKernel = function() { + if (null == IS_USING_X5_BLINK_KERNEL) { + // The extraction of `browserType` might take a considerable amount of time in mobile browser kernels. + IS_USING_X5_BLINK_KERNEL = (cc.sys.BROWSER_TYPE_MOBILE_QQ == cc.sys.browserType); + } + return IS_USING_X5_BLINK_KERNEL; +}; + +let IS_USING_X5_BLINK_KERNEL_OR_WKWECHAT_KERNEL = null; +window.isUsingX5BlinkKernelOrWebkitWeChatKernel = function() { + if (null == IS_USING_X5_BLINK_KERNEL_OR_WKWECHAT_KERNEL) { + // The extraction of `browserType` might take a considerable amount of time in mobile browser kernels. + IS_USING_X5_BLINK_KERNEL_OR_WKWECHAT_KERNEL = (cc.sys.BROWSER_TYPE_MOBILE_QQ == cc.sys.browserType || cc.sys.BROWSER_TYPE_WECHAT == cc.sys.browserType); + } + return IS_USING_X5_BLINK_KERNEL_OR_WKWECHAT_KERNEL; +}; + +window.getRandomInt = function(min, max) { + min = Math.ceil(min); + max = Math.floor(max); + return Math.floor(Math.random() * (max - min)) + min; +} + +window.safelyAssignParent = function(proposedChild, proposedParent) { + if (proposedChild.parent == proposedParent) return false; + proposedChild.parent = proposedParent; + return true; +}; + +window.get2dRotation = function(aCCNode) { + // return aCCNode.rotation; // For cc2.0+ + return aCCNode.angle; // For cc2.1+ +}; + +window.set2dRotation = function(aCCNode, clockwiseAngle) { + // aCCNode.rotation = angle; // For cc2.0+ + aCCNode.angle = -clockwiseAngle; // For cc2.1+ +}; + +window.setLocalZOrder = function(aCCNode, zIndex) { + aCCNode.zIndex = zIndex; // For cc2.0+ +}; + +window.getLocalZOrder = function(aCCNode) { + return aCCNode.zIndex; // For cc2.0+ +}; + +window.safelyAddChild = function(proposedParent, proposedChild) { + if (proposedChild.parent == proposedParent) return false; + setLocalZOrder(proposedChild, getLocalZOrder(proposedParent) + 1); + proposedParent.addChild(proposedChild); + return true; +}; + +window.setVisible = function(aCCNode) { + aCCNode.opacity = 255; +}; + +window.setInvisible = function(aCCNode) { + aCCNode.opacity = 0; +}; + +window.randomProperty = function (obj) { + var keys = Object.keys(obj) + return obj[keys[ keys.length * Math.random() << 0]]; +}; + +window.gidSpriteFrameMap = {}; +window.getOrCreateSpriteFrameForGid = function(gid, tiledMapInfo, tilesElListUnderTilesets) { + if (null != gidSpriteFrameMap[gid]) return gidSpriteFrameMap[gid]; + if (false == gidSpriteFrameMap[gid]) return null; + + var tilesets = tiledMapInfo.getTilesets(); + var targetTileset = null; + for (var i = 0; i < tilesets.length; ++i) { + // TODO: Optimize by binary search. + if (gid < tilesets[i].firstGid) continue; + if (i < tilesets.length - 1) { + if (gid >= tilesets[i + 1].firstGid) continue; + } + targetTileset = tilesets[i]; + break; + } + if (!targetTileset) return null; + var tileIdWithinTileset = (gid - targetTileset.firstGid); + var tilesElListUnderCurrentTileset = tilesElListUnderTilesets[targetTileset.name + ".tsx"]; + + var targetTileEl = null; + for (var tileIdx = 0; tileIdx < tilesElListUnderCurrentTileset.length; ++tileIdx) { + var tmpTileEl = tilesElListUnderCurrentTileset[tileIdx]; + if (tileIdWithinTileset != parseInt(tmpTileEl.id)) continue; + targetTileEl = tmpTileEl; + break; + } + + var tileId = tileIdWithinTileset; + var tilesPerRow = (targetTileset.sourceImage.width / targetTileset._tileSize.width); + var row = parseInt(tileId / tilesPerRow); + var col = (tileId % tilesPerRow); + var offset = cc.v2(targetTileset._tileSize.width * col, targetTileset._tileSize.height * row); + var origSize = targetTileset._tileSize; + var rect = cc.rect(offset.x, offset.y, origSize.width, origSize.height); + var sf = new cc.SpriteFrame(targetTileset.sourceImage, rect, false /* rotated */ , cc.v2() /* DON'T use `offset` here or you will have an offsetted image from the `cc.Sprite.node.anchor`. */, origSize); + const data = { + origSize: targetTileset._tileSize, + spriteFrame: sf, + } + window.gidSpriteFrameMap[gid] = data; + return data; +} + +window.gidAnimationClipMap = {}; +window.getOrCreateAnimationClipForGid = function(gid, tiledMapInfo, tilesElListUnderTilesets) { + if (null != gidAnimationClipMap[gid]) return gidAnimationClipMap[gid]; + if (false == gidAnimationClipMap[gid]) return null; + + var tilesets = tiledMapInfo.getTilesets(); + var targetTileset = null; + for (var i = 0; i < tilesets.length; ++i) { + // TODO: Optimize by binary search. + if (gid < tilesets[i].firstGid) continue; + if (i < tilesets.length - 1) { + if (gid >= tilesets[i + 1].firstGid) continue; + } + targetTileset = tilesets[i]; + break; + } + if (!targetTileset) return null; + var tileIdWithinTileset = (gid - targetTileset.firstGid); + var tilesElListUnderCurrentTileset = tilesElListUnderTilesets[targetTileset.name + ".tsx"]; + + var targetTileEl = null; + for (var tileIdx = 0; tileIdx < tilesElListUnderCurrentTileset.length; ++tileIdx) { + var tmpTileEl = tilesElListUnderCurrentTileset[tileIdx]; + if (tileIdWithinTileset != parseInt(tmpTileEl.id)) continue; + targetTileEl = tmpTileEl; + break; + } + + if (!targetTileEl) return null; + var animElList = targetTileEl.getElementsByTagName("animation"); + if (!animElList || 0 >= animElList.length) return null; + var animEl = animElList[0]; + + var uniformDurationSecondsPerFrame = null; + var totDurationSeconds = 0; + var sfList = []; + var frameElListUnderAnim = animEl.getElementsByTagName("frame"); + var tilesPerRow = (targetTileset.sourceImage.width/targetTileset._tileSize.width); + + for (var k = 0; k < frameElListUnderAnim.length; ++k) { + var frameEl = frameElListUnderAnim[k]; + var tileId = parseInt(frameEl.attributes.tileid.value); + var durationSeconds = frameEl.attributes.duration.value/1000; + if (null == uniformDurationSecondsPerFrame) uniformDurationSecondsPerFrame = durationSeconds; + totDurationSeconds += durationSeconds; + var row = parseInt(tileId / tilesPerRow); + var col = (tileId % tilesPerRow); + var offset = cc.v2(targetTileset._tileSize.width*col, targetTileset._tileSize.height*row); + var origSize = targetTileset._tileSize; + var rect = cc.rect(offset.x, offset.y, origSize.width, origSize.height); + var sf = new cc.SpriteFrame(targetTileset.sourceImage, rect, false /* rotated */, cc.v2(), origSize); + sfList.push(sf); + } + var sampleRate = 1/uniformDurationSecondsPerFrame; // A.k.a. fps. + var animClip = cc.AnimationClip.createWithSpriteFrames(sfList, sampleRate); + // http://docs.cocos.com/creator/api/en/enums/WrapMode.html. + animClip.wrapMode = cc.WrapMode.Loop; + return { + origSize: targetTileset._tileSize, + animationClip: animClip, + }; +}; diff --git a/frontend/assets/plugin_scripts/auxiliaries.js.meta b/frontend/assets/plugin_scripts/auxiliaries.js.meta new file mode 100644 index 0000000..f0f02ca --- /dev/null +++ b/frontend/assets/plugin_scripts/auxiliaries.js.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.5", + "uuid": "c119f5bb-720a-4ac8-960f-6f5eeda0c360", + "isPlugin": true, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/plugin_scripts/conf.js.template b/frontend/assets/plugin_scripts/conf.js.template new file mode 100644 index 0000000..69c7505 --- /dev/null +++ b/frontend/assets/plugin_scripts/conf.js.template @@ -0,0 +1,37 @@ +"use strict"; + +if (CC_DEBUG) { + var backendAddress = { + PROTOCOL: 'http', + HOST: 'localhost', + PORT: "9992", + WS_PATH_PREFIX: "/tsrht", + }; + + var wechatAddress = { + PROTOCOL: "http", + HOST: "119.29.236.44", + PORT: "8089", + PROXY: "", + APPID_LITERAL: "appid=wx5432dc1d6164d4e", + }; +} else { + var backendAddress = { + PROTOCOL: 'https', + HOST: 'tsrht.lokcol.com', + PORT: "443", + WS_PATH_PREFIX: "/tsrht", + }; + + var wechatAddress = { + PROTOCOL: "https", + HOST: "open.weixin.qq.com", + PORT: "", + PROXY: "", + APPID_LITERAL: "appid=wxe7063ab415266544", + }; +} + +window.language = "zh"; +window.backendAddress = backendAddress; +window.wechatAddress = wechatAddress; diff --git a/frontend/assets/plugin_scripts/conf.js.template.meta b/frontend/assets/plugin_scripts/conf.js.template.meta new file mode 100644 index 0000000..0a01847 --- /dev/null +++ b/frontend/assets/plugin_scripts/conf.js.template.meta @@ -0,0 +1,5 @@ +{ + "ver": "1.0.1", + "uuid": "1712c9ec-6940-4356-a87d-37887608f224", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/plugin_scripts/constants.js b/frontend/assets/plugin_scripts/constants.js new file mode 100644 index 0000000..4fb537c --- /dev/null +++ b/frontend/assets/plugin_scripts/constants.js @@ -0,0 +1,170 @@ +"use strict"; + + +var _ROUTE_PATH; + +function _defineProperty(obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + + return obj; +} + +var constants = { + BGM: { + DIR_PATH: "resources/musicEffect/", + FILE_NAME: { + TREASURE_PICKEDUP: "TreasurePicked", + CRASHED_BY_TRAP_BULLET: "CrashedByTrapBullet", + HIGH_SCORE_TREASURE_PICKED:"HighScoreTreasurePicked", + COUNT_DOWN_10SEC_TO_END:"countDown10SecToEnd", + BGM: "BGM" + } + }, + PLAYER_NAME: { + 1: "Merdan", + 2: "Monroe", + }, + SOCKET_EVENT: { + CONTROL: "control", + SYNC: "sync", + LOGIN: "login", + CREATE: "create" + }, + WECHAT: { + AUTHORIZE_PATH: "/connect/oauth2/authorize", + REDIRECT_RUI_KEY: "redirect_uri=", + RESPONSE_TYPE: "response_type=code", + SCOPE: "scope=snsapi_userinfo", + FIN: "#wechat_redirect" + }, + ROUTE_PATH: (_ROUTE_PATH = { + PLAYER: "/player", + JSCONFIG: "/jsconfig", + API: "/api", + VERSION: "/v1", + SMS_CAPTCHA: "/SmsCaptcha", + INT_AUTH_TOKEN: "/IntAuthToken", + LOGIN: "/login", + LOGOUT: "/logout", + GET: "/get", + TUTORIAL: "/tutorial", + REPORT: "/report", + LIST: "/list", + READ: "/read", + PROFILE: "/profile", + WECHAT: "/wechat", + WECHATGAME: "/wechatGame", + FETCH: "/fetch", + }, _defineProperty(_ROUTE_PATH, "LOGIN", "/login"), _defineProperty(_ROUTE_PATH, "RET_CODE", "/retCode"), _defineProperty(_ROUTE_PATH, "REGEX", "/regex"), _defineProperty(_ROUTE_PATH, "SMS_CAPTCHA", "/SmsCaptcha"), _defineProperty(_ROUTE_PATH, "GET", "/get"), _ROUTE_PATH), + REQUEST_QUERY: { + ROOM_ID: "roomId", + TOKEN: "/token" + }, + GAME_SYNC: { + SERVER_UPSYNC: 30, + CLIENT_UPSYNC: 30 + }, + RET_CODE: { + /** + * NOTE: The "RET_CODE"s from 1000-1015 are reserved for the websocket "WebsocketStdCloseCode"s. + * + * References + * - https://tools.ietf.org/html/rfc6455#section-7.4 + * - https://godoc.org/github.com/gorilla/websocket#pkg-constants. + */ + "__comment__": "基础", + "OK": 9000, + "UNKNOWN_ERROR": 9001, + "INVALID_REQUEST_PARAM": 9002, + "IS_TEST_ACC": 9003, + "MYSQL_ERROR": 9004, + "NONEXISTENT_ACT": 9005, + "LACK_OF_DIAMOND": 9006, + "LACK_OF_GOLD": 9007, + "LACK_OF_ENERGY": 9008, + "NONEXISTENT_ACT_HANDLER": 9009, + "LOCALLY_NO_AVAILABLE_ROOM": 9010, + "LOCALLY_NO_SPECIFIED_ROOM": 9011, + "PLAYER_NOT_ADDABLE_TO_ROOM": 9012, + "PLAYER_NOT_READDABLE_TO_ROOM": 9013, + "PLAYER_NOT_FOUND": 9014, + "PLAYER_CHEATING": 9015, + + + "__comment__": "SMS", + "SMS_CAPTCHA_REQUESTED_TOO_FREQUENTLY": 5001, + "SMS_CAPTCHA_NOT_MATCH": 5002, + "INVALID_TOKEN": 2001, + + "DUPLICATED": 2002, + "INCORRECT_HANDLE": 2004, + "NONEXISTENT_HANDLE": 2005, + "INCORRECT_PASSWORD": 2006, + "INCORRECT_CAPTCHA": 2007, + "INVALID_EMAIL_LITERAL": 2008, + "NO_ASSOCIATED_EMAIL": 2009, + "SEND_EMAIL_TIMEOUT": 2010, + "INCORRECT_PHONE_COUNTRY_CODE": 2011, + "NEW_HANDLE_CONFLICT": 2013, + "FAILED_TO_UPDATE": 2014, + "FAILED_TO_DELETE": 2015, + "FAILED_TO_CREATE": 2016, + "INCORRECT_PHONE_NUMBER": 2018, + "PASSWORD_RESET_CODE_GENERATION_PER_EMAIL_TOO_FREQUENTLY": 4000, + "TRADE_CREATION_TOO_FREQUENTLY": 4002, + "MAP_NOT_UNLOCKED": 4003, + + "NOT_IMPLEMENTED_YET": 65535 + }, + ALERT: { + TIP_NODE: 'captchaTips', + TIP_LABEL: { + INCORRECT_PHONE_COUNTRY_CODE: '国家号不正确', + CAPTCHA_ERR: '验证码不正确', + PHONE_ERR: '手机号格式不正确', + TOKEN_EXPIRED: 'token已过期!', + SMS_CAPTCHA_FREEQUENT_REQUIRE: '请求过于频繁', + SMS_CAPTCHA_NOT_MATCH: '验证码不正确', + TEST_USER: '该账号为测试账号', + INCORRECT_PHONE_NUMBER: '手机号不正确', + LOG_OUT: '您已在其他地方登陆', + GAME_OVER: '游戏结束,您的得分是', + WECHAT_LOGIN_FAILS: "微信登录失败", + }, + CONFIRM_BUTTON_LABEL: { + RESTART: '重新开始' + } + }, + PLAYER: '玩家', + ONLINE: '在线', + NOT_ONLINE: '', + SPEED: { + NORMAL: 100, + PAUSE: 0 + }, + COUNTDOWN_LABEL: { + BASE: '倒计时 ', + MINUTE: '00', + SECOND: '30' + }, + SCORE_LABEL: { + BASE: '分数 ', + PLUS_SCORE: 5, + MINUS_SECOND: 5, + INIT_SCORE: 0 + }, + TUTORIAL_STAGE: { + NOT_YET_STARTED: 0, + ENDED: 1, + }, +}; +window.constants = constants; diff --git a/frontend/assets/plugin_scripts/constants.js.meta b/frontend/assets/plugin_scripts/constants.js.meta new file mode 100644 index 0000000..87feddf --- /dev/null +++ b/frontend/assets/plugin_scripts/constants.js.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.5", + "uuid": "31ca9500-50c9-44f9-8d33-f9a969e53195", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/plugin_scripts/protobuf.js b/frontend/assets/plugin_scripts/protobuf.js new file mode 100644 index 0000000..c3e1c02 --- /dev/null +++ b/frontend/assets/plugin_scripts/protobuf.js @@ -0,0 +1,8726 @@ +/*! + * protobuf.js v6.8.8 (c) 2016, daniel wirtz + * compiled thu, 19 jul 2018 00:33:25 utc + * licensed under the bsd-3-clause license + * see: https://github.com/dcodeio/protobuf.js for details + */ +(function(undefined){"use strict";(function prelude(modules, cache, entries) { + + // This is the prelude used to bundle protobuf.js for the browser. Wraps up the CommonJS + // sources through a conflict-free require shim and is again wrapped within an iife that + // provides a minification-friendly `undefined` var plus a global "use strict" directive + // so that minification can remove the directives of each module. + + function $require(name) { + var $module = cache[name]; + if (!$module) + modules[name][0].call($module = cache[name] = { exports: {} }, $require, $module, $module.exports); + return $module.exports; + } + + var protobuf = $require(entries[0]); + + // Expose globally + protobuf.util.global.protobuf = protobuf; + + // Be nice to AMD + if (typeof define === "function" && define.amd) + define(["long"], function(Long) { + if (Long && Long.isLong) { + protobuf.util.Long = Long; + protobuf.configure(); + } + return protobuf; + }); + + // Be nice to CommonJS + if (typeof module === "object" && module && module.exports) + module.exports = protobuf; + +})/* end of prelude */({1:[function(require,module,exports){ +"use strict"; +module.exports = asPromise; + +/** + * Callback as used by {@link util.asPromise}. + * @typedef asPromiseCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {...*} params Additional arguments + * @returns {undefined} + */ + +/** + * Returns a promise from a node-style callback function. + * @memberof util + * @param {asPromiseCallback} fn Function to call + * @param {*} ctx Function context + * @param {...*} params Function arguments + * @returns {Promise<*>} Promisified function + */ +function asPromise(fn, ctx/*, varargs */) { + var params = new Array(arguments.length - 1), + offset = 0, + index = 2, + pending = true; + while (index < arguments.length) + params[offset++] = arguments[index++]; + return new Promise(function executor(resolve, reject) { + params[offset] = function callback(err/*, varargs */) { + if (pending) { + pending = false; + if (err) + reject(err); + else { + var params = new Array(arguments.length - 1), + offset = 0; + while (offset < params.length) + params[offset++] = arguments[offset]; + resolve.apply(null, params); + } + } + }; + try { + fn.apply(ctx || null, params); + } catch (err) { + if (pending) { + pending = false; + reject(err); + } + } + }); +} + +},{}],2:[function(require,module,exports){ +"use strict"; + +/** + * A minimal base64 implementation for number arrays. + * @memberof util + * @namespace + */ +var base64 = exports; + +/** + * Calculates the byte length of a base64 encoded string. + * @param {string} string Base64 encoded string + * @returns {number} Byte length + */ +base64.length = function length(string) { + var p = string.length; + if (!p) + return 0; + var n = 0; + while (--p % 4 > 1 && string.charAt(p) === "=") + ++n; + return Math.ceil(string.length * 3) / 4 - n; +}; + +// Base64 encoding table +var b64 = new Array(64); + +// Base64 decoding table +var s64 = new Array(123); + +// 65..90, 97..122, 48..57, 43, 47 +for (var i = 0; i < 64;) + s64[b64[i] = i < 26 ? i + 65 : i < 52 ? i + 71 : i < 62 ? i - 4 : i - 59 | 43] = i++; + +/** + * Encodes a buffer to a base64 encoded string. + * @param {Uint8Array} buffer Source buffer + * @param {number} start Source start + * @param {number} end Source end + * @returns {string} Base64 encoded string + */ +base64.encode = function encode(buffer, start, end) { + var parts = null, + chunk = []; + var i = 0, // output index + j = 0, // goto index + t; // temporary + while (start < end) { + var b = buffer[start++]; + switch (j) { + case 0: + chunk[i++] = b64[b >> 2]; + t = (b & 3) << 4; + j = 1; + break; + case 1: + chunk[i++] = b64[t | b >> 4]; + t = (b & 15) << 2; + j = 2; + break; + case 2: + chunk[i++] = b64[t | b >> 6]; + chunk[i++] = b64[b & 63]; + j = 0; + break; + } + if (i > 8191) { + (parts || (parts = [])).push(String.fromCharCode.apply(String, chunk)); + i = 0; + } + } + if (j) { + chunk[i++] = b64[t]; + chunk[i++] = 61; + if (j === 1) + chunk[i++] = 61; + } + if (parts) { + if (i) + parts.push(String.fromCharCode.apply(String, chunk.slice(0, i))); + return parts.join(""); + } + return String.fromCharCode.apply(String, chunk.slice(0, i)); +}; + +var invalidEncoding = "invalid encoding"; + +/** + * Decodes a base64 encoded string to a buffer. + * @param {string} string Source string + * @param {Uint8Array} buffer Destination buffer + * @param {number} offset Destination offset + * @returns {number} Number of bytes written + * @throws {Error} If encoding is invalid + */ +base64.decode = function decode(string, buffer, offset) { + var start = offset; + var j = 0, // goto index + t; // temporary + for (var i = 0; i < string.length;) { + var c = string.charCodeAt(i++); + if (c === 61 && j > 1) + break; + if ((c = s64[c]) === undefined) + throw Error(invalidEncoding); + switch (j) { + case 0: + t = c; + j = 1; + break; + case 1: + buffer[offset++] = t << 2 | (c & 48) >> 4; + t = c; + j = 2; + break; + case 2: + buffer[offset++] = (t & 15) << 4 | (c & 60) >> 2; + t = c; + j = 3; + break; + case 3: + buffer[offset++] = (t & 3) << 6 | c; + j = 0; + break; + } + } + if (j === 1) + throw Error(invalidEncoding); + return offset - start; +}; + +/** + * Tests if the specified string appears to be base64 encoded. + * @param {string} string String to test + * @returns {boolean} `true` if probably base64 encoded, otherwise false + */ +base64.test = function test(string) { + return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(string); +}; + +},{}],3:[function(require,module,exports){ +"use strict"; +module.exports = codegen; + +/** + * Begins generating a function. + * @memberof util + * @param {string[]} functionParams Function parameter names + * @param {string} [functionName] Function name if not anonymous + * @returns {Codegen} Appender that appends code to the function's body + */ +function codegen(functionParams, functionName) { + + /* istanbul ignore if */ + if (typeof functionParams === "string") { + functionName = functionParams; + functionParams = undefined; + } + + var body = []; + + /** + * Appends code to the function's body or finishes generation. + * @typedef Codegen + * @type {function} + * @param {string|Object.} [formatStringOrScope] Format string or, to finish the function, an object of additional scope variables, if any + * @param {...*} [formatParams] Format parameters + * @returns {Codegen|Function} Itself or the generated function if finished + * @throws {Error} If format parameter counts do not match + */ + + function Codegen(formatStringOrScope) { + // note that explicit array handling below makes this ~50% faster + + // finish the function + if (typeof formatStringOrScope !== "string") { + var source = toString(); + if (codegen.verbose) + console.log("codegen: " + source); // eslint-disable-line no-console + source = "return " + source; + if (formatStringOrScope) { + var scopeKeys = Object.keys(formatStringOrScope), + scopeParams = new Array(scopeKeys.length + 1), + scopeValues = new Array(scopeKeys.length), + scopeOffset = 0; + while (scopeOffset < scopeKeys.length) { + scopeParams[scopeOffset] = scopeKeys[scopeOffset]; + scopeValues[scopeOffset] = formatStringOrScope[scopeKeys[scopeOffset++]]; + } + scopeParams[scopeOffset] = source; + return Function.apply(null, scopeParams).apply(null, scopeValues); // eslint-disable-line no-new-func + } + return Function(source)(); // eslint-disable-line no-new-func + } + + // otherwise append to body + var formatParams = new Array(arguments.length - 1), + formatOffset = 0; + while (formatOffset < formatParams.length) + formatParams[formatOffset] = arguments[++formatOffset]; + formatOffset = 0; + formatStringOrScope = formatStringOrScope.replace(/%([%dfijs])/g, function replace($0, $1) { + var value = formatParams[formatOffset++]; + switch ($1) { + case "d": case "f": return String(Number(value)); + case "i": return String(Math.floor(value)); + case "j": return JSON.stringify(value); + case "s": return String(value); + } + return "%"; + }); + if (formatOffset !== formatParams.length) + throw Error("parameter count mismatch"); + body.push(formatStringOrScope); + return Codegen; + } + + function toString(functionNameOverride) { + return "function " + (functionNameOverride || functionName || "") + "(" + (functionParams && functionParams.join(",") || "") + "){\n " + body.join("\n ") + "\n}"; + } + + Codegen.toString = toString; + return Codegen; +} + +/** + * Begins generating a function. + * @memberof util + * @function codegen + * @param {string} [functionName] Function name if not anonymous + * @returns {Codegen} Appender that appends code to the function's body + * @variation 2 + */ + +/** + * When set to `true`, codegen will log generated code to console. Useful for debugging. + * @name util.codegen.verbose + * @type {boolean} + */ +codegen.verbose = false; + +},{}],4:[function(require,module,exports){ +"use strict"; +module.exports = EventEmitter; + +/** + * Constructs a new event emitter instance. + * @classdesc A minimal event emitter. + * @memberof util + * @constructor + */ +function EventEmitter() { + + /** + * Registered listeners. + * @type {Object.} + * @private + */ + this._listeners = {}; +} + +/** + * Registers an event listener. + * @param {string} evt Event name + * @param {function} fn Listener + * @param {*} [ctx] Listener context + * @returns {util.EventEmitter} `this` + */ +EventEmitter.prototype.on = function on(evt, fn, ctx) { + (this._listeners[evt] || (this._listeners[evt] = [])).push({ + fn : fn, + ctx : ctx || this + }); + return this; +}; + +/** + * Removes an event listener or any matching listeners if arguments are omitted. + * @param {string} [evt] Event name. Removes all listeners if omitted. + * @param {function} [fn] Listener to remove. Removes all listeners of `evt` if omitted. + * @returns {util.EventEmitter} `this` + */ +EventEmitter.prototype.off = function off(evt, fn) { + if (evt === undefined) + this._listeners = {}; + else { + if (fn === undefined) + this._listeners[evt] = []; + else { + var listeners = this._listeners[evt]; + for (var i = 0; i < listeners.length;) + if (listeners[i].fn === fn) + listeners.splice(i, 1); + else + ++i; + } + } + return this; +}; + +/** + * Emits an event by calling its listeners with the specified arguments. + * @param {string} evt Event name + * @param {...*} args Arguments + * @returns {util.EventEmitter} `this` + */ +EventEmitter.prototype.emit = function emit(evt) { + var listeners = this._listeners[evt]; + if (listeners) { + var args = [], + i = 1; + for (; i < arguments.length;) + args.push(arguments[i++]); + for (i = 0; i < listeners.length;) + listeners[i].fn.apply(listeners[i++].ctx, args); + } + return this; +}; + +},{}],5:[function(require,module,exports){ +"use strict"; +module.exports = fetch; + +var asPromise = require(1), + inquire = require(7); + +var fs = inquire("fs"); + +/** + * Node-style callback as used by {@link util.fetch}. + * @typedef FetchCallback + * @type {function} + * @param {?Error} error Error, if any, otherwise `null` + * @param {string} [contents] File contents, if there hasn't been an error + * @returns {undefined} + */ + +/** + * Options as used by {@link util.fetch}. + * @typedef FetchOptions + * @type {Object} + * @property {boolean} [binary=false] Whether expecting a binary response + * @property {boolean} [xhr=false] If `true`, forces the use of XMLHttpRequest + */ + +/** + * Fetches the contents of a file. + * @memberof util + * @param {string} filename File path or url + * @param {FetchOptions} options Fetch options + * @param {FetchCallback} callback Callback function + * @returns {undefined} + */ +function fetch(filename, options, callback) { + if (typeof options === "function") { + callback = options; + options = {}; + } else if (!options) + options = {}; + + if (!callback) + return asPromise(fetch, this, filename, options); // eslint-disable-line no-invalid-this + + // if a node-like filesystem is present, try it first but fall back to XHR if nothing is found. + if (!options.xhr && fs && fs.readFile) + return fs.readFile(filename, function fetchReadFileCallback(err, contents) { + return err && typeof XMLHttpRequest !== "undefined" + ? fetch.xhr(filename, options, callback) + : err + ? callback(err) + : callback(null, options.binary ? contents : contents.toString("utf8")); + }); + + // use the XHR version otherwise. + return fetch.xhr(filename, options, callback); +} + +/** + * Fetches the contents of a file. + * @name util.fetch + * @function + * @param {string} path File path or url + * @param {FetchCallback} callback Callback function + * @returns {undefined} + * @variation 2 + */ + +/** + * Fetches the contents of a file. + * @name util.fetch + * @function + * @param {string} path File path or url + * @param {FetchOptions} [options] Fetch options + * @returns {Promise} Promise + * @variation 3 + */ + +/**/ +fetch.xhr = function fetch_xhr(filename, options, callback) { + var xhr = new XMLHttpRequest(); + xhr.onreadystatechange /* works everywhere */ = function fetchOnReadyStateChange() { + + if (xhr.readyState !== 4) + return undefined; + + // local cors security errors return status 0 / empty string, too. afaik this cannot be + // reliably distinguished from an actually empty file for security reasons. feel free + // to send a pull request if you are aware of a solution. + if (xhr.status !== 0 && xhr.status !== 200) + return callback(Error("status " + xhr.status)); + + // if binary data is expected, make sure that some sort of array is returned, even if + // ArrayBuffers are not supported. the binary string fallback, however, is unsafe. + if (options.binary) { + var buffer = xhr.response; + if (!buffer) { + buffer = []; + for (var i = 0; i < xhr.responseText.length; ++i) + buffer.push(xhr.responseText.charCodeAt(i) & 255); + } + return callback(null, typeof Uint8Array !== "undefined" ? new Uint8Array(buffer) : buffer); + } + return callback(null, xhr.responseText); + }; + + if (options.binary) { + // ref: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Sending_and_Receiving_Binary_Data#Receiving_binary_data_in_older_browsers + if ("overrideMimeType" in xhr) + xhr.overrideMimeType("text/plain; charset=x-user-defined"); + xhr.responseType = "arraybuffer"; + } + + xhr.open("GET", filename); + xhr.send(); +}; + +},{"1":1,"7":7}],6:[function(require,module,exports){ +"use strict"; + +module.exports = factory(factory); + +/** + * Reads / writes floats / doubles from / to buffers. + * @name util.float + * @namespace + */ + +/** + * Writes a 32 bit float to a buffer using little endian byte order. + * @name util.float.writeFloatLE + * @function + * @param {number} val Value to write + * @param {Uint8Array} buf Target buffer + * @param {number} pos Target buffer offset + * @returns {undefined} + */ + +/** + * Writes a 32 bit float to a buffer using big endian byte order. + * @name util.float.writeFloatBE + * @function + * @param {number} val Value to write + * @param {Uint8Array} buf Target buffer + * @param {number} pos Target buffer offset + * @returns {undefined} + */ + +/** + * Reads a 32 bit float from a buffer using little endian byte order. + * @name util.float.readFloatLE + * @function + * @param {Uint8Array} buf Source buffer + * @param {number} pos Source buffer offset + * @returns {number} Value read + */ + +/** + * Reads a 32 bit float from a buffer using big endian byte order. + * @name util.float.readFloatBE + * @function + * @param {Uint8Array} buf Source buffer + * @param {number} pos Source buffer offset + * @returns {number} Value read + */ + +/** + * Writes a 64 bit double to a buffer using little endian byte order. + * @name util.float.writeDoubleLE + * @function + * @param {number} val Value to write + * @param {Uint8Array} buf Target buffer + * @param {number} pos Target buffer offset + * @returns {undefined} + */ + +/** + * Writes a 64 bit double to a buffer using big endian byte order. + * @name util.float.writeDoubleBE + * @function + * @param {number} val Value to write + * @param {Uint8Array} buf Target buffer + * @param {number} pos Target buffer offset + * @returns {undefined} + */ + +/** + * Reads a 64 bit double from a buffer using little endian byte order. + * @name util.float.readDoubleLE + * @function + * @param {Uint8Array} buf Source buffer + * @param {number} pos Source buffer offset + * @returns {number} Value read + */ + +/** + * Reads a 64 bit double from a buffer using big endian byte order. + * @name util.float.readDoubleBE + * @function + * @param {Uint8Array} buf Source buffer + * @param {number} pos Source buffer offset + * @returns {number} Value read + */ + +// Factory function for the purpose of node-based testing in modified global environments +function factory(exports) { + + // float: typed array + if (typeof Float32Array !== "undefined") (function() { + + var f32 = new Float32Array([ -0 ]), + f8b = new Uint8Array(f32.buffer), + le = f8b[3] === 128; + + function writeFloat_f32_cpy(val, buf, pos) { + f32[0] = val; + buf[pos ] = f8b[0]; + buf[pos + 1] = f8b[1]; + buf[pos + 2] = f8b[2]; + buf[pos + 3] = f8b[3]; + } + + function writeFloat_f32_rev(val, buf, pos) { + f32[0] = val; + buf[pos ] = f8b[3]; + buf[pos + 1] = f8b[2]; + buf[pos + 2] = f8b[1]; + buf[pos + 3] = f8b[0]; + } + + /* istanbul ignore next */ + exports.writeFloatLE = le ? writeFloat_f32_cpy : writeFloat_f32_rev; + /* istanbul ignore next */ + exports.writeFloatBE = le ? writeFloat_f32_rev : writeFloat_f32_cpy; + + function readFloat_f32_cpy(buf, pos) { + f8b[0] = buf[pos ]; + f8b[1] = buf[pos + 1]; + f8b[2] = buf[pos + 2]; + f8b[3] = buf[pos + 3]; + return f32[0]; + } + + function readFloat_f32_rev(buf, pos) { + f8b[3] = buf[pos ]; + f8b[2] = buf[pos + 1]; + f8b[1] = buf[pos + 2]; + f8b[0] = buf[pos + 3]; + return f32[0]; + } + + /* istanbul ignore next */ + exports.readFloatLE = le ? readFloat_f32_cpy : readFloat_f32_rev; + /* istanbul ignore next */ + exports.readFloatBE = le ? readFloat_f32_rev : readFloat_f32_cpy; + + // float: ieee754 + })(); else (function() { + + function writeFloat_ieee754(writeUint, val, buf, pos) { + var sign = val < 0 ? 1 : 0; + if (sign) + val = -val; + if (val === 0) + writeUint(1 / val > 0 ? /* positive */ 0 : /* negative 0 */ 2147483648, buf, pos); + else if (isNaN(val)) + writeUint(2143289344, buf, pos); + else if (val > 3.4028234663852886e+38) // +-Infinity + writeUint((sign << 31 | 2139095040) >>> 0, buf, pos); + else if (val < 1.1754943508222875e-38) // denormal + writeUint((sign << 31 | Math.round(val / 1.401298464324817e-45)) >>> 0, buf, pos); + else { + var exponent = Math.floor(Math.log(val) / Math.LN2), + mantissa = Math.round(val * Math.pow(2, -exponent) * 8388608) & 8388607; + writeUint((sign << 31 | exponent + 127 << 23 | mantissa) >>> 0, buf, pos); + } + } + + exports.writeFloatLE = writeFloat_ieee754.bind(null, writeUintLE); + exports.writeFloatBE = writeFloat_ieee754.bind(null, writeUintBE); + + function readFloat_ieee754(readUint, buf, pos) { + var uint = readUint(buf, pos), + sign = (uint >> 31) * 2 + 1, + exponent = uint >>> 23 & 255, + mantissa = uint & 8388607; + return exponent === 255 + ? mantissa + ? NaN + : sign * Infinity + : exponent === 0 // denormal + ? sign * 1.401298464324817e-45 * mantissa + : sign * Math.pow(2, exponent - 150) * (mantissa + 8388608); + } + + exports.readFloatLE = readFloat_ieee754.bind(null, readUintLE); + exports.readFloatBE = readFloat_ieee754.bind(null, readUintBE); + + })(); + + // double: typed array + if (typeof Float64Array !== "undefined") (function() { + + var f64 = new Float64Array([-0]), + f8b = new Uint8Array(f64.buffer), + le = f8b[7] === 128; + + function writeDouble_f64_cpy(val, buf, pos) { + f64[0] = val; + buf[pos ] = f8b[0]; + buf[pos + 1] = f8b[1]; + buf[pos + 2] = f8b[2]; + buf[pos + 3] = f8b[3]; + buf[pos + 4] = f8b[4]; + buf[pos + 5] = f8b[5]; + buf[pos + 6] = f8b[6]; + buf[pos + 7] = f8b[7]; + } + + function writeDouble_f64_rev(val, buf, pos) { + f64[0] = val; + buf[pos ] = f8b[7]; + buf[pos + 1] = f8b[6]; + buf[pos + 2] = f8b[5]; + buf[pos + 3] = f8b[4]; + buf[pos + 4] = f8b[3]; + buf[pos + 5] = f8b[2]; + buf[pos + 6] = f8b[1]; + buf[pos + 7] = f8b[0]; + } + + /* istanbul ignore next */ + exports.writeDoubleLE = le ? writeDouble_f64_cpy : writeDouble_f64_rev; + /* istanbul ignore next */ + exports.writeDoubleBE = le ? writeDouble_f64_rev : writeDouble_f64_cpy; + + function readDouble_f64_cpy(buf, pos) { + f8b[0] = buf[pos ]; + f8b[1] = buf[pos + 1]; + f8b[2] = buf[pos + 2]; + f8b[3] = buf[pos + 3]; + f8b[4] = buf[pos + 4]; + f8b[5] = buf[pos + 5]; + f8b[6] = buf[pos + 6]; + f8b[7] = buf[pos + 7]; + return f64[0]; + } + + function readDouble_f64_rev(buf, pos) { + f8b[7] = buf[pos ]; + f8b[6] = buf[pos + 1]; + f8b[5] = buf[pos + 2]; + f8b[4] = buf[pos + 3]; + f8b[3] = buf[pos + 4]; + f8b[2] = buf[pos + 5]; + f8b[1] = buf[pos + 6]; + f8b[0] = buf[pos + 7]; + return f64[0]; + } + + /* istanbul ignore next */ + exports.readDoubleLE = le ? readDouble_f64_cpy : readDouble_f64_rev; + /* istanbul ignore next */ + exports.readDoubleBE = le ? readDouble_f64_rev : readDouble_f64_cpy; + + // double: ieee754 + })(); else (function() { + + function writeDouble_ieee754(writeUint, off0, off1, val, buf, pos) { + var sign = val < 0 ? 1 : 0; + if (sign) + val = -val; + if (val === 0) { + writeUint(0, buf, pos + off0); + writeUint(1 / val > 0 ? /* positive */ 0 : /* negative 0 */ 2147483648, buf, pos + off1); + } else if (isNaN(val)) { + writeUint(0, buf, pos + off0); + writeUint(2146959360, buf, pos + off1); + } else if (val > 1.7976931348623157e+308) { // +-Infinity + writeUint(0, buf, pos + off0); + writeUint((sign << 31 | 2146435072) >>> 0, buf, pos + off1); + } else { + var mantissa; + if (val < 2.2250738585072014e-308) { // denormal + mantissa = val / 5e-324; + writeUint(mantissa >>> 0, buf, pos + off0); + writeUint((sign << 31 | mantissa / 4294967296) >>> 0, buf, pos + off1); + } else { + var exponent = Math.floor(Math.log(val) / Math.LN2); + if (exponent === 1024) + exponent = 1023; + mantissa = val * Math.pow(2, -exponent); + writeUint(mantissa * 4503599627370496 >>> 0, buf, pos + off0); + writeUint((sign << 31 | exponent + 1023 << 20 | mantissa * 1048576 & 1048575) >>> 0, buf, pos + off1); + } + } + } + + exports.writeDoubleLE = writeDouble_ieee754.bind(null, writeUintLE, 0, 4); + exports.writeDoubleBE = writeDouble_ieee754.bind(null, writeUintBE, 4, 0); + + function readDouble_ieee754(readUint, off0, off1, buf, pos) { + var lo = readUint(buf, pos + off0), + hi = readUint(buf, pos + off1); + var sign = (hi >> 31) * 2 + 1, + exponent = hi >>> 20 & 2047, + mantissa = 4294967296 * (hi & 1048575) + lo; + return exponent === 2047 + ? mantissa + ? NaN + : sign * Infinity + : exponent === 0 // denormal + ? sign * 5e-324 * mantissa + : sign * Math.pow(2, exponent - 1075) * (mantissa + 4503599627370496); + } + + exports.readDoubleLE = readDouble_ieee754.bind(null, readUintLE, 0, 4); + exports.readDoubleBE = readDouble_ieee754.bind(null, readUintBE, 4, 0); + + })(); + + return exports; +} + +// uint helpers + +function writeUintLE(val, buf, pos) { + buf[pos ] = val & 255; + buf[pos + 1] = val >>> 8 & 255; + buf[pos + 2] = val >>> 16 & 255; + buf[pos + 3] = val >>> 24; +} + +function writeUintBE(val, buf, pos) { + buf[pos ] = val >>> 24; + buf[pos + 1] = val >>> 16 & 255; + buf[pos + 2] = val >>> 8 & 255; + buf[pos + 3] = val & 255; +} + +function readUintLE(buf, pos) { + return (buf[pos ] + | buf[pos + 1] << 8 + | buf[pos + 2] << 16 + | buf[pos + 3] << 24) >>> 0; +} + +function readUintBE(buf, pos) { + return (buf[pos ] << 24 + | buf[pos + 1] << 16 + | buf[pos + 2] << 8 + | buf[pos + 3]) >>> 0; +} + +},{}],7:[function(require,module,exports){ +"use strict"; +module.exports = inquire; + +/** + * Requires a module only if available. + * @memberof util + * @param {string} moduleName Module to require + * @returns {?Object} Required module if available and not empty, otherwise `null` + */ +function inquire(moduleName) { + try { + var mod = eval("quire".replace(/^/,"re"))(moduleName); // eslint-disable-line no-eval + if (mod && (mod.length || Object.keys(mod).length)) + return mod; + } catch (e) {} // eslint-disable-line no-empty + return null; +} + +},{}],8:[function(require,module,exports){ +"use strict"; + +/** + * A minimal path module to resolve Unix, Windows and URL paths alike. + * @memberof util + * @namespace + */ +var path = exports; + +var isAbsolute = +/** + * Tests if the specified path is absolute. + * @param {string} path Path to test + * @returns {boolean} `true` if path is absolute + */ +path.isAbsolute = function isAbsolute(path) { + return /^(?:\/|\w+:)/.test(path); +}; + +var normalize = +/** + * Normalizes the specified path. + * @param {string} path Path to normalize + * @returns {string} Normalized path + */ +path.normalize = function normalize(path) { + path = path.replace(/\\/g, "/") + .replace(/\/{2,}/g, "/"); + var parts = path.split("/"), + absolute = isAbsolute(path), + prefix = ""; + if (absolute) + prefix = parts.shift() + "/"; + for (var i = 0; i < parts.length;) { + if (parts[i] === "..") { + if (i > 0 && parts[i - 1] !== "..") + parts.splice(--i, 2); + else if (absolute) + parts.splice(i, 1); + else + ++i; + } else if (parts[i] === ".") + parts.splice(i, 1); + else + ++i; + } + return prefix + parts.join("/"); +}; + +/** + * Resolves the specified include path against the specified origin path. + * @param {string} originPath Path to the origin file + * @param {string} includePath Include path relative to origin path + * @param {boolean} [alreadyNormalized=false] `true` if both paths are already known to be normalized + * @returns {string} Path to the include file + */ +path.resolve = function resolve(originPath, includePath, alreadyNormalized) { + if (!alreadyNormalized) + includePath = normalize(includePath); + if (isAbsolute(includePath)) + return includePath; + if (!alreadyNormalized) + originPath = normalize(originPath); + return (originPath = originPath.replace(/(?:\/|^)[^/]+$/, "")).length ? normalize(originPath + "/" + includePath) : includePath; +}; + +},{}],9:[function(require,module,exports){ +"use strict"; +module.exports = pool; + +/** + * An allocator as used by {@link util.pool}. + * @typedef PoolAllocator + * @type {function} + * @param {number} size Buffer size + * @returns {Uint8Array} Buffer + */ + +/** + * A slicer as used by {@link util.pool}. + * @typedef PoolSlicer + * @type {function} + * @param {number} start Start offset + * @param {number} end End offset + * @returns {Uint8Array} Buffer slice + * @this {Uint8Array} + */ + +/** + * A general purpose buffer pool. + * @memberof util + * @function + * @param {PoolAllocator} alloc Allocator + * @param {PoolSlicer} slice Slicer + * @param {number} [size=8192] Slab size + * @returns {PoolAllocator} Pooled allocator + */ +function pool(alloc, slice, size) { + var SIZE = size || 8192; + var MAX = SIZE >>> 1; + var slab = null; + var offset = SIZE; + return function pool_alloc(size) { + if (size < 1 || size > MAX) + return alloc(size); + if (offset + size > SIZE) { + slab = alloc(SIZE); + offset = 0; + } + var buf = slice.call(slab, offset, offset += size); + if (offset & 7) // align to 32 bit + offset = (offset | 7) + 1; + return buf; + }; +} + +},{}],10:[function(require,module,exports){ +"use strict"; + +/** + * A minimal UTF8 implementation for number arrays. + * @memberof util + * @namespace + */ +var utf8 = exports; + +/** + * Calculates the UTF8 byte length of a string. + * @param {string} string String + * @returns {number} Byte length + */ +utf8.length = function utf8_length(string) { + var len = 0, + c = 0; + for (var i = 0; i < string.length; ++i) { + c = string.charCodeAt(i); + if (c < 128) + len += 1; + else if (c < 2048) + len += 2; + else if ((c & 0xFC00) === 0xD800 && (string.charCodeAt(i + 1) & 0xFC00) === 0xDC00) { + ++i; + len += 4; + } else + len += 3; + } + return len; +}; + +/** + * Reads UTF8 bytes as a string. + * @param {Uint8Array} buffer Source buffer + * @param {number} start Source start + * @param {number} end Source end + * @returns {string} String read + */ +utf8.read = function utf8_read(buffer, start, end) { + var len = end - start; + if (len < 1) + return ""; + var parts = null, + chunk = [], + i = 0, // char offset + t; // temporary + while (start < end) { + t = buffer[start++]; + if (t < 128) + chunk[i++] = t; + else if (t > 191 && t < 224) + chunk[i++] = (t & 31) << 6 | buffer[start++] & 63; + else if (t > 239 && t < 365) { + t = ((t & 7) << 18 | (buffer[start++] & 63) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63) - 0x10000; + chunk[i++] = 0xD800 + (t >> 10); + chunk[i++] = 0xDC00 + (t & 1023); + } else + chunk[i++] = (t & 15) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63; + if (i > 8191) { + (parts || (parts = [])).push(String.fromCharCode.apply(String, chunk)); + i = 0; + } + } + if (parts) { + if (i) + parts.push(String.fromCharCode.apply(String, chunk.slice(0, i))); + return parts.join(""); + } + return String.fromCharCode.apply(String, chunk.slice(0, i)); +}; + +/** + * Writes a string as UTF8 bytes. + * @param {string} string Source string + * @param {Uint8Array} buffer Destination buffer + * @param {number} offset Destination offset + * @returns {number} Bytes written + */ +utf8.write = function utf8_write(string, buffer, offset) { + var start = offset, + c1, // character 1 + c2; // character 2 + for (var i = 0; i < string.length; ++i) { + c1 = string.charCodeAt(i); + if (c1 < 128) { + buffer[offset++] = c1; + } else if (c1 < 2048) { + buffer[offset++] = c1 >> 6 | 192; + buffer[offset++] = c1 & 63 | 128; + } else if ((c1 & 0xFC00) === 0xD800 && ((c2 = string.charCodeAt(i + 1)) & 0xFC00) === 0xDC00) { + c1 = 0x10000 + ((c1 & 0x03FF) << 10) + (c2 & 0x03FF); + ++i; + buffer[offset++] = c1 >> 18 | 240; + buffer[offset++] = c1 >> 12 & 63 | 128; + buffer[offset++] = c1 >> 6 & 63 | 128; + buffer[offset++] = c1 & 63 | 128; + } else { + buffer[offset++] = c1 >> 12 | 224; + buffer[offset++] = c1 >> 6 & 63 | 128; + buffer[offset++] = c1 & 63 | 128; + } + } + return offset - start; +}; + +},{}],11:[function(require,module,exports){ +"use strict"; +module.exports = common; + +var commonRe = /\/|\./; + +/** + * Provides common type definitions. + * Can also be used to provide additional google types or your own custom types. + * @param {string} name Short name as in `google/protobuf/[name].proto` or full file name + * @param {Object.} json JSON definition within `google.protobuf` if a short name, otherwise the file's root definition + * @returns {undefined} + * @property {INamespace} google/protobuf/any.proto Any + * @property {INamespace} google/protobuf/duration.proto Duration + * @property {INamespace} google/protobuf/empty.proto Empty + * @property {INamespace} google/protobuf/field_mask.proto FieldMask + * @property {INamespace} google/protobuf/struct.proto Struct, Value, NullValue and ListValue + * @property {INamespace} google/protobuf/timestamp.proto Timestamp + * @property {INamespace} google/protobuf/wrappers.proto Wrappers + * @example + * // manually provides descriptor.proto (assumes google/protobuf/ namespace and .proto extension) + * protobuf.common("descriptor", descriptorJson); + * + * // manually provides a custom definition (uses my.foo namespace) + * protobuf.common("my/foo/bar.proto", myFooBarJson); + */ +function common(name, json) { + if (!commonRe.test(name)) { + name = "google/protobuf/" + name + ".proto"; + json = { nested: { google: { nested: { protobuf: { nested: json } } } } }; + } + common[name] = json; +} + +// Not provided because of limited use (feel free to discuss or to provide yourself): +// +// google/protobuf/descriptor.proto +// google/protobuf/source_context.proto +// google/protobuf/type.proto +// +// Stripped and pre-parsed versions of these non-bundled files are instead available as part of +// the repository or package within the google/protobuf directory. + +common("any", { + + /** + * Properties of a google.protobuf.Any message. + * @interface IAny + * @type {Object} + * @property {string} [typeUrl] + * @property {Uint8Array} [bytes] + * @memberof common + */ + Any: { + fields: { + type_url: { + type: "string", + id: 1 + }, + value: { + type: "bytes", + id: 2 + } + } + } +}); + +var timeType; + +common("duration", { + + /** + * Properties of a google.protobuf.Duration message. + * @interface IDuration + * @type {Object} + * @property {number|Long} [seconds] + * @property {number} [nanos] + * @memberof common + */ + Duration: timeType = { + fields: { + seconds: { + type: "int64", + id: 1 + }, + nanos: { + type: "int32", + id: 2 + } + } + } +}); + +common("timestamp", { + + /** + * Properties of a google.protobuf.Timestamp message. + * @interface ITimestamp + * @type {Object} + * @property {number|Long} [seconds] + * @property {number} [nanos] + * @memberof common + */ + Timestamp: timeType +}); + +common("empty", { + + /** + * Properties of a google.protobuf.Empty message. + * @interface IEmpty + * @memberof common + */ + Empty: { + fields: {} + } +}); + +common("struct", { + + /** + * Properties of a google.protobuf.Struct message. + * @interface IStruct + * @type {Object} + * @property {Object.} [fields] + * @memberof common + */ + Struct: { + fields: { + fields: { + keyType: "string", + type: "Value", + id: 1 + } + } + }, + + /** + * Properties of a google.protobuf.Value message. + * @interface IValue + * @type {Object} + * @property {string} [kind] + * @property {0} [nullValue] + * @property {number} [numberValue] + * @property {string} [stringValue] + * @property {boolean} [boolValue] + * @property {IStruct} [structValue] + * @property {IListValue} [listValue] + * @memberof common + */ + Value: { + oneofs: { + kind: { + oneof: [ + "nullValue", + "numberValue", + "stringValue", + "boolValue", + "structValue", + "listValue" + ] + } + }, + fields: { + nullValue: { + type: "NullValue", + id: 1 + }, + numberValue: { + type: "double", + id: 2 + }, + stringValue: { + type: "string", + id: 3 + }, + boolValue: { + type: "bool", + id: 4 + }, + structValue: { + type: "Struct", + id: 5 + }, + listValue: { + type: "ListValue", + id: 6 + } + } + }, + + NullValue: { + values: { + NULL_VALUE: 0 + } + }, + + /** + * Properties of a google.protobuf.ListValue message. + * @interface IListValue + * @type {Object} + * @property {Array.} [values] + * @memberof common + */ + ListValue: { + fields: { + values: { + rule: "repeated", + type: "Value", + id: 1 + } + } + } +}); + +common("wrappers", { + + /** + * Properties of a google.protobuf.DoubleValue message. + * @interface IDoubleValue + * @type {Object} + * @property {number} [value] + * @memberof common + */ + DoubleValue: { + fields: { + value: { + type: "double", + id: 1 + } + } + }, + + /** + * Properties of a google.protobuf.FloatValue message. + * @interface IFloatValue + * @type {Object} + * @property {number} [value] + * @memberof common + */ + FloatValue: { + fields: { + value: { + type: "float", + id: 1 + } + } + }, + + /** + * Properties of a google.protobuf.Int64Value message. + * @interface IInt64Value + * @type {Object} + * @property {number|Long} [value] + * @memberof common + */ + Int64Value: { + fields: { + value: { + type: "int64", + id: 1 + } + } + }, + + /** + * Properties of a google.protobuf.UInt64Value message. + * @interface IUInt64Value + * @type {Object} + * @property {number|Long} [value] + * @memberof common + */ + UInt64Value: { + fields: { + value: { + type: "uint64", + id: 1 + } + } + }, + + /** + * Properties of a google.protobuf.Int32Value message. + * @interface IInt32Value + * @type {Object} + * @property {number} [value] + * @memberof common + */ + Int32Value: { + fields: { + value: { + type: "int32", + id: 1 + } + } + }, + + /** + * Properties of a google.protobuf.UInt32Value message. + * @interface IUInt32Value + * @type {Object} + * @property {number} [value] + * @memberof common + */ + UInt32Value: { + fields: { + value: { + type: "uint32", + id: 1 + } + } + }, + + /** + * Properties of a google.protobuf.BoolValue message. + * @interface IBoolValue + * @type {Object} + * @property {boolean} [value] + * @memberof common + */ + BoolValue: { + fields: { + value: { + type: "bool", + id: 1 + } + } + }, + + /** + * Properties of a google.protobuf.StringValue message. + * @interface IStringValue + * @type {Object} + * @property {string} [value] + * @memberof common + */ + StringValue: { + fields: { + value: { + type: "string", + id: 1 + } + } + }, + + /** + * Properties of a google.protobuf.BytesValue message. + * @interface IBytesValue + * @type {Object} + * @property {Uint8Array} [value] + * @memberof common + */ + BytesValue: { + fields: { + value: { + type: "bytes", + id: 1 + } + } + } +}); + +common("field_mask", { + + /** + * Properties of a google.protobuf.FieldMask message. + * @interface IDoubleValue + * @type {Object} + * @property {number} [value] + * @memberof common + */ + FieldMask: { + fields: { + paths: { + rule: "repeated", + type: "string", + id: 1 + } + } + } +}); + +/** + * Gets the root definition of the specified common proto file. + * + * Bundled definitions are: + * - google/protobuf/any.proto + * - google/protobuf/duration.proto + * - google/protobuf/empty.proto + * - google/protobuf/field_mask.proto + * - google/protobuf/struct.proto + * - google/protobuf/timestamp.proto + * - google/protobuf/wrappers.proto + * + * @param {string} file Proto file name + * @returns {INamespace|null} Root definition or `null` if not defined + */ +common.get = function get(file) { + return common[file] || null; +}; + +},{}],12:[function(require,module,exports){ +"use strict"; +/** + * Runtime message from/to plain object converters. + * @namespace + */ +var converter = exports; + +var Enum = require(15), + util = require(37); + +/** + * Generates a partial value fromObject conveter. + * @param {Codegen} gen Codegen instance + * @param {Field} field Reflected field + * @param {number} fieldIndex Field index + * @param {string} prop Property reference + * @returns {Codegen} Codegen instance + * @ignore + */ +function genValuePartial_fromObject(gen, field, fieldIndex, prop) { + /* eslint-disable no-unexpected-multiline, block-scoped-var, no-redeclare */ + if (field.resolvedType) { + if (field.resolvedType instanceof Enum) { gen + ("switch(d%s){", prop); + for (var values = field.resolvedType.values, keys = Object.keys(values), i = 0; i < keys.length; ++i) { + if (field.repeated && values[keys[i]] === field.typeDefault) gen + ("default:"); + gen + ("case%j:", keys[i]) + ("case %i:", values[keys[i]]) + ("m%s=%j", prop, values[keys[i]]) + ("break"); + } gen + ("}"); + } else gen + ("if(typeof d%s!==\"object\")", prop) + ("throw TypeError(%j)", field.fullName + ": object expected") + ("m%s=types[%i].fromObject(d%s)", prop, fieldIndex, prop); + } else { + var isUnsigned = false; + switch (field.type) { + case "double": + case "float": gen + ("m%s=Number(d%s)", prop, prop); // also catches "NaN", "Infinity" + break; + case "uint32": + case "fixed32": gen + ("m%s=d%s>>>0", prop, prop); + break; + case "int32": + case "sint32": + case "sfixed32": gen + ("m%s=d%s|0", prop, prop); + break; + case "uint64": + isUnsigned = true; + // eslint-disable-line no-fallthrough + case "int64": + case "sint64": + case "fixed64": + case "sfixed64": gen + ("if(util.Long)") + ("(m%s=util.Long.fromValue(d%s)).unsigned=%j", prop, prop, isUnsigned) + ("else if(typeof d%s===\"string\")", prop) + ("m%s=parseInt(d%s,10)", prop, prop) + ("else if(typeof d%s===\"number\")", prop) + ("m%s=d%s", prop, prop) + ("else if(typeof d%s===\"object\")", prop) + ("m%s=new util.LongBits(d%s.low>>>0,d%s.high>>>0).toNumber(%s)", prop, prop, prop, isUnsigned ? "true" : ""); + break; + case "bytes": gen + ("if(typeof d%s===\"string\")", prop) + ("util.base64.decode(d%s,m%s=util.newBuffer(util.base64.length(d%s)),0)", prop, prop, prop) + ("else if(d%s.length)", prop) + ("m%s=d%s", prop, prop); + break; + case "string": gen + ("m%s=String(d%s)", prop, prop); + break; + case "bool": gen + ("m%s=Boolean(d%s)", prop, prop); + break; + /* default: gen + ("m%s=d%s", prop, prop); + break; */ + } + } + return gen; + /* eslint-enable no-unexpected-multiline, block-scoped-var, no-redeclare */ +} + +/** + * Generates a plain object to runtime message converter specific to the specified message type. + * @param {Type} mtype Message type + * @returns {Codegen} Codegen instance + */ +converter.fromObject = function fromObject(mtype) { + /* eslint-disable no-unexpected-multiline, block-scoped-var, no-redeclare */ + var fields = mtype.fieldsArray; + var gen = util.codegen(["d"], mtype.name + "$fromObject") + ("if(d instanceof this.ctor)") + ("return d"); + if (!fields.length) return gen + ("return new this.ctor"); + gen + ("var m=new this.ctor"); + for (var i = 0; i < fields.length; ++i) { + var field = fields[i].resolve(), + prop = util.safeProp(field.name); + + // Map fields + if (field.map) { gen + ("if(d%s){", prop) + ("if(typeof d%s!==\"object\")", prop) + ("throw TypeError(%j)", field.fullName + ": object expected") + ("m%s={}", prop) + ("for(var ks=Object.keys(d%s),i=0;i>>0,m%s.high>>>0).toNumber(%s):m%s", prop, prop, prop, prop, isUnsigned ? "true": "", prop); + break; + case "bytes": gen + ("d%s=o.bytes===String?util.base64.encode(m%s,0,m%s.length):o.bytes===Array?Array.prototype.slice.call(m%s):m%s", prop, prop, prop, prop, prop); + break; + default: gen + ("d%s=m%s", prop, prop); + break; + } + } + return gen; + /* eslint-enable no-unexpected-multiline, block-scoped-var, no-redeclare */ +} + +/** + * Generates a runtime message to plain object converter specific to the specified message type. + * @param {Type} mtype Message type + * @returns {Codegen} Codegen instance + */ +converter.toObject = function toObject(mtype) { + /* eslint-disable no-unexpected-multiline, block-scoped-var, no-redeclare */ + var fields = mtype.fieldsArray.slice().sort(util.compareFieldsById); + if (!fields.length) + return util.codegen()("return {}"); + var gen = util.codegen(["m", "o"], mtype.name + "$toObject") + ("if(!o)") + ("o={}") + ("var d={}"); + + var repeatedFields = [], + mapFields = [], + normalFields = [], + i = 0; + for (; i < fields.length; ++i) + if (!fields[i].partOf) + ( fields[i].resolve().repeated ? repeatedFields + : fields[i].map ? mapFields + : normalFields).push(fields[i]); + + if (repeatedFields.length) { gen + ("if(o.arrays||o.defaults){"); + for (i = 0; i < repeatedFields.length; ++i) gen + ("d%s=[]", util.safeProp(repeatedFields[i].name)); + gen + ("}"); + } + + if (mapFields.length) { gen + ("if(o.objects||o.defaults){"); + for (i = 0; i < mapFields.length; ++i) gen + ("d%s={}", util.safeProp(mapFields[i].name)); + gen + ("}"); + } + + if (normalFields.length) { gen + ("if(o.defaults){"); + for (i = 0; i < normalFields.length; ++i) { + var field = normalFields[i], + prop = util.safeProp(field.name); + if (field.resolvedType instanceof Enum) gen + ("d%s=o.enums===String?%j:%j", prop, field.resolvedType.valuesById[field.typeDefault], field.typeDefault); + else if (field.long) gen + ("if(util.Long){") + ("var n=new util.Long(%i,%i,%j)", field.typeDefault.low, field.typeDefault.high, field.typeDefault.unsigned) + ("d%s=o.longs===String?n.toString():o.longs===Number?n.toNumber():n", prop) + ("}else") + ("d%s=o.longs===String?%j:%i", prop, field.typeDefault.toString(), field.typeDefault.toNumber()); + else if (field.bytes) { + var arrayDefault = "[" + Array.prototype.slice.call(field.typeDefault).join(",") + "]"; + gen + ("if(o.bytes===String)d%s=%j", prop, String.fromCharCode.apply(String, field.typeDefault)) + ("else{") + ("d%s=%s", prop, arrayDefault) + ("if(o.bytes!==Array)d%s=util.newBuffer(d%s)", prop, prop) + ("}"); + } else gen + ("d%s=%j", prop, field.typeDefault); // also messages (=null) + } gen + ("}"); + } + var hasKs2 = false; + for (i = 0; i < fields.length; ++i) { + var field = fields[i], + index = mtype._fieldsArray.indexOf(field), + prop = util.safeProp(field.name); + if (field.map) { + if (!hasKs2) { hasKs2 = true; gen + ("var ks2"); + } gen + ("if(m%s&&(ks2=Object.keys(m%s)).length){", prop, prop) + ("d%s={}", prop) + ("for(var j=0;j>>3){"); + + var i = 0; + for (; i < /* initializes */ mtype.fieldsArray.length; ++i) { + var field = mtype._fieldsArray[i].resolve(), + type = field.resolvedType instanceof Enum ? "int32" : field.type, + ref = "m" + util.safeProp(field.name); gen + ("case %i:", field.id); + + // Map fields + if (field.map) { gen + ("r.skip().pos++") // assumes id 1 + key wireType + ("if(%s===util.emptyObject)", ref) + ("%s={}", ref) + ("k=r.%s()", field.keyType) + ("r.pos++"); // assumes id 2 + value wireType + if (types.long[field.keyType] !== undefined) { + if (types.basic[type] === undefined) gen + ("%s[typeof k===\"object\"?util.longToHash(k):k]=types[%i].decode(r,r.uint32())", ref, i); // can't be groups + else gen + ("%s[typeof k===\"object\"?util.longToHash(k):k]=r.%s()", ref, type); + } else { + if (types.basic[type] === undefined) gen + ("%s[k]=types[%i].decode(r,r.uint32())", ref, i); // can't be groups + else gen + ("%s[k]=r.%s()", ref, type); + } + + // Repeated fields + } else if (field.repeated) { gen + + ("if(!(%s&&%s.length))", ref, ref) + ("%s=[]", ref); + + // Packable (always check for forward and backward compatiblity) + if (types.packed[type] !== undefined) gen + ("if((t&7)===2){") + ("var c2=r.uint32()+r.pos") + ("while(r.pos>> 0, (field.id << 3 | 4) >>> 0) + : gen("types[%i].encode(%s,w.uint32(%i).fork()).ldelim()", fieldIndex, ref, (field.id << 3 | 2) >>> 0); +} + +/** + * Generates an encoder specific to the specified message type. + * @param {Type} mtype Message type + * @returns {Codegen} Codegen instance + */ +function encoder(mtype) { + /* eslint-disable no-unexpected-multiline, block-scoped-var, no-redeclare */ + var gen = util.codegen(["m", "w"], mtype.name + "$encode") + ("if(!w)") + ("w=Writer.create()"); + + var i, ref; + + // "when a message is serialized its known fields should be written sequentially by field number" + var fields = /* initializes */ mtype.fieldsArray.slice().sort(util.compareFieldsById); + + for (var i = 0; i < fields.length; ++i) { + var field = fields[i].resolve(), + index = mtype._fieldsArray.indexOf(field), + type = field.resolvedType instanceof Enum ? "int32" : field.type, + wireType = types.basic[type]; + ref = "m" + util.safeProp(field.name); + + // Map fields + if (field.map) { + gen + ("if(%s!=null&&m.hasOwnProperty(%j)){", ref, field.name) // !== undefined && !== null + ("for(var ks=Object.keys(%s),i=0;i>> 0, 8 | types.mapKey[field.keyType], field.keyType); + if (wireType === undefined) gen + ("types[%i].encode(%s[ks[i]],w.uint32(18).fork()).ldelim().ldelim()", index, ref); // can't be groups + else gen + (".uint32(%i).%s(%s[ks[i]]).ldelim()", 16 | wireType, type, ref); + gen + ("}") + ("}"); + + // Repeated fields + } else if (field.repeated) { gen + ("if(%s!=null&&%s.length){", ref, ref); // !== undefined && !== null + + // Packed repeated + if (field.packed && types.packed[type] !== undefined) { gen + + ("w.uint32(%i).fork()", (field.id << 3 | 2) >>> 0) + ("for(var i=0;i<%s.length;++i)", ref) + ("w.%s(%s[i])", type, ref) + ("w.ldelim()"); + + // Non-packed + } else { gen + + ("for(var i=0;i<%s.length;++i)", ref); + if (wireType === undefined) + genTypePartial(gen, field, index, ref + "[i]"); + else gen + ("w.uint32(%i).%s(%s[i])", (field.id << 3 | wireType) >>> 0, type, ref); + + } gen + ("}"); + + // Non-repeated + } else { + if (field.optional) gen + ("if(%s!=null&&m.hasOwnProperty(%j))", ref, field.name); // !== undefined && !== null + + if (wireType === undefined) + genTypePartial(gen, field, index, ref); + else gen + ("w.uint32(%i).%s(%s)", (field.id << 3 | wireType) >>> 0, type, ref); + + } + } + + return gen + ("return w"); + /* eslint-enable no-unexpected-multiline, block-scoped-var, no-redeclare */ +} +},{"15":15,"36":36,"37":37}],15:[function(require,module,exports){ +"use strict"; +module.exports = Enum; + +// extends ReflectionObject +var ReflectionObject = require(24); +((Enum.prototype = Object.create(ReflectionObject.prototype)).constructor = Enum).className = "Enum"; + +var Namespace = require(23), + util = require(37); + +/** + * Constructs a new enum instance. + * @classdesc Reflected enum. + * @extends ReflectionObject + * @constructor + * @param {string} name Unique name within its namespace + * @param {Object.} [values] Enum values as an object, by name + * @param {Object.} [options] Declared options + * @param {string} [comment] The comment for this enum + * @param {Object.} [comments] The value comments for this enum + */ +function Enum(name, values, options, comment, comments) { + ReflectionObject.call(this, name, options); + + if (values && typeof values !== "object") + throw TypeError("values must be an object"); + + /** + * Enum values by id. + * @type {Object.} + */ + this.valuesById = {}; + + /** + * Enum values by name. + * @type {Object.} + */ + this.values = Object.create(this.valuesById); // toJSON, marker + + /** + * Enum comment text. + * @type {string|null} + */ + this.comment = comment; + + /** + * Value comment texts, if any. + * @type {Object.} + */ + this.comments = comments || {}; + + /** + * Reserved ranges, if any. + * @type {Array.} + */ + this.reserved = undefined; // toJSON + + // Note that values inherit valuesById on their prototype which makes them a TypeScript- + // compatible enum. This is used by pbts to write actual enum definitions that work for + // static and reflection code alike instead of emitting generic object definitions. + + if (values) + for (var keys = Object.keys(values), i = 0; i < keys.length; ++i) + if (typeof values[keys[i]] === "number") // use forward entries only + this.valuesById[ this.values[keys[i]] = values[keys[i]] ] = keys[i]; +} + +/** + * Enum descriptor. + * @interface IEnum + * @property {Object.} values Enum values + * @property {Object.} [options] Enum options + */ + +/** + * Constructs an enum from an enum descriptor. + * @param {string} name Enum name + * @param {IEnum} json Enum descriptor + * @returns {Enum} Created enum + * @throws {TypeError} If arguments are invalid + */ +Enum.fromJSON = function fromJSON(name, json) { + var enm = new Enum(name, json.values, json.options, json.comment, json.comments); + enm.reserved = json.reserved; + return enm; +}; + +/** + * Converts this enum to an enum descriptor. + * @param {IToJSONOptions} [toJSONOptions] JSON conversion options + * @returns {IEnum} Enum descriptor + */ +Enum.prototype.toJSON = function toJSON(toJSONOptions) { + var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false; + return util.toObject([ + "options" , this.options, + "values" , this.values, + "reserved" , this.reserved && this.reserved.length ? this.reserved : undefined, + "comment" , keepComments ? this.comment : undefined, + "comments" , keepComments ? this.comments : undefined + ]); +}; + +/** + * Adds a value to this enum. + * @param {string} name Value name + * @param {number} id Value id + * @param {string} [comment] Comment, if any + * @returns {Enum} `this` + * @throws {TypeError} If arguments are invalid + * @throws {Error} If there is already a value with this name or id + */ +Enum.prototype.add = function add(name, id, comment) { + // utilized by the parser but not by .fromJSON + + if (!util.isString(name)) + throw TypeError("name must be a string"); + + if (!util.isInteger(id)) + throw TypeError("id must be an integer"); + + if (this.values[name] !== undefined) + throw Error("duplicate name '" + name + "' in " + this); + + if (this.isReservedId(id)) + throw Error("id " + id + " is reserved in " + this); + + if (this.isReservedName(name)) + throw Error("name '" + name + "' is reserved in " + this); + + if (this.valuesById[id] !== undefined) { + if (!(this.options && this.options.allow_alias)) + throw Error("duplicate id " + id + " in " + this); + this.values[name] = id; + } else + this.valuesById[this.values[name] = id] = name; + + this.comments[name] = comment || null; + return this; +}; + +/** + * Removes a value from this enum + * @param {string} name Value name + * @returns {Enum} `this` + * @throws {TypeError} If arguments are invalid + * @throws {Error} If `name` is not a name of this enum + */ +Enum.prototype.remove = function remove(name) { + + if (!util.isString(name)) + throw TypeError("name must be a string"); + + var val = this.values[name]; + if (val == null) + throw Error("name '" + name + "' does not exist in " + this); + + delete this.valuesById[val]; + delete this.values[name]; + delete this.comments[name]; + + return this; +}; + +/** + * Tests if the specified id is reserved. + * @param {number} id Id to test + * @returns {boolean} `true` if reserved, otherwise `false` + */ +Enum.prototype.isReservedId = function isReservedId(id) { + return Namespace.isReservedId(this.reserved, id); +}; + +/** + * Tests if the specified name is reserved. + * @param {string} name Name to test + * @returns {boolean} `true` if reserved, otherwise `false` + */ +Enum.prototype.isReservedName = function isReservedName(name) { + return Namespace.isReservedName(this.reserved, name); +}; + +},{"23":23,"24":24,"37":37}],16:[function(require,module,exports){ +"use strict"; +module.exports = Field; + +// extends ReflectionObject +var ReflectionObject = require(24); +((Field.prototype = Object.create(ReflectionObject.prototype)).constructor = Field).className = "Field"; + +var Enum = require(15), + types = require(36), + util = require(37); + +var Type; // cyclic + +var ruleRe = /^required|optional|repeated$/; + +/** + * Constructs a new message field instance. Note that {@link MapField|map fields} have their own class. + * @name Field + * @classdesc Reflected message field. + * @extends FieldBase + * @constructor + * @param {string} name Unique name within its namespace + * @param {number} id Unique id within its namespace + * @param {string} type Value type + * @param {string|Object.} [rule="optional"] Field rule + * @param {string|Object.} [extend] Extended type if different from parent + * @param {Object.} [options] Declared options + */ + +/** + * Constructs a field from a field descriptor. + * @param {string} name Field name + * @param {IField} json Field descriptor + * @returns {Field} Created field + * @throws {TypeError} If arguments are invalid + */ +Field.fromJSON = function fromJSON(name, json) { + return new Field(name, json.id, json.type, json.rule, json.extend, json.options, json.comment); +}; + +/** + * Not an actual constructor. Use {@link Field} instead. + * @classdesc Base class of all reflected message fields. This is not an actual class but here for the sake of having consistent type definitions. + * @exports FieldBase + * @extends ReflectionObject + * @constructor + * @param {string} name Unique name within its namespace + * @param {number} id Unique id within its namespace + * @param {string} type Value type + * @param {string|Object.} [rule="optional"] Field rule + * @param {string|Object.} [extend] Extended type if different from parent + * @param {Object.} [options] Declared options + * @param {string} [comment] Comment associated with this field + */ +function Field(name, id, type, rule, extend, options, comment) { + + if (util.isObject(rule)) { + comment = extend; + options = rule; + rule = extend = undefined; + } else if (util.isObject(extend)) { + comment = options; + options = extend; + extend = undefined; + } + + ReflectionObject.call(this, name, options); + + if (!util.isInteger(id) || id < 0) + throw TypeError("id must be a non-negative integer"); + + if (!util.isString(type)) + throw TypeError("type must be a string"); + + if (rule !== undefined && !ruleRe.test(rule = rule.toString().toLowerCase())) + throw TypeError("rule must be a string rule"); + + if (extend !== undefined && !util.isString(extend)) + throw TypeError("extend must be a string"); + + /** + * Field rule, if any. + * @type {string|undefined} + */ + this.rule = rule && rule !== "optional" ? rule : undefined; // toJSON + + /** + * Field type. + * @type {string} + */ + this.type = type; // toJSON + + /** + * Unique field id. + * @type {number} + */ + this.id = id; // toJSON, marker + + /** + * Extended type if different from parent. + * @type {string|undefined} + */ + this.extend = extend || undefined; // toJSON + + /** + * Whether this field is required. + * @type {boolean} + */ + this.required = rule === "required"; + + /** + * Whether this field is optional. + * @type {boolean} + */ + this.optional = !this.required; + + /** + * Whether this field is repeated. + * @type {boolean} + */ + this.repeated = rule === "repeated"; + + /** + * Whether this field is a map or not. + * @type {boolean} + */ + this.map = false; + + /** + * Message this field belongs to. + * @type {Type|null} + */ + this.message = null; + + /** + * OneOf this field belongs to, if any, + * @type {OneOf|null} + */ + this.partOf = null; + + /** + * The field type's default value. + * @type {*} + */ + this.typeDefault = null; + + /** + * The field's default value on prototypes. + * @type {*} + */ + this.defaultValue = null; + + /** + * Whether this field's value should be treated as a long. + * @type {boolean} + */ + this.long = util.Long ? types.long[type] !== undefined : /* istanbul ignore next */ false; + + /** + * Whether this field's value is a buffer. + * @type {boolean} + */ + this.bytes = type === "bytes"; + + /** + * Resolved type if not a basic type. + * @type {Type|Enum|null} + */ + this.resolvedType = null; + + /** + * Sister-field within the extended type if a declaring extension field. + * @type {Field|null} + */ + this.extensionField = null; + + /** + * Sister-field within the declaring namespace if an extended field. + * @type {Field|null} + */ + this.declaringField = null; + + /** + * Internally remembers whether this field is packed. + * @type {boolean|null} + * @private + */ + this._packed = null; + + /** + * Comment for this field. + * @type {string|null} + */ + this.comment = comment; +} + +/** + * Determines whether this field is packed. Only relevant when repeated and working with proto2. + * @name Field#packed + * @type {boolean} + * @readonly + */ +Object.defineProperty(Field.prototype, "packed", { + get: function() { + // defaults to packed=true if not explicity set to false + if (this._packed === null) + this._packed = this.getOption("packed") !== false; + return this._packed; + } +}); + +/** + * @override + */ +Field.prototype.setOption = function setOption(name, value, ifNotSet) { + if (name === "packed") // clear cached before setting + this._packed = null; + return ReflectionObject.prototype.setOption.call(this, name, value, ifNotSet); +}; + +/** + * Field descriptor. + * @interface IField + * @property {string} [rule="optional"] Field rule + * @property {string} type Field type + * @property {number} id Field id + * @property {Object.} [options] Field options + */ + +/** + * Extension field descriptor. + * @interface IExtensionField + * @extends IField + * @property {string} extend Extended type + */ + +/** + * Converts this field to a field descriptor. + * @param {IToJSONOptions} [toJSONOptions] JSON conversion options + * @returns {IField} Field descriptor + */ +Field.prototype.toJSON = function toJSON(toJSONOptions) { + var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false; + return util.toObject([ + "rule" , this.rule !== "optional" && this.rule || undefined, + "type" , this.type, + "id" , this.id, + "extend" , this.extend, + "options" , this.options, + "comment" , keepComments ? this.comment : undefined + ]); +}; + +/** + * Resolves this field's type references. + * @returns {Field} `this` + * @throws {Error} If any reference cannot be resolved + */ +Field.prototype.resolve = function resolve() { + + if (this.resolved) + return this; + + if ((this.typeDefault = types.defaults[this.type]) === undefined) { // if not a basic type, resolve it + this.resolvedType = (this.declaringField ? this.declaringField.parent : this.parent).lookupTypeOrEnum(this.type); + if (this.resolvedType instanceof Type) + this.typeDefault = null; + else // instanceof Enum + this.typeDefault = this.resolvedType.values[Object.keys(this.resolvedType.values)[0]]; // first defined + } + + // use explicitly set default value if present + if (this.options && this.options["default"] != null) { + this.typeDefault = this.options["default"]; + if (this.resolvedType instanceof Enum && typeof this.typeDefault === "string") + this.typeDefault = this.resolvedType.values[this.typeDefault]; + } + + // remove unnecessary options + if (this.options) { + if (this.options.packed === true || this.options.packed !== undefined && this.resolvedType && !(this.resolvedType instanceof Enum)) + delete this.options.packed; + if (!Object.keys(this.options).length) + this.options = undefined; + } + + // convert to internal data type if necesssary + if (this.long) { + this.typeDefault = util.Long.fromNumber(this.typeDefault, this.type.charAt(0) === "u"); + + /* istanbul ignore else */ + if (Object.freeze) + Object.freeze(this.typeDefault); // long instances are meant to be immutable anyway (i.e. use small int cache that even requires it) + + } else if (this.bytes && typeof this.typeDefault === "string") { + var buf; + if (util.base64.test(this.typeDefault)) + util.base64.decode(this.typeDefault, buf = util.newBuffer(util.base64.length(this.typeDefault)), 0); + else + util.utf8.write(this.typeDefault, buf = util.newBuffer(util.utf8.length(this.typeDefault)), 0); + this.typeDefault = buf; + } + + // take special care of maps and repeated fields + if (this.map) + this.defaultValue = util.emptyObject; + else if (this.repeated) + this.defaultValue = util.emptyArray; + else + this.defaultValue = this.typeDefault; + + // ensure proper value on prototype + if (this.parent instanceof Type) + this.parent.ctor.prototype[this.name] = this.defaultValue; + + return ReflectionObject.prototype.resolve.call(this); +}; + +/** + * Decorator function as returned by {@link Field.d} and {@link MapField.d} (TypeScript). + * @typedef FieldDecorator + * @type {function} + * @param {Object} prototype Target prototype + * @param {string} fieldName Field name + * @returns {undefined} + */ + +/** + * Field decorator (TypeScript). + * @name Field.d + * @function + * @param {number} fieldId Field id + * @param {"double"|"float"|"int32"|"uint32"|"sint32"|"fixed32"|"sfixed32"|"int64"|"uint64"|"sint64"|"fixed64"|"sfixed64"|"string"|"bool"|"bytes"|Object} fieldType Field type + * @param {"optional"|"required"|"repeated"} [fieldRule="optional"] Field rule + * @param {T} [defaultValue] Default value + * @returns {FieldDecorator} Decorator function + * @template T extends number | number[] | Long | Long[] | string | string[] | boolean | boolean[] | Uint8Array | Uint8Array[] | Buffer | Buffer[] + */ +Field.d = function decorateField(fieldId, fieldType, fieldRule, defaultValue) { + + // submessage: decorate the submessage and use its name as the type + if (typeof fieldType === "function") + fieldType = util.decorateType(fieldType).name; + + // enum reference: create a reflected copy of the enum and keep reuseing it + else if (fieldType && typeof fieldType === "object") + fieldType = util.decorateEnum(fieldType).name; + + return function fieldDecorator(prototype, fieldName) { + util.decorateType(prototype.constructor) + .add(new Field(fieldName, fieldId, fieldType, fieldRule, { "default": defaultValue })); + }; +}; + +/** + * Field decorator (TypeScript). + * @name Field.d + * @function + * @param {number} fieldId Field id + * @param {Constructor|string} fieldType Field type + * @param {"optional"|"required"|"repeated"} [fieldRule="optional"] Field rule + * @returns {FieldDecorator} Decorator function + * @template T extends Message + * @variation 2 + */ +// like Field.d but without a default value + +// Sets up cyclic dependencies (called in index-light) +Field._configure = function configure(Type_) { + Type = Type_; +}; + +},{"15":15,"24":24,"36":36,"37":37}],17:[function(require,module,exports){ +"use strict"; +var protobuf = module.exports = require(18); + +protobuf.build = "light"; + +/** + * A node-style callback as used by {@link load} and {@link Root#load}. + * @typedef LoadCallback + * @type {function} + * @param {Error|null} error Error, if any, otherwise `null` + * @param {Root} [root] Root, if there hasn't been an error + * @returns {undefined} + */ + +/** + * Loads one or multiple .proto or preprocessed .json files into a common root namespace and calls the callback. + * @param {string|string[]} filename One or multiple files to load + * @param {Root} root Root namespace, defaults to create a new one if omitted. + * @param {LoadCallback} callback Callback function + * @returns {undefined} + * @see {@link Root#load} + */ +function load(filename, root, callback) { + if (typeof root === "function") { + callback = root; + root = new protobuf.Root(); + } else if (!root) + root = new protobuf.Root(); + return root.load(filename, callback); +} + +/** + * Loads one or multiple .proto or preprocessed .json files into a common root namespace and calls the callback. + * @name load + * @function + * @param {string|string[]} filename One or multiple files to load + * @param {LoadCallback} callback Callback function + * @returns {undefined} + * @see {@link Root#load} + * @variation 2 + */ +// function load(filename:string, callback:LoadCallback):undefined + +/** + * Loads one or multiple .proto or preprocessed .json files into a common root namespace and returns a promise. + * @name load + * @function + * @param {string|string[]} filename One or multiple files to load + * @param {Root} [root] Root namespace, defaults to create a new one if omitted. + * @returns {Promise} Promise + * @see {@link Root#load} + * @variation 3 + */ +// function load(filename:string, [root:Root]):Promise + +protobuf.load = load; + +/** + * Synchronously loads one or multiple .proto or preprocessed .json files into a common root namespace (node only). + * @param {string|string[]} filename One or multiple files to load + * @param {Root} [root] Root namespace, defaults to create a new one if omitted. + * @returns {Root} Root namespace + * @throws {Error} If synchronous fetching is not supported (i.e. in browsers) or if a file's syntax is invalid + * @see {@link Root#loadSync} + */ +function loadSync(filename, root) { + if (!root) + root = new protobuf.Root(); + return root.loadSync(filename); +} + +protobuf.loadSync = loadSync; + +// Serialization +protobuf.encoder = require(14); +protobuf.decoder = require(13); +protobuf.verifier = require(40); +protobuf.converter = require(12); + +// Reflection +protobuf.ReflectionObject = require(24); +protobuf.Namespace = require(23); +protobuf.Root = require(29); +protobuf.Enum = require(15); +protobuf.Type = require(35); +protobuf.Field = require(16); +protobuf.OneOf = require(25); +protobuf.MapField = require(20); +protobuf.Service = require(33); +protobuf.Method = require(22); + +// Runtime +protobuf.Message = require(21); +protobuf.wrappers = require(41); + +// Utility +protobuf.types = require(36); +protobuf.util = require(37); + +// Set up possibly cyclic reflection dependencies +protobuf.ReflectionObject._configure(protobuf.Root); +protobuf.Namespace._configure(protobuf.Type, protobuf.Service, protobuf.Enum); +protobuf.Root._configure(protobuf.Type); +protobuf.Field._configure(protobuf.Type); + +},{"12":12,"13":13,"14":14,"15":15,"16":16,"18":18,"20":20,"21":21,"22":22,"23":23,"24":24,"25":25,"29":29,"33":33,"35":35,"36":36,"37":37,"40":40,"41":41}],18:[function(require,module,exports){ +"use strict"; +var protobuf = exports; + +/** + * Build type, one of `"full"`, `"light"` or `"minimal"`. + * @name build + * @type {string} + * @const + */ +protobuf.build = "minimal"; + +// Serialization +protobuf.Writer = require(42); +protobuf.BufferWriter = require(43); +protobuf.Reader = require(27); +protobuf.BufferReader = require(28); + +// Utility +protobuf.util = require(39); +protobuf.rpc = require(31); +protobuf.roots = require(30); +protobuf.configure = configure; + +/* istanbul ignore next */ +/** + * Reconfigures the library according to the environment. + * @returns {undefined} + */ +function configure() { + protobuf.Reader._configure(protobuf.BufferReader); + protobuf.util._configure(); +} + +// Set up buffer utility according to the environment +protobuf.Writer._configure(protobuf.BufferWriter); +configure(); + +},{"27":27,"28":28,"30":30,"31":31,"39":39,"42":42,"43":43}],19:[function(require,module,exports){ +"use strict"; +var protobuf = module.exports = require(17); + +protobuf.build = "full"; + +// Parser +protobuf.tokenize = require(34); +protobuf.parse = require(26); +protobuf.common = require(11); + +// Configure parser +protobuf.Root._configure(protobuf.Type, protobuf.parse, protobuf.common); + +},{"11":11,"17":17,"26":26,"34":34}],20:[function(require,module,exports){ +"use strict"; +module.exports = MapField; + +// extends Field +var Field = require(16); +((MapField.prototype = Object.create(Field.prototype)).constructor = MapField).className = "MapField"; + +var types = require(36), + util = require(37); + +/** + * Constructs a new map field instance. + * @classdesc Reflected map field. + * @extends FieldBase + * @constructor + * @param {string} name Unique name within its namespace + * @param {number} id Unique id within its namespace + * @param {string} keyType Key type + * @param {string} type Value type + * @param {Object.} [options] Declared options + * @param {string} [comment] Comment associated with this field + */ +function MapField(name, id, keyType, type, options, comment) { + Field.call(this, name, id, type, undefined, undefined, options, comment); + + /* istanbul ignore if */ + if (!util.isString(keyType)) + throw TypeError("keyType must be a string"); + + /** + * Key type. + * @type {string} + */ + this.keyType = keyType; // toJSON, marker + + /** + * Resolved key type if not a basic type. + * @type {ReflectionObject|null} + */ + this.resolvedKeyType = null; + + // Overrides Field#map + this.map = true; +} + +/** + * Map field descriptor. + * @interface IMapField + * @extends {IField} + * @property {string} keyType Key type + */ + +/** + * Extension map field descriptor. + * @interface IExtensionMapField + * @extends IMapField + * @property {string} extend Extended type + */ + +/** + * Constructs a map field from a map field descriptor. + * @param {string} name Field name + * @param {IMapField} json Map field descriptor + * @returns {MapField} Created map field + * @throws {TypeError} If arguments are invalid + */ +MapField.fromJSON = function fromJSON(name, json) { + return new MapField(name, json.id, json.keyType, json.type, json.options, json.comment); +}; + +/** + * Converts this map field to a map field descriptor. + * @param {IToJSONOptions} [toJSONOptions] JSON conversion options + * @returns {IMapField} Map field descriptor + */ +MapField.prototype.toJSON = function toJSON(toJSONOptions) { + var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false; + return util.toObject([ + "keyType" , this.keyType, + "type" , this.type, + "id" , this.id, + "extend" , this.extend, + "options" , this.options, + "comment" , keepComments ? this.comment : undefined + ]); +}; + +/** + * @override + */ +MapField.prototype.resolve = function resolve() { + if (this.resolved) + return this; + + // Besides a value type, map fields have a key type that may be "any scalar type except for floating point types and bytes" + if (types.mapKey[this.keyType] === undefined) + throw Error("invalid key type: " + this.keyType); + + return Field.prototype.resolve.call(this); +}; + +/** + * Map field decorator (TypeScript). + * @name MapField.d + * @function + * @param {number} fieldId Field id + * @param {"int32"|"uint32"|"sint32"|"fixed32"|"sfixed32"|"int64"|"uint64"|"sint64"|"fixed64"|"sfixed64"|"bool"|"string"} fieldKeyType Field key type + * @param {"double"|"float"|"int32"|"uint32"|"sint32"|"fixed32"|"sfixed32"|"int64"|"uint64"|"sint64"|"fixed64"|"sfixed64"|"bool"|"string"|"bytes"|Object|Constructor<{}>} fieldValueType Field value type + * @returns {FieldDecorator} Decorator function + * @template T extends { [key: string]: number | Long | string | boolean | Uint8Array | Buffer | number[] | Message<{}> } + */ +MapField.d = function decorateMapField(fieldId, fieldKeyType, fieldValueType) { + + // submessage value: decorate the submessage and use its name as the type + if (typeof fieldValueType === "function") + fieldValueType = util.decorateType(fieldValueType).name; + + // enum reference value: create a reflected copy of the enum and keep reuseing it + else if (fieldValueType && typeof fieldValueType === "object") + fieldValueType = util.decorateEnum(fieldValueType).name; + + return function mapFieldDecorator(prototype, fieldName) { + util.decorateType(prototype.constructor) + .add(new MapField(fieldName, fieldId, fieldKeyType, fieldValueType)); + }; +}; + +},{"16":16,"36":36,"37":37}],21:[function(require,module,exports){ +"use strict"; +module.exports = Message; + +var util = require(39); + +/** + * Constructs a new message instance. + * @classdesc Abstract runtime message. + * @constructor + * @param {Properties} [properties] Properties to set + * @template T extends object = object + */ +function Message(properties) { + // not used internally + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + this[keys[i]] = properties[keys[i]]; +} + +/** + * Reference to the reflected type. + * @name Message.$type + * @type {Type} + * @readonly + */ + +/** + * Reference to the reflected type. + * @name Message#$type + * @type {Type} + * @readonly + */ + +/*eslint-disable valid-jsdoc*/ + +/** + * Creates a new message of this type using the specified properties. + * @param {Object.} [properties] Properties to set + * @returns {Message} Message instance + * @template T extends Message + * @this Constructor + */ +Message.create = function create(properties) { + return this.$type.create(properties); +}; + +/** + * Encodes a message of this type. + * @param {T|Object.} message Message to encode + * @param {Writer} [writer] Writer to use + * @returns {Writer} Writer + * @template T extends Message + * @this Constructor + */ +Message.encode = function encode(message, writer) { + return this.$type.encode(message, writer); +}; + +/** + * Encodes a message of this type preceeded by its length as a varint. + * @param {T|Object.} message Message to encode + * @param {Writer} [writer] Writer to use + * @returns {Writer} Writer + * @template T extends Message + * @this Constructor + */ +Message.encodeDelimited = function encodeDelimited(message, writer) { + return this.$type.encodeDelimited(message, writer); +}; + +/** + * Decodes a message of this type. + * @name Message.decode + * @function + * @param {Reader|Uint8Array} reader Reader or buffer to decode + * @returns {T} Decoded message + * @template T extends Message + * @this Constructor + */ +Message.decode = function decode(reader) { + return this.$type.decode(reader); +}; + +/** + * Decodes a message of this type preceeded by its length as a varint. + * @name Message.decodeDelimited + * @function + * @param {Reader|Uint8Array} reader Reader or buffer to decode + * @returns {T} Decoded message + * @template T extends Message + * @this Constructor + */ +Message.decodeDelimited = function decodeDelimited(reader) { + return this.$type.decodeDelimited(reader); +}; + +/** + * Verifies a message of this type. + * @name Message.verify + * @function + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ +Message.verify = function verify(message) { + return this.$type.verify(message); +}; + +/** + * Creates a new message of this type from a plain object. Also converts values to their respective internal types. + * @param {Object.} object Plain object + * @returns {T} Message instance + * @template T extends Message + * @this Constructor + */ +Message.fromObject = function fromObject(object) { + return this.$type.fromObject(object); +}; + +/** + * Creates a plain object from a message of this type. Also converts values to other types if specified. + * @param {T} message Message instance + * @param {IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + * @template T extends Message + * @this Constructor + */ +Message.toObject = function toObject(message, options) { + return this.$type.toObject(message, options); +}; + +/** + * Converts this message to JSON. + * @returns {Object.} JSON object + */ +Message.prototype.toJSON = function toJSON() { + return this.$type.toObject(this, util.toJSONOptions); +}; + +/*eslint-enable valid-jsdoc*/ +},{"39":39}],22:[function(require,module,exports){ +"use strict"; +module.exports = Method; + +// extends ReflectionObject +var ReflectionObject = require(24); +((Method.prototype = Object.create(ReflectionObject.prototype)).constructor = Method).className = "Method"; + +var util = require(37); + +/** + * Constructs a new service method instance. + * @classdesc Reflected service method. + * @extends ReflectionObject + * @constructor + * @param {string} name Method name + * @param {string|undefined} type Method type, usually `"rpc"` + * @param {string} requestType Request message type + * @param {string} responseType Response message type + * @param {boolean|Object.} [requestStream] Whether the request is streamed + * @param {boolean|Object.} [responseStream] Whether the response is streamed + * @param {Object.} [options] Declared options + * @param {string} [comment] The comment for this method + */ +function Method(name, type, requestType, responseType, requestStream, responseStream, options, comment) { + + /* istanbul ignore next */ + if (util.isObject(requestStream)) { + options = requestStream; + requestStream = responseStream = undefined; + } else if (util.isObject(responseStream)) { + options = responseStream; + responseStream = undefined; + } + + /* istanbul ignore if */ + if (!(type === undefined || util.isString(type))) + throw TypeError("type must be a string"); + + /* istanbul ignore if */ + if (!util.isString(requestType)) + throw TypeError("requestType must be a string"); + + /* istanbul ignore if */ + if (!util.isString(responseType)) + throw TypeError("responseType must be a string"); + + ReflectionObject.call(this, name, options); + + /** + * Method type. + * @type {string} + */ + this.type = type || "rpc"; // toJSON + + /** + * Request type. + * @type {string} + */ + this.requestType = requestType; // toJSON, marker + + /** + * Whether requests are streamed or not. + * @type {boolean|undefined} + */ + this.requestStream = requestStream ? true : undefined; // toJSON + + /** + * Response type. + * @type {string} + */ + this.responseType = responseType; // toJSON + + /** + * Whether responses are streamed or not. + * @type {boolean|undefined} + */ + this.responseStream = responseStream ? true : undefined; // toJSON + + /** + * Resolved request type. + * @type {Type|null} + */ + this.resolvedRequestType = null; + + /** + * Resolved response type. + * @type {Type|null} + */ + this.resolvedResponseType = null; + + /** + * Comment for this method + * @type {string|null} + */ + this.comment = comment; +} + +/** + * Method descriptor. + * @interface IMethod + * @property {string} [type="rpc"] Method type + * @property {string} requestType Request type + * @property {string} responseType Response type + * @property {boolean} [requestStream=false] Whether requests are streamed + * @property {boolean} [responseStream=false] Whether responses are streamed + * @property {Object.} [options] Method options + */ + +/** + * Constructs a method from a method descriptor. + * @param {string} name Method name + * @param {IMethod} json Method descriptor + * @returns {Method} Created method + * @throws {TypeError} If arguments are invalid + */ +Method.fromJSON = function fromJSON(name, json) { + return new Method(name, json.type, json.requestType, json.responseType, json.requestStream, json.responseStream, json.options, json.comment); +}; + +/** + * Converts this method to a method descriptor. + * @param {IToJSONOptions} [toJSONOptions] JSON conversion options + * @returns {IMethod} Method descriptor + */ +Method.prototype.toJSON = function toJSON(toJSONOptions) { + var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false; + return util.toObject([ + "type" , this.type !== "rpc" && /* istanbul ignore next */ this.type || undefined, + "requestType" , this.requestType, + "requestStream" , this.requestStream, + "responseType" , this.responseType, + "responseStream" , this.responseStream, + "options" , this.options, + "comment" , keepComments ? this.comment : undefined + ]); +}; + +/** + * @override + */ +Method.prototype.resolve = function resolve() { + + /* istanbul ignore if */ + if (this.resolved) + return this; + + this.resolvedRequestType = this.parent.lookupType(this.requestType); + this.resolvedResponseType = this.parent.lookupType(this.responseType); + + return ReflectionObject.prototype.resolve.call(this); +}; + +},{"24":24,"37":37}],23:[function(require,module,exports){ +"use strict"; +module.exports = Namespace; + +// extends ReflectionObject +var ReflectionObject = require(24); +((Namespace.prototype = Object.create(ReflectionObject.prototype)).constructor = Namespace).className = "Namespace"; + +var Field = require(16), + util = require(37); + +var Type, // cyclic + Service, + Enum; + +/** + * Constructs a new namespace instance. + * @name Namespace + * @classdesc Reflected namespace. + * @extends NamespaceBase + * @constructor + * @param {string} name Namespace name + * @param {Object.} [options] Declared options + */ + +/** + * Constructs a namespace from JSON. + * @memberof Namespace + * @function + * @param {string} name Namespace name + * @param {Object.} json JSON object + * @returns {Namespace} Created namespace + * @throws {TypeError} If arguments are invalid + */ +Namespace.fromJSON = function fromJSON(name, json) { + return new Namespace(name, json.options).addJSON(json.nested); +}; + +/** + * Converts an array of reflection objects to JSON. + * @memberof Namespace + * @param {ReflectionObject[]} array Object array + * @param {IToJSONOptions} [toJSONOptions] JSON conversion options + * @returns {Object.|undefined} JSON object or `undefined` when array is empty + */ +function arrayToJSON(array, toJSONOptions) { + if (!(array && array.length)) + return undefined; + var obj = {}; + for (var i = 0; i < array.length; ++i) + obj[array[i].name] = array[i].toJSON(toJSONOptions); + return obj; +} + +Namespace.arrayToJSON = arrayToJSON; + +/** + * Tests if the specified id is reserved. + * @param {Array.|undefined} reserved Array of reserved ranges and names + * @param {number} id Id to test + * @returns {boolean} `true` if reserved, otherwise `false` + */ +Namespace.isReservedId = function isReservedId(reserved, id) { + if (reserved) + for (var i = 0; i < reserved.length; ++i) + if (typeof reserved[i] !== "string" && reserved[i][0] <= id && reserved[i][1] >= id) + return true; + return false; +}; + +/** + * Tests if the specified name is reserved. + * @param {Array.|undefined} reserved Array of reserved ranges and names + * @param {string} name Name to test + * @returns {boolean} `true` if reserved, otherwise `false` + */ +Namespace.isReservedName = function isReservedName(reserved, name) { + if (reserved) + for (var i = 0; i < reserved.length; ++i) + if (reserved[i] === name) + return true; + return false; +}; + +/** + * Not an actual constructor. Use {@link Namespace} instead. + * @classdesc Base class of all reflection objects containing nested objects. This is not an actual class but here for the sake of having consistent type definitions. + * @exports NamespaceBase + * @extends ReflectionObject + * @abstract + * @constructor + * @param {string} name Namespace name + * @param {Object.} [options] Declared options + * @see {@link Namespace} + */ +function Namespace(name, options) { + ReflectionObject.call(this, name, options); + + /** + * Nested objects by name. + * @type {Object.|undefined} + */ + this.nested = undefined; // toJSON + + /** + * Cached nested objects as an array. + * @type {ReflectionObject[]|null} + * @private + */ + this._nestedArray = null; +} + +function clearCache(namespace) { + namespace._nestedArray = null; + return namespace; +} + +/** + * Nested objects of this namespace as an array for iteration. + * @name NamespaceBase#nestedArray + * @type {ReflectionObject[]} + * @readonly + */ +Object.defineProperty(Namespace.prototype, "nestedArray", { + get: function() { + return this._nestedArray || (this._nestedArray = util.toArray(this.nested)); + } +}); + +/** + * Namespace descriptor. + * @interface INamespace + * @property {Object.} [options] Namespace options + * @property {Object.} [nested] Nested object descriptors + */ + +/** + * Any extension field descriptor. + * @typedef AnyExtensionField + * @type {IExtensionField|IExtensionMapField} + */ + +/** + * Any nested object descriptor. + * @typedef AnyNestedObject + * @type {IEnum|IType|IService|AnyExtensionField|INamespace} + */ +// ^ BEWARE: VSCode hangs forever when using more than 5 types (that's why AnyExtensionField exists in the first place) + +/** + * Converts this namespace to a namespace descriptor. + * @param {IToJSONOptions} [toJSONOptions] JSON conversion options + * @returns {INamespace} Namespace descriptor + */ +Namespace.prototype.toJSON = function toJSON(toJSONOptions) { + return util.toObject([ + "options" , this.options, + "nested" , arrayToJSON(this.nestedArray, toJSONOptions) + ]); +}; + +/** + * Adds nested objects to this namespace from nested object descriptors. + * @param {Object.} nestedJson Any nested object descriptors + * @returns {Namespace} `this` + */ +Namespace.prototype.addJSON = function addJSON(nestedJson) { + var ns = this; + /* istanbul ignore else */ + if (nestedJson) { + for (var names = Object.keys(nestedJson), i = 0, nested; i < names.length; ++i) { + nested = nestedJson[names[i]]; + ns.add( // most to least likely + ( nested.fields !== undefined + ? Type.fromJSON + : nested.values !== undefined + ? Enum.fromJSON + : nested.methods !== undefined + ? Service.fromJSON + : nested.id !== undefined + ? Field.fromJSON + : Namespace.fromJSON )(names[i], nested) + ); + } + } + return this; +}; + +/** + * Gets the nested object of the specified name. + * @param {string} name Nested object name + * @returns {ReflectionObject|null} The reflection object or `null` if it doesn't exist + */ +Namespace.prototype.get = function get(name) { + return this.nested && this.nested[name] + || null; +}; + +/** + * Gets the values of the nested {@link Enum|enum} of the specified name. + * This methods differs from {@link Namespace#get|get} in that it returns an enum's values directly and throws instead of returning `null`. + * @param {string} name Nested enum name + * @returns {Object.} Enum values + * @throws {Error} If there is no such enum + */ +Namespace.prototype.getEnum = function getEnum(name) { + if (this.nested && this.nested[name] instanceof Enum) + return this.nested[name].values; + throw Error("no such enum: " + name); +}; + +/** + * Adds a nested object to this namespace. + * @param {ReflectionObject} object Nested object to add + * @returns {Namespace} `this` + * @throws {TypeError} If arguments are invalid + * @throws {Error} If there is already a nested object with this name + */ +Namespace.prototype.add = function add(object) { + + if (!(object instanceof Field && object.extend !== undefined || object instanceof Type || object instanceof Enum || object instanceof Service || object instanceof Namespace)) + throw TypeError("object must be a valid nested object"); + + if (!this.nested) + this.nested = {}; + else { + var prev = this.get(object.name); + if (prev) { + if (prev instanceof Namespace && object instanceof Namespace && !(prev instanceof Type || prev instanceof Service)) { + // replace plain namespace but keep existing nested elements and options + var nested = prev.nestedArray; + for (var i = 0; i < nested.length; ++i) + object.add(nested[i]); + this.remove(prev); + if (!this.nested) + this.nested = {}; + object.setOptions(prev.options, true); + + } else + throw Error("duplicate name '" + object.name + "' in " + this); + } + } + this.nested[object.name] = object; + object.onAdd(this); + return clearCache(this); +}; + +/** + * Removes a nested object from this namespace. + * @param {ReflectionObject} object Nested object to remove + * @returns {Namespace} `this` + * @throws {TypeError} If arguments are invalid + * @throws {Error} If `object` is not a member of this namespace + */ +Namespace.prototype.remove = function remove(object) { + + if (!(object instanceof ReflectionObject)) + throw TypeError("object must be a ReflectionObject"); + if (object.parent !== this) + throw Error(object + " is not a member of " + this); + + delete this.nested[object.name]; + if (!Object.keys(this.nested).length) + this.nested = undefined; + + object.onRemove(this); + return clearCache(this); +}; + +/** + * Defines additial namespaces within this one if not yet existing. + * @param {string|string[]} path Path to create + * @param {*} [json] Nested types to create from JSON + * @returns {Namespace} Pointer to the last namespace created or `this` if path is empty + */ +Namespace.prototype.define = function define(path, json) { + + if (util.isString(path)) + path = path.split("."); + else if (!Array.isArray(path)) + throw TypeError("illegal path"); + if (path && path.length && path[0] === "") + throw Error("path must be relative"); + + var ptr = this; + while (path.length > 0) { + var part = path.shift(); + if (ptr.nested && ptr.nested[part]) { + ptr = ptr.nested[part]; + if (!(ptr instanceof Namespace)) + throw Error("path conflicts with non-namespace objects"); + } else + ptr.add(ptr = new Namespace(part)); + } + if (json) + ptr.addJSON(json); + return ptr; +}; + +/** + * Resolves this namespace's and all its nested objects' type references. Useful to validate a reflection tree, but comes at a cost. + * @returns {Namespace} `this` + */ +Namespace.prototype.resolveAll = function resolveAll() { + var nested = this.nestedArray, i = 0; + while (i < nested.length) + if (nested[i] instanceof Namespace) + nested[i++].resolveAll(); + else + nested[i++].resolve(); + return this.resolve(); +}; + +/** + * Recursively looks up the reflection object matching the specified path in the scope of this namespace. + * @param {string|string[]} path Path to look up + * @param {*|Array.<*>} filterTypes Filter types, any combination of the constructors of `protobuf.Type`, `protobuf.Enum`, `protobuf.Service` etc. + * @param {boolean} [parentAlreadyChecked=false] If known, whether the parent has already been checked + * @returns {ReflectionObject|null} Looked up object or `null` if none could be found + */ +Namespace.prototype.lookup = function lookup(path, filterTypes, parentAlreadyChecked) { + + /* istanbul ignore next */ + if (typeof filterTypes === "boolean") { + parentAlreadyChecked = filterTypes; + filterTypes = undefined; + } else if (filterTypes && !Array.isArray(filterTypes)) + filterTypes = [ filterTypes ]; + + if (util.isString(path) && path.length) { + if (path === ".") + return this.root; + path = path.split("."); + } else if (!path.length) + return this; + + // Start at root if path is absolute + if (path[0] === "") + return this.root.lookup(path.slice(1), filterTypes); + + // Test if the first part matches any nested object, and if so, traverse if path contains more + var found = this.get(path[0]); + if (found) { + if (path.length === 1) { + if (!filterTypes || filterTypes.indexOf(found.constructor) > -1) + return found; + } else if (found instanceof Namespace && (found = found.lookup(path.slice(1), filterTypes, true))) + return found; + + // Otherwise try each nested namespace + } else + for (var i = 0; i < this.nestedArray.length; ++i) + if (this._nestedArray[i] instanceof Namespace && (found = this._nestedArray[i].lookup(path, filterTypes, true))) + return found; + + // If there hasn't been a match, try again at the parent + if (this.parent === null || parentAlreadyChecked) + return null; + return this.parent.lookup(path, filterTypes); +}; + +/** + * Looks up the reflection object at the specified path, relative to this namespace. + * @name NamespaceBase#lookup + * @function + * @param {string|string[]} path Path to look up + * @param {boolean} [parentAlreadyChecked=false] Whether the parent has already been checked + * @returns {ReflectionObject|null} Looked up object or `null` if none could be found + * @variation 2 + */ +// lookup(path: string, [parentAlreadyChecked: boolean]) + +/** + * Looks up the {@link Type|type} at the specified path, relative to this namespace. + * Besides its signature, this methods differs from {@link Namespace#lookup|lookup} in that it throws instead of returning `null`. + * @param {string|string[]} path Path to look up + * @returns {Type} Looked up type + * @throws {Error} If `path` does not point to a type + */ +Namespace.prototype.lookupType = function lookupType(path) { + var found = this.lookup(path, [ Type ]); + if (!found) + throw Error("no such type: " + path); + return found; +}; + +/** + * Looks up the values of the {@link Enum|enum} at the specified path, relative to this namespace. + * Besides its signature, this methods differs from {@link Namespace#lookup|lookup} in that it throws instead of returning `null`. + * @param {string|string[]} path Path to look up + * @returns {Enum} Looked up enum + * @throws {Error} If `path` does not point to an enum + */ +Namespace.prototype.lookupEnum = function lookupEnum(path) { + var found = this.lookup(path, [ Enum ]); + if (!found) + throw Error("no such Enum '" + path + "' in " + this); + return found; +}; + +/** + * Looks up the {@link Type|type} or {@link Enum|enum} at the specified path, relative to this namespace. + * Besides its signature, this methods differs from {@link Namespace#lookup|lookup} in that it throws instead of returning `null`. + * @param {string|string[]} path Path to look up + * @returns {Type} Looked up type or enum + * @throws {Error} If `path` does not point to a type or enum + */ +Namespace.prototype.lookupTypeOrEnum = function lookupTypeOrEnum(path) { + var found = this.lookup(path, [ Type, Enum ]); + if (!found) + throw Error("no such Type or Enum '" + path + "' in " + this); + return found; +}; + +/** + * Looks up the {@link Service|service} at the specified path, relative to this namespace. + * Besides its signature, this methods differs from {@link Namespace#lookup|lookup} in that it throws instead of returning `null`. + * @param {string|string[]} path Path to look up + * @returns {Service} Looked up service + * @throws {Error} If `path` does not point to a service + */ +Namespace.prototype.lookupService = function lookupService(path) { + var found = this.lookup(path, [ Service ]); + if (!found) + throw Error("no such Service '" + path + "' in " + this); + return found; +}; + +// Sets up cyclic dependencies (called in index-light) +Namespace._configure = function(Type_, Service_, Enum_) { + Type = Type_; + Service = Service_; + Enum = Enum_; +}; + +},{"16":16,"24":24,"37":37}],24:[function(require,module,exports){ +"use strict"; +module.exports = ReflectionObject; + +ReflectionObject.className = "ReflectionObject"; + +var util = require(37); + +var Root; // cyclic + +/** + * Constructs a new reflection object instance. + * @classdesc Base class of all reflection objects. + * @constructor + * @param {string} name Object name + * @param {Object.} [options] Declared options + * @abstract + */ +function ReflectionObject(name, options) { + + if (!util.isString(name)) + throw TypeError("name must be a string"); + + if (options && !util.isObject(options)) + throw TypeError("options must be an object"); + + /** + * Options. + * @type {Object.|undefined} + */ + this.options = options; // toJSON + + /** + * Unique name within its namespace. + * @type {string} + */ + this.name = name; + + /** + * Parent namespace. + * @type {Namespace|null} + */ + this.parent = null; + + /** + * Whether already resolved or not. + * @type {boolean} + */ + this.resolved = false; + + /** + * Comment text, if any. + * @type {string|null} + */ + this.comment = null; + + /** + * Defining file name. + * @type {string|null} + */ + this.filename = null; +} + +Object.defineProperties(ReflectionObject.prototype, { + + /** + * Reference to the root namespace. + * @name ReflectionObject#root + * @type {Root} + * @readonly + */ + root: { + get: function() { + var ptr = this; + while (ptr.parent !== null) + ptr = ptr.parent; + return ptr; + } + }, + + /** + * Full name including leading dot. + * @name ReflectionObject#fullName + * @type {string} + * @readonly + */ + fullName: { + get: function() { + var path = [ this.name ], + ptr = this.parent; + while (ptr) { + path.unshift(ptr.name); + ptr = ptr.parent; + } + return path.join("."); + } + } +}); + +/** + * Converts this reflection object to its descriptor representation. + * @returns {Object.} Descriptor + * @abstract + */ +ReflectionObject.prototype.toJSON = /* istanbul ignore next */ function toJSON() { + throw Error(); // not implemented, shouldn't happen +}; + +/** + * Called when this object is added to a parent. + * @param {ReflectionObject} parent Parent added to + * @returns {undefined} + */ +ReflectionObject.prototype.onAdd = function onAdd(parent) { + if (this.parent && this.parent !== parent) + this.parent.remove(this); + this.parent = parent; + this.resolved = false; + var root = parent.root; + if (root instanceof Root) + root._handleAdd(this); +}; + +/** + * Called when this object is removed from a parent. + * @param {ReflectionObject} parent Parent removed from + * @returns {undefined} + */ +ReflectionObject.prototype.onRemove = function onRemove(parent) { + var root = parent.root; + if (root instanceof Root) + root._handleRemove(this); + this.parent = null; + this.resolved = false; +}; + +/** + * Resolves this objects type references. + * @returns {ReflectionObject} `this` + */ +ReflectionObject.prototype.resolve = function resolve() { + if (this.resolved) + return this; + if (this.root instanceof Root) + this.resolved = true; // only if part of a root + return this; +}; + +/** + * Gets an option value. + * @param {string} name Option name + * @returns {*} Option value or `undefined` if not set + */ +ReflectionObject.prototype.getOption = function getOption(name) { + if (this.options) + return this.options[name]; + return undefined; +}; + +/** + * Sets an option. + * @param {string} name Option name + * @param {*} value Option value + * @param {boolean} [ifNotSet] Sets the option only if it isn't currently set + * @returns {ReflectionObject} `this` + */ +ReflectionObject.prototype.setOption = function setOption(name, value, ifNotSet) { + if (!ifNotSet || !this.options || this.options[name] === undefined) + (this.options || (this.options = {}))[name] = value; + return this; +}; + +/** + * Sets multiple options. + * @param {Object.} options Options to set + * @param {boolean} [ifNotSet] Sets an option only if it isn't currently set + * @returns {ReflectionObject} `this` + */ +ReflectionObject.prototype.setOptions = function setOptions(options, ifNotSet) { + if (options) + for (var keys = Object.keys(options), i = 0; i < keys.length; ++i) + this.setOption(keys[i], options[keys[i]], ifNotSet); + return this; +}; + +/** + * Converts this instance to its string representation. + * @returns {string} Class name[, space, full name] + */ +ReflectionObject.prototype.toString = function toString() { + var className = this.constructor.className, + fullName = this.fullName; + if (fullName.length) + return className + " " + fullName; + return className; +}; + +// Sets up cyclic dependencies (called in index-light) +ReflectionObject._configure = function(Root_) { + Root = Root_; +}; + +},{"37":37}],25:[function(require,module,exports){ +"use strict"; +module.exports = OneOf; + +// extends ReflectionObject +var ReflectionObject = require(24); +((OneOf.prototype = Object.create(ReflectionObject.prototype)).constructor = OneOf).className = "OneOf"; + +var Field = require(16), + util = require(37); + +/** + * Constructs a new oneof instance. + * @classdesc Reflected oneof. + * @extends ReflectionObject + * @constructor + * @param {string} name Oneof name + * @param {string[]|Object.} [fieldNames] Field names + * @param {Object.} [options] Declared options + * @param {string} [comment] Comment associated with this field + */ +function OneOf(name, fieldNames, options, comment) { + if (!Array.isArray(fieldNames)) { + options = fieldNames; + fieldNames = undefined; + } + ReflectionObject.call(this, name, options); + + /* istanbul ignore if */ + if (!(fieldNames === undefined || Array.isArray(fieldNames))) + throw TypeError("fieldNames must be an Array"); + + /** + * Field names that belong to this oneof. + * @type {string[]} + */ + this.oneof = fieldNames || []; // toJSON, marker + + /** + * Fields that belong to this oneof as an array for iteration. + * @type {Field[]} + * @readonly + */ + this.fieldsArray = []; // declared readonly for conformance, possibly not yet added to parent + + /** + * Comment for this field. + * @type {string|null} + */ + this.comment = comment; +} + +/** + * Oneof descriptor. + * @interface IOneOf + * @property {Array.} oneof Oneof field names + * @property {Object.} [options] Oneof options + */ + +/** + * Constructs a oneof from a oneof descriptor. + * @param {string} name Oneof name + * @param {IOneOf} json Oneof descriptor + * @returns {OneOf} Created oneof + * @throws {TypeError} If arguments are invalid + */ +OneOf.fromJSON = function fromJSON(name, json) { + return new OneOf(name, json.oneof, json.options, json.comment); +}; + +/** + * Converts this oneof to a oneof descriptor. + * @param {IToJSONOptions} [toJSONOptions] JSON conversion options + * @returns {IOneOf} Oneof descriptor + */ +OneOf.prototype.toJSON = function toJSON(toJSONOptions) { + var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false; + return util.toObject([ + "options" , this.options, + "oneof" , this.oneof, + "comment" , keepComments ? this.comment : undefined + ]); +}; + +/** + * Adds the fields of the specified oneof to the parent if not already done so. + * @param {OneOf} oneof The oneof + * @returns {undefined} + * @inner + * @ignore + */ +function addFieldsToParent(oneof) { + if (oneof.parent) + for (var i = 0; i < oneof.fieldsArray.length; ++i) + if (!oneof.fieldsArray[i].parent) + oneof.parent.add(oneof.fieldsArray[i]); +} + +/** + * Adds a field to this oneof and removes it from its current parent, if any. + * @param {Field} field Field to add + * @returns {OneOf} `this` + */ +OneOf.prototype.add = function add(field) { + + /* istanbul ignore if */ + if (!(field instanceof Field)) + throw TypeError("field must be a Field"); + + if (field.parent && field.parent !== this.parent) + field.parent.remove(field); + this.oneof.push(field.name); + this.fieldsArray.push(field); + field.partOf = this; // field.parent remains null + addFieldsToParent(this); + return this; +}; + +/** + * Removes a field from this oneof and puts it back to the oneof's parent. + * @param {Field} field Field to remove + * @returns {OneOf} `this` + */ +OneOf.prototype.remove = function remove(field) { + + /* istanbul ignore if */ + if (!(field instanceof Field)) + throw TypeError("field must be a Field"); + + var index = this.fieldsArray.indexOf(field); + + /* istanbul ignore if */ + if (index < 0) + throw Error(field + " is not a member of " + this); + + this.fieldsArray.splice(index, 1); + index = this.oneof.indexOf(field.name); + + /* istanbul ignore else */ + if (index > -1) // theoretical + this.oneof.splice(index, 1); + + field.partOf = null; + return this; +}; + +/** + * @override + */ +OneOf.prototype.onAdd = function onAdd(parent) { + ReflectionObject.prototype.onAdd.call(this, parent); + var self = this; + // Collect present fields + for (var i = 0; i < this.oneof.length; ++i) { + var field = parent.get(this.oneof[i]); + if (field && !field.partOf) { + field.partOf = self; + self.fieldsArray.push(field); + } + } + // Add not yet present fields + addFieldsToParent(this); +}; + +/** + * @override + */ +OneOf.prototype.onRemove = function onRemove(parent) { + for (var i = 0, field; i < this.fieldsArray.length; ++i) + if ((field = this.fieldsArray[i]).parent) + field.parent.remove(field); + ReflectionObject.prototype.onRemove.call(this, parent); +}; + +/** + * Decorator function as returned by {@link OneOf.d} (TypeScript). + * @typedef OneOfDecorator + * @type {function} + * @param {Object} prototype Target prototype + * @param {string} oneofName OneOf name + * @returns {undefined} + */ + +/** + * OneOf decorator (TypeScript). + * @function + * @param {...string} fieldNames Field names + * @returns {OneOfDecorator} Decorator function + * @template T extends string + */ +OneOf.d = function decorateOneOf() { + var fieldNames = new Array(arguments.length), + index = 0; + while (index < arguments.length) + fieldNames[index] = arguments[index++]; + return function oneOfDecorator(prototype, oneofName) { + util.decorateType(prototype.constructor) + .add(new OneOf(oneofName, fieldNames)); + Object.defineProperty(prototype, oneofName, { + get: util.oneOfGetter(fieldNames), + set: util.oneOfSetter(fieldNames) + }); + }; +}; + +},{"16":16,"24":24,"37":37}],26:[function(require,module,exports){ +"use strict"; +module.exports = parse; + +parse.filename = null; +parse.defaults = { keepCase: false }; + +var tokenize = require(34), + Root = require(29), + Type = require(35), + Field = require(16), + MapField = require(20), + OneOf = require(25), + Enum = require(15), + Service = require(33), + Method = require(22), + types = require(36), + util = require(37); + +var base10Re = /^[1-9][0-9]*$/, + base10NegRe = /^-?[1-9][0-9]*$/, + base16Re = /^0[x][0-9a-fA-F]+$/, + base16NegRe = /^-?0[x][0-9a-fA-F]+$/, + base8Re = /^0[0-7]+$/, + base8NegRe = /^-?0[0-7]+$/, + numberRe = /^(?![eE])[0-9]*(?:\.[0-9]*)?(?:[eE][+-]?[0-9]+)?$/, + nameRe = /^[a-zA-Z_][a-zA-Z_0-9]*$/, + typeRefRe = /^(?:\.?[a-zA-Z_][a-zA-Z_0-9]*)(?:\.[a-zA-Z_][a-zA-Z_0-9]*)*$/, + fqTypeRefRe = /^(?:\.[a-zA-Z_][a-zA-Z_0-9]*)+$/; + +/** + * Result object returned from {@link parse}. + * @interface IParserResult + * @property {string|undefined} package Package name, if declared + * @property {string[]|undefined} imports Imports, if any + * @property {string[]|undefined} weakImports Weak imports, if any + * @property {string|undefined} syntax Syntax, if specified (either `"proto2"` or `"proto3"`) + * @property {Root} root Populated root instance + */ + +/** + * Options modifying the behavior of {@link parse}. + * @interface IParseOptions + * @property {boolean} [keepCase=false] Keeps field casing instead of converting to camel case + * @property {boolean} [alternateCommentMode=false] Recognize double-slash comments in addition to doc-block comments. + */ + +/** + * Options modifying the behavior of JSON serialization. + * @interface IToJSONOptions + * @property {boolean} [keepComments=false] Serializes comments. + */ + +/** + * Parses the given .proto source and returns an object with the parsed contents. + * @param {string} source Source contents + * @param {Root} root Root to populate + * @param {IParseOptions} [options] Parse options. Defaults to {@link parse.defaults} when omitted. + * @returns {IParserResult} Parser result + * @property {string} filename=null Currently processing file name for error reporting, if known + * @property {IParseOptions} defaults Default {@link IParseOptions} + */ +function parse(source, root, options) { + /* eslint-disable callback-return */ + if (!(root instanceof Root)) { + options = root; + root = new Root(); + } + if (!options) + options = parse.defaults; + + var tn = tokenize(source, options.alternateCommentMode || false), + next = tn.next, + push = tn.push, + peek = tn.peek, + skip = tn.skip, + cmnt = tn.cmnt; + + var head = true, + pkg, + imports, + weakImports, + syntax, + isProto3 = false; + + var ptr = root; + + var applyCase = options.keepCase ? function(name) { return name; } : util.camelCase; + + /* istanbul ignore next */ + function illegal(token, name, insideTryCatch) { + var filename = parse.filename; + if (!insideTryCatch) + parse.filename = null; + return Error("illegal " + (name || "token") + " '" + token + "' (" + (filename ? filename + ", " : "") + "line " + tn.line + ")"); + } + + function readString() { + var values = [], + token; + do { + /* istanbul ignore if */ + if ((token = next()) !== "\"" && token !== "'") + throw illegal(token); + + values.push(next()); + skip(token); + token = peek(); + } while (token === "\"" || token === "'"); + return values.join(""); + } + + function readValue(acceptTypeRef) { + var token = next(); + switch (token) { + case "'": + case "\"": + push(token); + return readString(); + case "true": case "TRUE": + return true; + case "false": case "FALSE": + return false; + } + try { + return parseNumber(token, /* insideTryCatch */ true); + } catch (e) { + + /* istanbul ignore else */ + if (acceptTypeRef && typeRefRe.test(token)) + return token; + + /* istanbul ignore next */ + throw illegal(token, "value"); + } + } + + function readRanges(target, acceptStrings) { + var token, start; + do { + if (acceptStrings && ((token = peek()) === "\"" || token === "'")) + target.push(readString()); + else + target.push([ start = parseId(next()), skip("to", true) ? parseId(next()) : start ]); + } while (skip(",", true)); + skip(";"); + } + + function parseNumber(token, insideTryCatch) { + var sign = 1; + if (token.charAt(0) === "-") { + sign = -1; + token = token.substring(1); + } + switch (token) { + case "inf": case "INF": case "Inf": + return sign * Infinity; + case "nan": case "NAN": case "Nan": case "NaN": + return NaN; + case "0": + return 0; + } + if (base10Re.test(token)) + return sign * parseInt(token, 10); + if (base16Re.test(token)) + return sign * parseInt(token, 16); + if (base8Re.test(token)) + return sign * parseInt(token, 8); + + /* istanbul ignore else */ + if (numberRe.test(token)) + return sign * parseFloat(token); + + /* istanbul ignore next */ + throw illegal(token, "number", insideTryCatch); + } + + function parseId(token, acceptNegative) { + switch (token) { + case "max": case "MAX": case "Max": + return 536870911; + case "0": + return 0; + } + + /* istanbul ignore if */ + if (!acceptNegative && token.charAt(0) === "-") + throw illegal(token, "id"); + + if (base10NegRe.test(token)) + return parseInt(token, 10); + if (base16NegRe.test(token)) + return parseInt(token, 16); + + /* istanbul ignore else */ + if (base8NegRe.test(token)) + return parseInt(token, 8); + + /* istanbul ignore next */ + throw illegal(token, "id"); + } + + function parsePackage() { + + /* istanbul ignore if */ + if (pkg !== undefined) + throw illegal("package"); + + pkg = next(); + + /* istanbul ignore if */ + if (!typeRefRe.test(pkg)) + throw illegal(pkg, "name"); + + ptr = ptr.define(pkg); + skip(";"); + } + + function parseImport() { + var token = peek(); + var whichImports; + switch (token) { + case "weak": + whichImports = weakImports || (weakImports = []); + next(); + break; + case "public": + next(); + // eslint-disable-line no-fallthrough + default: + whichImports = imports || (imports = []); + break; + } + token = readString(); + skip(";"); + whichImports.push(token); + } + + function parseSyntax() { + skip("="); + syntax = readString(); + isProto3 = syntax === "proto3"; + + /* istanbul ignore if */ + if (!isProto3 && syntax !== "proto2") + throw illegal(syntax, "syntax"); + + skip(";"); + } + + function parseCommon(parent, token) { + switch (token) { + + case "option": + parseOption(parent, token); + skip(";"); + return true; + + case "message": + parseType(parent, token); + return true; + + case "enum": + parseEnum(parent, token); + return true; + + case "service": + parseService(parent, token); + return true; + + case "extend": + parseExtension(parent, token); + return true; + } + return false; + } + + function ifBlock(obj, fnIf, fnElse) { + var trailingLine = tn.line; + if (obj) { + obj.comment = cmnt(); // try block-type comment + obj.filename = parse.filename; + } + if (skip("{", true)) { + var token; + while ((token = next()) !== "}") + fnIf(token); + skip(";", true); + } else { + if (fnElse) + fnElse(); + skip(";"); + if (obj && typeof obj.comment !== "string") + obj.comment = cmnt(trailingLine); // try line-type comment if no block + } + } + + function parseType(parent, token) { + + /* istanbul ignore if */ + if (!nameRe.test(token = next())) + throw illegal(token, "type name"); + + var type = new Type(token); + ifBlock(type, function parseType_block(token) { + if (parseCommon(type, token)) + return; + + switch (token) { + + case "map": + parseMapField(type, token); + break; + + case "required": + case "optional": + case "repeated": + parseField(type, token); + break; + + case "oneof": + parseOneOf(type, token); + break; + + case "extensions": + readRanges(type.extensions || (type.extensions = [])); + break; + + case "reserved": + readRanges(type.reserved || (type.reserved = []), true); + break; + + default: + /* istanbul ignore if */ + if (!isProto3 || !typeRefRe.test(token)) + throw illegal(token); + + push(token); + parseField(type, "optional"); + break; + } + }); + parent.add(type); + } + + function parseField(parent, rule, extend) { + var type = next(); + if (type === "group") { + parseGroup(parent, rule); + return; + } + + /* istanbul ignore if */ + if (!typeRefRe.test(type)) + throw illegal(type, "type"); + + var name = next(); + + /* istanbul ignore if */ + if (!nameRe.test(name)) + throw illegal(name, "name"); + + name = applyCase(name); + skip("="); + + var field = new Field(name, parseId(next()), type, rule, extend); + ifBlock(field, function parseField_block(token) { + + /* istanbul ignore else */ + if (token === "option") { + parseOption(field, token); + skip(";"); + } else + throw illegal(token); + + }, function parseField_line() { + parseInlineOptions(field); + }); + parent.add(field); + + // JSON defaults to packed=true if not set so we have to set packed=false explicity when + // parsing proto2 descriptors without the option, where applicable. This must be done for + // all known packable types and anything that could be an enum (= is not a basic type). + if (!isProto3 && field.repeated && (types.packed[type] !== undefined || types.basic[type] === undefined)) + field.setOption("packed", false, /* ifNotSet */ true); + } + + function parseGroup(parent, rule) { + var name = next(); + + /* istanbul ignore if */ + if (!nameRe.test(name)) + throw illegal(name, "name"); + + var fieldName = util.lcFirst(name); + if (name === fieldName) + name = util.ucFirst(name); + skip("="); + var id = parseId(next()); + var type = new Type(name); + type.group = true; + var field = new Field(fieldName, id, name, rule); + field.filename = parse.filename; + ifBlock(type, function parseGroup_block(token) { + switch (token) { + + case "option": + parseOption(type, token); + skip(";"); + break; + + case "required": + case "optional": + case "repeated": + parseField(type, token); + break; + + /* istanbul ignore next */ + default: + throw illegal(token); // there are no groups with proto3 semantics + } + }); + parent.add(type) + .add(field); + } + + function parseMapField(parent) { + skip("<"); + var keyType = next(); + + /* istanbul ignore if */ + if (types.mapKey[keyType] === undefined) + throw illegal(keyType, "type"); + + skip(","); + var valueType = next(); + + /* istanbul ignore if */ + if (!typeRefRe.test(valueType)) + throw illegal(valueType, "type"); + + skip(">"); + var name = next(); + + /* istanbul ignore if */ + if (!nameRe.test(name)) + throw illegal(name, "name"); + + skip("="); + var field = new MapField(applyCase(name), parseId(next()), keyType, valueType); + ifBlock(field, function parseMapField_block(token) { + + /* istanbul ignore else */ + if (token === "option") { + parseOption(field, token); + skip(";"); + } else + throw illegal(token); + + }, function parseMapField_line() { + parseInlineOptions(field); + }); + parent.add(field); + } + + function parseOneOf(parent, token) { + + /* istanbul ignore if */ + if (!nameRe.test(token = next())) + throw illegal(token, "name"); + + var oneof = new OneOf(applyCase(token)); + ifBlock(oneof, function parseOneOf_block(token) { + if (token === "option") { + parseOption(oneof, token); + skip(";"); + } else { + push(token); + parseField(oneof, "optional"); + } + }); + parent.add(oneof); + } + + function parseEnum(parent, token) { + + /* istanbul ignore if */ + if (!nameRe.test(token = next())) + throw illegal(token, "name"); + + var enm = new Enum(token); + ifBlock(enm, function parseEnum_block(token) { + switch(token) { + case "option": + parseOption(enm, token); + skip(";"); + break; + + case "reserved": + readRanges(enm.reserved || (enm.reserved = []), true); + break; + + default: + parseEnumValue(enm, token); + } + }); + parent.add(enm); + } + + function parseEnumValue(parent, token) { + + /* istanbul ignore if */ + if (!nameRe.test(token)) + throw illegal(token, "name"); + + skip("="); + var value = parseId(next(), true), + dummy = {}; + ifBlock(dummy, function parseEnumValue_block(token) { + + /* istanbul ignore else */ + if (token === "option") { + parseOption(dummy, token); // skip + skip(";"); + } else + throw illegal(token); + + }, function parseEnumValue_line() { + parseInlineOptions(dummy); // skip + }); + parent.add(token, value, dummy.comment); + } + + function parseOption(parent, token) { + var isCustom = skip("(", true); + + /* istanbul ignore if */ + if (!typeRefRe.test(token = next())) + throw illegal(token, "name"); + + var name = token; + if (isCustom) { + skip(")"); + name = "(" + name + ")"; + token = peek(); + if (fqTypeRefRe.test(token)) { + name += token; + next(); + } + } + skip("="); + parseOptionValue(parent, name); + } + + function parseOptionValue(parent, name) { + if (skip("{", true)) { // { a: "foo" b { c: "bar" } } + do { + /* istanbul ignore if */ + if (!nameRe.test(token = next())) + throw illegal(token, "name"); + + if (peek() === "{") + parseOptionValue(parent, name + "." + token); + else { + skip(":"); + if (peek() === "{") + parseOptionValue(parent, name + "." + token); + else + setOption(parent, name + "." + token, readValue(true)); + } + skip(",", true); + } while (!skip("}", true)); + } else + setOption(parent, name, readValue(true)); + // Does not enforce a delimiter to be universal + } + + function setOption(parent, name, value) { + if (parent.setOption) + parent.setOption(name, value); + } + + function parseInlineOptions(parent) { + if (skip("[", true)) { + do { + parseOption(parent, "option"); + } while (skip(",", true)); + skip("]"); + } + return parent; + } + + function parseService(parent, token) { + + /* istanbul ignore if */ + if (!nameRe.test(token = next())) + throw illegal(token, "service name"); + + var service = new Service(token); + ifBlock(service, function parseService_block(token) { + if (parseCommon(service, token)) + return; + + /* istanbul ignore else */ + if (token === "rpc") + parseMethod(service, token); + else + throw illegal(token); + }); + parent.add(service); + } + + function parseMethod(parent, token) { + var type = token; + + /* istanbul ignore if */ + if (!nameRe.test(token = next())) + throw illegal(token, "name"); + + var name = token, + requestType, requestStream, + responseType, responseStream; + + skip("("); + if (skip("stream", true)) + requestStream = true; + + /* istanbul ignore if */ + if (!typeRefRe.test(token = next())) + throw illegal(token); + + requestType = token; + skip(")"); skip("returns"); skip("("); + if (skip("stream", true)) + responseStream = true; + + /* istanbul ignore if */ + if (!typeRefRe.test(token = next())) + throw illegal(token); + + responseType = token; + skip(")"); + + var method = new Method(name, type, requestType, responseType, requestStream, responseStream); + ifBlock(method, function parseMethod_block(token) { + + /* istanbul ignore else */ + if (token === "option") { + parseOption(method, token); + skip(";"); + } else + throw illegal(token); + + }); + parent.add(method); + } + + function parseExtension(parent, token) { + + /* istanbul ignore if */ + if (!typeRefRe.test(token = next())) + throw illegal(token, "reference"); + + var reference = token; + ifBlock(null, function parseExtension_block(token) { + switch (token) { + + case "required": + case "repeated": + case "optional": + parseField(parent, token, reference); + break; + + default: + /* istanbul ignore if */ + if (!isProto3 || !typeRefRe.test(token)) + throw illegal(token); + push(token); + parseField(parent, "optional", reference); + break; + } + }); + } + + var token; + while ((token = next()) !== null) { + switch (token) { + + case "package": + + /* istanbul ignore if */ + if (!head) + throw illegal(token); + + parsePackage(); + break; + + case "import": + + /* istanbul ignore if */ + if (!head) + throw illegal(token); + + parseImport(); + break; + + case "syntax": + + /* istanbul ignore if */ + if (!head) + throw illegal(token); + + parseSyntax(); + break; + + case "option": + + /* istanbul ignore if */ + if (!head) + throw illegal(token); + + parseOption(ptr, token); + skip(";"); + break; + + default: + + /* istanbul ignore else */ + if (parseCommon(ptr, token)) { + head = false; + continue; + } + + /* istanbul ignore next */ + throw illegal(token); + } + } + + parse.filename = null; + return { + "package" : pkg, + "imports" : imports, + weakImports : weakImports, + syntax : syntax, + root : root + }; +} + +/** + * Parses the given .proto source and returns an object with the parsed contents. + * @name parse + * @function + * @param {string} source Source contents + * @param {IParseOptions} [options] Parse options. Defaults to {@link parse.defaults} when omitted. + * @returns {IParserResult} Parser result + * @property {string} filename=null Currently processing file name for error reporting, if known + * @property {IParseOptions} defaults Default {@link IParseOptions} + * @variation 2 + */ + +},{"15":15,"16":16,"20":20,"22":22,"25":25,"29":29,"33":33,"34":34,"35":35,"36":36,"37":37}],27:[function(require,module,exports){ +"use strict"; +module.exports = Reader; + +var util = require(39); + +var BufferReader; // cyclic + +var LongBits = util.LongBits, + utf8 = util.utf8; + +/* istanbul ignore next */ +function indexOutOfRange(reader, writeLength) { + return RangeError("index out of range: " + reader.pos + " + " + (writeLength || 1) + " > " + reader.len); +} + +/** + * Constructs a new reader instance using the specified buffer. + * @classdesc Wire format reader using `Uint8Array` if available, otherwise `Array`. + * @constructor + * @param {Uint8Array} buffer Buffer to read from + */ +function Reader(buffer) { + + /** + * Read buffer. + * @type {Uint8Array} + */ + this.buf = buffer; + + /** + * Read buffer position. + * @type {number} + */ + this.pos = 0; + + /** + * Read buffer length. + * @type {number} + */ + this.len = buffer.length; +} + +var create_array = typeof Uint8Array !== "undefined" + ? function create_typed_array(buffer) { + if (buffer instanceof Uint8Array || Array.isArray(buffer)) + return new Reader(buffer); + throw Error("illegal buffer"); + } + /* istanbul ignore next */ + : function create_array(buffer) { + if (Array.isArray(buffer)) + return new Reader(buffer); + throw Error("illegal buffer"); + }; + +/** + * Creates a new reader using the specified buffer. + * @function + * @param {Uint8Array|Buffer} buffer Buffer to read from + * @returns {Reader|BufferReader} A {@link BufferReader} if `buffer` is a Buffer, otherwise a {@link Reader} + * @throws {Error} If `buffer` is not a valid buffer + */ +Reader.create = util.Buffer + ? function create_buffer_setup(buffer) { + return (Reader.create = function create_buffer(buffer) { + return util.Buffer.isBuffer(buffer) + ? new BufferReader(buffer) + /* istanbul ignore next */ + : create_array(buffer); + })(buffer); + } + /* istanbul ignore next */ + : create_array; + +Reader.prototype._slice = util.Array.prototype.subarray || /* istanbul ignore next */ util.Array.prototype.slice; + +/** + * Reads a varint as an unsigned 32 bit value. + * @function + * @returns {number} Value read + */ +Reader.prototype.uint32 = (function read_uint32_setup() { + var value = 4294967295; // optimizer type-hint, tends to deopt otherwise (?!) + return function read_uint32() { + value = ( this.buf[this.pos] & 127 ) >>> 0; if (this.buf[this.pos++] < 128) return value; + value = (value | (this.buf[this.pos] & 127) << 7) >>> 0; if (this.buf[this.pos++] < 128) return value; + value = (value | (this.buf[this.pos] & 127) << 14) >>> 0; if (this.buf[this.pos++] < 128) return value; + value = (value | (this.buf[this.pos] & 127) << 21) >>> 0; if (this.buf[this.pos++] < 128) return value; + value = (value | (this.buf[this.pos] & 15) << 28) >>> 0; if (this.buf[this.pos++] < 128) return value; + + /* istanbul ignore if */ + if ((this.pos += 5) > this.len) { + this.pos = this.len; + throw indexOutOfRange(this, 10); + } + return value; + }; +})(); + +/** + * Reads a varint as a signed 32 bit value. + * @returns {number} Value read + */ +Reader.prototype.int32 = function read_int32() { + return this.uint32() | 0; +}; + +/** + * Reads a zig-zag encoded varint as a signed 32 bit value. + * @returns {number} Value read + */ +Reader.prototype.sint32 = function read_sint32() { + var value = this.uint32(); + return value >>> 1 ^ -(value & 1) | 0; +}; + +/* eslint-disable no-invalid-this */ + +function readLongVarint() { + // tends to deopt with local vars for octet etc. + var bits = new LongBits(0, 0); + var i = 0; + if (this.len - this.pos > 4) { // fast route (lo) + for (; i < 4; ++i) { + // 1st..4th + bits.lo = (bits.lo | (this.buf[this.pos] & 127) << i * 7) >>> 0; + if (this.buf[this.pos++] < 128) + return bits; + } + // 5th + bits.lo = (bits.lo | (this.buf[this.pos] & 127) << 28) >>> 0; + bits.hi = (bits.hi | (this.buf[this.pos] & 127) >> 4) >>> 0; + if (this.buf[this.pos++] < 128) + return bits; + i = 0; + } else { + for (; i < 3; ++i) { + /* istanbul ignore if */ + if (this.pos >= this.len) + throw indexOutOfRange(this); + // 1st..3th + bits.lo = (bits.lo | (this.buf[this.pos] & 127) << i * 7) >>> 0; + if (this.buf[this.pos++] < 128) + return bits; + } + // 4th + bits.lo = (bits.lo | (this.buf[this.pos++] & 127) << i * 7) >>> 0; + return bits; + } + if (this.len - this.pos > 4) { // fast route (hi) + for (; i < 5; ++i) { + // 6th..10th + bits.hi = (bits.hi | (this.buf[this.pos] & 127) << i * 7 + 3) >>> 0; + if (this.buf[this.pos++] < 128) + return bits; + } + } else { + for (; i < 5; ++i) { + /* istanbul ignore if */ + if (this.pos >= this.len) + throw indexOutOfRange(this); + // 6th..10th + bits.hi = (bits.hi | (this.buf[this.pos] & 127) << i * 7 + 3) >>> 0; + if (this.buf[this.pos++] < 128) + return bits; + } + } + /* istanbul ignore next */ + throw Error("invalid varint encoding"); +} + +/* eslint-enable no-invalid-this */ + +/** + * Reads a varint as a signed 64 bit value. + * @name Reader#int64 + * @function + * @returns {Long} Value read + */ + +/** + * Reads a varint as an unsigned 64 bit value. + * @name Reader#uint64 + * @function + * @returns {Long} Value read + */ + +/** + * Reads a zig-zag encoded varint as a signed 64 bit value. + * @name Reader#sint64 + * @function + * @returns {Long} Value read + */ + +/** + * Reads a varint as a boolean. + * @returns {boolean} Value read + */ +Reader.prototype.bool = function read_bool() { + return this.uint32() !== 0; +}; + +function readFixed32_end(buf, end) { // note that this uses `end`, not `pos` + return (buf[end - 4] + | buf[end - 3] << 8 + | buf[end - 2] << 16 + | buf[end - 1] << 24) >>> 0; +} + +/** + * Reads fixed 32 bits as an unsigned 32 bit integer. + * @returns {number} Value read + */ +Reader.prototype.fixed32 = function read_fixed32() { + + /* istanbul ignore if */ + if (this.pos + 4 > this.len) + throw indexOutOfRange(this, 4); + + return readFixed32_end(this.buf, this.pos += 4); +}; + +/** + * Reads fixed 32 bits as a signed 32 bit integer. + * @returns {number} Value read + */ +Reader.prototype.sfixed32 = function read_sfixed32() { + + /* istanbul ignore if */ + if (this.pos + 4 > this.len) + throw indexOutOfRange(this, 4); + + return readFixed32_end(this.buf, this.pos += 4) | 0; +}; + +/* eslint-disable no-invalid-this */ + +function readFixed64(/* this: Reader */) { + + /* istanbul ignore if */ + if (this.pos + 8 > this.len) + throw indexOutOfRange(this, 8); + + return new LongBits(readFixed32_end(this.buf, this.pos += 4), readFixed32_end(this.buf, this.pos += 4)); +} + +/* eslint-enable no-invalid-this */ + +/** + * Reads fixed 64 bits. + * @name Reader#fixed64 + * @function + * @returns {Long} Value read + */ + +/** + * Reads zig-zag encoded fixed 64 bits. + * @name Reader#sfixed64 + * @function + * @returns {Long} Value read + */ + +/** + * Reads a float (32 bit) as a number. + * @function + * @returns {number} Value read + */ +Reader.prototype.float = function read_float() { + + /* istanbul ignore if */ + if (this.pos + 4 > this.len) + throw indexOutOfRange(this, 4); + + var value = util.float.readFloatLE(this.buf, this.pos); + this.pos += 4; + return value; +}; + +/** + * Reads a double (64 bit float) as a number. + * @function + * @returns {number} Value read + */ +Reader.prototype.double = function read_double() { + + /* istanbul ignore if */ + if (this.pos + 8 > this.len) + throw indexOutOfRange(this, 4); + + var value = util.float.readDoubleLE(this.buf, this.pos); + this.pos += 8; + return value; +}; + +/** + * Reads a sequence of bytes preceeded by its length as a varint. + * @returns {Uint8Array} Value read + */ +Reader.prototype.bytes = function read_bytes() { + var length = this.uint32(), + start = this.pos, + end = this.pos + length; + + /* istanbul ignore if */ + if (end > this.len) + throw indexOutOfRange(this, length); + + this.pos += length; + if (Array.isArray(this.buf)) // plain array + return this.buf.slice(start, end); + return start === end // fix for IE 10/Win8 and others' subarray returning array of size 1 + ? new this.buf.constructor(0) + : this._slice.call(this.buf, start, end); +}; + +/** + * Reads a string preceeded by its byte length as a varint. + * @returns {string} Value read + */ +Reader.prototype.string = function read_string() { + var bytes = this.bytes(); + return utf8.read(bytes, 0, bytes.length); +}; + +/** + * Skips the specified number of bytes if specified, otherwise skips a varint. + * @param {number} [length] Length if known, otherwise a varint is assumed + * @returns {Reader} `this` + */ +Reader.prototype.skip = function skip(length) { + if (typeof length === "number") { + /* istanbul ignore if */ + if (this.pos + length > this.len) + throw indexOutOfRange(this, length); + this.pos += length; + } else { + do { + /* istanbul ignore if */ + if (this.pos >= this.len) + throw indexOutOfRange(this); + } while (this.buf[this.pos++] & 128); + } + return this; +}; + +/** + * Skips the next element of the specified wire type. + * @param {number} wireType Wire type received + * @returns {Reader} `this` + */ +Reader.prototype.skipType = function(wireType) { + switch (wireType) { + case 0: + this.skip(); + break; + case 1: + this.skip(8); + break; + case 2: + this.skip(this.uint32()); + break; + case 3: + while ((wireType = this.uint32() & 7) !== 4) { + this.skipType(wireType); + } + break; + case 5: + this.skip(4); + break; + + /* istanbul ignore next */ + default: + throw Error("invalid wire type " + wireType + " at offset " + this.pos); + } + return this; +}; + +Reader._configure = function(BufferReader_) { + BufferReader = BufferReader_; + + var fn = util.Long ? "toLong" : /* istanbul ignore next */ "toNumber"; + util.merge(Reader.prototype, { + + int64: function read_int64() { + return readLongVarint.call(this)[fn](false); + }, + + uint64: function read_uint64() { + return readLongVarint.call(this)[fn](true); + }, + + sint64: function read_sint64() { + return readLongVarint.call(this).zzDecode()[fn](false); + }, + + fixed64: function read_fixed64() { + return readFixed64.call(this)[fn](true); + }, + + sfixed64: function read_sfixed64() { + return readFixed64.call(this)[fn](false); + } + + }); +}; + +},{"39":39}],28:[function(require,module,exports){ +"use strict"; +module.exports = BufferReader; + +// extends Reader +var Reader = require(27); +(BufferReader.prototype = Object.create(Reader.prototype)).constructor = BufferReader; + +var util = require(39); + +/** + * Constructs a new buffer reader instance. + * @classdesc Wire format reader using node buffers. + * @extends Reader + * @constructor + * @param {Buffer} buffer Buffer to read from + */ +function BufferReader(buffer) { + Reader.call(this, buffer); + + /** + * Read buffer. + * @name BufferReader#buf + * @type {Buffer} + */ +} + +/* istanbul ignore else */ +if (util.Buffer) + BufferReader.prototype._slice = util.Buffer.prototype.slice; + +/** + * @override + */ +BufferReader.prototype.string = function read_string_buffer() { + var len = this.uint32(); // modifies pos + return this.buf.utf8Slice(this.pos, this.pos = Math.min(this.pos + len, this.len)); +}; + +/** + * Reads a sequence of bytes preceeded by its length as a varint. + * @name BufferReader#bytes + * @function + * @returns {Buffer} Value read + */ + +},{"27":27,"39":39}],29:[function(require,module,exports){ +"use strict"; +module.exports = Root; + +// extends Namespace +var Namespace = require(23); +((Root.prototype = Object.create(Namespace.prototype)).constructor = Root).className = "Root"; + +var Field = require(16), + Enum = require(15), + OneOf = require(25), + util = require(37); + +var Type, // cyclic + parse, // might be excluded + common; // " + +/** + * Constructs a new root namespace instance. + * @classdesc Root namespace wrapping all types, enums, services, sub-namespaces etc. that belong together. + * @extends NamespaceBase + * @constructor + * @param {Object.} [options] Top level options + */ +function Root(options) { + Namespace.call(this, "", options); + + /** + * Deferred extension fields. + * @type {Field[]} + */ + this.deferred = []; + + /** + * Resolved file names of loaded files. + * @type {string[]} + */ + this.files = []; +} + +/** + * Loads a namespace descriptor into a root namespace. + * @param {INamespace} json Nameespace descriptor + * @param {Root} [root] Root namespace, defaults to create a new one if omitted + * @returns {Root} Root namespace + */ +Root.fromJSON = function fromJSON(json, root) { + if (!root) + root = new Root(); + if (json.options) + root.setOptions(json.options); + return root.addJSON(json.nested); +}; + +/** + * Resolves the path of an imported file, relative to the importing origin. + * This method exists so you can override it with your own logic in case your imports are scattered over multiple directories. + * @function + * @param {string} origin The file name of the importing file + * @param {string} target The file name being imported + * @returns {string|null} Resolved path to `target` or `null` to skip the file + */ +Root.prototype.resolvePath = util.path.resolve; + +// A symbol-like function to safely signal synchronous loading +/* istanbul ignore next */ +function SYNC() {} // eslint-disable-line no-empty-function + +/** + * Loads one or multiple .proto or preprocessed .json files into this root namespace and calls the callback. + * @param {string|string[]} filename Names of one or multiple files to load + * @param {IParseOptions} options Parse options + * @param {LoadCallback} callback Callback function + * @returns {undefined} + */ +Root.prototype.load = function load(filename, options, callback) { + if (typeof options === "function") { + callback = options; + options = undefined; + } + var self = this; + if (!callback) + return util.asPromise(load, self, filename, options); + + var sync = callback === SYNC; // undocumented + + // Finishes loading by calling the callback (exactly once) + function finish(err, root) { + /* istanbul ignore if */ + if (!callback) + return; + var cb = callback; + callback = null; + if (sync) + throw err; + cb(err, root); + } + + // Processes a single file + function process(filename, source) { + try { + if (util.isString(source) && source.charAt(0) === "{") + source = JSON.parse(source); + if (!util.isString(source)) + self.setOptions(source.options).addJSON(source.nested); + else { + parse.filename = filename; + var parsed = parse(source, self, options), + resolved, + i = 0; + if (parsed.imports) + for (; i < parsed.imports.length; ++i) + if (resolved = self.resolvePath(filename, parsed.imports[i])) + fetch(resolved); + if (parsed.weakImports) + for (i = 0; i < parsed.weakImports.length; ++i) + if (resolved = self.resolvePath(filename, parsed.weakImports[i])) + fetch(resolved, true); + } + } catch (err) { + finish(err); + } + if (!sync && !queued) + finish(null, self); // only once anyway + } + + // Fetches a single file + function fetch(filename, weak) { + + // Strip path if this file references a bundled definition + var idx = filename.lastIndexOf("google/protobuf/"); + if (idx > -1) { + var altname = filename.substring(idx); + if (altname in common) + filename = altname; + } + + // Skip if already loaded / attempted + if (self.files.indexOf(filename) > -1) + return; + self.files.push(filename); + + // Shortcut bundled definitions + if (filename in common) { + if (sync) + process(filename, common[filename]); + else { + ++queued; + setTimeout(function() { + --queued; + process(filename, common[filename]); + }); + } + return; + } + + // Otherwise fetch from disk or network + if (sync) { + var source; + try { + source = util.fs.readFileSync(filename).toString("utf8"); + } catch (err) { + if (!weak) + finish(err); + return; + } + process(filename, source); + } else { + ++queued; + util.fetch(filename, function(err, source) { + --queued; + /* istanbul ignore if */ + if (!callback) + return; // terminated meanwhile + if (err) { + /* istanbul ignore else */ + if (!weak) + finish(err); + else if (!queued) // can't be covered reliably + finish(null, self); + return; + } + process(filename, source); + }); + } + } + var queued = 0; + + // Assembling the root namespace doesn't require working type + // references anymore, so we can load everything in parallel + if (util.isString(filename)) + filename = [ filename ]; + for (var i = 0, resolved; i < filename.length; ++i) + if (resolved = self.resolvePath("", filename[i])) + fetch(resolved); + + if (sync) + return self; + if (!queued) + finish(null, self); + return undefined; +}; +// function load(filename:string, options:IParseOptions, callback:LoadCallback):undefined + +/** + * Loads one or multiple .proto or preprocessed .json files into this root namespace and calls the callback. + * @function Root#load + * @param {string|string[]} filename Names of one or multiple files to load + * @param {LoadCallback} callback Callback function + * @returns {undefined} + * @variation 2 + */ +// function load(filename:string, callback:LoadCallback):undefined + +/** + * Loads one or multiple .proto or preprocessed .json files into this root namespace and returns a promise. + * @function Root#load + * @param {string|string[]} filename Names of one or multiple files to load + * @param {IParseOptions} [options] Parse options. Defaults to {@link parse.defaults} when omitted. + * @returns {Promise} Promise + * @variation 3 + */ +// function load(filename:string, [options:IParseOptions]):Promise + +/** + * Synchronously loads one or multiple .proto or preprocessed .json files into this root namespace (node only). + * @function Root#loadSync + * @param {string|string[]} filename Names of one or multiple files to load + * @param {IParseOptions} [options] Parse options. Defaults to {@link parse.defaults} when omitted. + * @returns {Root} Root namespace + * @throws {Error} If synchronous fetching is not supported (i.e. in browsers) or if a file's syntax is invalid + */ +Root.prototype.loadSync = function loadSync(filename, options) { + if (!util.isNode) + throw Error("not supported"); + return this.load(filename, options, SYNC); +}; + +/** + * @override + */ +Root.prototype.resolveAll = function resolveAll() { + if (this.deferred.length) + throw Error("unresolvable extensions: " + this.deferred.map(function(field) { + return "'extend " + field.extend + "' in " + field.parent.fullName; + }).join(", ")); + return Namespace.prototype.resolveAll.call(this); +}; + +// only uppercased (and thus conflict-free) children are exposed, see below +var exposeRe = /^[A-Z]/; + +/** + * Handles a deferred declaring extension field by creating a sister field to represent it within its extended type. + * @param {Root} root Root instance + * @param {Field} field Declaring extension field witin the declaring type + * @returns {boolean} `true` if successfully added to the extended type, `false` otherwise + * @inner + * @ignore + */ +function tryHandleExtension(root, field) { + var extendedType = field.parent.lookup(field.extend); + if (extendedType) { + var sisterField = new Field(field.fullName, field.id, field.type, field.rule, undefined, field.options); + sisterField.declaringField = field; + field.extensionField = sisterField; + extendedType.add(sisterField); + return true; + } + return false; +} + +/** + * Called when any object is added to this root or its sub-namespaces. + * @param {ReflectionObject} object Object added + * @returns {undefined} + * @private + */ +Root.prototype._handleAdd = function _handleAdd(object) { + if (object instanceof Field) { + + if (/* an extension field (implies not part of a oneof) */ object.extend !== undefined && /* not already handled */ !object.extensionField) + if (!tryHandleExtension(this, object)) + this.deferred.push(object); + + } else if (object instanceof Enum) { + + if (exposeRe.test(object.name)) + object.parent[object.name] = object.values; // expose enum values as property of its parent + + } else if (!(object instanceof OneOf)) /* everything else is a namespace */ { + + if (object instanceof Type) // Try to handle any deferred extensions + for (var i = 0; i < this.deferred.length;) + if (tryHandleExtension(this, this.deferred[i])) + this.deferred.splice(i, 1); + else + ++i; + for (var j = 0; j < /* initializes */ object.nestedArray.length; ++j) // recurse into the namespace + this._handleAdd(object._nestedArray[j]); + if (exposeRe.test(object.name)) + object.parent[object.name] = object; // expose namespace as property of its parent + } + + // The above also adds uppercased (and thus conflict-free) nested types, services and enums as + // properties of namespaces just like static code does. This allows using a .d.ts generated for + // a static module with reflection-based solutions where the condition is met. +}; + +/** + * Called when any object is removed from this root or its sub-namespaces. + * @param {ReflectionObject} object Object removed + * @returns {undefined} + * @private + */ +Root.prototype._handleRemove = function _handleRemove(object) { + if (object instanceof Field) { + + if (/* an extension field */ object.extend !== undefined) { + if (/* already handled */ object.extensionField) { // remove its sister field + object.extensionField.parent.remove(object.extensionField); + object.extensionField = null; + } else { // cancel the extension + var index = this.deferred.indexOf(object); + /* istanbul ignore else */ + if (index > -1) + this.deferred.splice(index, 1); + } + } + + } else if (object instanceof Enum) { + + if (exposeRe.test(object.name)) + delete object.parent[object.name]; // unexpose enum values + + } else if (object instanceof Namespace) { + + for (var i = 0; i < /* initializes */ object.nestedArray.length; ++i) // recurse into the namespace + this._handleRemove(object._nestedArray[i]); + + if (exposeRe.test(object.name)) + delete object.parent[object.name]; // unexpose namespaces + + } +}; + +// Sets up cyclic dependencies (called in index-light) +Root._configure = function(Type_, parse_, common_) { + Type = Type_; + parse = parse_; + common = common_; +}; + +},{"15":15,"16":16,"23":23,"25":25,"37":37}],30:[function(require,module,exports){ +"use strict"; +module.exports = {}; + +/** + * Named roots. + * This is where pbjs stores generated structures (the option `-r, --root` specifies a name). + * Can also be used manually to make roots available accross modules. + * @name roots + * @type {Object.} + * @example + * // pbjs -r myroot -o compiled.js ... + * + * // in another module: + * require("./compiled.js"); + * + * // in any subsequent module: + * var root = protobuf.roots["myroot"]; + */ + +},{}],31:[function(require,module,exports){ +"use strict"; + +/** + * Streaming RPC helpers. + * @namespace + */ +var rpc = exports; + +/** + * RPC implementation passed to {@link Service#create} performing a service request on network level, i.e. by utilizing http requests or websockets. + * @typedef RPCImpl + * @type {function} + * @param {Method|rpc.ServiceMethod,Message<{}>>} method Reflected or static method being called + * @param {Uint8Array} requestData Request data + * @param {RPCImplCallback} callback Callback function + * @returns {undefined} + * @example + * function rpcImpl(method, requestData, callback) { + * if (protobuf.util.lcFirst(method.name) !== "myMethod") // compatible with static code + * throw Error("no such method"); + * asynchronouslyObtainAResponse(requestData, function(err, responseData) { + * callback(err, responseData); + * }); + * } + */ + +/** + * Node-style callback as used by {@link RPCImpl}. + * @typedef RPCImplCallback + * @type {function} + * @param {Error|null} error Error, if any, otherwise `null` + * @param {Uint8Array|null} [response] Response data or `null` to signal end of stream, if there hasn't been an error + * @returns {undefined} + */ + +rpc.Service = require(32); + +},{"32":32}],32:[function(require,module,exports){ +"use strict"; +module.exports = Service; + +var util = require(39); + +// Extends EventEmitter +(Service.prototype = Object.create(util.EventEmitter.prototype)).constructor = Service; + +/** + * A service method callback as used by {@link rpc.ServiceMethod|ServiceMethod}. + * + * Differs from {@link RPCImplCallback} in that it is an actual callback of a service method which may not return `response = null`. + * @typedef rpc.ServiceMethodCallback + * @template TRes extends Message + * @type {function} + * @param {Error|null} error Error, if any + * @param {TRes} [response] Response message + * @returns {undefined} + */ + +/** + * A service method part of a {@link rpc.Service} as created by {@link Service.create}. + * @typedef rpc.ServiceMethod + * @template TReq extends Message + * @template TRes extends Message + * @type {function} + * @param {TReq|Properties} request Request message or plain object + * @param {rpc.ServiceMethodCallback} [callback] Node-style callback called with the error, if any, and the response message + * @returns {Promise>} Promise if `callback` has been omitted, otherwise `undefined` + */ + +/** + * Constructs a new RPC service instance. + * @classdesc An RPC service as returned by {@link Service#create}. + * @exports rpc.Service + * @extends util.EventEmitter + * @constructor + * @param {RPCImpl} rpcImpl RPC implementation + * @param {boolean} [requestDelimited=false] Whether requests are length-delimited + * @param {boolean} [responseDelimited=false] Whether responses are length-delimited + */ +function Service(rpcImpl, requestDelimited, responseDelimited) { + + if (typeof rpcImpl !== "function") + throw TypeError("rpcImpl must be a function"); + + util.EventEmitter.call(this); + + /** + * RPC implementation. Becomes `null` once the service is ended. + * @type {RPCImpl|null} + */ + this.rpcImpl = rpcImpl; + + /** + * Whether requests are length-delimited. + * @type {boolean} + */ + this.requestDelimited = Boolean(requestDelimited); + + /** + * Whether responses are length-delimited. + * @type {boolean} + */ + this.responseDelimited = Boolean(responseDelimited); +} + +/** + * Calls a service method through {@link rpc.Service#rpcImpl|rpcImpl}. + * @param {Method|rpc.ServiceMethod} method Reflected or static method + * @param {Constructor} requestCtor Request constructor + * @param {Constructor} responseCtor Response constructor + * @param {TReq|Properties} request Request message or plain object + * @param {rpc.ServiceMethodCallback} callback Service callback + * @returns {undefined} + * @template TReq extends Message + * @template TRes extends Message + */ +Service.prototype.rpcCall = function rpcCall(method, requestCtor, responseCtor, request, callback) { + + if (!request) + throw TypeError("request must be specified"); + + var self = this; + if (!callback) + return util.asPromise(rpcCall, self, method, requestCtor, responseCtor, request); + + if (!self.rpcImpl) { + setTimeout(function() { callback(Error("already ended")); }, 0); + return undefined; + } + + try { + return self.rpcImpl( + method, + requestCtor[self.requestDelimited ? "encodeDelimited" : "encode"](request).finish(), + function rpcCallback(err, response) { + + if (err) { + self.emit("error", err, method); + return callback(err); + } + + if (response === null) { + self.end(/* endedByRPC */ true); + return undefined; + } + + if (!(response instanceof responseCtor)) { + try { + response = responseCtor[self.responseDelimited ? "decodeDelimited" : "decode"](response); + } catch (err) { + self.emit("error", err, method); + return callback(err); + } + } + + self.emit("data", response, method); + return callback(null, response); + } + ); + } catch (err) { + self.emit("error", err, method); + setTimeout(function() { callback(err); }, 0); + return undefined; + } +}; + +/** + * Ends this service and emits the `end` event. + * @param {boolean} [endedByRPC=false] Whether the service has been ended by the RPC implementation. + * @returns {rpc.Service} `this` + */ +Service.prototype.end = function end(endedByRPC) { + if (this.rpcImpl) { + if (!endedByRPC) // signal end to rpcImpl + this.rpcImpl(null, null, null); + this.rpcImpl = null; + this.emit("end").off(); + } + return this; +}; + +},{"39":39}],33:[function(require,module,exports){ +"use strict"; +module.exports = Service; + +// extends Namespace +var Namespace = require(23); +((Service.prototype = Object.create(Namespace.prototype)).constructor = Service).className = "Service"; + +var Method = require(22), + util = require(37), + rpc = require(31); + +/** + * Constructs a new service instance. + * @classdesc Reflected service. + * @extends NamespaceBase + * @constructor + * @param {string} name Service name + * @param {Object.} [options] Service options + * @throws {TypeError} If arguments are invalid + */ +function Service(name, options) { + Namespace.call(this, name, options); + + /** + * Service methods. + * @type {Object.} + */ + this.methods = {}; // toJSON, marker + + /** + * Cached methods as an array. + * @type {Method[]|null} + * @private + */ + this._methodsArray = null; +} + +/** + * Service descriptor. + * @interface IService + * @extends INamespace + * @property {Object.} methods Method descriptors + */ + +/** + * Constructs a service from a service descriptor. + * @param {string} name Service name + * @param {IService} json Service descriptor + * @returns {Service} Created service + * @throws {TypeError} If arguments are invalid + */ +Service.fromJSON = function fromJSON(name, json) { + var service = new Service(name, json.options); + /* istanbul ignore else */ + if (json.methods) + for (var names = Object.keys(json.methods), i = 0; i < names.length; ++i) + service.add(Method.fromJSON(names[i], json.methods[names[i]])); + if (json.nested) + service.addJSON(json.nested); + service.comment = json.comment; + return service; +}; + +/** + * Converts this service to a service descriptor. + * @param {IToJSONOptions} [toJSONOptions] JSON conversion options + * @returns {IService} Service descriptor + */ +Service.prototype.toJSON = function toJSON(toJSONOptions) { + var inherited = Namespace.prototype.toJSON.call(this, toJSONOptions); + var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false; + return util.toObject([ + "options" , inherited && inherited.options || undefined, + "methods" , Namespace.arrayToJSON(this.methodsArray, toJSONOptions) || /* istanbul ignore next */ {}, + "nested" , inherited && inherited.nested || undefined, + "comment" , keepComments ? this.comment : undefined + ]); +}; + +/** + * Methods of this service as an array for iteration. + * @name Service#methodsArray + * @type {Method[]} + * @readonly + */ +Object.defineProperty(Service.prototype, "methodsArray", { + get: function() { + return this._methodsArray || (this._methodsArray = util.toArray(this.methods)); + } +}); + +function clearCache(service) { + service._methodsArray = null; + return service; +} + +/** + * @override + */ +Service.prototype.get = function get(name) { + return this.methods[name] + || Namespace.prototype.get.call(this, name); +}; + +/** + * @override + */ +Service.prototype.resolveAll = function resolveAll() { + var methods = this.methodsArray; + for (var i = 0; i < methods.length; ++i) + methods[i].resolve(); + return Namespace.prototype.resolve.call(this); +}; + +/** + * @override + */ +Service.prototype.add = function add(object) { + + /* istanbul ignore if */ + if (this.get(object.name)) + throw Error("duplicate name '" + object.name + "' in " + this); + + if (object instanceof Method) { + this.methods[object.name] = object; + object.parent = this; + return clearCache(this); + } + return Namespace.prototype.add.call(this, object); +}; + +/** + * @override + */ +Service.prototype.remove = function remove(object) { + if (object instanceof Method) { + + /* istanbul ignore if */ + if (this.methods[object.name] !== object) + throw Error(object + " is not a member of " + this); + + delete this.methods[object.name]; + object.parent = null; + return clearCache(this); + } + return Namespace.prototype.remove.call(this, object); +}; + +/** + * Creates a runtime service using the specified rpc implementation. + * @param {RPCImpl} rpcImpl RPC implementation + * @param {boolean} [requestDelimited=false] Whether requests are length-delimited + * @param {boolean} [responseDelimited=false] Whether responses are length-delimited + * @returns {rpc.Service} RPC service. Useful where requests and/or responses are streamed. + */ +Service.prototype.create = function create(rpcImpl, requestDelimited, responseDelimited) { + var rpcService = new rpc.Service(rpcImpl, requestDelimited, responseDelimited); + for (var i = 0, method; i < /* initializes */ this.methodsArray.length; ++i) { + var methodName = util.lcFirst((method = this._methodsArray[i]).resolve().name).replace(/[^$\w_]/g, ""); + rpcService[methodName] = util.codegen(["r","c"], util.isReserved(methodName) ? methodName + "_" : methodName)("return this.rpcCall(m,q,s,r,c)")({ + m: method, + q: method.resolvedRequestType.ctor, + s: method.resolvedResponseType.ctor + }); + } + return rpcService; +}; + +},{"22":22,"23":23,"31":31,"37":37}],34:[function(require,module,exports){ +"use strict"; +module.exports = tokenize; + +var delimRe = /[\s{}=;:[\],'"()<>]/g, + stringDoubleRe = /(?:"([^"\\]*(?:\\.[^"\\]*)*)")/g, + stringSingleRe = /(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g; + +var setCommentRe = /^ *[*/]+ */, + setCommentAltRe = /^\s*\*?\/*/, + setCommentSplitRe = /\n/g, + whitespaceRe = /\s/, + unescapeRe = /\\(.?)/g; + +var unescapeMap = { + "0": "\0", + "r": "\r", + "n": "\n", + "t": "\t" +}; + +/** + * Unescapes a string. + * @param {string} str String to unescape + * @returns {string} Unescaped string + * @property {Object.} map Special characters map + * @memberof tokenize + */ +function unescape(str) { + return str.replace(unescapeRe, function($0, $1) { + switch ($1) { + case "\\": + case "": + return $1; + default: + return unescapeMap[$1] || ""; + } + }); +} + +tokenize.unescape = unescape; + +/** + * Gets the next token and advances. + * @typedef TokenizerHandleNext + * @type {function} + * @returns {string|null} Next token or `null` on eof + */ + +/** + * Peeks for the next token. + * @typedef TokenizerHandlePeek + * @type {function} + * @returns {string|null} Next token or `null` on eof + */ + +/** + * Pushes a token back to the stack. + * @typedef TokenizerHandlePush + * @type {function} + * @param {string} token Token + * @returns {undefined} + */ + +/** + * Skips the next token. + * @typedef TokenizerHandleSkip + * @type {function} + * @param {string} expected Expected token + * @param {boolean} [optional=false] If optional + * @returns {boolean} Whether the token matched + * @throws {Error} If the token didn't match and is not optional + */ + +/** + * Gets the comment on the previous line or, alternatively, the line comment on the specified line. + * @typedef TokenizerHandleCmnt + * @type {function} + * @param {number} [line] Line number + * @returns {string|null} Comment text or `null` if none + */ + +/** + * Handle object returned from {@link tokenize}. + * @interface ITokenizerHandle + * @property {TokenizerHandleNext} next Gets the next token and advances (`null` on eof) + * @property {TokenizerHandlePeek} peek Peeks for the next token (`null` on eof) + * @property {TokenizerHandlePush} push Pushes a token back to the stack + * @property {TokenizerHandleSkip} skip Skips a token, returns its presence and advances or, if non-optional and not present, throws + * @property {TokenizerHandleCmnt} cmnt Gets the comment on the previous line or the line comment on the specified line, if any + * @property {number} line Current line number + */ + +/** + * Tokenizes the given .proto source and returns an object with useful utility functions. + * @param {string} source Source contents + * @param {boolean} alternateCommentMode Whether we should activate alternate comment parsing mode. + * @returns {ITokenizerHandle} Tokenizer handle + */ +function tokenize(source, alternateCommentMode) { + /* eslint-disable callback-return */ + source = source.toString(); + + var offset = 0, + length = source.length, + line = 1, + commentType = null, + commentText = null, + commentLine = 0, + commentLineEmpty = false; + + var stack = []; + + var stringDelim = null; + + /* istanbul ignore next */ + /** + * Creates an error for illegal syntax. + * @param {string} subject Subject + * @returns {Error} Error created + * @inner + */ + function illegal(subject) { + return Error("illegal " + subject + " (line " + line + ")"); + } + + /** + * Reads a string till its end. + * @returns {string} String read + * @inner + */ + function readString() { + var re = stringDelim === "'" ? stringSingleRe : stringDoubleRe; + re.lastIndex = offset - 1; + var match = re.exec(source); + if (!match) + throw illegal("string"); + offset = re.lastIndex; + push(stringDelim); + stringDelim = null; + return unescape(match[1]); + } + + /** + * Gets the character at `pos` within the source. + * @param {number} pos Position + * @returns {string} Character + * @inner + */ + function charAt(pos) { + return source.charAt(pos); + } + + /** + * Sets the current comment text. + * @param {number} start Start offset + * @param {number} end End offset + * @returns {undefined} + * @inner + */ + function setComment(start, end) { + commentType = source.charAt(start++); + commentLine = line; + commentLineEmpty = false; + var lookback; + if (alternateCommentMode) { + lookback = 2; // alternate comment parsing: "//" or "/*" + } else { + lookback = 3; // "///" or "/**" + } + var commentOffset = start - lookback, + c; + do { + if (--commentOffset < 0 || + (c = source.charAt(commentOffset)) === "\n") { + commentLineEmpty = true; + break; + } + } while (c === " " || c === "\t"); + var lines = source + .substring(start, end) + .split(setCommentSplitRe); + for (var i = 0; i < lines.length; ++i) + lines[i] = lines[i] + .replace(alternateCommentMode ? setCommentAltRe : setCommentRe, "") + .trim(); + commentText = lines + .join("\n") + .trim(); + } + + function isDoubleSlashCommentLine(startOffset) { + var endOffset = findEndOfLine(startOffset); + + // see if remaining line matches comment pattern + var lineText = source.substring(startOffset, endOffset); + // look for 1 or 2 slashes since startOffset would already point past + // the first slash that started the comment. + var isComment = /^\s*\/{1,2}/.test(lineText); + return isComment; + } + + function findEndOfLine(cursor) { + // find end of cursor's line + var endOffset = cursor; + while (endOffset < length && charAt(endOffset) !== "\n") { + endOffset++; + } + return endOffset; + } + + /** + * Obtains the next token. + * @returns {string|null} Next token or `null` on eof + * @inner + */ + function next() { + if (stack.length > 0) + return stack.shift(); + if (stringDelim) + return readString(); + var repeat, + prev, + curr, + start, + isDoc; + do { + if (offset === length) + return null; + repeat = false; + while (whitespaceRe.test(curr = charAt(offset))) { + if (curr === "\n") + ++line; + if (++offset === length) + return null; + } + + if (charAt(offset) === "/") { + if (++offset === length) { + throw illegal("comment"); + } + if (charAt(offset) === "/") { // Line + if (!alternateCommentMode) { + // check for triple-slash comment + isDoc = charAt(start = offset + 1) === "/"; + + while (charAt(++offset) !== "\n") { + if (offset === length) { + return null; + } + } + ++offset; + if (isDoc) { + setComment(start, offset - 1); + } + ++line; + repeat = true; + } else { + // check for double-slash comments, consolidating consecutive lines + start = offset; + isDoc = false; + if (isDoubleSlashCommentLine(offset)) { + isDoc = true; + do { + offset = findEndOfLine(offset); + if (offset === length) { + break; + } + offset++; + } while (isDoubleSlashCommentLine(offset)); + } else { + offset = Math.min(length, findEndOfLine(offset) + 1); + } + if (isDoc) { + setComment(start, offset); + } + line++; + repeat = true; + } + } else if ((curr = charAt(offset)) === "*") { /* Block */ + // check for /** (regular comment mode) or /* (alternate comment mode) + start = offset + 1; + isDoc = alternateCommentMode || charAt(start) === "*"; + do { + if (curr === "\n") { + ++line; + } + if (++offset === length) { + throw illegal("comment"); + } + prev = curr; + curr = charAt(offset); + } while (prev !== "*" || curr !== "/"); + ++offset; + if (isDoc) { + setComment(start, offset - 2); + } + repeat = true; + } else { + return "/"; + } + } + } while (repeat); + + // offset !== length if we got here + + var end = offset; + delimRe.lastIndex = 0; + var delim = delimRe.test(charAt(end++)); + if (!delim) + while (end < length && !delimRe.test(charAt(end))) + ++end; + var token = source.substring(offset, offset = end); + if (token === "\"" || token === "'") + stringDelim = token; + return token; + } + + /** + * Pushes a token back to the stack. + * @param {string} token Token + * @returns {undefined} + * @inner + */ + function push(token) { + stack.push(token); + } + + /** + * Peeks for the next token. + * @returns {string|null} Token or `null` on eof + * @inner + */ + function peek() { + if (!stack.length) { + var token = next(); + if (token === null) + return null; + push(token); + } + return stack[0]; + } + + /** + * Skips a token. + * @param {string} expected Expected token + * @param {boolean} [optional=false] Whether the token is optional + * @returns {boolean} `true` when skipped, `false` if not + * @throws {Error} When a required token is not present + * @inner + */ + function skip(expected, optional) { + var actual = peek(), + equals = actual === expected; + if (equals) { + next(); + return true; + } + if (!optional) + throw illegal("token '" + actual + "', '" + expected + "' expected"); + return false; + } + + /** + * Gets a comment. + * @param {number} [trailingLine] Line number if looking for a trailing comment + * @returns {string|null} Comment text + * @inner + */ + function cmnt(trailingLine) { + var ret = null; + if (trailingLine === undefined) { + if (commentLine === line - 1 && (alternateCommentMode || commentType === "*" || commentLineEmpty)) { + ret = commentText; + } + } else { + /* istanbul ignore else */ + if (commentLine < trailingLine) { + peek(); + } + if (commentLine === trailingLine && !commentLineEmpty && (alternateCommentMode || commentType === "/")) { + ret = commentText; + } + } + return ret; + } + + return Object.defineProperty({ + next: next, + peek: peek, + push: push, + skip: skip, + cmnt: cmnt + }, "line", { + get: function() { return line; } + }); + /* eslint-enable callback-return */ +} + +},{}],35:[function(require,module,exports){ +"use strict"; +module.exports = Type; + +// extends Namespace +var Namespace = require(23); +((Type.prototype = Object.create(Namespace.prototype)).constructor = Type).className = "Type"; + +var Enum = require(15), + OneOf = require(25), + Field = require(16), + MapField = require(20), + Service = require(33), + Message = require(21), + Reader = require(27), + Writer = require(42), + util = require(37), + encoder = require(14), + decoder = require(13), + verifier = require(40), + converter = require(12), + wrappers = require(41); + +/** + * Constructs a new reflected message type instance. + * @classdesc Reflected message type. + * @extends NamespaceBase + * @constructor + * @param {string} name Message name + * @param {Object.} [options] Declared options + */ +function Type(name, options) { + Namespace.call(this, name, options); + + /** + * Message fields. + * @type {Object.} + */ + this.fields = {}; // toJSON, marker + + /** + * Oneofs declared within this namespace, if any. + * @type {Object.} + */ + this.oneofs = undefined; // toJSON + + /** + * Extension ranges, if any. + * @type {number[][]} + */ + this.extensions = undefined; // toJSON + + /** + * Reserved ranges, if any. + * @type {Array.} + */ + this.reserved = undefined; // toJSON + + /*? + * Whether this type is a legacy group. + * @type {boolean|undefined} + */ + this.group = undefined; // toJSON + + /** + * Cached fields by id. + * @type {Object.|null} + * @private + */ + this._fieldsById = null; + + /** + * Cached fields as an array. + * @type {Field[]|null} + * @private + */ + this._fieldsArray = null; + + /** + * Cached oneofs as an array. + * @type {OneOf[]|null} + * @private + */ + this._oneofsArray = null; + + /** + * Cached constructor. + * @type {Constructor<{}>} + * @private + */ + this._ctor = null; +} + +Object.defineProperties(Type.prototype, { + + /** + * Message fields by id. + * @name Type#fieldsById + * @type {Object.} + * @readonly + */ + fieldsById: { + get: function() { + + /* istanbul ignore if */ + if (this._fieldsById) + return this._fieldsById; + + this._fieldsById = {}; + for (var names = Object.keys(this.fields), i = 0; i < names.length; ++i) { + var field = this.fields[names[i]], + id = field.id; + + /* istanbul ignore if */ + if (this._fieldsById[id]) + throw Error("duplicate id " + id + " in " + this); + + this._fieldsById[id] = field; + } + return this._fieldsById; + } + }, + + /** + * Fields of this message as an array for iteration. + * @name Type#fieldsArray + * @type {Field[]} + * @readonly + */ + fieldsArray: { + get: function() { + return this._fieldsArray || (this._fieldsArray = util.toArray(this.fields)); + } + }, + + /** + * Oneofs of this message as an array for iteration. + * @name Type#oneofsArray + * @type {OneOf[]} + * @readonly + */ + oneofsArray: { + get: function() { + return this._oneofsArray || (this._oneofsArray = util.toArray(this.oneofs)); + } + }, + + /** + * The registered constructor, if any registered, otherwise a generic constructor. + * Assigning a function replaces the internal constructor. If the function does not extend {@link Message} yet, its prototype will be setup accordingly and static methods will be populated. If it already extends {@link Message}, it will just replace the internal constructor. + * @name Type#ctor + * @type {Constructor<{}>} + */ + ctor: { + get: function() { + return this._ctor || (this.ctor = Type.generateConstructor(this)()); + }, + set: function(ctor) { + + // Ensure proper prototype + var prototype = ctor.prototype; + if (!(prototype instanceof Message)) { + (ctor.prototype = new Message()).constructor = ctor; + util.merge(ctor.prototype, prototype); + } + + // Classes and messages reference their reflected type + ctor.$type = ctor.prototype.$type = this; + + // Mix in static methods + util.merge(ctor, Message, true); + + this._ctor = ctor; + + // Messages have non-enumerable default values on their prototype + var i = 0; + for (; i < /* initializes */ this.fieldsArray.length; ++i) + this._fieldsArray[i].resolve(); // ensures a proper value + + // Messages have non-enumerable getters and setters for each virtual oneof field + var ctorProperties = {}; + for (i = 0; i < /* initializes */ this.oneofsArray.length; ++i) + ctorProperties[this._oneofsArray[i].resolve().name] = { + get: util.oneOfGetter(this._oneofsArray[i].oneof), + set: util.oneOfSetter(this._oneofsArray[i].oneof) + }; + if (i) + Object.defineProperties(ctor.prototype, ctorProperties); + } + } +}); + +/** + * Generates a constructor function for the specified type. + * @param {Type} mtype Message type + * @returns {Codegen} Codegen instance + */ +Type.generateConstructor = function generateConstructor(mtype) { + /* eslint-disable no-unexpected-multiline */ + var gen = util.codegen(["p"], mtype.name); + // explicitly initialize mutable object/array fields so that these aren't just inherited from the prototype + for (var i = 0, field; i < mtype.fieldsArray.length; ++i) + if ((field = mtype._fieldsArray[i]).map) gen + ("this%s={}", util.safeProp(field.name)); + else if (field.repeated) gen + ("this%s=[]", util.safeProp(field.name)); + return gen + ("if(p)for(var ks=Object.keys(p),i=0;i} [oneofs] Oneof descriptors + * @property {Object.} fields Field descriptors + * @property {number[][]} [extensions] Extension ranges + * @property {number[][]} [reserved] Reserved ranges + * @property {boolean} [group=false] Whether a legacy group or not + */ + +/** + * Creates a message type from a message type descriptor. + * @param {string} name Message name + * @param {IType} json Message type descriptor + * @returns {Type} Created message type + */ +Type.fromJSON = function fromJSON(name, json) { + var type = new Type(name, json.options); + type.extensions = json.extensions; + type.reserved = json.reserved; + var names = Object.keys(json.fields), + i = 0; + for (; i < names.length; ++i) + type.add( + ( typeof json.fields[names[i]].keyType !== "undefined" + ? MapField.fromJSON + : Field.fromJSON )(names[i], json.fields[names[i]]) + ); + if (json.oneofs) + for (names = Object.keys(json.oneofs), i = 0; i < names.length; ++i) + type.add(OneOf.fromJSON(names[i], json.oneofs[names[i]])); + if (json.nested) + for (names = Object.keys(json.nested), i = 0; i < names.length; ++i) { + var nested = json.nested[names[i]]; + type.add( // most to least likely + ( nested.id !== undefined + ? Field.fromJSON + : nested.fields !== undefined + ? Type.fromJSON + : nested.values !== undefined + ? Enum.fromJSON + : nested.methods !== undefined + ? Service.fromJSON + : Namespace.fromJSON )(names[i], nested) + ); + } + if (json.extensions && json.extensions.length) + type.extensions = json.extensions; + if (json.reserved && json.reserved.length) + type.reserved = json.reserved; + if (json.group) + type.group = true; + if (json.comment) + type.comment = json.comment; + return type; +}; + +/** + * Converts this message type to a message type descriptor. + * @param {IToJSONOptions} [toJSONOptions] JSON conversion options + * @returns {IType} Message type descriptor + */ +Type.prototype.toJSON = function toJSON(toJSONOptions) { + var inherited = Namespace.prototype.toJSON.call(this, toJSONOptions); + var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false; + return util.toObject([ + "options" , inherited && inherited.options || undefined, + "oneofs" , Namespace.arrayToJSON(this.oneofsArray, toJSONOptions), + "fields" , Namespace.arrayToJSON(this.fieldsArray.filter(function(obj) { return !obj.declaringField; }), toJSONOptions) || {}, + "extensions" , this.extensions && this.extensions.length ? this.extensions : undefined, + "reserved" , this.reserved && this.reserved.length ? this.reserved : undefined, + "group" , this.group || undefined, + "nested" , inherited && inherited.nested || undefined, + "comment" , keepComments ? this.comment : undefined + ]); +}; + +/** + * @override + */ +Type.prototype.resolveAll = function resolveAll() { + var fields = this.fieldsArray, i = 0; + while (i < fields.length) + fields[i++].resolve(); + var oneofs = this.oneofsArray; i = 0; + while (i < oneofs.length) + oneofs[i++].resolve(); + return Namespace.prototype.resolveAll.call(this); +}; + +/** + * @override + */ +Type.prototype.get = function get(name) { + return this.fields[name] + || this.oneofs && this.oneofs[name] + || this.nested && this.nested[name] + || null; +}; + +/** + * Adds a nested object to this type. + * @param {ReflectionObject} object Nested object to add + * @returns {Type} `this` + * @throws {TypeError} If arguments are invalid + * @throws {Error} If there is already a nested object with this name or, if a field, when there is already a field with this id + */ +Type.prototype.add = function add(object) { + + if (this.get(object.name)) + throw Error("duplicate name '" + object.name + "' in " + this); + + if (object instanceof Field && object.extend === undefined) { + // NOTE: Extension fields aren't actual fields on the declaring type, but nested objects. + // The root object takes care of adding distinct sister-fields to the respective extended + // type instead. + + // avoids calling the getter if not absolutely necessary because it's called quite frequently + if (this._fieldsById ? /* istanbul ignore next */ this._fieldsById[object.id] : this.fieldsById[object.id]) + throw Error("duplicate id " + object.id + " in " + this); + if (this.isReservedId(object.id)) + throw Error("id " + object.id + " is reserved in " + this); + if (this.isReservedName(object.name)) + throw Error("name '" + object.name + "' is reserved in " + this); + + if (object.parent) + object.parent.remove(object); + this.fields[object.name] = object; + object.message = this; + object.onAdd(this); + return clearCache(this); + } + if (object instanceof OneOf) { + if (!this.oneofs) + this.oneofs = {}; + this.oneofs[object.name] = object; + object.onAdd(this); + return clearCache(this); + } + return Namespace.prototype.add.call(this, object); +}; + +/** + * Removes a nested object from this type. + * @param {ReflectionObject} object Nested object to remove + * @returns {Type} `this` + * @throws {TypeError} If arguments are invalid + * @throws {Error} If `object` is not a member of this type + */ +Type.prototype.remove = function remove(object) { + if (object instanceof Field && object.extend === undefined) { + // See Type#add for the reason why extension fields are excluded here. + + /* istanbul ignore if */ + if (!this.fields || this.fields[object.name] !== object) + throw Error(object + " is not a member of " + this); + + delete this.fields[object.name]; + object.parent = null; + object.onRemove(this); + return clearCache(this); + } + if (object instanceof OneOf) { + + /* istanbul ignore if */ + if (!this.oneofs || this.oneofs[object.name] !== object) + throw Error(object + " is not a member of " + this); + + delete this.oneofs[object.name]; + object.parent = null; + object.onRemove(this); + return clearCache(this); + } + return Namespace.prototype.remove.call(this, object); +}; + +/** + * Tests if the specified id is reserved. + * @param {number} id Id to test + * @returns {boolean} `true` if reserved, otherwise `false` + */ +Type.prototype.isReservedId = function isReservedId(id) { + return Namespace.isReservedId(this.reserved, id); +}; + +/** + * Tests if the specified name is reserved. + * @param {string} name Name to test + * @returns {boolean} `true` if reserved, otherwise `false` + */ +Type.prototype.isReservedName = function isReservedName(name) { + return Namespace.isReservedName(this.reserved, name); +}; + +/** + * Creates a new message of this type using the specified properties. + * @param {Object.} [properties] Properties to set + * @returns {Message<{}>} Message instance + */ +Type.prototype.create = function create(properties) { + return new this.ctor(properties); +}; + +/** + * Sets up {@link Type#encode|encode}, {@link Type#decode|decode} and {@link Type#verify|verify}. + * @returns {Type} `this` + */ +Type.prototype.setup = function setup() { + // Sets up everything at once so that the prototype chain does not have to be re-evaluated + // multiple times (V8, soft-deopt prototype-check). + + var fullName = this.fullName, + types = []; + for (var i = 0; i < /* initializes */ this.fieldsArray.length; ++i) + types.push(this._fieldsArray[i].resolve().resolvedType); + + // Replace setup methods with type-specific generated functions + this.encode = encoder(this)({ + Writer : Writer, + types : types, + util : util + }); + this.decode = decoder(this)({ + Reader : Reader, + types : types, + util : util + }); + this.verify = verifier(this)({ + types : types, + util : util + }); + this.fromObject = converter.fromObject(this)({ + types : types, + util : util + }); + this.toObject = converter.toObject(this)({ + types : types, + util : util + }); + + // Inject custom wrappers for common types + var wrapper = wrappers[fullName]; + if (wrapper) { + var originalThis = Object.create(this); + // if (wrapper.fromObject) { + originalThis.fromObject = this.fromObject; + this.fromObject = wrapper.fromObject.bind(originalThis); + // } + // if (wrapper.toObject) { + originalThis.toObject = this.toObject; + this.toObject = wrapper.toObject.bind(originalThis); + // } + } + + return this; +}; + +/** + * Encodes a message of this type. Does not implicitly {@link Type#verify|verify} messages. + * @param {Message<{}>|Object.} message Message instance or plain object + * @param {Writer} [writer] Writer to encode to + * @returns {Writer} writer + */ +Type.prototype.encode = function encode_setup(message, writer) { + return this.setup().encode(message, writer); // overrides this method +}; + +/** + * Encodes a message of this type preceeded by its byte length as a varint. Does not implicitly {@link Type#verify|verify} messages. + * @param {Message<{}>|Object.} message Message instance or plain object + * @param {Writer} [writer] Writer to encode to + * @returns {Writer} writer + */ +Type.prototype.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer && writer.len ? writer.fork() : writer).ldelim(); +}; + +/** + * Decodes a message of this type. + * @param {Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Length of the message, if known beforehand + * @returns {Message<{}>} Decoded message + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {util.ProtocolError<{}>} If required fields are missing + */ +Type.prototype.decode = function decode_setup(reader, length) { + return this.setup().decode(reader, length); // overrides this method +}; + +/** + * Decodes a message of this type preceeded by its byte length as a varint. + * @param {Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {Message<{}>} Decoded message + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {util.ProtocolError} If required fields are missing + */ +Type.prototype.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof Reader)) + reader = Reader.create(reader); + return this.decode(reader, reader.uint32()); +}; + +/** + * Verifies that field values are valid and that required fields are present. + * @param {Object.} message Plain object to verify + * @returns {null|string} `null` if valid, otherwise the reason why it is not + */ +Type.prototype.verify = function verify_setup(message) { + return this.setup().verify(message); // overrides this method +}; + +/** + * Creates a new message of this type from a plain object. Also converts values to their respective internal types. + * @param {Object.} object Plain object to convert + * @returns {Message<{}>} Message instance + */ +Type.prototype.fromObject = function fromObject(object) { + return this.setup().fromObject(object); +}; + +/** + * Conversion options as used by {@link Type#toObject} and {@link Message.toObject}. + * @interface IConversionOptions + * @property {Function} [longs] Long conversion type. + * Valid values are `String` and `Number` (the global types). + * Defaults to copy the present value, which is a possibly unsafe number without and a {@link Long} with a long library. + * @property {Function} [enums] Enum value conversion type. + * Only valid value is `String` (the global type). + * Defaults to copy the present value, which is the numeric id. + * @property {Function} [bytes] Bytes value conversion type. + * Valid values are `Array` and (a base64 encoded) `String` (the global types). + * Defaults to copy the present value, which usually is a Buffer under node and an Uint8Array in the browser. + * @property {boolean} [defaults=false] Also sets default values on the resulting object + * @property {boolean} [arrays=false] Sets empty arrays for missing repeated fields even if `defaults=false` + * @property {boolean} [objects=false] Sets empty objects for missing map fields even if `defaults=false` + * @property {boolean} [oneofs=false] Includes virtual oneof properties set to the present field's name, if any + * @property {boolean} [json=false] Performs additional JSON compatibility conversions, i.e. NaN and Infinity to strings + */ + +/** + * Creates a plain object from a message of this type. Also converts values to other types if specified. + * @param {Message<{}>} message Message instance + * @param {IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ +Type.prototype.toObject = function toObject(message, options) { + return this.setup().toObject(message, options); +}; + +/** + * Decorator function as returned by {@link Type.d} (TypeScript). + * @typedef TypeDecorator + * @type {function} + * @param {Constructor} target Target constructor + * @returns {undefined} + * @template T extends Message + */ + +/** + * Type decorator (TypeScript). + * @param {string} [typeName] Type name, defaults to the constructor's name + * @returns {TypeDecorator} Decorator function + * @template T extends Message + */ +Type.d = function decorateType(typeName) { + return function typeDecorator(target) { + util.decorateType(target, typeName); + }; +}; + +},{"12":12,"13":13,"14":14,"15":15,"16":16,"20":20,"21":21,"23":23,"25":25,"27":27,"33":33,"37":37,"40":40,"41":41,"42":42}],36:[function(require,module,exports){ +"use strict"; + +/** + * Common type constants. + * @namespace + */ +var types = exports; + +var util = require(37); + +var s = [ + "double", // 0 + "float", // 1 + "int32", // 2 + "uint32", // 3 + "sint32", // 4 + "fixed32", // 5 + "sfixed32", // 6 + "int64", // 7 + "uint64", // 8 + "sint64", // 9 + "fixed64", // 10 + "sfixed64", // 11 + "bool", // 12 + "string", // 13 + "bytes" // 14 +]; + +function bake(values, offset) { + var i = 0, o = {}; + offset |= 0; + while (i < values.length) o[s[i + offset]] = values[i++]; + return o; +} + +/** + * Basic type wire types. + * @type {Object.} + * @const + * @property {number} double=1 Fixed64 wire type + * @property {number} float=5 Fixed32 wire type + * @property {number} int32=0 Varint wire type + * @property {number} uint32=0 Varint wire type + * @property {number} sint32=0 Varint wire type + * @property {number} fixed32=5 Fixed32 wire type + * @property {number} sfixed32=5 Fixed32 wire type + * @property {number} int64=0 Varint wire type + * @property {number} uint64=0 Varint wire type + * @property {number} sint64=0 Varint wire type + * @property {number} fixed64=1 Fixed64 wire type + * @property {number} sfixed64=1 Fixed64 wire type + * @property {number} bool=0 Varint wire type + * @property {number} string=2 Ldelim wire type + * @property {number} bytes=2 Ldelim wire type + */ +types.basic = bake([ + /* double */ 1, + /* float */ 5, + /* int32 */ 0, + /* uint32 */ 0, + /* sint32 */ 0, + /* fixed32 */ 5, + /* sfixed32 */ 5, + /* int64 */ 0, + /* uint64 */ 0, + /* sint64 */ 0, + /* fixed64 */ 1, + /* sfixed64 */ 1, + /* bool */ 0, + /* string */ 2, + /* bytes */ 2 +]); + +/** + * Basic type defaults. + * @type {Object.} + * @const + * @property {number} double=0 Double default + * @property {number} float=0 Float default + * @property {number} int32=0 Int32 default + * @property {number} uint32=0 Uint32 default + * @property {number} sint32=0 Sint32 default + * @property {number} fixed32=0 Fixed32 default + * @property {number} sfixed32=0 Sfixed32 default + * @property {number} int64=0 Int64 default + * @property {number} uint64=0 Uint64 default + * @property {number} sint64=0 Sint32 default + * @property {number} fixed64=0 Fixed64 default + * @property {number} sfixed64=0 Sfixed64 default + * @property {boolean} bool=false Bool default + * @property {string} string="" String default + * @property {Array.} bytes=Array(0) Bytes default + * @property {null} message=null Message default + */ +types.defaults = bake([ + /* double */ 0, + /* float */ 0, + /* int32 */ 0, + /* uint32 */ 0, + /* sint32 */ 0, + /* fixed32 */ 0, + /* sfixed32 */ 0, + /* int64 */ 0, + /* uint64 */ 0, + /* sint64 */ 0, + /* fixed64 */ 0, + /* sfixed64 */ 0, + /* bool */ false, + /* string */ "", + /* bytes */ util.emptyArray, + /* message */ null +]); + +/** + * Basic long type wire types. + * @type {Object.} + * @const + * @property {number} int64=0 Varint wire type + * @property {number} uint64=0 Varint wire type + * @property {number} sint64=0 Varint wire type + * @property {number} fixed64=1 Fixed64 wire type + * @property {number} sfixed64=1 Fixed64 wire type + */ +types.long = bake([ + /* int64 */ 0, + /* uint64 */ 0, + /* sint64 */ 0, + /* fixed64 */ 1, + /* sfixed64 */ 1 +], 7); + +/** + * Allowed types for map keys with their associated wire type. + * @type {Object.} + * @const + * @property {number} int32=0 Varint wire type + * @property {number} uint32=0 Varint wire type + * @property {number} sint32=0 Varint wire type + * @property {number} fixed32=5 Fixed32 wire type + * @property {number} sfixed32=5 Fixed32 wire type + * @property {number} int64=0 Varint wire type + * @property {number} uint64=0 Varint wire type + * @property {number} sint64=0 Varint wire type + * @property {number} fixed64=1 Fixed64 wire type + * @property {number} sfixed64=1 Fixed64 wire type + * @property {number} bool=0 Varint wire type + * @property {number} string=2 Ldelim wire type + */ +types.mapKey = bake([ + /* int32 */ 0, + /* uint32 */ 0, + /* sint32 */ 0, + /* fixed32 */ 5, + /* sfixed32 */ 5, + /* int64 */ 0, + /* uint64 */ 0, + /* sint64 */ 0, + /* fixed64 */ 1, + /* sfixed64 */ 1, + /* bool */ 0, + /* string */ 2 +], 2); + +/** + * Allowed types for packed repeated fields with their associated wire type. + * @type {Object.} + * @const + * @property {number} double=1 Fixed64 wire type + * @property {number} float=5 Fixed32 wire type + * @property {number} int32=0 Varint wire type + * @property {number} uint32=0 Varint wire type + * @property {number} sint32=0 Varint wire type + * @property {number} fixed32=5 Fixed32 wire type + * @property {number} sfixed32=5 Fixed32 wire type + * @property {number} int64=0 Varint wire type + * @property {number} uint64=0 Varint wire type + * @property {number} sint64=0 Varint wire type + * @property {number} fixed64=1 Fixed64 wire type + * @property {number} sfixed64=1 Fixed64 wire type + * @property {number} bool=0 Varint wire type + */ +types.packed = bake([ + /* double */ 1, + /* float */ 5, + /* int32 */ 0, + /* uint32 */ 0, + /* sint32 */ 0, + /* fixed32 */ 5, + /* sfixed32 */ 5, + /* int64 */ 0, + /* uint64 */ 0, + /* sint64 */ 0, + /* fixed64 */ 1, + /* sfixed64 */ 1, + /* bool */ 0 +]); + +},{"37":37}],37:[function(require,module,exports){ +"use strict"; + +/** + * Various utility functions. + * @namespace + */ +var util = module.exports = require(39); + +var roots = require(30); + +var Type, // cyclic + Enum; + +util.codegen = require(3); +util.fetch = require(5); +util.path = require(8); + +/** + * Node's fs module if available. + * @type {Object.} + */ +util.fs = util.inquire("fs"); + +/** + * Converts an object's values to an array. + * @param {Object.} object Object to convert + * @returns {Array.<*>} Converted array + */ +util.toArray = function toArray(object) { + if (object) { + var keys = Object.keys(object), + array = new Array(keys.length), + index = 0; + while (index < keys.length) + array[index] = object[keys[index++]]; + return array; + } + return []; +}; + +/** + * Converts an array of keys immediately followed by their respective value to an object, omitting undefined values. + * @param {Array.<*>} array Array to convert + * @returns {Object.} Converted object + */ +util.toObject = function toObject(array) { + var object = {}, + index = 0; + while (index < array.length) { + var key = array[index++], + val = array[index++]; + if (val !== undefined) + object[key] = val; + } + return object; +}; + +var safePropBackslashRe = /\\/g, + safePropQuoteRe = /"/g; + +/** + * Tests whether the specified name is a reserved word in JS. + * @param {string} name Name to test + * @returns {boolean} `true` if reserved, otherwise `false` + */ +util.isReserved = function isReserved(name) { + return /^(?:do|if|in|for|let|new|try|var|case|else|enum|eval|false|null|this|true|void|with|break|catch|class|const|super|throw|while|yield|delete|export|import|public|return|static|switch|typeof|default|extends|finally|package|private|continue|debugger|function|arguments|interface|protected|implements|instanceof)$/.test(name); +}; + +/** + * Returns a safe property accessor for the specified property name. + * @param {string} prop Property name + * @returns {string} Safe accessor + */ +util.safeProp = function safeProp(prop) { + if (!/^[$\w_]+$/.test(prop) || util.isReserved(prop)) + return "[\"" + prop.replace(safePropBackslashRe, "\\\\").replace(safePropQuoteRe, "\\\"") + "\"]"; + return "." + prop; +}; + +/** + * Converts the first character of a string to upper case. + * @param {string} str String to convert + * @returns {string} Converted string + */ +util.ucFirst = function ucFirst(str) { + return str.charAt(0).toUpperCase() + str.substring(1); +}; + +var camelCaseRe = /_([a-z])/g; + +/** + * Converts a string to camel case. + * @param {string} str String to convert + * @returns {string} Converted string + */ +util.camelCase = function camelCase(str) { + return str.substring(0, 1) + + str.substring(1) + .replace(camelCaseRe, function($0, $1) { return $1.toUpperCase(); }); +}; + +/** + * Compares reflected fields by id. + * @param {Field} a First field + * @param {Field} b Second field + * @returns {number} Comparison value + */ +util.compareFieldsById = function compareFieldsById(a, b) { + return a.id - b.id; +}; + +/** + * Decorator helper for types (TypeScript). + * @param {Constructor} ctor Constructor function + * @param {string} [typeName] Type name, defaults to the constructor's name + * @returns {Type} Reflected type + * @template T extends Message + * @property {Root} root Decorators root + */ +util.decorateType = function decorateType(ctor, typeName) { + + /* istanbul ignore if */ + if (ctor.$type) { + if (typeName && ctor.$type.name !== typeName) { + util.decorateRoot.remove(ctor.$type); + ctor.$type.name = typeName; + util.decorateRoot.add(ctor.$type); + } + return ctor.$type; + } + + /* istanbul ignore next */ + if (!Type) + Type = require(35); + + var type = new Type(typeName || ctor.name); + util.decorateRoot.add(type); + type.ctor = ctor; // sets up .encode, .decode etc. + Object.defineProperty(ctor, "$type", { value: type, enumerable: false }); + Object.defineProperty(ctor.prototype, "$type", { value: type, enumerable: false }); + return type; +}; + +var decorateEnumIndex = 0; + +/** + * Decorator helper for enums (TypeScript). + * @param {Object} object Enum object + * @returns {Enum} Reflected enum + */ +util.decorateEnum = function decorateEnum(object) { + + /* istanbul ignore if */ + if (object.$type) + return object.$type; + + /* istanbul ignore next */ + if (!Enum) + Enum = require(15); + + var enm = new Enum("Enum" + decorateEnumIndex++, object); + util.decorateRoot.add(enm); + Object.defineProperty(object, "$type", { value: enm, enumerable: false }); + return enm; +}; + +/** + * Decorator root (TypeScript). + * @name util.decorateRoot + * @type {Root} + * @readonly + */ +Object.defineProperty(util, "decorateRoot", { + get: function() { + return roots["decorated"] || (roots["decorated"] = new (require(29))()); + } +}); + +},{"15":15,"29":29,"3":3,"30":30,"35":35,"39":39,"5":5,"8":8}],38:[function(require,module,exports){ +"use strict"; +module.exports = LongBits; + +var util = require(39); + +/** + * Constructs new long bits. + * @classdesc Helper class for working with the low and high bits of a 64 bit value. + * @memberof util + * @constructor + * @param {number} lo Low 32 bits, unsigned + * @param {number} hi High 32 bits, unsigned + */ +function LongBits(lo, hi) { + + // note that the casts below are theoretically unnecessary as of today, but older statically + // generated converter code might still call the ctor with signed 32bits. kept for compat. + + /** + * Low bits. + * @type {number} + */ + this.lo = lo >>> 0; + + /** + * High bits. + * @type {number} + */ + this.hi = hi >>> 0; +} + +/** + * Zero bits. + * @memberof util.LongBits + * @type {util.LongBits} + */ +var zero = LongBits.zero = new LongBits(0, 0); + +zero.toNumber = function() { return 0; }; +zero.zzEncode = zero.zzDecode = function() { return this; }; +zero.length = function() { return 1; }; + +/** + * Zero hash. + * @memberof util.LongBits + * @type {string} + */ +var zeroHash = LongBits.zeroHash = "\0\0\0\0\0\0\0\0"; + +/** + * Constructs new long bits from the specified number. + * @param {number} value Value + * @returns {util.LongBits} Instance + */ +LongBits.fromNumber = function fromNumber(value) { + if (value === 0) + return zero; + var sign = value < 0; + if (sign) + value = -value; + var lo = value >>> 0, + hi = (value - lo) / 4294967296 >>> 0; + if (sign) { + hi = ~hi >>> 0; + lo = ~lo >>> 0; + if (++lo > 4294967295) { + lo = 0; + if (++hi > 4294967295) + hi = 0; + } + } + return new LongBits(lo, hi); +}; + +/** + * Constructs new long bits from a number, long or string. + * @param {Long|number|string} value Value + * @returns {util.LongBits} Instance + */ +LongBits.from = function from(value) { + if (typeof value === "number") + return LongBits.fromNumber(value); + if (util.isString(value)) { + /* istanbul ignore else */ + if (util.Long) + value = util.Long.fromString(value); + else + return LongBits.fromNumber(parseInt(value, 10)); + } + return value.low || value.high ? new LongBits(value.low >>> 0, value.high >>> 0) : zero; +}; + +/** + * Converts this long bits to a possibly unsafe JavaScript number. + * @param {boolean} [unsigned=false] Whether unsigned or not + * @returns {number} Possibly unsafe number + */ +LongBits.prototype.toNumber = function toNumber(unsigned) { + if (!unsigned && this.hi >>> 31) { + var lo = ~this.lo + 1 >>> 0, + hi = ~this.hi >>> 0; + if (!lo) + hi = hi + 1 >>> 0; + return -(lo + hi * 4294967296); + } + return this.lo + this.hi * 4294967296; +}; + +/** + * Converts this long bits to a long. + * @param {boolean} [unsigned=false] Whether unsigned or not + * @returns {Long} Long + */ +LongBits.prototype.toLong = function toLong(unsigned) { + return util.Long + ? new util.Long(this.lo | 0, this.hi | 0, Boolean(unsigned)) + /* istanbul ignore next */ + : { low: this.lo | 0, high: this.hi | 0, unsigned: Boolean(unsigned) }; +}; + +var charCodeAt = String.prototype.charCodeAt; + +/** + * Constructs new long bits from the specified 8 characters long hash. + * @param {string} hash Hash + * @returns {util.LongBits} Bits + */ +LongBits.fromHash = function fromHash(hash) { + if (hash === zeroHash) + return zero; + return new LongBits( + ( charCodeAt.call(hash, 0) + | charCodeAt.call(hash, 1) << 8 + | charCodeAt.call(hash, 2) << 16 + | charCodeAt.call(hash, 3) << 24) >>> 0 + , + ( charCodeAt.call(hash, 4) + | charCodeAt.call(hash, 5) << 8 + | charCodeAt.call(hash, 6) << 16 + | charCodeAt.call(hash, 7) << 24) >>> 0 + ); +}; + +/** + * Converts this long bits to a 8 characters long hash. + * @returns {string} Hash + */ +LongBits.prototype.toHash = function toHash() { + return String.fromCharCode( + this.lo & 255, + this.lo >>> 8 & 255, + this.lo >>> 16 & 255, + this.lo >>> 24 , + this.hi & 255, + this.hi >>> 8 & 255, + this.hi >>> 16 & 255, + this.hi >>> 24 + ); +}; + +/** + * Zig-zag encodes this long bits. + * @returns {util.LongBits} `this` + */ +LongBits.prototype.zzEncode = function zzEncode() { + var mask = this.hi >> 31; + this.hi = ((this.hi << 1 | this.lo >>> 31) ^ mask) >>> 0; + this.lo = ( this.lo << 1 ^ mask) >>> 0; + return this; +}; + +/** + * Zig-zag decodes this long bits. + * @returns {util.LongBits} `this` + */ +LongBits.prototype.zzDecode = function zzDecode() { + var mask = -(this.lo & 1); + this.lo = ((this.lo >>> 1 | this.hi << 31) ^ mask) >>> 0; + this.hi = ( this.hi >>> 1 ^ mask) >>> 0; + return this; +}; + +/** + * Calculates the length of this longbits when encoded as a varint. + * @returns {number} Length + */ +LongBits.prototype.length = function length() { + var part0 = this.lo, + part1 = (this.lo >>> 28 | this.hi << 4) >>> 0, + part2 = this.hi >>> 24; + return part2 === 0 + ? part1 === 0 + ? part0 < 16384 + ? part0 < 128 ? 1 : 2 + : part0 < 2097152 ? 3 : 4 + : part1 < 16384 + ? part1 < 128 ? 5 : 6 + : part1 < 2097152 ? 7 : 8 + : part2 < 128 ? 9 : 10; +}; + +},{"39":39}],39:[function(require,module,exports){ +"use strict"; +var util = exports; + +// used to return a Promise where callback is omitted +util.asPromise = require(1); + +// converts to / from base64 encoded strings +util.base64 = require(2); + +// base class of rpc.Service +util.EventEmitter = require(4); + +// float handling accross browsers +util.float = require(6); + +// requires modules optionally and hides the call from bundlers +util.inquire = require(7); + +// converts to / from utf8 encoded strings +util.utf8 = require(10); + +// provides a node-like buffer pool in the browser +util.pool = require(9); + +// utility to work with the low and high bits of a 64 bit value +util.LongBits = require(38); + +// global object reference +util.global = typeof window !== "undefined" && window + || typeof global !== "undefined" && global + || typeof self !== "undefined" && self + || this; // eslint-disable-line no-invalid-this + +/** + * An immuable empty array. + * @memberof util + * @type {Array.<*>} + * @const + */ +util.emptyArray = Object.freeze ? Object.freeze([]) : /* istanbul ignore next */ []; // used on prototypes + +/** + * An immutable empty object. + * @type {Object} + * @const + */ +util.emptyObject = Object.freeze ? Object.freeze({}) : /* istanbul ignore next */ {}; // used on prototypes + +/** + * Whether running within node or not. + * @memberof util + * @type {boolean} + * @const + */ +util.isNode = Boolean(util.global.process && util.global.process.versions && util.global.process.versions.node); + +/** + * Tests if the specified value is an integer. + * @function + * @param {*} value Value to test + * @returns {boolean} `true` if the value is an integer + */ +util.isInteger = Number.isInteger || /* istanbul ignore next */ function isInteger(value) { + return typeof value === "number" && isFinite(value) && Math.floor(value) === value; +}; + +/** + * Tests if the specified value is a string. + * @param {*} value Value to test + * @returns {boolean} `true` if the value is a string + */ +util.isString = function isString(value) { + return typeof value === "string" || value instanceof String; +}; + +/** + * Tests if the specified value is a non-null object. + * @param {*} value Value to test + * @returns {boolean} `true` if the value is a non-null object + */ +util.isObject = function isObject(value) { + return value && typeof value === "object"; +}; + +/** + * Checks if a property on a message is considered to be present. + * This is an alias of {@link util.isSet}. + * @function + * @param {Object} obj Plain object or message instance + * @param {string} prop Property name + * @returns {boolean} `true` if considered to be present, otherwise `false` + */ +util.isset = + +/** + * Checks if a property on a message is considered to be present. + * @param {Object} obj Plain object or message instance + * @param {string} prop Property name + * @returns {boolean} `true` if considered to be present, otherwise `false` + */ +util.isSet = function isSet(obj, prop) { + var value = obj[prop]; + if (value != null && obj.hasOwnProperty(prop)) // eslint-disable-line eqeqeq, no-prototype-builtins + return typeof value !== "object" || (Array.isArray(value) ? value.length : Object.keys(value).length) > 0; + return false; +}; + +/** + * Any compatible Buffer instance. + * This is a minimal stand-alone definition of a Buffer instance. The actual type is that exported by node's typings. + * @interface Buffer + * @extends Uint8Array + */ + +/** + * Node's Buffer class if available. + * @type {Constructor} + */ +util.Buffer = (function() { + try { + var Buffer = util.inquire("buffer").Buffer; + // refuse to use non-node buffers if not explicitly assigned (perf reasons): + return Buffer.prototype.utf8Write ? Buffer : /* istanbul ignore next */ null; + } catch (e) { + /* istanbul ignore next */ + return null; + } +})(); + +// Internal alias of or polyfull for Buffer.from. +util._Buffer_from = null; + +// Internal alias of or polyfill for Buffer.allocUnsafe. +util._Buffer_allocUnsafe = null; + +/** + * Creates a new buffer of whatever type supported by the environment. + * @param {number|number[]} [sizeOrArray=0] Buffer size or number array + * @returns {Uint8Array|Buffer} Buffer + */ +util.newBuffer = function newBuffer(sizeOrArray) { + /* istanbul ignore next */ + return typeof sizeOrArray === "number" + ? util.Buffer + ? util._Buffer_allocUnsafe(sizeOrArray) + : new util.Array(sizeOrArray) + : util.Buffer + ? util._Buffer_from(sizeOrArray) + : typeof Uint8Array === "undefined" + ? sizeOrArray + : new Uint8Array(sizeOrArray); +}; + +/** + * Array implementation used in the browser. `Uint8Array` if supported, otherwise `Array`. + * @type {Constructor} + */ +util.Array = typeof Uint8Array !== "undefined" ? Uint8Array /* istanbul ignore next */ : Array; + +/** + * Any compatible Long instance. + * This is a minimal stand-alone definition of a Long instance. The actual type is that exported by long.js. + * @interface Long + * @property {number} low Low bits + * @property {number} high High bits + * @property {boolean} unsigned Whether unsigned or not + */ + +/** + * Long.js's Long class if available. + * @type {Constructor} + */ +util.Long = /* istanbul ignore next */ util.global.dcodeIO && /* istanbul ignore next */ util.global.dcodeIO.Long + || /* istanbul ignore next */ util.global.Long + || util.inquire("long"); + +/** + * Regular expression used to verify 2 bit (`bool`) map keys. + * @type {RegExp} + * @const + */ +util.key2Re = /^true|false|0|1$/; + +/** + * Regular expression used to verify 32 bit (`int32` etc.) map keys. + * @type {RegExp} + * @const + */ +util.key32Re = /^-?(?:0|[1-9][0-9]*)$/; + +/** + * Regular expression used to verify 64 bit (`int64` etc.) map keys. + * @type {RegExp} + * @const + */ +util.key64Re = /^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/; + +/** + * Converts a number or long to an 8 characters long hash string. + * @param {Long|number} value Value to convert + * @returns {string} Hash + */ +util.longToHash = function longToHash(value) { + return value + ? util.LongBits.from(value).toHash() + : util.LongBits.zeroHash; +}; + +/** + * Converts an 8 characters long hash string to a long or number. + * @param {string} hash Hash + * @param {boolean} [unsigned=false] Whether unsigned or not + * @returns {Long|number} Original value + */ +util.longFromHash = function longFromHash(hash, unsigned) { + var bits = util.LongBits.fromHash(hash); + if (util.Long) + return util.Long.fromBits(bits.lo, bits.hi, unsigned); + return bits.toNumber(Boolean(unsigned)); +}; + +/** + * Merges the properties of the source object into the destination object. + * @memberof util + * @param {Object.} dst Destination object + * @param {Object.} src Source object + * @param {boolean} [ifNotSet=false] Merges only if the key is not already set + * @returns {Object.} Destination object + */ +function merge(dst, src, ifNotSet) { // used by converters + for (var keys = Object.keys(src), i = 0; i < keys.length; ++i) + if (dst[keys[i]] === undefined || !ifNotSet) + dst[keys[i]] = src[keys[i]]; + return dst; +} + +util.merge = merge; + +/** + * Converts the first character of a string to lower case. + * @param {string} str String to convert + * @returns {string} Converted string + */ +util.lcFirst = function lcFirst(str) { + return str.charAt(0).toLowerCase() + str.substring(1); +}; + +/** + * Creates a custom error constructor. + * @memberof util + * @param {string} name Error name + * @returns {Constructor} Custom error constructor + */ +function newError(name) { + + function CustomError(message, properties) { + + if (!(this instanceof CustomError)) + return new CustomError(message, properties); + + // Error.call(this, message); + // ^ just returns a new error instance because the ctor can be called as a function + + Object.defineProperty(this, "message", { get: function() { return message; } }); + + /* istanbul ignore next */ + if (Error.captureStackTrace) // node + Error.captureStackTrace(this, CustomError); + else + Object.defineProperty(this, "stack", { value: (new Error()).stack || "" }); + + if (properties) + merge(this, properties); + } + + (CustomError.prototype = Object.create(Error.prototype)).constructor = CustomError; + + Object.defineProperty(CustomError.prototype, "name", { get: function() { return name; } }); + + CustomError.prototype.toString = function toString() { + return this.name + ": " + this.message; + }; + + return CustomError; +} + +util.newError = newError; + +/** + * Constructs a new protocol error. + * @classdesc Error subclass indicating a protocol specifc error. + * @memberof util + * @extends Error + * @template T extends Message + * @constructor + * @param {string} message Error message + * @param {Object.} [properties] Additional properties + * @example + * try { + * MyMessage.decode(someBuffer); // throws if required fields are missing + * } catch (e) { + * if (e instanceof ProtocolError && e.instance) + * console.log("decoded so far: " + JSON.stringify(e.instance)); + * } + */ +util.ProtocolError = newError("ProtocolError"); + +/** + * So far decoded message instance. + * @name util.ProtocolError#instance + * @type {Message} + */ + +/** + * A OneOf getter as returned by {@link util.oneOfGetter}. + * @typedef OneOfGetter + * @type {function} + * @returns {string|undefined} Set field name, if any + */ + +/** + * Builds a getter for a oneof's present field name. + * @param {string[]} fieldNames Field names + * @returns {OneOfGetter} Unbound getter + */ +util.oneOfGetter = function getOneOf(fieldNames) { + var fieldMap = {}; + for (var i = 0; i < fieldNames.length; ++i) + fieldMap[fieldNames[i]] = 1; + + /** + * @returns {string|undefined} Set field name, if any + * @this Object + * @ignore + */ + return function() { // eslint-disable-line consistent-return + for (var keys = Object.keys(this), i = keys.length - 1; i > -1; --i) + if (fieldMap[keys[i]] === 1 && this[keys[i]] !== undefined && this[keys[i]] !== null) + return keys[i]; + }; +}; + +/** + * A OneOf setter as returned by {@link util.oneOfSetter}. + * @typedef OneOfSetter + * @type {function} + * @param {string|undefined} value Field name + * @returns {undefined} + */ + +/** + * Builds a setter for a oneof's present field name. + * @param {string[]} fieldNames Field names + * @returns {OneOfSetter} Unbound setter + */ +util.oneOfSetter = function setOneOf(fieldNames) { + + /** + * @param {string} name Field name + * @returns {undefined} + * @this Object + * @ignore + */ + return function(name) { + for (var i = 0; i < fieldNames.length; ++i) + if (fieldNames[i] !== name) + delete this[fieldNames[i]]; + }; +}; + +/** + * Default conversion options used for {@link Message#toJSON} implementations. + * + * These options are close to proto3's JSON mapping with the exception that internal types like Any are handled just like messages. More precisely: + * + * - Longs become strings + * - Enums become string keys + * - Bytes become base64 encoded strings + * - (Sub-)Messages become plain objects + * - Maps become plain objects with all string keys + * - Repeated fields become arrays + * - NaN and Infinity for float and double fields become strings + * + * @type {IConversionOptions} + * @see https://developers.google.com/protocol-buffers/docs/proto3?hl=en#json + */ +util.toJSONOptions = { + longs: String, + enums: String, + bytes: String, + json: true +}; + +// Sets up buffer utility according to the environment (called in index-minimal) +util._configure = function() { + var Buffer = util.Buffer; + /* istanbul ignore if */ + if (!Buffer) { + util._Buffer_from = util._Buffer_allocUnsafe = null; + return; + } + // because node 4.x buffers are incompatible & immutable + // see: https://github.com/dcodeIO/protobuf.js/pull/665 + util._Buffer_from = Buffer.from !== Uint8Array.from && Buffer.from || + /* istanbul ignore next */ + function Buffer_from(value, encoding) { + return new Buffer(value, encoding); + }; + util._Buffer_allocUnsafe = Buffer.allocUnsafe || + /* istanbul ignore next */ + function Buffer_allocUnsafe(size) { + return new Buffer(size); + }; +}; + +},{"1":1,"10":10,"2":2,"38":38,"4":4,"6":6,"7":7,"9":9}],40:[function(require,module,exports){ +"use strict"; +module.exports = verifier; + +var Enum = require(15), + util = require(37); + +function invalid(field, expected) { + return field.name + ": " + expected + (field.repeated && expected !== "array" ? "[]" : field.map && expected !== "object" ? "{k:"+field.keyType+"}" : "") + " expected"; +} + +/** + * Generates a partial value verifier. + * @param {Codegen} gen Codegen instance + * @param {Field} field Reflected field + * @param {number} fieldIndex Field index + * @param {string} ref Variable reference + * @returns {Codegen} Codegen instance + * @ignore + */ +function genVerifyValue(gen, field, fieldIndex, ref) { + /* eslint-disable no-unexpected-multiline */ + if (field.resolvedType) { + if (field.resolvedType instanceof Enum) { gen + ("switch(%s){", ref) + ("default:") + ("return%j", invalid(field, "enum value")); + for (var keys = Object.keys(field.resolvedType.values), j = 0; j < keys.length; ++j) gen + ("case %i:", field.resolvedType.values[keys[j]]); + gen + ("break") + ("}"); + } else { + gen + ("{") + ("var e=types[%i].verify(%s);", fieldIndex, ref) + ("if(e)") + ("return%j+e", field.name + ".") + ("}"); + } + } else { + switch (field.type) { + case "int32": + case "uint32": + case "sint32": + case "fixed32": + case "sfixed32": gen + ("if(!util.isInteger(%s))", ref) + ("return%j", invalid(field, "integer")); + break; + case "int64": + case "uint64": + case "sint64": + case "fixed64": + case "sfixed64": gen + ("if(!util.isInteger(%s)&&!(%s&&util.isInteger(%s.low)&&util.isInteger(%s.high)))", ref, ref, ref, ref) + ("return%j", invalid(field, "integer|Long")); + break; + case "float": + case "double": gen + ("if(typeof %s!==\"number\")", ref) + ("return%j", invalid(field, "number")); + break; + case "bool": gen + ("if(typeof %s!==\"boolean\")", ref) + ("return%j", invalid(field, "boolean")); + break; + case "string": gen + ("if(!util.isString(%s))", ref) + ("return%j", invalid(field, "string")); + break; + case "bytes": gen + ("if(!(%s&&typeof %s.length===\"number\"||util.isString(%s)))", ref, ref, ref) + ("return%j", invalid(field, "buffer")); + break; + } + } + return gen; + /* eslint-enable no-unexpected-multiline */ +} + +/** + * Generates a partial key verifier. + * @param {Codegen} gen Codegen instance + * @param {Field} field Reflected field + * @param {string} ref Variable reference + * @returns {Codegen} Codegen instance + * @ignore + */ +function genVerifyKey(gen, field, ref) { + /* eslint-disable no-unexpected-multiline */ + switch (field.keyType) { + case "int32": + case "uint32": + case "sint32": + case "fixed32": + case "sfixed32": gen + ("if(!util.key32Re.test(%s))", ref) + ("return%j", invalid(field, "integer key")); + break; + case "int64": + case "uint64": + case "sint64": + case "fixed64": + case "sfixed64": gen + ("if(!util.key64Re.test(%s))", ref) // see comment above: x is ok, d is not + ("return%j", invalid(field, "integer|Long key")); + break; + case "bool": gen + ("if(!util.key2Re.test(%s))", ref) + ("return%j", invalid(field, "boolean key")); + break; + } + return gen; + /* eslint-enable no-unexpected-multiline */ +} + +/** + * Generates a verifier specific to the specified message type. + * @param {Type} mtype Message type + * @returns {Codegen} Codegen instance + */ +function verifier(mtype) { + /* eslint-disable no-unexpected-multiline */ + + var gen = util.codegen(["m"], mtype.name + "$verify") + ("if(typeof m!==\"object\"||m===null)") + ("return%j", "object expected"); + var oneofs = mtype.oneofsArray, + seenFirstField = {}; + if (oneofs.length) gen + ("var p={}"); + + for (var i = 0; i < /* initializes */ mtype.fieldsArray.length; ++i) { + var field = mtype._fieldsArray[i].resolve(), + ref = "m" + util.safeProp(field.name); + + if (field.optional) gen + ("if(%s!=null&&m.hasOwnProperty(%j)){", ref, field.name); // !== undefined && !== null + + // map fields + if (field.map) { gen + ("if(!util.isObject(%s))", ref) + ("return%j", invalid(field, "object")) + ("var k=Object.keys(%s)", ref) + ("for(var i=0;i} + * @const + */ +var wrappers = exports; + +var Message = require(21); + +/** + * From object converter part of an {@link IWrapper}. + * @typedef WrapperFromObjectConverter + * @type {function} + * @param {Object.} object Plain object + * @returns {Message<{}>} Message instance + * @this Type + */ + +/** + * To object converter part of an {@link IWrapper}. + * @typedef WrapperToObjectConverter + * @type {function} + * @param {Message<{}>} message Message instance + * @param {IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + * @this Type + */ + +/** + * Common type wrapper part of {@link wrappers}. + * @interface IWrapper + * @property {WrapperFromObjectConverter} [fromObject] From object converter + * @property {WrapperToObjectConverter} [toObject] To object converter + */ + +// Custom wrapper for Any +wrappers[".google.protobuf.Any"] = { + + fromObject: function(object) { + + // unwrap value type if mapped + if (object && object["@type"]) { + var type = this.lookup(object["@type"]); + /* istanbul ignore else */ + if (type) { + // type_url does not accept leading "." + var type_url = object["@type"].charAt(0) === "." ? + object["@type"].substr(1) : object["@type"]; + // type_url prefix is optional, but path seperator is required + return this.create({ + type_url: "/" + type_url, + value: type.encode(type.fromObject(object)).finish() + }); + } + } + + return this.fromObject(object); + }, + + toObject: function(message, options) { + + // decode value if requested and unmapped + if (options && options.json && message.type_url && message.value) { + // Only use fully qualified type name after the last '/' + var name = message.type_url.substring(message.type_url.lastIndexOf("/") + 1); + var type = this.lookup(name); + /* istanbul ignore else */ + if (type) + message = type.decode(message.value); + } + + // wrap value if unmapped + if (!(message instanceof this.ctor) && message instanceof Message) { + var object = message.$type.toObject(message, options); + object["@type"] = message.$type.fullName; + return object; + } + + return this.toObject(message, options); + } +}; + +},{"21":21}],42:[function(require,module,exports){ +"use strict"; +module.exports = Writer; + +var util = require(39); + +var BufferWriter; // cyclic + +var LongBits = util.LongBits, + base64 = util.base64, + utf8 = util.utf8; + +/** + * Constructs a new writer operation instance. + * @classdesc Scheduled writer operation. + * @constructor + * @param {function(*, Uint8Array, number)} fn Function to call + * @param {number} len Value byte length + * @param {*} val Value to write + * @ignore + */ +function Op(fn, len, val) { + + /** + * Function to call. + * @type {function(Uint8Array, number, *)} + */ + this.fn = fn; + + /** + * Value byte length. + * @type {number} + */ + this.len = len; + + /** + * Next operation. + * @type {Writer.Op|undefined} + */ + this.next = undefined; + + /** + * Value to write. + * @type {*} + */ + this.val = val; // type varies +} + +/* istanbul ignore next */ +function noop() {} // eslint-disable-line no-empty-function + +/** + * Constructs a new writer state instance. + * @classdesc Copied writer state. + * @memberof Writer + * @constructor + * @param {Writer} writer Writer to copy state from + * @ignore + */ +function State(writer) { + + /** + * Current head. + * @type {Writer.Op} + */ + this.head = writer.head; + + /** + * Current tail. + * @type {Writer.Op} + */ + this.tail = writer.tail; + + /** + * Current buffer length. + * @type {number} + */ + this.len = writer.len; + + /** + * Next state. + * @type {State|null} + */ + this.next = writer.states; +} + +/** + * Constructs a new writer instance. + * @classdesc Wire format writer using `Uint8Array` if available, otherwise `Array`. + * @constructor + */ +function Writer() { + + /** + * Current length. + * @type {number} + */ + this.len = 0; + + /** + * Operations head. + * @type {Object} + */ + this.head = new Op(noop, 0, 0); + + /** + * Operations tail + * @type {Object} + */ + this.tail = this.head; + + /** + * Linked forked states. + * @type {Object|null} + */ + this.states = null; + + // When a value is written, the writer calculates its byte length and puts it into a linked + // list of operations to perform when finish() is called. This both allows us to allocate + // buffers of the exact required size and reduces the amount of work we have to do compared + // to first calculating over objects and then encoding over objects. In our case, the encoding + // part is just a linked list walk calling operations with already prepared values. +} + +/** + * Creates a new writer. + * @function + * @returns {BufferWriter|Writer} A {@link BufferWriter} when Buffers are supported, otherwise a {@link Writer} + */ +Writer.create = util.Buffer + ? function create_buffer_setup() { + return (Writer.create = function create_buffer() { + return new BufferWriter(); + })(); + } + /* istanbul ignore next */ + : function create_array() { + return new Writer(); + }; + +/** + * Allocates a buffer of the specified size. + * @param {number} size Buffer size + * @returns {Uint8Array} Buffer + */ +Writer.alloc = function alloc(size) { + return new util.Array(size); +}; + +// Use Uint8Array buffer pool in the browser, just like node does with buffers +/* istanbul ignore else */ +if (util.Array !== Array) + Writer.alloc = util.pool(Writer.alloc, util.Array.prototype.subarray); + +/** + * Pushes a new operation to the queue. + * @param {function(Uint8Array, number, *)} fn Function to call + * @param {number} len Value byte length + * @param {number} val Value to write + * @returns {Writer} `this` + * @private + */ +Writer.prototype._push = function push(fn, len, val) { + this.tail = this.tail.next = new Op(fn, len, val); + this.len += len; + return this; +}; + +function writeByte(val, buf, pos) { + buf[pos] = val & 255; +} + +function writeVarint32(val, buf, pos) { + while (val > 127) { + buf[pos++] = val & 127 | 128; + val >>>= 7; + } + buf[pos] = val; +} + +/** + * Constructs a new varint writer operation instance. + * @classdesc Scheduled varint writer operation. + * @extends Op + * @constructor + * @param {number} len Value byte length + * @param {number} val Value to write + * @ignore + */ +function VarintOp(len, val) { + this.len = len; + this.next = undefined; + this.val = val; +} + +VarintOp.prototype = Object.create(Op.prototype); +VarintOp.prototype.fn = writeVarint32; + +/** + * Writes an unsigned 32 bit value as a varint. + * @param {number} value Value to write + * @returns {Writer} `this` + */ +Writer.prototype.uint32 = function write_uint32(value) { + // here, the call to this.push has been inlined and a varint specific Op subclass is used. + // uint32 is by far the most frequently used operation and benefits significantly from this. + this.len += (this.tail = this.tail.next = new VarintOp( + (value = value >>> 0) + < 128 ? 1 + : value < 16384 ? 2 + : value < 2097152 ? 3 + : value < 268435456 ? 4 + : 5, + value)).len; + return this; +}; + +/** + * Writes a signed 32 bit value as a varint. + * @function + * @param {number} value Value to write + * @returns {Writer} `this` + */ +Writer.prototype.int32 = function write_int32(value) { + return value < 0 + ? this._push(writeVarint64, 10, LongBits.fromNumber(value)) // 10 bytes per spec + : this.uint32(value); +}; + +/** + * Writes a 32 bit value as a varint, zig-zag encoded. + * @param {number} value Value to write + * @returns {Writer} `this` + */ +Writer.prototype.sint32 = function write_sint32(value) { + return this.uint32((value << 1 ^ value >> 31) >>> 0); +}; + +function writeVarint64(val, buf, pos) { + while (val.hi) { + buf[pos++] = val.lo & 127 | 128; + val.lo = (val.lo >>> 7 | val.hi << 25) >>> 0; + val.hi >>>= 7; + } + while (val.lo > 127) { + buf[pos++] = val.lo & 127 | 128; + val.lo = val.lo >>> 7; + } + buf[pos++] = val.lo; +} + +/** + * Writes an unsigned 64 bit value as a varint. + * @param {Long|number|string} value Value to write + * @returns {Writer} `this` + * @throws {TypeError} If `value` is a string and no long library is present. + */ +Writer.prototype.uint64 = function write_uint64(value) { + var bits = LongBits.from(value); + return this._push(writeVarint64, bits.length(), bits); +}; + +/** + * Writes a signed 64 bit value as a varint. + * @function + * @param {Long|number|string} value Value to write + * @returns {Writer} `this` + * @throws {TypeError} If `value` is a string and no long library is present. + */ +Writer.prototype.int64 = Writer.prototype.uint64; + +/** + * Writes a signed 64 bit value as a varint, zig-zag encoded. + * @param {Long|number|string} value Value to write + * @returns {Writer} `this` + * @throws {TypeError} If `value` is a string and no long library is present. + */ +Writer.prototype.sint64 = function write_sint64(value) { + var bits = LongBits.from(value).zzEncode(); + return this._push(writeVarint64, bits.length(), bits); +}; + +/** + * Writes a boolish value as a varint. + * @param {boolean} value Value to write + * @returns {Writer} `this` + */ +Writer.prototype.bool = function write_bool(value) { + return this._push(writeByte, 1, value ? 1 : 0); +}; + +function writeFixed32(val, buf, pos) { + buf[pos ] = val & 255; + buf[pos + 1] = val >>> 8 & 255; + buf[pos + 2] = val >>> 16 & 255; + buf[pos + 3] = val >>> 24; +} + +/** + * Writes an unsigned 32 bit value as fixed 32 bits. + * @param {number} value Value to write + * @returns {Writer} `this` + */ +Writer.prototype.fixed32 = function write_fixed32(value) { + return this._push(writeFixed32, 4, value >>> 0); +}; + +/** + * Writes a signed 32 bit value as fixed 32 bits. + * @function + * @param {number} value Value to write + * @returns {Writer} `this` + */ +Writer.prototype.sfixed32 = Writer.prototype.fixed32; + +/** + * Writes an unsigned 64 bit value as fixed 64 bits. + * @param {Long|number|string} value Value to write + * @returns {Writer} `this` + * @throws {TypeError} If `value` is a string and no long library is present. + */ +Writer.prototype.fixed64 = function write_fixed64(value) { + var bits = LongBits.from(value); + return this._push(writeFixed32, 4, bits.lo)._push(writeFixed32, 4, bits.hi); +}; + +/** + * Writes a signed 64 bit value as fixed 64 bits. + * @function + * @param {Long|number|string} value Value to write + * @returns {Writer} `this` + * @throws {TypeError} If `value` is a string and no long library is present. + */ +Writer.prototype.sfixed64 = Writer.prototype.fixed64; + +/** + * Writes a float (32 bit). + * @function + * @param {number} value Value to write + * @returns {Writer} `this` + */ +Writer.prototype.float = function write_float(value) { + return this._push(util.float.writeFloatLE, 4, value); +}; + +/** + * Writes a double (64 bit float). + * @function + * @param {number} value Value to write + * @returns {Writer} `this` + */ +Writer.prototype.double = function write_double(value) { + return this._push(util.float.writeDoubleLE, 8, value); +}; + +var writeBytes = util.Array.prototype.set + ? function writeBytes_set(val, buf, pos) { + buf.set(val, pos); // also works for plain array values + } + /* istanbul ignore next */ + : function writeBytes_for(val, buf, pos) { + for (var i = 0; i < val.length; ++i) + buf[pos + i] = val[i]; + }; + +/** + * Writes a sequence of bytes. + * @param {Uint8Array|string} value Buffer or base64 encoded string to write + * @returns {Writer} `this` + */ +Writer.prototype.bytes = function write_bytes(value) { + var len = value.length >>> 0; + if (!len) + return this._push(writeByte, 1, 0); + if (util.isString(value)) { + var buf = Writer.alloc(len = base64.length(value)); + base64.decode(value, buf, 0); + value = buf; + } + return this.uint32(len)._push(writeBytes, len, value); +}; + +/** + * Writes a string. + * @param {string} value Value to write + * @returns {Writer} `this` + */ +Writer.prototype.string = function write_string(value) { + var len = utf8.length(value); + return len + ? this.uint32(len)._push(utf8.write, len, value) + : this._push(writeByte, 1, 0); +}; + +/** + * Forks this writer's state by pushing it to a stack. + * Calling {@link Writer#reset|reset} or {@link Writer#ldelim|ldelim} resets the writer to the previous state. + * @returns {Writer} `this` + */ +Writer.prototype.fork = function fork() { + this.states = new State(this); + this.head = this.tail = new Op(noop, 0, 0); + this.len = 0; + return this; +}; + +/** + * Resets this instance to the last state. + * @returns {Writer} `this` + */ +Writer.prototype.reset = function reset() { + if (this.states) { + this.head = this.states.head; + this.tail = this.states.tail; + this.len = this.states.len; + this.states = this.states.next; + } else { + this.head = this.tail = new Op(noop, 0, 0); + this.len = 0; + } + return this; +}; + +/** + * Resets to the last state and appends the fork state's current write length as a varint followed by its operations. + * @returns {Writer} `this` + */ +Writer.prototype.ldelim = function ldelim() { + var head = this.head, + tail = this.tail, + len = this.len; + this.reset().uint32(len); + if (len) { + this.tail.next = head.next; // skip noop + this.tail = tail; + this.len += len; + } + return this; +}; + +/** + * Finishes the write operation. + * @returns {Uint8Array} Finished buffer + */ +Writer.prototype.finish = function finish() { + var head = this.head.next, // skip noop + buf = this.constructor.alloc(this.len), + pos = 0; + while (head) { + head.fn(head.val, buf, pos); + pos += head.len; + head = head.next; + } + // this.head = this.tail = null; + return buf; +}; + +Writer._configure = function(BufferWriter_) { + BufferWriter = BufferWriter_; +}; + +},{"39":39}],43:[function(require,module,exports){ +"use strict"; +module.exports = BufferWriter; + +// extends Writer +var Writer = require(42); +(BufferWriter.prototype = Object.create(Writer.prototype)).constructor = BufferWriter; + +var util = require(39); + +var Buffer = util.Buffer; + +/** + * Constructs a new buffer writer instance. + * @classdesc Wire format writer using node buffers. + * @extends Writer + * @constructor + */ +function BufferWriter() { + Writer.call(this); +} + +/** + * Allocates a buffer of the specified size. + * @param {number} size Buffer size + * @returns {Buffer} Buffer + */ +BufferWriter.alloc = function alloc_buffer(size) { + return (BufferWriter.alloc = util._Buffer_allocUnsafe)(size); +}; + +var writeBytesBuffer = Buffer && Buffer.prototype instanceof Uint8Array && Buffer.prototype.set.name === "set" + ? function writeBytesBuffer_set(val, buf, pos) { + buf.set(val, pos); // faster than copy (requires node >= 4 where Buffers extend Uint8Array and set is properly inherited) + // also works for plain array values + } + /* istanbul ignore next */ + : function writeBytesBuffer_copy(val, buf, pos) { + if (val.copy) // Buffer values + val.copy(buf, pos, 0, val.length); + else for (var i = 0; i < val.length;) // plain array values + buf[pos++] = val[i++]; + }; + +/** + * @override + */ +BufferWriter.prototype.bytes = function write_bytes_buffer(value) { + if (util.isString(value)) + value = util._Buffer_from(value, "base64"); + var len = value.length >>> 0; + this.uint32(len); + if (len) + this._push(writeBytesBuffer, len, value); + return this; +}; + +function writeStringBuffer(val, buf, pos) { + if (val.length < 40) // plain js is faster for short strings (probably due to redundant assertions) + util.utf8.write(val, buf, pos); + else + buf.utf8Write(val, pos); +} + +/** + * @override + */ +BufferWriter.prototype.string = function write_string_buffer(value) { + var len = Buffer.byteLength(value); + this.uint32(len); + if (len) + this._push(writeStringBuffer, len, value); + return this; +}; + + +/** + * Finishes the write operation. + * @name BufferWriter#finish + * @function + * @returns {Buffer} Finished buffer + */ + +},{"39":39,"42":42}]},{},[19]) + +})(); +//# sourceMappingURL=protobuf.js.map diff --git a/frontend/assets/plugin_scripts/protobuf.js.meta b/frontend/assets/plugin_scripts/protobuf.js.meta new file mode 100644 index 0000000..871aec5 --- /dev/null +++ b/frontend/assets/plugin_scripts/protobuf.js.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.5", + "uuid": "bd514df4-095e-4088-9060-d99397a29a4f", + "isPlugin": true, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources.meta b/frontend/assets/resources.meta new file mode 100644 index 0000000..e5117a0 --- /dev/null +++ b/frontend/assets/resources.meta @@ -0,0 +1,5 @@ +{ + "ver": "1.0.1", + "uuid": "0bcc8702-42bd-4b5f-b576-6a95eabfe996", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/animation.meta b/frontend/assets/resources/animation.meta new file mode 100644 index 0000000..66a573c --- /dev/null +++ b/frontend/assets/resources/animation.meta @@ -0,0 +1,5 @@ +{ + "ver": "1.0.1", + "uuid": "3b59087c-771e-40f1-b126-2f5ec4bcde3d", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/BluePacman.meta b/frontend/assets/resources/animation/BluePacman.meta new file mode 100644 index 0000000..5b3979f --- /dev/null +++ b/frontend/assets/resources/animation/BluePacman.meta @@ -0,0 +1,7 @@ +{ + "ver": "1.0.1", + "uuid": "0e243c83-a137-4880-9bfe-9e1b57adc453", + "isSubpackage": false, + "subpackageName": "", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/BluePacman/Bottom.anim b/frontend/assets/resources/animation/BluePacman/Bottom.anim new file mode 100644 index 0000000..cd41ddb --- /dev/null +++ b/frontend/assets/resources/animation/BluePacman/Bottom.anim @@ -0,0 +1,31 @@ +{ + "__type__": "cc.AnimationClip", + "_name": "Bottom", + "_objFlags": 0, + "_native": "", + "_duration": 0.25, + "sample": 12, + "speed": 1, + "wrapMode": "2", + "curveData": { + "comps": { + "cc.Sprite": { + "spriteFrame": [ + { + "frame": 0, + "value": { + "__uuid__": "783f1240-d608-40be-8108-3013ab53cfe6" + } + }, + { + "frame": 0.16666666666666666, + "value": { + "__uuid__": "393e649b-addb-4f91-b687-438433026c8d" + } + } + ] + } + } + }, + "events": [] +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/BluePacman/Bottom.anim.meta b/frontend/assets/resources/animation/BluePacman/Bottom.anim.meta new file mode 100644 index 0000000..8672c1d --- /dev/null +++ b/frontend/assets/resources/animation/BluePacman/Bottom.anim.meta @@ -0,0 +1,5 @@ +{ + "ver": "2.1.0", + "uuid": "115ea7bb-d47f-4d3c-a52a-f46584346c3f", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/BluePacman/BottomLeft.anim b/frontend/assets/resources/animation/BluePacman/BottomLeft.anim new file mode 100644 index 0000000..bde3aae --- /dev/null +++ b/frontend/assets/resources/animation/BluePacman/BottomLeft.anim @@ -0,0 +1,31 @@ +{ + "__type__": "cc.AnimationClip", + "_name": "BottomLeft", + "_objFlags": 0, + "_native": "", + "_duration": 0.25, + "sample": 12, + "speed": 1, + "wrapMode": "2", + "curveData": { + "comps": { + "cc.Sprite": { + "spriteFrame": [ + { + "frame": 0, + "value": { + "__uuid__": "748c55f0-e761-40f6-b13b-e416b3d8a55c" + } + }, + { + "frame": 0.16666666666666666, + "value": { + "__uuid__": "6164bac7-9882-43ce-b3d0-9d062d6d0b49" + } + } + ] + } + } + }, + "events": [] +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/BluePacman/BottomLeft.anim.meta b/frontend/assets/resources/animation/BluePacman/BottomLeft.anim.meta new file mode 100644 index 0000000..9553a51 --- /dev/null +++ b/frontend/assets/resources/animation/BluePacman/BottomLeft.anim.meta @@ -0,0 +1,5 @@ +{ + "ver": "2.1.0", + "uuid": "a1bf7c7c-b9f7-4b65-86e3-f86a9e798fb6", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/BluePacman/BottomRight.anim b/frontend/assets/resources/animation/BluePacman/BottomRight.anim new file mode 100644 index 0000000..4cf215f --- /dev/null +++ b/frontend/assets/resources/animation/BluePacman/BottomRight.anim @@ -0,0 +1,31 @@ +{ + "__type__": "cc.AnimationClip", + "_name": "BottomRight", + "_objFlags": 0, + "_native": "", + "_duration": 0.25, + "sample": 12, + "speed": 1, + "wrapMode": "2", + "curveData": { + "comps": { + "cc.Sprite": { + "spriteFrame": [ + { + "frame": 0, + "value": { + "__uuid__": "34cf9fbb-8def-4faf-a56e-123b4c45706c" + } + }, + { + "frame": 0.16666666666666666, + "value": { + "__uuid__": "b6709dd6-6ba7-4222-af38-de79ac80ce8b" + } + } + ] + } + } + }, + "events": [] +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/BluePacman/BottomRight.anim.meta b/frontend/assets/resources/animation/BluePacman/BottomRight.anim.meta new file mode 100644 index 0000000..3e51dcc --- /dev/null +++ b/frontend/assets/resources/animation/BluePacman/BottomRight.anim.meta @@ -0,0 +1,5 @@ +{ + "ver": "2.1.0", + "uuid": "d5af527a-9f0c-4398-b2dd-84426be7bd32", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/BluePacman/Left.anim b/frontend/assets/resources/animation/BluePacman/Left.anim new file mode 100644 index 0000000..1e95eaf --- /dev/null +++ b/frontend/assets/resources/animation/BluePacman/Left.anim @@ -0,0 +1,31 @@ +{ + "__type__": "cc.AnimationClip", + "_name": "Left", + "_objFlags": 0, + "_native": "", + "_duration": 0.25, + "sample": 12, + "speed": 1, + "wrapMode": "2", + "curveData": { + "comps": { + "cc.Sprite": { + "spriteFrame": [ + { + "frame": 0, + "value": { + "__uuid__": "02cd24e3-1c4a-46d7-85af-9034c9445ba7" + } + }, + { + "frame": 0.16666666666666666, + "value": { + "__uuid__": "1f121837-a493-4a41-90e5-74ea560930ad" + } + } + ] + } + } + }, + "events": [] +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/BluePacman/Left.anim.meta b/frontend/assets/resources/animation/BluePacman/Left.anim.meta new file mode 100644 index 0000000..484d85c --- /dev/null +++ b/frontend/assets/resources/animation/BluePacman/Left.anim.meta @@ -0,0 +1,5 @@ +{ + "ver": "2.1.0", + "uuid": "b60618d7-569d-4f13-bdeb-f20341fbadb6", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/BluePacman/Right.anim b/frontend/assets/resources/animation/BluePacman/Right.anim new file mode 100644 index 0000000..e8b9bf0 --- /dev/null +++ b/frontend/assets/resources/animation/BluePacman/Right.anim @@ -0,0 +1,31 @@ +{ + "__type__": "cc.AnimationClip", + "_name": "Right", + "_objFlags": 0, + "_native": "", + "_duration": 0.25, + "sample": 12, + "speed": 1, + "wrapMode": "2", + "curveData": { + "comps": { + "cc.Sprite": { + "spriteFrame": [ + { + "frame": 0, + "value": { + "__uuid__": "a6ec6a1c-dde5-459d-84f9-7b2b8a163e7b" + } + }, + { + "frame": 0.16666666666666666, + "value": { + "__uuid__": "b5d11244-f30a-4b0d-b67b-23648d253d44" + } + } + ] + } + } + }, + "events": [] +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/BluePacman/Right.anim.meta b/frontend/assets/resources/animation/BluePacman/Right.anim.meta new file mode 100644 index 0000000..f0cf6c4 --- /dev/null +++ b/frontend/assets/resources/animation/BluePacman/Right.anim.meta @@ -0,0 +1,5 @@ +{ + "ver": "2.1.0", + "uuid": "0b3fb38e-9110-4191-9b72-6b64a224d049", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/BluePacman/Top.anim b/frontend/assets/resources/animation/BluePacman/Top.anim new file mode 100644 index 0000000..6d5d5e9 --- /dev/null +++ b/frontend/assets/resources/animation/BluePacman/Top.anim @@ -0,0 +1,31 @@ +{ + "__type__": "cc.AnimationClip", + "_name": "Top", + "_objFlags": 0, + "_native": "", + "_duration": 0.25, + "sample": 12, + "speed": 1, + "wrapMode": "2", + "curveData": { + "comps": { + "cc.Sprite": { + "spriteFrame": [ + { + "frame": 0, + "value": { + "__uuid__": "8967d249-e9cf-4e44-85e8-6b9377129d9e" + } + }, + { + "frame": 0.16666666666666666, + "value": { + "__uuid__": "492a57fb-6a5c-423a-bcfe-0695a7828881" + } + } + ] + } + } + }, + "events": [] +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/BluePacman/Top.anim.meta b/frontend/assets/resources/animation/BluePacman/Top.anim.meta new file mode 100644 index 0000000..a6bfb2e --- /dev/null +++ b/frontend/assets/resources/animation/BluePacman/Top.anim.meta @@ -0,0 +1,5 @@ +{ + "ver": "2.1.0", + "uuid": "1bc6de53-800b-4da3-ab8e-4a45e3aa4230", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/BluePacman/TopLeft.anim b/frontend/assets/resources/animation/BluePacman/TopLeft.anim new file mode 100644 index 0000000..c49acf4 --- /dev/null +++ b/frontend/assets/resources/animation/BluePacman/TopLeft.anim @@ -0,0 +1,31 @@ +{ + "__type__": "cc.AnimationClip", + "_name": "TopLeft", + "_objFlags": 0, + "_native": "", + "_duration": 0.25, + "sample": 12, + "speed": 1, + "wrapMode": "2", + "curveData": { + "comps": { + "cc.Sprite": { + "spriteFrame": [ + { + "frame": 0, + "value": { + "__uuid__": "96187689-85df-46e8-b4db-410eae03c135" + } + }, + { + "frame": 0.16666666666666666, + "value": { + "__uuid__": "6b002583-7688-43d3-b3fa-102ae0046628" + } + } + ] + } + } + }, + "events": [] +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/BluePacman/TopLeft.anim.meta b/frontend/assets/resources/animation/BluePacman/TopLeft.anim.meta new file mode 100644 index 0000000..bc4c75f --- /dev/null +++ b/frontend/assets/resources/animation/BluePacman/TopLeft.anim.meta @@ -0,0 +1,5 @@ +{ + "ver": "2.1.0", + "uuid": "ee0d670c-893e-4e4d-96dd-5571db18ee97", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/BluePacman/TopRight.anim b/frontend/assets/resources/animation/BluePacman/TopRight.anim new file mode 100644 index 0000000..b6755d1 --- /dev/null +++ b/frontend/assets/resources/animation/BluePacman/TopRight.anim @@ -0,0 +1,31 @@ +{ + "__type__": "cc.AnimationClip", + "_name": "TopRight", + "_objFlags": 0, + "_native": "", + "_duration": 0.25, + "sample": 12, + "speed": 1, + "wrapMode": "2", + "curveData": { + "comps": { + "cc.Sprite": { + "spriteFrame": [ + { + "frame": 0, + "value": { + "__uuid__": "ba89046f-8b70-4edb-9f61-534dff476325" + } + }, + { + "frame": 0.16666666666666666, + "value": { + "__uuid__": "bc1ef316-d6ad-4538-b223-a0fed8094609" + } + } + ] + } + } + }, + "events": [] +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/BluePacman/TopRight.anim.meta b/frontend/assets/resources/animation/BluePacman/TopRight.anim.meta new file mode 100644 index 0000000..27f22f6 --- /dev/null +++ b/frontend/assets/resources/animation/BluePacman/TopRight.anim.meta @@ -0,0 +1,5 @@ +{ + "ver": "2.1.0", + "uuid": "596df84a-2e4e-4f1d-967c-a82649f564a8", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/BluePacman/attackedLeft.anim b/frontend/assets/resources/animation/BluePacman/attackedLeft.anim new file mode 100644 index 0000000..2dbb233 --- /dev/null +++ b/frontend/assets/resources/animation/BluePacman/attackedLeft.anim @@ -0,0 +1,43 @@ +{ + "__type__": "cc.AnimationClip", + "_name": "attackedLeft", + "_objFlags": 0, + "_native": "", + "_duration": 0.3333333333333333, + "sample": 12, + "speed": 1, + "wrapMode": "2", + "curveData": { + "comps": { + "cc.Sprite": { + "spriteFrame": [ + { + "frame": 0, + "value": { + "__uuid__": "02cd24e3-1c4a-46d7-85af-9034c9445ba7" + } + }, + { + "frame": 0.08333333333333333, + "value": { + "__uuid__": "8c522ad3-ee82-41a7-892e-05c05442e2e3" + } + }, + { + "frame": 0.16666666666666666, + "value": { + "__uuid__": "1f121837-a493-4a41-90e5-74ea560930ad" + } + }, + { + "frame": 0.25, + "value": { + "__uuid__": "1c0ec5ec-51cb-467d-b597-8e69ce580cfd" + } + } + ] + } + } + }, + "events": [] +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/BluePacman/attackedLeft.anim.meta b/frontend/assets/resources/animation/BluePacman/attackedLeft.anim.meta new file mode 100644 index 0000000..66df4e6 --- /dev/null +++ b/frontend/assets/resources/animation/BluePacman/attackedLeft.anim.meta @@ -0,0 +1,5 @@ +{ + "ver": "2.1.0", + "uuid": "8acc4e9f-3c47-4b66-9a9d-d012709680f6", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/BluePacman/attackedRight.anim b/frontend/assets/resources/animation/BluePacman/attackedRight.anim new file mode 100644 index 0000000..bea4208 --- /dev/null +++ b/frontend/assets/resources/animation/BluePacman/attackedRight.anim @@ -0,0 +1,43 @@ +{ + "__type__": "cc.AnimationClip", + "_name": "attackedRight", + "_objFlags": 0, + "_native": "", + "_duration": 0.3333333333333333, + "sample": 12, + "speed": 1, + "wrapMode": "2", + "curveData": { + "comps": { + "cc.Sprite": { + "spriteFrame": [ + { + "frame": 0, + "value": { + "__uuid__": "a6ec6a1c-dde5-459d-84f9-7b2b8a163e7b" + } + }, + { + "frame": 0.08333333333333333, + "value": { + "__uuid__": "d5ec0aaf-d4a9-4b2e-b9c1-bdc54b355b73" + } + }, + { + "frame": 0.16666666666666666, + "value": { + "__uuid__": "b5d11244-f30a-4b0d-b67b-23648d253d44" + } + }, + { + "frame": 0.25, + "value": { + "__uuid__": "360dfc7d-4ed1-4fb9-8d2f-7533d05a4830" + } + } + ] + } + } + }, + "events": [] +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/BluePacman/attackedRight.anim.meta b/frontend/assets/resources/animation/BluePacman/attackedRight.anim.meta new file mode 100644 index 0000000..74dc175 --- /dev/null +++ b/frontend/assets/resources/animation/BluePacman/attackedRight.anim.meta @@ -0,0 +1,5 @@ +{ + "ver": "2.1.0", + "uuid": "c7cda0cd-dbce-4722-abd2-aeca28263a21", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/FrameAnimTextures.meta b/frontend/assets/resources/animation/FrameAnimTextures.meta new file mode 100644 index 0000000..14e4c5e --- /dev/null +++ b/frontend/assets/resources/animation/FrameAnimTextures.meta @@ -0,0 +1,7 @@ +{ + "ver": "1.0.1", + "uuid": "02291e64-1c6c-4d1e-a7df-5c618395cb42", + "isSubpackage": false, + "subpackageName": "", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/FrameAnimTextures/Bullets.meta b/frontend/assets/resources/animation/FrameAnimTextures/Bullets.meta new file mode 100644 index 0000000..a00a7ab --- /dev/null +++ b/frontend/assets/resources/animation/FrameAnimTextures/Bullets.meta @@ -0,0 +1,7 @@ +{ + "ver": "1.0.1", + "uuid": "4f910135-713c-4263-8ae8-7ca4800bf003", + "isSubpackage": false, + "subpackageName": "", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/FrameAnimTextures/Bullets/bullet.plist b/frontend/assets/resources/animation/FrameAnimTextures/Bullets/bullet.plist new file mode 100644 index 0000000..7b9fab8 --- /dev/null +++ b/frontend/assets/resources/animation/FrameAnimTextures/Bullets/bullet.plist @@ -0,0 +1,56 @@ + + + + + frames + + bullet_00@2x.png + + aliases + + spriteOffset + {0,0} + spriteSize + {492,283} + spriteSourceSize + {492,283} + textureRect + {{1,1},{492,283}} + textureRotated + + + bullet_01@2x.png + + aliases + + spriteOffset + {0,0} + spriteSize + {492,283} + spriteSourceSize + {492,283} + textureRect + {{495,1},{492,283}} + textureRotated + + + + metadata + + format + 3 + pixelFormat + RGBA8888 + premultiplyAlpha + + realTextureFileName + bullet.png + size + {988,285} + smartupdate + $TexturePacker:SmartUpdate:139e91e37896fc18f399db23b949f6ef:3eb3da2ae451e804babdfbc241dea716:c583b50ea4ff931494970feffd84ac43$ + textureFileName + billet.png + + + diff --git a/frontend/assets/resources/animation/FrameAnimTextures/Bullets/bullet.plist.meta b/frontend/assets/resources/animation/FrameAnimTextures/Bullets/bullet.plist.meta new file mode 100644 index 0000000..96100f2 --- /dev/null +++ b/frontend/assets/resources/animation/FrameAnimTextures/Bullets/bullet.plist.meta @@ -0,0 +1,56 @@ +{ + "ver": "1.2.4", + "uuid": "266c6cef-32d6-4545-b3e6-c2b75a895578", + "rawTextureUuid": "a37f1c6a-9a6b-49fa-8a2d-2fc5a3b93094", + "size": { + "width": 988, + "height": 285 + }, + "type": "Texture Packer", + "subMetas": { + "bullet_00@2x.png": { + "ver": "1.0.4", + "uuid": "2f525bb2-80d1-4508-bdc3-d03c11587ce4", + "rawTextureUuid": "a37f1c6a-9a6b-49fa-8a2d-2fc5a3b93094", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1, + "trimY": 1, + "width": 492, + "height": 283, + "rawWidth": 492, + "rawHeight": 283, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "bullet_01@2x.png": { + "ver": "1.0.4", + "uuid": "2c2c7c0c-5e91-4407-aa01-40383450386f", + "rawTextureUuid": "a37f1c6a-9a6b-49fa-8a2d-2fc5a3b93094", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 495, + "trimY": 1, + "width": 492, + "height": 283, + "rawWidth": 492, + "rawHeight": 283, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + } + } +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/FrameAnimTextures/Bullets/bullet.png b/frontend/assets/resources/animation/FrameAnimTextures/Bullets/bullet.png new file mode 100644 index 0000000..48c578a Binary files /dev/null and b/frontend/assets/resources/animation/FrameAnimTextures/Bullets/bullet.png differ diff --git a/frontend/assets/resources/animation/FrameAnimTextures/Bullets/bullet.png.meta b/frontend/assets/resources/animation/FrameAnimTextures/Bullets/bullet.png.meta new file mode 100644 index 0000000..dfa2991 --- /dev/null +++ b/frontend/assets/resources/animation/FrameAnimTextures/Bullets/bullet.png.meta @@ -0,0 +1,34 @@ +{ + "ver": "2.3.3", + "uuid": "a37f1c6a-9a6b-49fa-8a2d-2fc5a3b93094", + "type": "sprite", + "wrapMode": "clamp", + "filterMode": "bilinear", + "premultiplyAlpha": false, + "genMipmaps": false, + "packable": true, + "platformSettings": {}, + "subMetas": { + "bullet": { + "ver": "1.0.4", + "uuid": "e4de047d-dd9b-4da3-a375-0e70e8215258", + "rawTextureUuid": "a37f1c6a-9a6b-49fa-8a2d-2fc5a3b93094", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 0, + "trimY": 0, + "width": 988, + "height": 285, + "rawWidth": 988, + "rawHeight": 285, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "subMetas": {} + } + } +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/FrameAnimTextures/MagnifyinGlassAnimation.meta b/frontend/assets/resources/animation/FrameAnimTextures/MagnifyinGlassAnimation.meta new file mode 100644 index 0000000..2095fc6 --- /dev/null +++ b/frontend/assets/resources/animation/FrameAnimTextures/MagnifyinGlassAnimation.meta @@ -0,0 +1,7 @@ +{ + "ver": "1.0.1", + "uuid": "a91e9bf4-f213-47a9-989c-aa147bde9067", + "isSubpackage": false, + "subpackageName": "", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/FrameAnimTextures/MagnifyinGlassAnimation/MagnifyinGlass.plist b/frontend/assets/resources/animation/FrameAnimTextures/MagnifyinGlassAnimation/MagnifyinGlass.plist new file mode 100644 index 0000000..64601a1 --- /dev/null +++ b/frontend/assets/resources/animation/FrameAnimTextures/MagnifyinGlassAnimation/MagnifyinGlass.plist @@ -0,0 +1,116 @@ + + + + + frames + + MagnifyinGlass01.png + + aliases + + spriteOffset + {0,0} + spriteSize + {200,200} + spriteSourceSize + {200,200} + textureRect + {{1,1},{200,200}} + textureRotated + + + MagnifyinGlass02.png + + aliases + + spriteOffset + {0,0} + spriteSize + {200,200} + spriteSourceSize + {200,200} + textureRect + {{203,1},{200,200}} + textureRotated + + + MagnifyinGlass03.png + + aliases + + spriteOffset + {0,0} + spriteSize + {200,200} + spriteSourceSize + {200,200} + textureRect + {{1,203},{200,200}} + textureRotated + + + MagnifyinGlass04.png + + aliases + + spriteOffset + {0,0} + spriteSize + {200,200} + spriteSourceSize + {200,200} + textureRect + {{203,203},{200,200}} + textureRotated + + + MagnifyinGlass05.png + + aliases + + spriteOffset + {0,0} + spriteSize + {200,200} + spriteSourceSize + {200,200} + textureRect + {{1,405},{200,200}} + textureRotated + + + MagnifyinGlass06.png + + aliases + + spriteOffset + {0,0} + spriteSize + {200,200} + spriteSourceSize + {200,200} + textureRect + {{203,405},{200,200}} + textureRotated + + + + metadata + + format + 3 + pixelFormat + RGBA8888 + premultiplyAlpha + + realTextureFileName + MagnifyinGlass.png + size + {404,606} + smartupdate + $TexturePacker:SmartUpdate:edf2155a27f952fba88a6a73690ef5b6:98f418339738539cb621f0dcd91a80bc:9ec715c3c60d7bf4010bb55cc49c6b09$ + textureFileName + MagnifyinGlass.png + + + diff --git a/frontend/assets/resources/animation/FrameAnimTextures/MagnifyinGlassAnimation/MagnifyinGlass.plist.meta b/frontend/assets/resources/animation/FrameAnimTextures/MagnifyinGlassAnimation/MagnifyinGlass.plist.meta new file mode 100644 index 0000000..cd87741 --- /dev/null +++ b/frontend/assets/resources/animation/FrameAnimTextures/MagnifyinGlassAnimation/MagnifyinGlass.plist.meta @@ -0,0 +1,144 @@ +{ + "ver": "1.2.4", + "uuid": "06710517-f4f7-46d9-873f-c7599242f7be", + "rawTextureUuid": "b6746e1a-5020-430f-90f8-e710eb2bd516", + "size": { + "width": 404, + "height": 606 + }, + "type": "Texture Packer", + "subMetas": { + "MagnifyinGlass01.png": { + "ver": "1.0.4", + "uuid": "7b86de0f-ea49-42c3-bdd0-db8de330e9aa", + "rawTextureUuid": "b6746e1a-5020-430f-90f8-e710eb2bd516", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1, + "trimY": 1, + "width": 200, + "height": 200, + "rawWidth": 200, + "rawHeight": 200, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "MagnifyinGlass02.png": { + "ver": "1.0.4", + "uuid": "819073c0-7a15-4679-957b-65a226d8fce4", + "rawTextureUuid": "b6746e1a-5020-430f-90f8-e710eb2bd516", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 203, + "trimY": 1, + "width": 200, + "height": 200, + "rawWidth": 200, + "rawHeight": 200, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "MagnifyinGlass03.png": { + "ver": "1.0.4", + "uuid": "6ff26f1f-30d1-4e49-b76c-d9bc61eb6ce0", + "rawTextureUuid": "b6746e1a-5020-430f-90f8-e710eb2bd516", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1, + "trimY": 203, + "width": 200, + "height": 200, + "rawWidth": 200, + "rawHeight": 200, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "MagnifyinGlass04.png": { + "ver": "1.0.4", + "uuid": "44c52db6-d112-4829-96f2-6fd57a8a0d7f", + "rawTextureUuid": "b6746e1a-5020-430f-90f8-e710eb2bd516", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 203, + "trimY": 203, + "width": 200, + "height": 200, + "rawWidth": 200, + "rawHeight": 200, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "MagnifyinGlass05.png": { + "ver": "1.0.4", + "uuid": "efd42f06-82ad-4b1b-9134-6f35c26bf10f", + "rawTextureUuid": "b6746e1a-5020-430f-90f8-e710eb2bd516", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1, + "trimY": 405, + "width": 200, + "height": 200, + "rawWidth": 200, + "rawHeight": 200, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "MagnifyinGlass06.png": { + "ver": "1.0.4", + "uuid": "19094751-ab4e-40b6-9216-dd7887d80c86", + "rawTextureUuid": "b6746e1a-5020-430f-90f8-e710eb2bd516", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 203, + "trimY": 405, + "width": 200, + "height": 200, + "rawWidth": 200, + "rawHeight": 200, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + } + } +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/FrameAnimTextures/MagnifyinGlassAnimation/MagnifyinGlass.png b/frontend/assets/resources/animation/FrameAnimTextures/MagnifyinGlassAnimation/MagnifyinGlass.png new file mode 100644 index 0000000..374fc24 Binary files /dev/null and b/frontend/assets/resources/animation/FrameAnimTextures/MagnifyinGlassAnimation/MagnifyinGlass.png differ diff --git a/frontend/assets/resources/animation/FrameAnimTextures/MagnifyinGlassAnimation/MagnifyinGlass.png.meta b/frontend/assets/resources/animation/FrameAnimTextures/MagnifyinGlassAnimation/MagnifyinGlass.png.meta new file mode 100644 index 0000000..1593192 --- /dev/null +++ b/frontend/assets/resources/animation/FrameAnimTextures/MagnifyinGlassAnimation/MagnifyinGlass.png.meta @@ -0,0 +1,34 @@ +{ + "ver": "2.3.3", + "uuid": "b6746e1a-5020-430f-90f8-e710eb2bd516", + "type": "sprite", + "wrapMode": "clamp", + "filterMode": "bilinear", + "premultiplyAlpha": false, + "genMipmaps": false, + "packable": true, + "platformSettings": {}, + "subMetas": { + "MagnifyinGlass": { + "ver": "1.0.4", + "uuid": "27fff013-7382-47e4-9b96-4700ce22e91d", + "rawTextureUuid": "b6746e1a-5020-430f-90f8-e710eb2bd516", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 3.5, + "offsetY": -11, + "trimX": 38, + "trimY": 34, + "width": 335, + "height": 560, + "rawWidth": 404, + "rawHeight": 606, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "subMetas": {} + } + } +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/FrameAnimTextures/bulldozer-blue-transparent.plist b/frontend/assets/resources/animation/FrameAnimTextures/bulldozer-blue-transparent.plist new file mode 100644 index 0000000..84ca0aa --- /dev/null +++ b/frontend/assets/resources/animation/FrameAnimTextures/bulldozer-blue-transparent.plist @@ -0,0 +1,266 @@ + + + + + frames + + BlueEyePacman-Bottom-01.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{1,1},{500,500}} + textureRotated + + + BlueEyePacman-Bottom-02.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{1,503},{500,500}} + textureRotated + + + BlueEyePacman-BottomLeft-01.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{1,1005},{500,500}} + textureRotated + + + BlueEyePacman-BottomLeft-02.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{1,1507},{500,500}} + textureRotated + + + BlueEyePacman-BottomRight-01.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{503,1},{500,500}} + textureRotated + + + BlueEyePacman-BottomRight-02.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{1005,1},{500,500}} + textureRotated + + + BlueEyePacman-Left-01.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{1507,1},{500,500}} + textureRotated + + + BlueEyePacman-Left-02.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{503,503},{500,500}} + textureRotated + + + BlueEyePacman-Right-01.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{503,1005},{500,500}} + textureRotated + + + BlueEyePacman-Right-02.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{503,1507},{500,500}} + textureRotated + + + BlueEyePacman-Top-01.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{1005,503},{500,500}} + textureRotated + + + BlueEyePacman-Top-02.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{1507,503},{500,500}} + textureRotated + + + BlueEyePacman-TopLeft-01.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{1005,1005},{500,500}} + textureRotated + + + BlueEyePacman-TopLeft-02.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{1005,1507},{500,500}} + textureRotated + + + BlueEyePacman-TopRight-01.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{1507,1005},{500,500}} + textureRotated + + + BlueEyePacman-TopRight-02.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{1507,1507},{500,500}} + textureRotated + + + + metadata + + format + 3 + pixelFormat + RGBA8888 + premultiplyAlpha + + realTextureFileName + bulldozer-blue-transparent.png + size + {2008,2008} + smartupdate + $TexturePacker:SmartUpdate:b97cacd69ffb6f4dbe8b4351048601a2:fb0cecc51d52d2e22c2f2a4a68f5cf58:996337891ef72ef6069c01602a72bead$ + textureFileName + bulldozer-blue.png + + + diff --git a/frontend/assets/resources/animation/FrameAnimTextures/bulldozer-blue-transparent.plist.meta b/frontend/assets/resources/animation/FrameAnimTextures/bulldozer-blue-transparent.plist.meta new file mode 100644 index 0000000..5cebff3 --- /dev/null +++ b/frontend/assets/resources/animation/FrameAnimTextures/bulldozer-blue-transparent.plist.meta @@ -0,0 +1,364 @@ +{ + "ver": "1.2.4", + "uuid": "96b5268e-af3d-4670-bf30-6dc5da52745a", + "rawTextureUuid": "71ac3711-4cb2-4980-b108-d2f8f9a7f431", + "size": { + "width": 2008, + "height": 2008 + }, + "type": "Texture Packer", + "subMetas": { + "BlueEyePacman-Bottom-01.png": { + "ver": "1.0.4", + "uuid": "8b8deebe-e6ce-436b-9433-63d96bf9de23", + "rawTextureUuid": "71ac3711-4cb2-4980-b108-d2f8f9a7f431", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1, + "trimY": 1, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "BlueEyePacman-Bottom-02.png": { + "ver": "1.0.4", + "uuid": "c734e8cd-7894-4f5c-b02d-965942268d0b", + "rawTextureUuid": "71ac3711-4cb2-4980-b108-d2f8f9a7f431", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1, + "trimY": 503, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "BlueEyePacman-BottomLeft-01.png": { + "ver": "1.0.4", + "uuid": "b7a96496-6e51-4e16-984e-6a0086f81965", + "rawTextureUuid": "71ac3711-4cb2-4980-b108-d2f8f9a7f431", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1, + "trimY": 1005, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "BlueEyePacman-BottomLeft-02.png": { + "ver": "1.0.4", + "uuid": "f39589b8-529d-4b5a-a2d2-3d081f4e3d04", + "rawTextureUuid": "71ac3711-4cb2-4980-b108-d2f8f9a7f431", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1, + "trimY": 1507, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "BlueEyePacman-BottomRight-01.png": { + "ver": "1.0.4", + "uuid": "7cdbd8e0-bfd7-4409-9dbb-2ef02209e844", + "rawTextureUuid": "71ac3711-4cb2-4980-b108-d2f8f9a7f431", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 503, + "trimY": 1, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "BlueEyePacman-BottomRight-02.png": { + "ver": "1.0.4", + "uuid": "10307148-9719-45fe-9af2-3442f09b9681", + "rawTextureUuid": "71ac3711-4cb2-4980-b108-d2f8f9a7f431", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1005, + "trimY": 1, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "BlueEyePacman-Left-01.png": { + "ver": "1.0.4", + "uuid": "8c522ad3-ee82-41a7-892e-05c05442e2e3", + "rawTextureUuid": "71ac3711-4cb2-4980-b108-d2f8f9a7f431", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1507, + "trimY": 1, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "BlueEyePacman-Left-02.png": { + "ver": "1.0.4", + "uuid": "1c0ec5ec-51cb-467d-b597-8e69ce580cfd", + "rawTextureUuid": "71ac3711-4cb2-4980-b108-d2f8f9a7f431", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 503, + "trimY": 503, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "BlueEyePacman-Right-01.png": { + "ver": "1.0.4", + "uuid": "d5ec0aaf-d4a9-4b2e-b9c1-bdc54b355b73", + "rawTextureUuid": "71ac3711-4cb2-4980-b108-d2f8f9a7f431", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 503, + "trimY": 1005, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "BlueEyePacman-Right-02.png": { + "ver": "1.0.4", + "uuid": "360dfc7d-4ed1-4fb9-8d2f-7533d05a4830", + "rawTextureUuid": "71ac3711-4cb2-4980-b108-d2f8f9a7f431", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 503, + "trimY": 1507, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "BlueEyePacman-Top-01.png": { + "ver": "1.0.4", + "uuid": "768726a2-22af-415f-86fc-5c7e4717a53b", + "rawTextureUuid": "71ac3711-4cb2-4980-b108-d2f8f9a7f431", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1005, + "trimY": 503, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "BlueEyePacman-Top-02.png": { + "ver": "1.0.4", + "uuid": "d8d8e753-f4a4-4d26-ba2d-966c6b4d9e70", + "rawTextureUuid": "71ac3711-4cb2-4980-b108-d2f8f9a7f431", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1507, + "trimY": 503, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "BlueEyePacman-TopLeft-01.png": { + "ver": "1.0.4", + "uuid": "5e9ab8a4-903c-4675-8e1e-df7780d8896f", + "rawTextureUuid": "71ac3711-4cb2-4980-b108-d2f8f9a7f431", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1005, + "trimY": 1005, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "BlueEyePacman-TopLeft-02.png": { + "ver": "1.0.4", + "uuid": "6120dd6b-4704-4c0d-932d-dc912cb68ecc", + "rawTextureUuid": "71ac3711-4cb2-4980-b108-d2f8f9a7f431", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1005, + "trimY": 1507, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "BlueEyePacman-TopRight-01.png": { + "ver": "1.0.4", + "uuid": "4590fa14-a9de-49ef-bde4-692233f52b5a", + "rawTextureUuid": "71ac3711-4cb2-4980-b108-d2f8f9a7f431", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1507, + "trimY": 1005, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "BlueEyePacman-TopRight-02.png": { + "ver": "1.0.4", + "uuid": "3a55af77-cbf2-4678-a6ad-3bd277c5e07e", + "rawTextureUuid": "71ac3711-4cb2-4980-b108-d2f8f9a7f431", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1507, + "trimY": 1507, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + } + } +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/FrameAnimTextures/bulldozer-blue-transparent.png b/frontend/assets/resources/animation/FrameAnimTextures/bulldozer-blue-transparent.png new file mode 100644 index 0000000..1611db2 Binary files /dev/null and b/frontend/assets/resources/animation/FrameAnimTextures/bulldozer-blue-transparent.png differ diff --git a/frontend/assets/resources/animation/FrameAnimTextures/bulldozer-blue-transparent.png.meta b/frontend/assets/resources/animation/FrameAnimTextures/bulldozer-blue-transparent.png.meta new file mode 100644 index 0000000..1279abe --- /dev/null +++ b/frontend/assets/resources/animation/FrameAnimTextures/bulldozer-blue-transparent.png.meta @@ -0,0 +1,34 @@ +{ + "ver": "2.3.3", + "uuid": "71ac3711-4cb2-4980-b108-d2f8f9a7f431", + "type": "sprite", + "wrapMode": "clamp", + "filterMode": "bilinear", + "premultiplyAlpha": false, + "genMipmaps": false, + "packable": true, + "platformSettings": {}, + "subMetas": { + "bulldozer-blue-transparent": { + "ver": "1.0.4", + "uuid": "ad066269-5b70-4d25-8b6d-b96ea030f6b6", + "rawTextureUuid": "71ac3711-4cb2-4980-b108-d2f8f9a7f431", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": -46, + "trimX": 0, + "trimY": 92, + "width": 2008, + "height": 1916, + "rawWidth": 2008, + "rawHeight": 2008, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "subMetas": {} + } + } +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/FrameAnimTextures/bulldozer-blue.plist b/frontend/assets/resources/animation/FrameAnimTextures/bulldozer-blue.plist new file mode 100644 index 0000000..30dc0b3 --- /dev/null +++ b/frontend/assets/resources/animation/FrameAnimTextures/bulldozer-blue.plist @@ -0,0 +1,266 @@ + + + + + frames + + BlueEyePacman-Bottom-01.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{1,1},{500,500}} + textureRotated + + + BlueEyePacman-Bottom-02.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{1,503},{500,500}} + textureRotated + + + BlueEyePacman-BottomLeft-01.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{1,1005},{500,500}} + textureRotated + + + BlueEyePacman-BottomLeft-02.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{1,1507},{500,500}} + textureRotated + + + BlueEyePacman-BottomRight-01.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{503,1},{500,500}} + textureRotated + + + BlueEyePacman-BottomRight-02.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{1005,1},{500,500}} + textureRotated + + + BlueEyePacman-Left-01.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{1507,1},{500,500}} + textureRotated + + + BlueEyePacman-Left-02.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{503,503},{500,500}} + textureRotated + + + BlueEyePacman-Right-01.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{503,1005},{500,500}} + textureRotated + + + BlueEyePacman-Right-02.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{503,1507},{500,500}} + textureRotated + + + BlueEyePacman-Top-01.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{1005,503},{500,500}} + textureRotated + + + BlueEyePacman-Top-02.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{1507,503},{500,500}} + textureRotated + + + BlueEyePacman-TopLeft-01.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{1005,1005},{500,500}} + textureRotated + + + BlueEyePacman-TopLeft-02.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{1005,1507},{500,500}} + textureRotated + + + BlueEyePacman-TopRight-01.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{1507,1005},{500,500}} + textureRotated + + + BlueEyePacman-TopRight-02.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{1507,1507},{500,500}} + textureRotated + + + + metadata + + format + 3 + pixelFormat + RGBA8888 + premultiplyAlpha + + realTextureFileName + bulldozer-blue.png + size + {2008,2008} + smartupdate + $TexturePacker:SmartUpdate:b97cacd69ffb6f4dbe8b4351048601a2:fb0cecc51d52d2e22c2f2a4a68f5cf58:996337891ef72ef6069c01602a72bead$ + textureFileName + bulldozer-blue.png + + + diff --git a/frontend/assets/resources/animation/FrameAnimTextures/bulldozer-blue.plist.meta b/frontend/assets/resources/animation/FrameAnimTextures/bulldozer-blue.plist.meta new file mode 100644 index 0000000..9fbb361 --- /dev/null +++ b/frontend/assets/resources/animation/FrameAnimTextures/bulldozer-blue.plist.meta @@ -0,0 +1,364 @@ +{ + "ver": "1.2.4", + "uuid": "23fb8ada-95d1-4be0-8396-7f065d164dd3", + "rawTextureUuid": "ed1dbabe-cadf-460f-8a22-6c05654cd81d", + "size": { + "width": 2008, + "height": 2008 + }, + "type": "Texture Packer", + "subMetas": { + "BlueEyePacman-Bottom-01.png": { + "ver": "1.0.4", + "uuid": "783f1240-d608-40be-8108-3013ab53cfe6", + "rawTextureUuid": "ed1dbabe-cadf-460f-8a22-6c05654cd81d", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1, + "trimY": 1, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "BlueEyePacman-Bottom-02.png": { + "ver": "1.0.4", + "uuid": "393e649b-addb-4f91-b687-438433026c8d", + "rawTextureUuid": "ed1dbabe-cadf-460f-8a22-6c05654cd81d", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1, + "trimY": 503, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "BlueEyePacman-BottomLeft-01.png": { + "ver": "1.0.4", + "uuid": "748c55f0-e761-40f6-b13b-e416b3d8a55c", + "rawTextureUuid": "ed1dbabe-cadf-460f-8a22-6c05654cd81d", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1, + "trimY": 1005, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "BlueEyePacman-BottomLeft-02.png": { + "ver": "1.0.4", + "uuid": "6164bac7-9882-43ce-b3d0-9d062d6d0b49", + "rawTextureUuid": "ed1dbabe-cadf-460f-8a22-6c05654cd81d", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1, + "trimY": 1507, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "BlueEyePacman-BottomRight-01.png": { + "ver": "1.0.4", + "uuid": "34cf9fbb-8def-4faf-a56e-123b4c45706c", + "rawTextureUuid": "ed1dbabe-cadf-460f-8a22-6c05654cd81d", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 503, + "trimY": 1, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "BlueEyePacman-BottomRight-02.png": { + "ver": "1.0.4", + "uuid": "b6709dd6-6ba7-4222-af38-de79ac80ce8b", + "rawTextureUuid": "ed1dbabe-cadf-460f-8a22-6c05654cd81d", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1005, + "trimY": 1, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "BlueEyePacman-Left-01.png": { + "ver": "1.0.4", + "uuid": "02cd24e3-1c4a-46d7-85af-9034c9445ba7", + "rawTextureUuid": "ed1dbabe-cadf-460f-8a22-6c05654cd81d", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1507, + "trimY": 1, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "BlueEyePacman-Left-02.png": { + "ver": "1.0.4", + "uuid": "1f121837-a493-4a41-90e5-74ea560930ad", + "rawTextureUuid": "ed1dbabe-cadf-460f-8a22-6c05654cd81d", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 503, + "trimY": 503, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "BlueEyePacman-Right-01.png": { + "ver": "1.0.4", + "uuid": "a6ec6a1c-dde5-459d-84f9-7b2b8a163e7b", + "rawTextureUuid": "ed1dbabe-cadf-460f-8a22-6c05654cd81d", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 503, + "trimY": 1005, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "BlueEyePacman-Right-02.png": { + "ver": "1.0.4", + "uuid": "b5d11244-f30a-4b0d-b67b-23648d253d44", + "rawTextureUuid": "ed1dbabe-cadf-460f-8a22-6c05654cd81d", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 503, + "trimY": 1507, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "BlueEyePacman-Top-01.png": { + "ver": "1.0.4", + "uuid": "8967d249-e9cf-4e44-85e8-6b9377129d9e", + "rawTextureUuid": "ed1dbabe-cadf-460f-8a22-6c05654cd81d", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1005, + "trimY": 503, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "BlueEyePacman-Top-02.png": { + "ver": "1.0.4", + "uuid": "492a57fb-6a5c-423a-bcfe-0695a7828881", + "rawTextureUuid": "ed1dbabe-cadf-460f-8a22-6c05654cd81d", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1507, + "trimY": 503, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "BlueEyePacman-TopLeft-01.png": { + "ver": "1.0.4", + "uuid": "96187689-85df-46e8-b4db-410eae03c135", + "rawTextureUuid": "ed1dbabe-cadf-460f-8a22-6c05654cd81d", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1005, + "trimY": 1005, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "BlueEyePacman-TopLeft-02.png": { + "ver": "1.0.4", + "uuid": "6b002583-7688-43d3-b3fa-102ae0046628", + "rawTextureUuid": "ed1dbabe-cadf-460f-8a22-6c05654cd81d", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1005, + "trimY": 1507, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "BlueEyePacman-TopRight-01.png": { + "ver": "1.0.4", + "uuid": "ba89046f-8b70-4edb-9f61-534dff476325", + "rawTextureUuid": "ed1dbabe-cadf-460f-8a22-6c05654cd81d", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1507, + "trimY": 1005, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "BlueEyePacman-TopRight-02.png": { + "ver": "1.0.4", + "uuid": "bc1ef316-d6ad-4538-b223-a0fed8094609", + "rawTextureUuid": "ed1dbabe-cadf-460f-8a22-6c05654cd81d", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1507, + "trimY": 1507, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + } + } +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/FrameAnimTextures/bulldozer-blue.png b/frontend/assets/resources/animation/FrameAnimTextures/bulldozer-blue.png new file mode 100644 index 0000000..6999c27 Binary files /dev/null and b/frontend/assets/resources/animation/FrameAnimTextures/bulldozer-blue.png differ diff --git a/frontend/assets/resources/animation/FrameAnimTextures/bulldozer-blue.png.meta b/frontend/assets/resources/animation/FrameAnimTextures/bulldozer-blue.png.meta new file mode 100644 index 0000000..91d316f --- /dev/null +++ b/frontend/assets/resources/animation/FrameAnimTextures/bulldozer-blue.png.meta @@ -0,0 +1,34 @@ +{ + "ver": "2.3.3", + "uuid": "ed1dbabe-cadf-460f-8a22-6c05654cd81d", + "type": "sprite", + "wrapMode": "clamp", + "filterMode": "bilinear", + "premultiplyAlpha": false, + "genMipmaps": false, + "packable": true, + "platformSettings": {}, + "subMetas": { + "bulldozer-blue": { + "ver": "1.0.4", + "uuid": "f01ba52a-d33b-4456-bb1a-53d3afc70507", + "rawTextureUuid": "ed1dbabe-cadf-460f-8a22-6c05654cd81d", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": -46, + "trimX": 0, + "trimY": 92, + "width": 2008, + "height": 1916, + "rawWidth": 2008, + "rawHeight": 2008, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "subMetas": {} + } + } +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/FrameAnimTextures/bulldozer-red-transparent.plist b/frontend/assets/resources/animation/FrameAnimTextures/bulldozer-red-transparent.plist new file mode 100644 index 0000000..6b9a655 --- /dev/null +++ b/frontend/assets/resources/animation/FrameAnimTextures/bulldozer-red-transparent.plist @@ -0,0 +1,266 @@ + + + + + frames + + RedEyePacman-Bottom-01.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{1,1},{500,500}} + textureRotated + + + RedEyePacman-Bottom-02.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{1,503},{500,500}} + textureRotated + + + RedEyePacman-BottomLeft-01.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{1,1005},{500,500}} + textureRotated + + + RedEyePacman-BottomLeft-02.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{1,1507},{500,500}} + textureRotated + + + RedEyePacman-BottomRight-01.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{503,1},{500,500}} + textureRotated + + + RedEyePacman-BottomRight-02.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{1005,1},{500,500}} + textureRotated + + + RedEyePacman-Left-01.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{1507,1},{500,500}} + textureRotated + + + RedEyePacman-Left-02.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{503,503},{500,500}} + textureRotated + + + RedEyePacman-Right-01.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{503,1005},{500,500}} + textureRotated + + + RedEyePacman-Right-02.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{503,1507},{500,500}} + textureRotated + + + RedEyePacman-Top-01.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{1005,503},{500,500}} + textureRotated + + + RedEyePacman-Top-02.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{1507,503},{500,500}} + textureRotated + + + RedEyePacman-TopLeft-01.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{1005,1005},{500,500}} + textureRotated + + + RedEyePacman-TopLeft-02.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{1005,1507},{500,500}} + textureRotated + + + RedEyePacman-TopRight-01.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{1507,1005},{500,500}} + textureRotated + + + RedEyePacman-TopRight-02.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{1507,1507},{500,500}} + textureRotated + + + + metadata + + format + 3 + pixelFormat + RGBA8888 + premultiplyAlpha + + realTextureFileName + bulldozer-red-transparent.png + size + {2008,2008} + smartupdate + $TexturePacker:SmartUpdate:ddae6e75d84e0e816aa71938232564e7:2b1e30f28ea7a78dbb5c4c64f9192c8a:56afd1d5083c6201ac85a795f2357b44$ + textureFileName + bulldozer-red.png + + + diff --git a/frontend/assets/resources/animation/FrameAnimTextures/bulldozer-red-transparent.plist.meta b/frontend/assets/resources/animation/FrameAnimTextures/bulldozer-red-transparent.plist.meta new file mode 100644 index 0000000..9d6c095 --- /dev/null +++ b/frontend/assets/resources/animation/FrameAnimTextures/bulldozer-red-transparent.plist.meta @@ -0,0 +1,364 @@ +{ + "ver": "1.2.4", + "uuid": "b8d4ce3d-6648-44c5-bab9-0681b6d1e15a", + "rawTextureUuid": "0e2f98ed-755a-4e34-8aa7-f94b8c15cb9a", + "size": { + "width": 2008, + "height": 2008 + }, + "type": "Texture Packer", + "subMetas": { + "RedEyePacman-Bottom-01.png": { + "ver": "1.0.4", + "uuid": "d5291a19-3cf9-4736-8e06-a6cec12db1a2", + "rawTextureUuid": "0e2f98ed-755a-4e34-8aa7-f94b8c15cb9a", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1, + "trimY": 1, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "RedEyePacman-Bottom-02.png": { + "ver": "1.0.4", + "uuid": "342f1b55-6695-41e3-8560-cb44faabe3a2", + "rawTextureUuid": "0e2f98ed-755a-4e34-8aa7-f94b8c15cb9a", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1, + "trimY": 503, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "RedEyePacman-BottomLeft-01.png": { + "ver": "1.0.4", + "uuid": "e4ded4e0-0c35-470e-832c-016b26b1ec14", + "rawTextureUuid": "0e2f98ed-755a-4e34-8aa7-f94b8c15cb9a", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1, + "trimY": 1005, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "RedEyePacman-BottomLeft-02.png": { + "ver": "1.0.4", + "uuid": "2f220c2d-3fab-4541-814b-fda4ef4b068b", + "rawTextureUuid": "0e2f98ed-755a-4e34-8aa7-f94b8c15cb9a", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1, + "trimY": 1507, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "RedEyePacman-BottomRight-01.png": { + "ver": "1.0.4", + "uuid": "4604873c-537a-4e3b-bb85-72793c563e83", + "rawTextureUuid": "0e2f98ed-755a-4e34-8aa7-f94b8c15cb9a", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 503, + "trimY": 1, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "RedEyePacman-BottomRight-02.png": { + "ver": "1.0.4", + "uuid": "7c5d0c24-0150-4ec7-a136-271ad9b2d94c", + "rawTextureUuid": "0e2f98ed-755a-4e34-8aa7-f94b8c15cb9a", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1005, + "trimY": 1, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "RedEyePacman-Left-01.png": { + "ver": "1.0.4", + "uuid": "987c7dc0-e81f-4891-979d-0998794e6889", + "rawTextureUuid": "0e2f98ed-755a-4e34-8aa7-f94b8c15cb9a", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1507, + "trimY": 1, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "RedEyePacman-Left-02.png": { + "ver": "1.0.4", + "uuid": "9205c378-c50c-4303-af32-dbf9422375cf", + "rawTextureUuid": "0e2f98ed-755a-4e34-8aa7-f94b8c15cb9a", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 503, + "trimY": 503, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "RedEyePacman-Right-01.png": { + "ver": "1.0.4", + "uuid": "8f3cf81e-1251-4013-b684-13f2830c7425", + "rawTextureUuid": "0e2f98ed-755a-4e34-8aa7-f94b8c15cb9a", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 503, + "trimY": 1005, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "RedEyePacman-Right-02.png": { + "ver": "1.0.4", + "uuid": "69f1bd37-6628-4fd1-b0f2-08073d1edb29", + "rawTextureUuid": "0e2f98ed-755a-4e34-8aa7-f94b8c15cb9a", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 503, + "trimY": 1507, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "RedEyePacman-Top-01.png": { + "ver": "1.0.4", + "uuid": "0aa4ac87-8a86-4b64-956f-51fe0f3da1c8", + "rawTextureUuid": "0e2f98ed-755a-4e34-8aa7-f94b8c15cb9a", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1005, + "trimY": 503, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "RedEyePacman-Top-02.png": { + "ver": "1.0.4", + "uuid": "ffebf0b4-cad8-4a5d-963a-28fc09bd72e3", + "rawTextureUuid": "0e2f98ed-755a-4e34-8aa7-f94b8c15cb9a", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1507, + "trimY": 503, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "RedEyePacman-TopLeft-01.png": { + "ver": "1.0.4", + "uuid": "a95c7e00-8c98-42c4-a0b1-1c64cc08234f", + "rawTextureUuid": "0e2f98ed-755a-4e34-8aa7-f94b8c15cb9a", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1005, + "trimY": 1005, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "RedEyePacman-TopLeft-02.png": { + "ver": "1.0.4", + "uuid": "c468547a-7a79-46b6-8c49-e21608e09f21", + "rawTextureUuid": "0e2f98ed-755a-4e34-8aa7-f94b8c15cb9a", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1005, + "trimY": 1507, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "RedEyePacman-TopRight-01.png": { + "ver": "1.0.4", + "uuid": "de77fb04-1be6-4b45-a45d-c00003a27541", + "rawTextureUuid": "0e2f98ed-755a-4e34-8aa7-f94b8c15cb9a", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1507, + "trimY": 1005, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "RedEyePacman-TopRight-02.png": { + "ver": "1.0.4", + "uuid": "360b2e8a-80e3-44b1-aeb2-276daea77f7f", + "rawTextureUuid": "0e2f98ed-755a-4e34-8aa7-f94b8c15cb9a", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1507, + "trimY": 1507, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + } + } +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/FrameAnimTextures/bulldozer-red-transparent.png b/frontend/assets/resources/animation/FrameAnimTextures/bulldozer-red-transparent.png new file mode 100644 index 0000000..a10e7ab Binary files /dev/null and b/frontend/assets/resources/animation/FrameAnimTextures/bulldozer-red-transparent.png differ diff --git a/frontend/assets/resources/animation/FrameAnimTextures/bulldozer-red-transparent.png.meta b/frontend/assets/resources/animation/FrameAnimTextures/bulldozer-red-transparent.png.meta new file mode 100644 index 0000000..d516213 --- /dev/null +++ b/frontend/assets/resources/animation/FrameAnimTextures/bulldozer-red-transparent.png.meta @@ -0,0 +1,34 @@ +{ + "ver": "2.3.3", + "uuid": "0e2f98ed-755a-4e34-8aa7-f94b8c15cb9a", + "type": "sprite", + "wrapMode": "clamp", + "filterMode": "bilinear", + "premultiplyAlpha": false, + "genMipmaps": false, + "packable": true, + "platformSettings": {}, + "subMetas": { + "bulldozer-red-transparent": { + "ver": "1.0.4", + "uuid": "26147aca-b8d7-4064-bec3-80bf8fa98dfe", + "rawTextureUuid": "0e2f98ed-755a-4e34-8aa7-f94b8c15cb9a", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": -45.5, + "trimX": 0, + "trimY": 91, + "width": 2008, + "height": 1917, + "rawWidth": 2008, + "rawHeight": 2008, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "subMetas": {} + } + } +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/FrameAnimTextures/bulldozer-red.plist b/frontend/assets/resources/animation/FrameAnimTextures/bulldozer-red.plist new file mode 100644 index 0000000..36673a7 --- /dev/null +++ b/frontend/assets/resources/animation/FrameAnimTextures/bulldozer-red.plist @@ -0,0 +1,266 @@ + + + + + frames + + RedEyePacman-Bottom-01.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{1,1},{500,500}} + textureRotated + + + RedEyePacman-Bottom-02.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{1,503},{500,500}} + textureRotated + + + RedEyePacman-BottomLeft-01.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{1,1005},{500,500}} + textureRotated + + + RedEyePacman-BottomLeft-02.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{1,1507},{500,500}} + textureRotated + + + RedEyePacman-BottomRight-01.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{503,1},{500,500}} + textureRotated + + + RedEyePacman-BottomRight-02.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{1005,1},{500,500}} + textureRotated + + + RedEyePacman-Left-01.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{1507,1},{500,500}} + textureRotated + + + RedEyePacman-Left-02.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{503,503},{500,500}} + textureRotated + + + RedEyePacman-Right-01.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{503,1005},{500,500}} + textureRotated + + + RedEyePacman-Right-02.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{503,1507},{500,500}} + textureRotated + + + RedEyePacman-Top-01.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{1005,503},{500,500}} + textureRotated + + + RedEyePacman-Top-02.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{1507,503},{500,500}} + textureRotated + + + RedEyePacman-TopLeft-01.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{1005,1005},{500,500}} + textureRotated + + + RedEyePacman-TopLeft-02.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{1005,1507},{500,500}} + textureRotated + + + RedEyePacman-TopRight-01.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{1507,1005},{500,500}} + textureRotated + + + RedEyePacman-TopRight-02.png + + aliases + + spriteOffset + {0,0} + spriteSize + {500,500} + spriteSourceSize + {500,500} + textureRect + {{1507,1507},{500,500}} + textureRotated + + + + metadata + + format + 3 + pixelFormat + RGBA8888 + premultiplyAlpha + + realTextureFileName + bulldozer-red.png + size + {2008,2008} + smartupdate + $TexturePacker:SmartUpdate:ddae6e75d84e0e816aa71938232564e7:2b1e30f28ea7a78dbb5c4c64f9192c8a:56afd1d5083c6201ac85a795f2357b44$ + textureFileName + bulldozer-red.png + + + diff --git a/frontend/assets/resources/animation/FrameAnimTextures/bulldozer-red.plist.meta b/frontend/assets/resources/animation/FrameAnimTextures/bulldozer-red.plist.meta new file mode 100644 index 0000000..114d131 --- /dev/null +++ b/frontend/assets/resources/animation/FrameAnimTextures/bulldozer-red.plist.meta @@ -0,0 +1,364 @@ +{ + "ver": "1.2.4", + "uuid": "2c488eae-3a87-45d5-841e-e50780f91023", + "rawTextureUuid": "69e8c316-dbc5-4e11-a720-bc86db323a70", + "size": { + "width": 2008, + "height": 2008 + }, + "type": "Texture Packer", + "subMetas": { + "RedEyePacman-Bottom-01.png": { + "ver": "1.0.4", + "uuid": "c79694bc-ff6f-416b-9047-b82f41fe791a", + "rawTextureUuid": "69e8c316-dbc5-4e11-a720-bc86db323a70", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1, + "trimY": 1, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "RedEyePacman-Bottom-02.png": { + "ver": "1.0.4", + "uuid": "609c77a2-bdfe-4967-8de6-646532302c97", + "rawTextureUuid": "69e8c316-dbc5-4e11-a720-bc86db323a70", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1, + "trimY": 503, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "RedEyePacman-BottomLeft-01.png": { + "ver": "1.0.4", + "uuid": "07b6d385-3f51-48c1-8165-38756b3d84fa", + "rawTextureUuid": "69e8c316-dbc5-4e11-a720-bc86db323a70", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1, + "trimY": 1005, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "RedEyePacman-BottomLeft-02.png": { + "ver": "1.0.4", + "uuid": "c627bf3b-0e97-4423-aeea-54c7511894d6", + "rawTextureUuid": "69e8c316-dbc5-4e11-a720-bc86db323a70", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1, + "trimY": 1507, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "RedEyePacman-BottomRight-01.png": { + "ver": "1.0.4", + "uuid": "d0327836-1910-4c6a-9291-c8bb044c54f5", + "rawTextureUuid": "69e8c316-dbc5-4e11-a720-bc86db323a70", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 503, + "trimY": 1, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "RedEyePacman-BottomRight-02.png": { + "ver": "1.0.4", + "uuid": "1d3e614a-bb2a-4b1d-87ca-0cddd6e03fff", + "rawTextureUuid": "69e8c316-dbc5-4e11-a720-bc86db323a70", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1005, + "trimY": 1, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "RedEyePacman-Left-01.png": { + "ver": "1.0.4", + "uuid": "c9528117-c878-41aa-ad5d-641fefcaa89f", + "rawTextureUuid": "69e8c316-dbc5-4e11-a720-bc86db323a70", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1507, + "trimY": 1, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "RedEyePacman-Left-02.png": { + "ver": "1.0.4", + "uuid": "c0e5d042-8bc1-449b-9a2d-7844129c5188", + "rawTextureUuid": "69e8c316-dbc5-4e11-a720-bc86db323a70", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 503, + "trimY": 503, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "RedEyePacman-Right-01.png": { + "ver": "1.0.4", + "uuid": "1054cf4c-69a5-4834-8966-03bc613d4483", + "rawTextureUuid": "69e8c316-dbc5-4e11-a720-bc86db323a70", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 503, + "trimY": 1005, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "RedEyePacman-Right-02.png": { + "ver": "1.0.4", + "uuid": "b88522bd-8b6b-44a1-9c84-5518ae7f5c2c", + "rawTextureUuid": "69e8c316-dbc5-4e11-a720-bc86db323a70", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 503, + "trimY": 1507, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "RedEyePacman-Top-01.png": { + "ver": "1.0.4", + "uuid": "9702ca76-66c8-4ea9-a976-45f86e15830a", + "rawTextureUuid": "69e8c316-dbc5-4e11-a720-bc86db323a70", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1005, + "trimY": 503, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "RedEyePacman-Top-02.png": { + "ver": "1.0.4", + "uuid": "6390f1c3-b4cc-41df-acfb-645e8f90fb36", + "rawTextureUuid": "69e8c316-dbc5-4e11-a720-bc86db323a70", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1507, + "trimY": 503, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "RedEyePacman-TopLeft-01.png": { + "ver": "1.0.4", + "uuid": "a669112a-f263-443d-9757-60d0372e0fe8", + "rawTextureUuid": "69e8c316-dbc5-4e11-a720-bc86db323a70", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1005, + "trimY": 1005, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "RedEyePacman-TopLeft-02.png": { + "ver": "1.0.4", + "uuid": "3ed70f56-3b60-4bda-9d2a-8d4b5ecb12f9", + "rawTextureUuid": "69e8c316-dbc5-4e11-a720-bc86db323a70", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1005, + "trimY": 1507, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "RedEyePacman-TopRight-01.png": { + "ver": "1.0.4", + "uuid": "3d84f335-85c4-4dd0-a5d3-38f4da1e1611", + "rawTextureUuid": "69e8c316-dbc5-4e11-a720-bc86db323a70", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1507, + "trimY": 1005, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "RedEyePacman-TopRight-02.png": { + "ver": "1.0.4", + "uuid": "6d36877f-dc27-4ebc-9407-14fbcf2314df", + "rawTextureUuid": "69e8c316-dbc5-4e11-a720-bc86db323a70", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1507, + "trimY": 1507, + "width": 500, + "height": 500, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + } + } +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/FrameAnimTextures/bulldozer-red.png b/frontend/assets/resources/animation/FrameAnimTextures/bulldozer-red.png new file mode 100644 index 0000000..44e1abf Binary files /dev/null and b/frontend/assets/resources/animation/FrameAnimTextures/bulldozer-red.png differ diff --git a/frontend/assets/resources/animation/FrameAnimTextures/bulldozer-red.png.meta b/frontend/assets/resources/animation/FrameAnimTextures/bulldozer-red.png.meta new file mode 100644 index 0000000..064c13a --- /dev/null +++ b/frontend/assets/resources/animation/FrameAnimTextures/bulldozer-red.png.meta @@ -0,0 +1,34 @@ +{ + "ver": "2.3.3", + "uuid": "69e8c316-dbc5-4e11-a720-bc86db323a70", + "type": "sprite", + "wrapMode": "clamp", + "filterMode": "bilinear", + "premultiplyAlpha": false, + "genMipmaps": false, + "packable": true, + "platformSettings": {}, + "subMetas": { + "bulldozer-red": { + "ver": "1.0.4", + "uuid": "1ad07a4b-1001-4d16-a77b-17e4e5ef51bd", + "rawTextureUuid": "69e8c316-dbc5-4e11-a720-bc86db323a70", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": -45.5, + "trimX": 0, + "trimY": 91, + "width": 2008, + "height": 1917, + "rawWidth": 2008, + "rawHeight": 2008, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "subMetas": {} + } + } +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/RedPacman.meta b/frontend/assets/resources/animation/RedPacman.meta new file mode 100644 index 0000000..c2af5dd --- /dev/null +++ b/frontend/assets/resources/animation/RedPacman.meta @@ -0,0 +1,7 @@ +{ + "ver": "1.0.1", + "uuid": "135f388e-7e75-4ece-b267-4e07835cba74", + "isSubpackage": false, + "subpackageName": "", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/RedPacman/Bottom.anim b/frontend/assets/resources/animation/RedPacman/Bottom.anim new file mode 100644 index 0000000..edc93b1 --- /dev/null +++ b/frontend/assets/resources/animation/RedPacman/Bottom.anim @@ -0,0 +1,31 @@ +{ + "__type__": "cc.AnimationClip", + "_name": "Bottom", + "_objFlags": 0, + "_native": "", + "_duration": 0.25, + "sample": 12, + "speed": 1, + "wrapMode": "2", + "curveData": { + "comps": { + "cc.Sprite": { + "spriteFrame": [ + { + "frame": 0, + "value": { + "__uuid__": "c79694bc-ff6f-416b-9047-b82f41fe791a" + } + }, + { + "frame": 0.16666666666666666, + "value": { + "__uuid__": "609c77a2-bdfe-4967-8de6-646532302c97" + } + } + ] + } + } + }, + "events": [] +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/RedPacman/Bottom.anim.meta b/frontend/assets/resources/animation/RedPacman/Bottom.anim.meta new file mode 100644 index 0000000..e682f3b --- /dev/null +++ b/frontend/assets/resources/animation/RedPacman/Bottom.anim.meta @@ -0,0 +1,5 @@ +{ + "ver": "2.1.0", + "uuid": "28194c48-ae3b-4197-8263-0d474ae8b9bc", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/RedPacman/BottomLeft.anim b/frontend/assets/resources/animation/RedPacman/BottomLeft.anim new file mode 100644 index 0000000..ebdfdf4 --- /dev/null +++ b/frontend/assets/resources/animation/RedPacman/BottomLeft.anim @@ -0,0 +1,31 @@ +{ + "__type__": "cc.AnimationClip", + "_name": "BottomLeft", + "_objFlags": 0, + "_native": "", + "_duration": 0.25, + "sample": 12, + "speed": 1, + "wrapMode": "2", + "curveData": { + "comps": { + "cc.Sprite": { + "spriteFrame": [ + { + "frame": 0, + "value": { + "__uuid__": "07b6d385-3f51-48c1-8165-38756b3d84fa" + } + }, + { + "frame": 0.16666666666666666, + "value": { + "__uuid__": "c627bf3b-0e97-4423-aeea-54c7511894d6" + } + } + ] + } + } + }, + "events": [] +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/RedPacman/BottomLeft.anim.meta b/frontend/assets/resources/animation/RedPacman/BottomLeft.anim.meta new file mode 100644 index 0000000..8cb3222 --- /dev/null +++ b/frontend/assets/resources/animation/RedPacman/BottomLeft.anim.meta @@ -0,0 +1,5 @@ +{ + "ver": "2.1.0", + "uuid": "e1c45a36-2022-4b18-a2db-b5e2e0a120ed", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/RedPacman/BottomRight.anim b/frontend/assets/resources/animation/RedPacman/BottomRight.anim new file mode 100644 index 0000000..a74b079 --- /dev/null +++ b/frontend/assets/resources/animation/RedPacman/BottomRight.anim @@ -0,0 +1,31 @@ +{ + "__type__": "cc.AnimationClip", + "_name": "BottomRight", + "_objFlags": 0, + "_native": "", + "_duration": 0.25, + "sample": 12, + "speed": 1, + "wrapMode": "2", + "curveData": { + "comps": { + "cc.Sprite": { + "spriteFrame": [ + { + "frame": 0, + "value": { + "__uuid__": "d0327836-1910-4c6a-9291-c8bb044c54f5" + } + }, + { + "frame": 0.16666666666666666, + "value": { + "__uuid__": "1d3e614a-bb2a-4b1d-87ca-0cddd6e03fff" + } + } + ] + } + } + }, + "events": [] +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/RedPacman/BottomRight.anim.meta b/frontend/assets/resources/animation/RedPacman/BottomRight.anim.meta new file mode 100644 index 0000000..7395a43 --- /dev/null +++ b/frontend/assets/resources/animation/RedPacman/BottomRight.anim.meta @@ -0,0 +1,5 @@ +{ + "ver": "2.1.0", + "uuid": "126dff26-0ace-439d-89b5-b888aa52d159", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/RedPacman/Left.anim b/frontend/assets/resources/animation/RedPacman/Left.anim new file mode 100644 index 0000000..b72a0f5 --- /dev/null +++ b/frontend/assets/resources/animation/RedPacman/Left.anim @@ -0,0 +1,31 @@ +{ + "__type__": "cc.AnimationClip", + "_name": "Left", + "_objFlags": 0, + "_native": "", + "_duration": 0.25, + "sample": 12, + "speed": 1, + "wrapMode": "2", + "curveData": { + "comps": { + "cc.Sprite": { + "spriteFrame": [ + { + "frame": 0, + "value": { + "__uuid__": "c9528117-c878-41aa-ad5d-641fefcaa89f" + } + }, + { + "frame": 0.16666666666666666, + "value": { + "__uuid__": "c0e5d042-8bc1-449b-9a2d-7844129c5188" + } + } + ] + } + } + }, + "events": [] +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/RedPacman/Left.anim.meta b/frontend/assets/resources/animation/RedPacman/Left.anim.meta new file mode 100644 index 0000000..51d4959 --- /dev/null +++ b/frontend/assets/resources/animation/RedPacman/Left.anim.meta @@ -0,0 +1,5 @@ +{ + "ver": "2.1.0", + "uuid": "95c2d541-8f99-446a-a7e0-094130ce6d41", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/RedPacman/Right.anim b/frontend/assets/resources/animation/RedPacman/Right.anim new file mode 100644 index 0000000..b0efefa --- /dev/null +++ b/frontend/assets/resources/animation/RedPacman/Right.anim @@ -0,0 +1,31 @@ +{ + "__type__": "cc.AnimationClip", + "_name": "Right", + "_objFlags": 0, + "_native": "", + "_duration": 0.25, + "sample": 12, + "speed": 1, + "wrapMode": "2", + "curveData": { + "comps": { + "cc.Sprite": { + "spriteFrame": [ + { + "frame": 0, + "value": { + "__uuid__": "1054cf4c-69a5-4834-8966-03bc613d4483" + } + }, + { + "frame": 0.16666666666666666, + "value": { + "__uuid__": "b88522bd-8b6b-44a1-9c84-5518ae7f5c2c" + } + } + ] + } + } + }, + "events": [] +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/RedPacman/Right.anim.meta b/frontend/assets/resources/animation/RedPacman/Right.anim.meta new file mode 100644 index 0000000..8175ed2 --- /dev/null +++ b/frontend/assets/resources/animation/RedPacman/Right.anim.meta @@ -0,0 +1,5 @@ +{ + "ver": "2.1.0", + "uuid": "380f5fa0-f77f-434a-8f39-d545ee6823c5", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/RedPacman/Top.anim b/frontend/assets/resources/animation/RedPacman/Top.anim new file mode 100644 index 0000000..2a8f6f1 --- /dev/null +++ b/frontend/assets/resources/animation/RedPacman/Top.anim @@ -0,0 +1,31 @@ +{ + "__type__": "cc.AnimationClip", + "_name": "Top", + "_objFlags": 0, + "_native": "", + "_duration": 0.25, + "sample": 12, + "speed": 1, + "wrapMode": "2", + "curveData": { + "comps": { + "cc.Sprite": { + "spriteFrame": [ + { + "frame": 0, + "value": { + "__uuid__": "9702ca76-66c8-4ea9-a976-45f86e15830a" + } + }, + { + "frame": 0.16666666666666666, + "value": { + "__uuid__": "6390f1c3-b4cc-41df-acfb-645e8f90fb36" + } + } + ] + } + } + }, + "events": [] +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/RedPacman/Top.anim.meta b/frontend/assets/resources/animation/RedPacman/Top.anim.meta new file mode 100644 index 0000000..ecf45b1 --- /dev/null +++ b/frontend/assets/resources/animation/RedPacman/Top.anim.meta @@ -0,0 +1,5 @@ +{ + "ver": "2.1.0", + "uuid": "a306c6de-ccd8-492b-bfec-c6be0a4cbde2", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/RedPacman/TopLeft.anim b/frontend/assets/resources/animation/RedPacman/TopLeft.anim new file mode 100644 index 0000000..d97ead7 --- /dev/null +++ b/frontend/assets/resources/animation/RedPacman/TopLeft.anim @@ -0,0 +1,31 @@ +{ + "__type__": "cc.AnimationClip", + "_name": "TopLeft", + "_objFlags": 0, + "_native": "", + "_duration": 0.25, + "sample": 12, + "speed": 1, + "wrapMode": "2", + "curveData": { + "comps": { + "cc.Sprite": { + "spriteFrame": [ + { + "frame": 0, + "value": { + "__uuid__": "a669112a-f263-443d-9757-60d0372e0fe8" + } + }, + { + "frame": 0.16666666666666666, + "value": { + "__uuid__": "3ed70f56-3b60-4bda-9d2a-8d4b5ecb12f9" + } + } + ] + } + } + }, + "events": [] +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/RedPacman/TopLeft.anim.meta b/frontend/assets/resources/animation/RedPacman/TopLeft.anim.meta new file mode 100644 index 0000000..cd72087 --- /dev/null +++ b/frontend/assets/resources/animation/RedPacman/TopLeft.anim.meta @@ -0,0 +1,5 @@ +{ + "ver": "2.1.0", + "uuid": "f496072b-51fd-4406-abbd-9885ac23f7a9", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/RedPacman/TopRight.anim b/frontend/assets/resources/animation/RedPacman/TopRight.anim new file mode 100644 index 0000000..3b69ad5 --- /dev/null +++ b/frontend/assets/resources/animation/RedPacman/TopRight.anim @@ -0,0 +1,31 @@ +{ + "__type__": "cc.AnimationClip", + "_name": "TopRight", + "_objFlags": 0, + "_native": "", + "_duration": 0.25, + "sample": 12, + "speed": 1, + "wrapMode": "2", + "curveData": { + "comps": { + "cc.Sprite": { + "spriteFrame": [ + { + "frame": 0, + "value": { + "__uuid__": "3d84f335-85c4-4dd0-a5d3-38f4da1e1611" + } + }, + { + "frame": 0.16666666666666666, + "value": { + "__uuid__": "6d36877f-dc27-4ebc-9407-14fbcf2314df" + } + } + ] + } + } + }, + "events": [] +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/RedPacman/TopRight.anim.meta b/frontend/assets/resources/animation/RedPacman/TopRight.anim.meta new file mode 100644 index 0000000..bc4dfe2 --- /dev/null +++ b/frontend/assets/resources/animation/RedPacman/TopRight.anim.meta @@ -0,0 +1,5 @@ +{ + "ver": "2.1.0", + "uuid": "6405ad8b-3084-4b67-8c2e-9b4d34fa3d09", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/RedPacman/attackedLeft.anim b/frontend/assets/resources/animation/RedPacman/attackedLeft.anim new file mode 100644 index 0000000..160a842 --- /dev/null +++ b/frontend/assets/resources/animation/RedPacman/attackedLeft.anim @@ -0,0 +1,43 @@ +{ + "__type__": "cc.AnimationClip", + "_name": "attackedLeft", + "_objFlags": 0, + "_native": "", + "_duration": 0.3333333333333333, + "sample": 12, + "speed": 1, + "wrapMode": "2", + "curveData": { + "comps": { + "cc.Sprite": { + "spriteFrame": [ + { + "frame": 0, + "value": { + "__uuid__": "c9528117-c878-41aa-ad5d-641fefcaa89f" + } + }, + { + "frame": 0.08333333333333333, + "value": { + "__uuid__": "987c7dc0-e81f-4891-979d-0998794e6889" + } + }, + { + "frame": 0.16666666666666666, + "value": { + "__uuid__": "c0e5d042-8bc1-449b-9a2d-7844129c5188" + } + }, + { + "frame": 0.25, + "value": { + "__uuid__": "9205c378-c50c-4303-af32-dbf9422375cf" + } + } + ] + } + } + }, + "events": [] +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/RedPacman/attackedLeft.anim.meta b/frontend/assets/resources/animation/RedPacman/attackedLeft.anim.meta new file mode 100644 index 0000000..f0588c1 --- /dev/null +++ b/frontend/assets/resources/animation/RedPacman/attackedLeft.anim.meta @@ -0,0 +1,5 @@ +{ + "ver": "2.1.0", + "uuid": "af16cdcb-6e82-4be6-806d-9fc52ae99fff", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/RedPacman/attackedRight.anim b/frontend/assets/resources/animation/RedPacman/attackedRight.anim new file mode 100644 index 0000000..6845f6b --- /dev/null +++ b/frontend/assets/resources/animation/RedPacman/attackedRight.anim @@ -0,0 +1,43 @@ +{ + "__type__": "cc.AnimationClip", + "_name": "attackedRight", + "_objFlags": 0, + "_native": "", + "_duration": 0.3333333333333333, + "sample": 12, + "speed": 1, + "wrapMode": "2", + "curveData": { + "comps": { + "cc.Sprite": { + "spriteFrame": [ + { + "frame": 0, + "value": { + "__uuid__": "1054cf4c-69a5-4834-8966-03bc613d4483" + } + }, + { + "frame": 0.08333333333333333, + "value": { + "__uuid__": "8f3cf81e-1251-4013-b684-13f2830c7425" + } + }, + { + "frame": 0.16666666666666666, + "value": { + "__uuid__": "b88522bd-8b6b-44a1-9c84-5518ae7f5c2c" + } + }, + { + "frame": 0.25, + "value": { + "__uuid__": "69f1bd37-6628-4fd1-b0f2-08073d1edb29" + } + } + ] + } + } + }, + "events": [] +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/RedPacman/attackedRight.anim.meta b/frontend/assets/resources/animation/RedPacman/attackedRight.anim.meta new file mode 100644 index 0000000..e67bff2 --- /dev/null +++ b/frontend/assets/resources/animation/RedPacman/attackedRight.anim.meta @@ -0,0 +1,5 @@ +{ + "ver": "2.1.0", + "uuid": "02eba566-4d22-4fa7-99d7-f032f5845421", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/findingPlayer.anim b/frontend/assets/resources/animation/findingPlayer.anim new file mode 100644 index 0000000..fdda4ee --- /dev/null +++ b/frontend/assets/resources/animation/findingPlayer.anim @@ -0,0 +1,55 @@ +{ + "__type__": "cc.AnimationClip", + "_name": "findingPlayer", + "_objFlags": 0, + "_native": "", + "_duration": 0.75, + "sample": 8, + "speed": 1, + "wrapMode": "2", + "curveData": { + "comps": { + "cc.Sprite": { + "spriteFrame": [ + { + "frame": 0, + "value": { + "__uuid__": "7b86de0f-ea49-42c3-bdd0-db8de330e9aa" + } + }, + { + "frame": 0.125, + "value": { + "__uuid__": "819073c0-7a15-4679-957b-65a226d8fce4" + } + }, + { + "frame": 0.25, + "value": { + "__uuid__": "6ff26f1f-30d1-4e49-b76c-d9bc61eb6ce0" + } + }, + { + "frame": 0.375, + "value": { + "__uuid__": "44c52db6-d112-4829-96f2-6fd57a8a0d7f" + } + }, + { + "frame": 0.5, + "value": { + "__uuid__": "efd42f06-82ad-4b1b-9134-6f35c26bf10f" + } + }, + { + "frame": 0.625, + "value": { + "__uuid__": "19094751-ab4e-40b6-9216-dd7887d80c86" + } + } + ] + } + } + }, + "events": [] +} \ No newline at end of file diff --git a/frontend/assets/resources/animation/findingPlayer.anim.meta b/frontend/assets/resources/animation/findingPlayer.anim.meta new file mode 100644 index 0000000..6be95f3 --- /dev/null +++ b/frontend/assets/resources/animation/findingPlayer.anim.meta @@ -0,0 +1,5 @@ +{ + "ver": "2.1.0", + "uuid": "2062218a-c5d4-4cbb-959e-77e8e5a96344", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/font.meta b/frontend/assets/resources/font.meta new file mode 100644 index 0000000..6fe8e8b --- /dev/null +++ b/frontend/assets/resources/font.meta @@ -0,0 +1,7 @@ +{ + "ver": "1.0.1", + "uuid": "4e96044d-39b2-4388-8c2f-89264ffee38b", + "isSubpackage": false, + "subpackageName": "", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/font/mikado_outline_shadow.fnt b/frontend/assets/resources/font/mikado_outline_shadow.fnt new file mode 100644 index 0000000..0a43dfe --- /dev/null +++ b/frontend/assets/resources/font/mikado_outline_shadow.fnt @@ -0,0 +1,99 @@ +info face="Mikado" size=36 bold=1 italic=0 charset="" unicode=0 stretchH=100 smooth=1 aa=1 padding=0,0,0,0 spacing=2,2 +common lineHeight=49 base=36 scaleW=512 scaleH=256 pages=1 packed=0 +page id=0 file="mikado_outline_shadow.png" +chars count=95 +char id=32 x=294 y=208 width=0 height=0 xoffset=0 yoffset=40 xadvance=7 page=0 chnl=0 letter="space" +char id=33 x=460 y=132 width=18 height=37 xoffset=1 yoffset=3 xadvance=11 page=0 chnl=0 letter="!" +char id=34 x=131 y=208 width=23 height=22 xoffset=0 yoffset=3 xadvance=15 page=0 chnl=0 letter=""" +char id=35 x=68 y=132 width=31 height=37 xoffset=-0 yoffset=3 xadvance=22 page=0 chnl=0 letter="#" +char id=36 x=122 y=2 width=30 height=44 xoffset=0 yoffset=-1 xadvance=21 page=0 chnl=0 letter="$" +char id=37 x=128 y=51 width=39 height=38 xoffset=-0 yoffset=3 xadvance=30 page=0 chnl=0 letter="%" +char id=38 x=242 y=51 width=33 height=38 xoffset=1 yoffset=3 xadvance=25 page=0 chnl=0 letter="&" +char id=39 x=156 y=208 width=15 height=22 xoffset=0 yoffset=3 xadvance=7 page=0 chnl=0 letter="'" +char id=40 x=251 y=2 width=23 height=42 xoffset=0 yoffset=3 xadvance=14 page=0 chnl=0 letter="(" +char id=41 x=276 y=2 width=23 height=42 xoffset=-1 yoffset=3 xadvance=14 page=0 chnl=0 letter=")" +char id=42 x=50 y=208 width=23 height=24 xoffset=0 yoffset=1 xadvance=15 page=0 chnl=0 letter="*" +char id=43 x=232 y=171 width=28 height=30 xoffset=-0 yoffset=9 xadvance=19 page=0 chnl=0 letter="+" +char id=44 x=30 y=208 width=18 height=26 xoffset=0 yoffset=21 xadvance=10 page=0 chnl=0 letter="," +char id=45 x=246 y=208 width=22 height=16 xoffset=1 yoffset=16 xadvance=14 page=0 chnl=0 letter="-" +char id=46 x=196 y=208 width=18 height=19 xoffset=0 yoffset=22 xadvance=10 page=0 chnl=0 letter="." +char id=47 x=223 y=2 width=26 height=42 xoffset=-0 yoffset=1 xadvance=17 page=0 chnl=0 letter="/" +char id=48 x=134 y=92 width=30 height=38 xoffset=0 yoffset=3 xadvance=22 page=0 chnl=0 letter="0" +char id=49 x=435 y=132 width=23 height=37 xoffset=-1 yoffset=3 xadvance=15 page=0 chnl=0 letter="1" +char id=50 x=349 y=132 width=27 height=37 xoffset=-0 yoffset=3 xadvance=19 page=0 chnl=0 letter="2" +char id=51 x=351 y=92 width=28 height=38 xoffset=-0 yoffset=2 xadvance=19 page=0 chnl=0 letter="3" +char id=52 x=35 y=132 width=31 height=37 xoffset=-1 yoffset=3 xadvance=21 page=0 chnl=0 letter="4" +char id=53 x=321 y=92 width=28 height=38 xoffset=-0 yoffset=2 xadvance=19 page=0 chnl=0 letter="5" +char id=54 x=259 y=92 width=29 height=38 xoffset=0 yoffset=2 xadvance=20 page=0 chnl=0 letter="6" +char id=55 x=378 y=132 width=27 height=37 xoffset=-0 yoffset=3 xadvance=17 page=0 chnl=0 letter="7" +char id=56 x=228 y=92 width=29 height=38 xoffset=0 yoffset=3 xadvance=21 page=0 chnl=0 letter="8" +char id=57 x=290 y=92 width=29 height=38 xoffset=-0 yoffset=2 xadvance=20 page=0 chnl=0 letter="9" +char id=58 x=456 y=171 width=18 height=30 xoffset=0 yoffset=11 xadvance=10 page=0 chnl=0 letter=":" +char id=59 x=480 y=132 width=18 height=37 xoffset=1 yoffset=10 xadvance=11 page=0 chnl=0 letter=";" +char id=60 x=2 y=208 width=26 height=27 xoffset=-0 yoffset=10 xadvance=17 page=0 chnl=0 letter="<" +char id=61 x=103 y=208 width=26 height=22 xoffset=1 yoffset=13 xadvance=19 page=0 chnl=0 letter="=" +char id=62 x=476 y=171 width=26 height=28 xoffset=0 yoffset=11 xadvance=18 page=0 chnl=0 letter=">" +char id=63 x=381 y=92 width=25 height=38 xoffset=-0 yoffset=2 xadvance=17 page=0 chnl=0 letter="?" +char id=64 x=17 y=2 width=44 height=46 xoffset=0 yoffset=3 xadvance=36 page=0 chnl=0 letter="@" +char id=65 x=427 y=92 width=35 height=37 xoffset=-0 yoffset=3 xadvance=26 page=0 chnl=0 letter="A" +char id=66 x=101 y=132 width=30 height=37 xoffset=1 yoffset=3 xadvance=23 page=0 chnl=0 letter="B" +char id=67 x=2 y=92 width=32 height=38 xoffset=0 yoffset=3 xadvance=23 page=0 chnl=0 letter="C" +char id=68 x=464 y=92 width=32 height=37 xoffset=1 yoffset=3 xadvance=25 page=0 chnl=0 letter="D" +char id=69 x=260 y=132 width=28 height=37 xoffset=1 yoffset=3 xadvance=21 page=0 chnl=0 letter="E" +char id=70 x=290 y=132 width=28 height=37 xoffset=1 yoffset=3 xadvance=21 page=0 chnl=0 letter="F" +char id=71 x=312 y=51 width=33 height=38 xoffset=0 yoffset=3 xadvance=25 page=0 chnl=0 letter="G" +char id=72 x=277 y=51 width=33 height=38 xoffset=1 yoffset=3 xadvance=27 page=0 chnl=0 letter="H" +char id=73 x=408 y=92 width=17 height=38 xoffset=1 yoffset=3 xadvance=11 page=0 chnl=0 letter="I" +char id=74 x=407 y=132 width=26 height=37 xoffset=-1 yoffset=3 xadvance=17 page=0 chnl=0 letter="J" +char id=75 x=36 y=92 width=32 height=38 xoffset=1 yoffset=3 xadvance=24 page=0 chnl=0 letter="K" +char id=76 x=320 y=132 width=27 height=37 xoffset=1 yoffset=3 xadvance=19 page=0 chnl=0 letter="L" +char id=77 x=85 y=51 width=41 height=38 xoffset=-0 yoffset=3 xadvance=32 page=0 chnl=0 letter="M" +char id=78 x=417 y=51 width=33 height=38 xoffset=1 yoffset=3 xadvance=27 page=0 chnl=0 letter="N" +char id=79 x=169 y=51 width=35 height=38 xoffset=0 yoffset=3 xadvance=27 page=0 chnl=0 letter="O" +char id=80 x=165 y=132 width=30 height=37 xoffset=1 yoffset=3 xadvance=23 page=0 chnl=0 letter="P" +char id=81 x=85 y=2 width=35 height=45 xoffset=0 yoffset=3 xadvance=27 page=0 chnl=0 letter="Q" +char id=82 x=2 y=132 width=31 height=37 xoffset=1 yoffset=4 xadvance=24 page=0 chnl=0 letter="R" +char id=83 x=197 y=132 width=30 height=37 xoffset=-0 yoffset=3 xadvance=21 page=0 chnl=0 letter="S" +char id=84 x=133 y=132 width=30 height=37 xoffset=-1 yoffset=3 xadvance=21 page=0 chnl=0 letter="T" +char id=85 x=452 y=51 width=32 height=38 xoffset=1 yoffset=3 xadvance=26 page=0 chnl=0 letter="U" +char id=86 x=206 y=51 width=34 height=38 xoffset=-1 yoffset=2 xadvance=24 page=0 chnl=0 letter="V" +char id=87 x=40 y=51 width=43 height=38 xoffset=-0 yoffset=3 xadvance=34 page=0 chnl=0 letter="W" +char id=88 x=382 y=51 width=33 height=38 xoffset=-1 yoffset=3 xadvance=23 page=0 chnl=0 letter="X" +char id=89 x=347 y=51 width=33 height=38 xoffset=-1 yoffset=3 xadvance=23 page=0 chnl=0 letter="Y" +char id=90 x=229 y=132 width=29 height=37 xoffset=0 yoffset=3 xadvance=21 page=0 chnl=0 letter="Z" +char id=91 x=200 y=2 width=21 height=43 xoffset=1 yoffset=3 xadvance=13 page=0 chnl=0 letter="[" +char id=92 x=387 y=2 width=25 height=40 xoffset=-0 yoffset=1 xadvance=16 page=0 chnl=0 letter="\" +char id=93 x=301 y=2 width=21 height=42 xoffset=-0 yoffset=3 xadvance=13 page=0 chnl=0 letter="]" +char id=94 x=75 y=208 width=26 height=23 xoffset=-0 yoffset=2 xadvance=17 page=0 chnl=0 letter="^" +char id=95 x=270 y=208 width=22 height=15 xoffset=1 yoffset=30 xadvance=15 page=0 chnl=0 letter="_" +char id=96 x=173 y=208 width=21 height=19 xoffset=1 yoffset=2 xadvance=14 page=0 chnl=0 letter="`" +char id=97 x=321 y=171 width=26 height=30 xoffset=-0 yoffset=10 xadvance=18 page=0 chnl=0 letter="a" +char id=98 x=324 y=2 width=30 height=40 xoffset=-0 yoffset=1 xadvance=21 page=0 chnl=0 letter="b" +char id=99 x=349 y=171 width=26 height=30 xoffset=-0 yoffset=11 xadvance=17 page=0 chnl=0 letter="c" +char id=100 x=414 y=2 width=30 height=39 xoffset=0 yoffset=2 xadvance=22 page=0 chnl=0 letter="d" +char id=101 x=292 y=171 width=27 height=30 xoffset=-0 yoffset=10 xadvance=18 page=0 chnl=0 letter="e" +char id=102 x=476 y=2 width=26 height=39 xoffset=-1 yoffset=2 xadvance=15 page=0 chnl=0 letter="f" +char id=103 x=102 y=92 width=30 height=38 xoffset=0 yoffset=10 xadvance=22 page=0 chnl=0 letter="g" +char id=104 x=446 y=2 width=28 height=39 xoffset=1 yoffset=1 xadvance=21 page=0 chnl=0 letter="h" +char id=105 x=2 y=51 width=17 height=39 xoffset=1 yoffset=1 xadvance=10 page=0 chnl=0 letter="i" +char id=106 x=63 y=2 width=20 height=46 xoffset=-2 yoffset=2 xadvance=10 page=0 chnl=0 letter="j" +char id=107 x=356 y=2 width=29 height=40 xoffset=0 yoffset=1 xadvance=20 page=0 chnl=0 letter="k" +char id=108 x=21 y=51 width=17 height=39 xoffset=1 yoffset=1 xadvance=9 page=0 chnl=0 letter="l" +char id=109 x=68 y=171 width=38 height=30 xoffset=1 yoffset=10 xadvance=31 page=0 chnl=0 letter="m" +char id=110 x=202 y=171 width=28 height=30 xoffset=1 yoffset=10 xadvance=21 page=0 chnl=0 letter="n" +char id=111 x=171 y=171 width=29 height=30 xoffset=-0 yoffset=10 xadvance=20 page=0 chnl=0 letter="o" +char id=112 x=70 y=92 width=30 height=38 xoffset=1 yoffset=10 xadvance=22 page=0 chnl=0 letter="p" +char id=113 x=197 y=92 width=29 height=38 xoffset=0 yoffset=11 xadvance=21 page=0 chnl=0 letter="q" +char id=114 x=431 y=171 width=23 height=30 xoffset=1 yoffset=10 xadvance=14 page=0 chnl=0 letter="r" +char id=115 x=377 y=171 width=25 height=30 xoffset=-0 yoffset=11 xadvance=16 page=0 chnl=0 letter="s" +char id=116 x=2 y=171 width=24 height=35 xoffset=-0 yoffset=6 xadvance=15 page=0 chnl=0 letter="t" +char id=117 x=262 y=171 width=28 height=30 xoffset=1 yoffset=11 xadvance=21 page=0 chnl=0 letter="u" +char id=118 x=108 y=171 width=30 height=30 xoffset=-0 yoffset=11 xadvance=20 page=0 chnl=0 letter="v" +char id=119 x=28 y=171 width=38 height=30 xoffset=-0 yoffset=11 xadvance=29 page=0 chnl=0 letter="w" +char id=120 x=140 y=171 width=29 height=30 xoffset=-1 yoffset=11 xadvance=19 page=0 chnl=0 letter="x" +char id=121 x=166 y=92 width=29 height=38 xoffset=-1 yoffset=10 xadvance=19 page=0 chnl=0 letter="y" +char id=122 x=404 y=171 width=25 height=30 xoffset=-0 yoffset=10 xadvance=16 page=0 chnl=0 letter="z" +char id=123 x=154 y=2 width=21 height=43 xoffset=-1 yoffset=3 xadvance=12 page=0 chnl=0 letter="{" +char id=124 x=2 y=2 width=13 height=47 xoffset=1 yoffset=1 xadvance=7 page=0 chnl=0 letter="|" +char id=125 x=177 y=2 width=21 height=43 xoffset=-0 yoffset=3 xadvance=12 page=0 chnl=0 letter="}" +char id=126 x=216 y=208 width=28 height=18 xoffset=0 yoffset=14 xadvance=20 page=0 chnl=0 letter="~" diff --git a/frontend/assets/resources/font/mikado_outline_shadow.fnt.meta b/frontend/assets/resources/font/mikado_outline_shadow.fnt.meta new file mode 100644 index 0000000..629355e --- /dev/null +++ b/frontend/assets/resources/font/mikado_outline_shadow.fnt.meta @@ -0,0 +1,7 @@ +{ + "ver": "2.1.0", + "uuid": "a564b3db-b8cb-48b4-952e-25bb56949116", + "textureUuid": "71a46ef1-d7bc-4b93-b56d-1c0d1cd7bfee", + "fontSize": 36, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/font/mikado_outline_shadow.png b/frontend/assets/resources/font/mikado_outline_shadow.png new file mode 100644 index 0000000..30f9d34 Binary files /dev/null and b/frontend/assets/resources/font/mikado_outline_shadow.png differ diff --git a/frontend/assets/resources/font/mikado_outline_shadow.png.meta b/frontend/assets/resources/font/mikado_outline_shadow.png.meta new file mode 100644 index 0000000..dda9b5e --- /dev/null +++ b/frontend/assets/resources/font/mikado_outline_shadow.png.meta @@ -0,0 +1,34 @@ +{ + "ver": "2.3.3", + "uuid": "71a46ef1-d7bc-4b93-b56d-1c0d1cd7bfee", + "type": "sprite", + "wrapMode": "clamp", + "filterMode": "bilinear", + "premultiplyAlpha": false, + "genMipmaps": false, + "packable": true, + "platformSettings": {}, + "subMetas": { + "mikado_outline_shadow": { + "ver": "1.0.4", + "uuid": "c5f0f56d-1c5b-4c3a-a586-247ff0a50179", + "rawTextureUuid": "71a46ef1-d7bc-4b93-b56d-1c0d1cd7bfee", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": -4.5, + "offsetY": 9, + "trimX": 3, + "trimY": 3, + "width": 497, + "height": 232, + "rawWidth": 512, + "rawHeight": 256, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "subMetas": {} + } + } +} \ No newline at end of file diff --git a/frontend/assets/resources/i18n.meta b/frontend/assets/resources/i18n.meta new file mode 100644 index 0000000..e2f8a4d --- /dev/null +++ b/frontend/assets/resources/i18n.meta @@ -0,0 +1,7 @@ +{ + "ver": "1.0.1", + "uuid": "9c88608b-f02d-4bcc-b0e3-f486509e7fe1", + "isSubpackage": false, + "subpackageName": "", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/i18n/en.js b/frontend/assets/resources/i18n/en.js new file mode 100644 index 0000000..a63bcf7 --- /dev/null +++ b/frontend/assets/resources/i18n/en.js @@ -0,0 +1,57 @@ +'use strict'; + +if (!window.i18n) { + window.i18n = {}; +} + +if (!window.i18n.languages) { + window.i18n.languages = {}; +} + +window.i18n.languages['en'] = { + resultPanel: { + winnerLabel: "Winner", + loserLabel: "Loser", + timeLabel: "Time:", + timeTip: "(the last time to pick up the treasure) ", + awardLabel: "Award:", + againBtnLabel: "Again", + homeBtnLabel: "Home", + }, + gameRule: { + tip: "经典吃豆人玩法,加入了实时对战元素。金豆100分,煎蛋200分,玩家在规定时间内得分高则获胜。要注意躲避防御塔攻击,被击中会被定住5秒的哦。开始游戏吧~", + mode: "1v1 模式", + }, + login: { + "tips": { + "LOGOUT": 'Logout', + "DUPLICATED": 'Login id conflict, please retry', + "LOGIN_TOKEN_EXPIRED": 'Previous login status expired', + "PHONE_COUNTRY_CODE_ERR": 'Incorrect phone country code', + "CAPTCHA_ERR": 'Incorrect format', + "PHONE_ERR": 'Incorrect phone number format', + "SMS_CAPTCHA_FREQUENT_REQUIRE": 'Request too often', + "SMS_CAPTCHA_NOT_MATCH": 'Incorrect verification code', + "TEST_USER": 'test account', + "INCORRECT_PHONE_NUMBER": 'Incorrect phone number', + "LOGGED_IN_SUCCESSFULLY": "Logged in successfully, please wait...", + + "PLEASE_AUTHORIZE_WECHAT_LOGIN_FIRST": "Please tap the screen to authorize WeChat login first", + "WECHAT_AUTHORIZED_AND_INT_AUTH_TOKEN_LOGGING_IN": "WeChat authorized, logging in...", + "WECHAT_LOGIN_FAILED_TAP_SCREEN_TO_RETRY": "WeChat login failed, tap the screen to retry", + "AUTO_LOGIN_FAILED_WILL_USE_MANUAL_LOGIN": "Auto login failed, creating manual login button", + "AUTO_LOGIN_1": "Automatically logging in", + "AUTO_LOGIN_2": "Automatically logging in...", + }, + }, + findingPlayer: { + exit: "Exit", + tip: "我们正在为你匹配另一位玩家,请稍等", + finding: "等等我,马上到...", + }, + gameTip: { + start: "Start!", + resyncing: "Resyncing your battle, please wait...", + }, + +}; diff --git a/frontend/assets/resources/i18n/en.js.meta b/frontend/assets/resources/i18n/en.js.meta new file mode 100644 index 0000000..39c3c14 --- /dev/null +++ b/frontend/assets/resources/i18n/en.js.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.5", + "uuid": "225415b8-1a4c-4fd9-bb42-68b60c50bd7e", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/i18n/zh.js b/frontend/assets/resources/i18n/zh.js new file mode 100644 index 0000000..66bdc7b --- /dev/null +++ b/frontend/assets/resources/i18n/zh.js @@ -0,0 +1,55 @@ +'use strict'; + +if (!window.i18n) { + window.i18n = {}; +} + +if (!window.i18n.languages) { + window.i18n.languages = {}; +} + +window.i18n.languages['zh'] = { + resultPanel: { + winnerLabel: "Winner", + loserLabel: "Loser", + timeLabel: "Time:", + timeTip: "(the last time to pick up the treasure) ", + awardLabel: "Award:", + againBtnLabel: "再来一局", + homeBtnLabel: "回到首页", + }, + gameRule:{ + tip: "玩家在规定时间内得分高则获胜。要注意躲避防御塔的攻击,被击中会被定住5秒的哦。开始游戏吧~", + mode: "1v1 模式", + }, + login: { + "tips": { + "LOGOUT": '登出', + "LOGIN_TOKEN_EXPIRED": '登入状态已过期,请重新登入', + "PHONE_COUNTRY_CODE_ERR": '电话号码的国家号不正确', + "CAPTCHA_ERR": '格式有误', + "PHONE_ERR": '电话号码的格式不对', + "SMS_CAPTCHA_FREQUENT_REQUIRE": '请求过于频繁,请稍候再试', + "SMS_CAPTCHA_NOT_MATCH": '验证码不正确', + "TEST_USER": '测试账号', + "INCORRECT_PHONE_NUMBER": '电话号码不正确', + "LOGGED_IN_SUCCESSFULLY": "登入成功,正在加载中...", + + "PLEASE_AUTHORIZE_WECHAT_LOGIN_FIRST": "请先点击屏幕进行微信授权登录", + "WECHAT_AUTHORIZED_AND_INT_AUTH_TOKEN_LOGGING_IN": "微信授权登录成功,正在登入...", + "WECHAT_LOGIN_FAILED_TAP_SCREEN_TO_RETRY": "微信授权登录失败,请点击屏幕重试", + "AUTO_LOGIN_FAILED_WILL_USE_MANUAL_LOGIN": "自动登入失败,请点击屏幕空白处手动授权登入...", + "AUTO_LOGIN_1": "正在自动登入", + "AUTO_LOGIN_2": "正在自动登入...", + }, + }, + findingPlayer: { + exit: "退出", + tip: "我们正在为你匹配另一位玩家,请稍等", + finding: "等等我,马上到...", + }, + gameTip: { + start: "游戏开始!", + resyncing: "正在重连,请稍等...", + }, +}; diff --git a/frontend/assets/resources/i18n/zh.js.meta b/frontend/assets/resources/i18n/zh.js.meta new file mode 100644 index 0000000..32493e9 --- /dev/null +++ b/frontend/assets/resources/i18n/zh.js.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.5", + "uuid": "09bff2b7-f9a2-4eac-b561-f02ff8e28abe", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/map.meta b/frontend/assets/resources/map.meta new file mode 100644 index 0000000..f252b0d --- /dev/null +++ b/frontend/assets/resources/map.meta @@ -0,0 +1,7 @@ +{ + "ver": "1.0.1", + "uuid": "1fe4b981-93b1-4e65-aefb-898c615219e5", + "isSubpackage": false, + "subpackageName": "", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/map/pacman.meta b/frontend/assets/resources/map/pacman.meta new file mode 100644 index 0000000..61cb490 --- /dev/null +++ b/frontend/assets/resources/map/pacman.meta @@ -0,0 +1,7 @@ +{ + "ver": "1.0.1", + "uuid": "33d33d2f-5ca7-4677-9c82-4ced71aa0f8a", + "isSubpackage": false, + "subpackageName": "", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/map/pacman/BackgroundMap.meta b/frontend/assets/resources/map/pacman/BackgroundMap.meta new file mode 100644 index 0000000..c24e299 --- /dev/null +++ b/frontend/assets/resources/map/pacman/BackgroundMap.meta @@ -0,0 +1,7 @@ +{ + "ver": "1.0.1", + "uuid": "f9460fe9-26ad-4e4b-8a3c-c97bef705a71", + "isSubpackage": false, + "subpackageName": "", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/map/pacman/BackgroundMap/Tile_W256_H128_S01.png b/frontend/assets/resources/map/pacman/BackgroundMap/Tile_W256_H128_S01.png new file mode 100644 index 0000000..b651445 Binary files /dev/null and b/frontend/assets/resources/map/pacman/BackgroundMap/Tile_W256_H128_S01.png differ diff --git a/frontend/assets/resources/map/pacman/BackgroundMap/Tile_W256_H128_S01.png.meta b/frontend/assets/resources/map/pacman/BackgroundMap/Tile_W256_H128_S01.png.meta new file mode 100644 index 0000000..59dba9c --- /dev/null +++ b/frontend/assets/resources/map/pacman/BackgroundMap/Tile_W256_H128_S01.png.meta @@ -0,0 +1,34 @@ +{ + "ver": "2.3.3", + "uuid": "b711d3f8-b9f4-41ab-a7e4-6562992fb65e", + "type": "sprite", + "wrapMode": "clamp", + "filterMode": "bilinear", + "premultiplyAlpha": false, + "genMipmaps": false, + "packable": true, + "platformSettings": {}, + "subMetas": { + "Tile_W256_H128_S01": { + "ver": "1.0.4", + "uuid": "2d6c9481-6bd5-4c19-b468-529d027226c3", + "rawTextureUuid": "b711d3f8-b9f4-41ab-a7e4-6562992fb65e", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 831, + "trimX": 0, + "trimY": 0, + "width": 2048, + "height": 386, + "rawWidth": 2048, + "rawHeight": 2048, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "subMetas": {} + } + } +} \ No newline at end of file diff --git a/frontend/assets/resources/map/pacman/BackgroundMap/Tile_W256_H128_S01.tsx b/frontend/assets/resources/map/pacman/BackgroundMap/Tile_W256_H128_S01.tsx new file mode 100644 index 0000000..2d6b910 --- /dev/null +++ b/frontend/assets/resources/map/pacman/BackgroundMap/Tile_W256_H128_S01.tsx @@ -0,0 +1,4 @@ + + + + diff --git a/frontend/assets/resources/map/pacman/BackgroundMap/Tile_W256_H128_S01.tsx.meta b/frontend/assets/resources/map/pacman/BackgroundMap/Tile_W256_H128_S01.tsx.meta new file mode 100644 index 0000000..31b1b96 --- /dev/null +++ b/frontend/assets/resources/map/pacman/BackgroundMap/Tile_W256_H128_S01.tsx.meta @@ -0,0 +1,5 @@ +{ + "ver": "2.0.0", + "uuid": "51b3303a-7c55-4f8b-b6b9-b5efb6164d19", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/map/pacman/BackgroundMap/Tile_W256_H256_S01.png b/frontend/assets/resources/map/pacman/BackgroundMap/Tile_W256_H256_S01.png new file mode 100644 index 0000000..45aa8ef Binary files /dev/null and b/frontend/assets/resources/map/pacman/BackgroundMap/Tile_W256_H256_S01.png differ diff --git a/frontend/assets/resources/map/pacman/BackgroundMap/Tile_W256_H256_S01.png.meta b/frontend/assets/resources/map/pacman/BackgroundMap/Tile_W256_H256_S01.png.meta new file mode 100644 index 0000000..a666374 --- /dev/null +++ b/frontend/assets/resources/map/pacman/BackgroundMap/Tile_W256_H256_S01.png.meta @@ -0,0 +1,34 @@ +{ + "ver": "2.3.3", + "uuid": "757f31be-7ad1-42dc-bd6b-2b4c7652e457", + "type": "sprite", + "wrapMode": "clamp", + "filterMode": "bilinear", + "premultiplyAlpha": false, + "genMipmaps": false, + "packable": true, + "platformSettings": {}, + "subMetas": { + "Tile_W256_H256_S01": { + "ver": "1.0.4", + "uuid": "0d9aafd3-d738-473c-95b8-bf577b78f03d", + "rawTextureUuid": "757f31be-7ad1-42dc-bd6b-2b4c7652e457", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 0, + "trimY": 64, + "width": 1280, + "height": 896, + "rawWidth": 1280, + "rawHeight": 1024, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "subMetas": {} + } + } +} \ No newline at end of file diff --git a/frontend/assets/resources/map/pacman/BackgroundMap/Tile_W256_H256_S01.tsx b/frontend/assets/resources/map/pacman/BackgroundMap/Tile_W256_H256_S01.tsx new file mode 100644 index 0000000..b57d090 --- /dev/null +++ b/frontend/assets/resources/map/pacman/BackgroundMap/Tile_W256_H256_S01.tsx @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/frontend/assets/resources/map/pacman/BackgroundMap/Tile_W256_H256_S01.tsx.meta b/frontend/assets/resources/map/pacman/BackgroundMap/Tile_W256_H256_S01.tsx.meta new file mode 100644 index 0000000..e87b0a8 --- /dev/null +++ b/frontend/assets/resources/map/pacman/BackgroundMap/Tile_W256_H256_S01.tsx.meta @@ -0,0 +1,5 @@ +{ + "ver": "2.0.0", + "uuid": "8347ba4a-e73c-4173-a9ba-f7711fae5a90", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/map/pacman/BackgroundMap/Tile_W256_H256_S02.png b/frontend/assets/resources/map/pacman/BackgroundMap/Tile_W256_H256_S02.png new file mode 100644 index 0000000..8ddf7ff Binary files /dev/null and b/frontend/assets/resources/map/pacman/BackgroundMap/Tile_W256_H256_S02.png differ diff --git a/frontend/assets/resources/map/pacman/BackgroundMap/Tile_W256_H256_S02.png.meta b/frontend/assets/resources/map/pacman/BackgroundMap/Tile_W256_H256_S02.png.meta new file mode 100644 index 0000000..52f2c57 --- /dev/null +++ b/frontend/assets/resources/map/pacman/BackgroundMap/Tile_W256_H256_S02.png.meta @@ -0,0 +1,34 @@ +{ + "ver": "2.3.3", + "uuid": "2385ca17-af24-4122-a271-785f3010d7f2", + "type": "sprite", + "wrapMode": "clamp", + "filterMode": "bilinear", + "premultiplyAlpha": false, + "genMipmaps": false, + "packable": true, + "platformSettings": {}, + "subMetas": { + "Tile_W256_H256_S02": { + "ver": "1.0.4", + "uuid": "34e3f356-e65d-4745-8f70-7706aa4083f8", + "rawTextureUuid": "2385ca17-af24-4122-a271-785f3010d7f2", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 19.5, + "offsetY": 3.5, + "trimX": 89, + "trimY": 0, + "width": 1409, + "height": 251, + "rawWidth": 1548, + "rawHeight": 258, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "subMetas": {} + } + } +} \ No newline at end of file diff --git a/frontend/assets/resources/map/pacman/BackgroundMap/Tile_W256_H256_S02.tsx b/frontend/assets/resources/map/pacman/BackgroundMap/Tile_W256_H256_S02.tsx new file mode 100644 index 0000000..0f34291 --- /dev/null +++ b/frontend/assets/resources/map/pacman/BackgroundMap/Tile_W256_H256_S02.tsx @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/frontend/assets/resources/map/pacman/BackgroundMap/Tile_W256_H256_S02.tsx.meta b/frontend/assets/resources/map/pacman/BackgroundMap/Tile_W256_H256_S02.tsx.meta new file mode 100644 index 0000000..707df4a --- /dev/null +++ b/frontend/assets/resources/map/pacman/BackgroundMap/Tile_W256_H256_S02.tsx.meta @@ -0,0 +1,5 @@ +{ + "ver": "2.0.0", + "uuid": "05720598-8487-406c-b2f3-2059240fde56", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/map/pacman/BackgroundMap/map.tmx b/frontend/assets/resources/map/pacman/BackgroundMap/map.tmx new file mode 100644 index 0000000..4b1c9cf --- /dev/null +++ b/frontend/assets/resources/map/pacman/BackgroundMap/map.tmx @@ -0,0 +1,129 @@ + + + + + + + eJztmNsOAyEIRNXem97+/2urSU0MEbs2A9XIwzwtuocJLrjBORdMJpPJtIyeUZeKHhtiaJwWW9I+alfRuVh/ZWJoHJqZY2tpK/dJyPfWOxHcUvxa3Oi6eUUdmHd4sLLv0p570P6h4NbwfHRuzvMZuGuez8Bd83wWbur5LNyZ/fbRyNypz3PfUzR39uPesYZ7lmo692AqNDdyTatHo7mR88m3Po/ktj4/L3fr3jAyt+a5NG7974nN33y9SNzTJObvPD9wdYOS1D+VMgcujyOJaYmuR/bMWj1yefTMdNz5kfIceSZruffk/U9uLRn3etzoO5JxG/cq3P7H/bfu/QamEBWW + + + + + eJztmdEKwyAMRfsXjv7/h449CEWSNNFrvMoOlIHdktMsWtddl8xtHNb7NKx4nhhW7DaHRAk6eK9Lyh/5bCR+SxHyIvB6M+LpQUbevFmR1oP6ankX41wP0XjWOsaM5o3kA473Q+uTmTkRvHkzot2nmdH6mGlOSmtMpjdyjuxQb4mIN9OaYnkzs5t3uyduiXij9ygedqv3k6g3y/xE1zvruk7rEzZ36Xvs3X+vWEueZPxumMHfO5dTvOsYm7tnTaljbO4t1rNaZvcTnxHW82zuXic294gLwh21P4i6MNU96oF0H9mz9zr0+ve6tj02UruVfTOad5U7Iifi/0JtTOsrVL2y647MleU+I8+ddMwge55+AUD0Fwk= + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/frontend/assets/resources/map/pacman/BackgroundMap/map.tmx.meta b/frontend/assets/resources/map/pacman/BackgroundMap/map.tmx.meta new file mode 100644 index 0000000..02f5b17 --- /dev/null +++ b/frontend/assets/resources/map/pacman/BackgroundMap/map.tmx.meta @@ -0,0 +1,5 @@ +{ + "ver": "2.0.2", + "uuid": "4e2296fe-8855-4fb4-a407-fea295ded82e", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/map/pacman/Tile_W300_H300_S01.png b/frontend/assets/resources/map/pacman/Tile_W300_H300_S01.png new file mode 100644 index 0000000..3200517 Binary files /dev/null and b/frontend/assets/resources/map/pacman/Tile_W300_H300_S01.png differ diff --git a/frontend/assets/resources/map/pacman/Tile_W300_H300_S01.png.meta b/frontend/assets/resources/map/pacman/Tile_W300_H300_S01.png.meta new file mode 100644 index 0000000..a669ce6 --- /dev/null +++ b/frontend/assets/resources/map/pacman/Tile_W300_H300_S01.png.meta @@ -0,0 +1,34 @@ +{ + "ver": "2.3.3", + "uuid": "0a5e9b39-6a98-4b45-9ad5-6df3effec2ef", + "type": "sprite", + "wrapMode": "clamp", + "filterMode": "bilinear", + "premultiplyAlpha": false, + "genMipmaps": false, + "packable": true, + "platformSettings": {}, + "subMetas": { + "Tile_W300_H300_S01": { + "ver": "1.0.4", + "uuid": "acb30663-c0cf-4727-a046-26e40610c49f", + "rawTextureUuid": "0a5e9b39-6a98-4b45-9ad5-6df3effec2ef", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 4, + "offsetY": -24.5, + "trimX": 97, + "trimY": 85, + "width": 114, + "height": 179, + "rawWidth": 300, + "rawHeight": 300, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "subMetas": {} + } + } +} \ No newline at end of file diff --git a/frontend/assets/resources/map/pacman/Tile_W300_H300_S01.tsx b/frontend/assets/resources/map/pacman/Tile_W300_H300_S01.tsx new file mode 100644 index 0000000..d958003 --- /dev/null +++ b/frontend/assets/resources/map/pacman/Tile_W300_H300_S01.tsx @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/frontend/assets/resources/map/pacman/Tile_W300_H300_S01.tsx.meta b/frontend/assets/resources/map/pacman/Tile_W300_H300_S01.tsx.meta new file mode 100644 index 0000000..08c04a6 --- /dev/null +++ b/frontend/assets/resources/map/pacman/Tile_W300_H300_S01.tsx.meta @@ -0,0 +1,5 @@ +{ + "ver": "2.0.0", + "uuid": "da664a14-58c3-4f57-8aca-1270f96bf3ee", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/map/pacman/Tile_W64_H64_S01.png b/frontend/assets/resources/map/pacman/Tile_W64_H64_S01.png new file mode 100644 index 0000000..1b7cb9d Binary files /dev/null and b/frontend/assets/resources/map/pacman/Tile_W64_H64_S01.png differ diff --git a/frontend/assets/resources/map/pacman/Tile_W64_H64_S01.png.meta b/frontend/assets/resources/map/pacman/Tile_W64_H64_S01.png.meta new file mode 100644 index 0000000..e1f3459 --- /dev/null +++ b/frontend/assets/resources/map/pacman/Tile_W64_H64_S01.png.meta @@ -0,0 +1,34 @@ +{ + "ver": "2.3.3", + "uuid": "5e68ce04-f41f-4ab0-a55c-608542e5638a", + "type": "sprite", + "wrapMode": "clamp", + "filterMode": "bilinear", + "premultiplyAlpha": false, + "genMipmaps": false, + "packable": true, + "platformSettings": {}, + "subMetas": { + "Tile_W64_H64_S01": { + "ver": "1.0.4", + "uuid": "610a5bd5-c643-426e-a6e8-63acc5c516d9", + "rawTextureUuid": "5e68ce04-f41f-4ab0-a55c-608542e5638a", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 0, + "trimY": 0, + "width": 256, + "height": 256, + "rawWidth": 256, + "rawHeight": 256, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "subMetas": {} + } + } +} \ No newline at end of file diff --git a/frontend/assets/resources/map/pacman/Tile_W64_H64_S01.tsx b/frontend/assets/resources/map/pacman/Tile_W64_H64_S01.tsx new file mode 100644 index 0000000..319467a --- /dev/null +++ b/frontend/assets/resources/map/pacman/Tile_W64_H64_S01.tsx @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/frontend/assets/resources/map/pacman/Tile_W64_H64_S01.tsx.meta b/frontend/assets/resources/map/pacman/Tile_W64_H64_S01.tsx.meta new file mode 100644 index 0000000..d10cb1a --- /dev/null +++ b/frontend/assets/resources/map/pacman/Tile_W64_H64_S01.tsx.meta @@ -0,0 +1,5 @@ +{ + "ver": "2.0.0", + "uuid": "59b65107-0da7-47b3-a08d-7de824dd5a39", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/map/pacman/map.tmx b/frontend/assets/resources/map/pacman/map.tmx new file mode 100644 index 0000000..e04fee4 --- /dev/null +++ b/frontend/assets/resources/map/pacman/map.tmx @@ -0,0 +1,335 @@ + + + + + + + eJztz0ENACAMALGR4F8zNspyjwronZm7xPlcD0sPSw9LD0sPSw9LD0sPSw9LD0sPSw9LD0sPSw9LD0sPSw9LD0sPSw9LD0sPy7bHBg/ldQwR + + + + + + + + + + + + + eJztWctuBCEMW7Vqt9v2/7+32gMSQnnYTmB6WB+ZwZmEkHHgdnuBxe8/5WLwcyHXuzH2ccAuw5Wty3j/bjyzxlC7M9iYrFxZfNbnqi/IOqAxqfow8AWOoXZmZL58k9xvzrg1L+JS9oO6LijfCR882yvWdUH5rG+KuBgfrFo42+7CJ/m+l5MWoloYjZ+CUsN2+OLVc0YDRPa9nNzhC7LPs//Xo8FuNs5wRvt2Rw7v8AXZ5zty2FvL3Xsf4e+qsVf60l1jq754MR2w8qFSY6MaqdSRJ7KYRnNWIL509iseZ4de93TyHZirwOOM1lXtC6JnSg+K2FPnVHSysr9P+4Dq8a5+Wp2jcHq5FPWgFXuZXu/sqxCuHX1cR+1BtN4A0y96/ycldiu8XOquxWhNOZ1LDFA+RCdn/4OOeFjw9nLl/5TVUPZ8YIX3bSd6z26w33zKl0xzM/xd2hvhnKFo7ox/h/ZmtOcpXzp1q6K5PXjfjPSAKJcF9jwXQdd9B8q1E8pZYUW3zlBqVYSOPRatm1XjKrUqQsUXties1qqs9kd8im5l7ovQnOzYr0wuWc+YOz7kvcq6ILkU9ZOqhmfvdj17M6rn3ayGV30YUM8qB6qxeIK9n96FaixmXOVDJ3bomRc4/AGscghn + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/frontend/assets/resources/map/pacman/map.tmx.meta b/frontend/assets/resources/map/pacman/map.tmx.meta new file mode 100644 index 0000000..0afb7ea --- /dev/null +++ b/frontend/assets/resources/map/pacman/map.tmx.meta @@ -0,0 +1,5 @@ +{ + "ver": "2.0.2", + "uuid": "7fd0b77d-0736-4e00-89eb-7111f07ed4f1", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/map/richsoil.meta b/frontend/assets/resources/map/richsoil.meta new file mode 100644 index 0000000..f5974b9 --- /dev/null +++ b/frontend/assets/resources/map/richsoil.meta @@ -0,0 +1,7 @@ +{ + "ver": "1.0.1", + "uuid": "e3bd018e-d604-45a3-878d-18dcd9531e59", + "isSubpackage": false, + "subpackageName": "", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/map/richsoil/BackgroundMap.meta b/frontend/assets/resources/map/richsoil/BackgroundMap.meta new file mode 100644 index 0000000..803aefb --- /dev/null +++ b/frontend/assets/resources/map/richsoil/BackgroundMap.meta @@ -0,0 +1,7 @@ +{ + "ver": "1.0.1", + "uuid": "2f0bdedd-7215-4462-ae54-b71c054cffbe", + "isSubpackage": false, + "subpackageName": "", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/map/richsoil/BackgroundMap/Tile_W256_H128_S01.png b/frontend/assets/resources/map/richsoil/BackgroundMap/Tile_W256_H128_S01.png new file mode 100644 index 0000000..b651445 Binary files /dev/null and b/frontend/assets/resources/map/richsoil/BackgroundMap/Tile_W256_H128_S01.png differ diff --git a/frontend/assets/resources/map/richsoil/BackgroundMap/Tile_W256_H128_S01.png.meta b/frontend/assets/resources/map/richsoil/BackgroundMap/Tile_W256_H128_S01.png.meta new file mode 100644 index 0000000..2b8a57f --- /dev/null +++ b/frontend/assets/resources/map/richsoil/BackgroundMap/Tile_W256_H128_S01.png.meta @@ -0,0 +1,34 @@ +{ + "ver": "2.3.3", + "uuid": "c71de11b-4efc-4b7a-bbc7-eb926d08baf6", + "type": "sprite", + "wrapMode": "clamp", + "filterMode": "bilinear", + "premultiplyAlpha": false, + "genMipmaps": false, + "packable": true, + "platformSettings": {}, + "subMetas": { + "Tile_W256_H128_S01": { + "ver": "1.0.4", + "uuid": "b4fba8f6-ffc7-468b-9086-ec855c73388a", + "rawTextureUuid": "c71de11b-4efc-4b7a-bbc7-eb926d08baf6", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 831, + "trimX": 0, + "trimY": 0, + "width": 2048, + "height": 386, + "rawWidth": 2048, + "rawHeight": 2048, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "subMetas": {} + } + } +} \ No newline at end of file diff --git a/frontend/assets/resources/map/richsoil/BackgroundMap/Tile_W256_H128_S01.tsx b/frontend/assets/resources/map/richsoil/BackgroundMap/Tile_W256_H128_S01.tsx new file mode 100644 index 0000000..2d6b910 --- /dev/null +++ b/frontend/assets/resources/map/richsoil/BackgroundMap/Tile_W256_H128_S01.tsx @@ -0,0 +1,4 @@ + + + + diff --git a/frontend/assets/resources/map/richsoil/BackgroundMap/Tile_W256_H128_S01.tsx.meta b/frontend/assets/resources/map/richsoil/BackgroundMap/Tile_W256_H128_S01.tsx.meta new file mode 100644 index 0000000..57602b0 --- /dev/null +++ b/frontend/assets/resources/map/richsoil/BackgroundMap/Tile_W256_H128_S01.tsx.meta @@ -0,0 +1,5 @@ +{ + "ver": "2.0.0", + "uuid": "356c1165-6c15-40fe-95d0-baf11b053ada", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/map/richsoil/BackgroundMap/Tile_W256_H256_S01.png b/frontend/assets/resources/map/richsoil/BackgroundMap/Tile_W256_H256_S01.png new file mode 100644 index 0000000..45aa8ef Binary files /dev/null and b/frontend/assets/resources/map/richsoil/BackgroundMap/Tile_W256_H256_S01.png differ diff --git a/frontend/assets/resources/map/richsoil/BackgroundMap/Tile_W256_H256_S01.png.meta b/frontend/assets/resources/map/richsoil/BackgroundMap/Tile_W256_H256_S01.png.meta new file mode 100644 index 0000000..5a0efc8 --- /dev/null +++ b/frontend/assets/resources/map/richsoil/BackgroundMap/Tile_W256_H256_S01.png.meta @@ -0,0 +1,34 @@ +{ + "ver": "2.3.3", + "uuid": "ad433d85-5c88-4067-b4b7-129be0f54d57", + "type": "sprite", + "wrapMode": "clamp", + "filterMode": "bilinear", + "premultiplyAlpha": false, + "genMipmaps": false, + "packable": true, + "platformSettings": {}, + "subMetas": { + "Tile_W256_H256_S01": { + "ver": "1.0.4", + "uuid": "6c14c41c-4946-4992-b75d-8b580de43c83", + "rawTextureUuid": "ad433d85-5c88-4067-b4b7-129be0f54d57", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 0, + "trimY": 64, + "width": 1280, + "height": 896, + "rawWidth": 1280, + "rawHeight": 1024, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "subMetas": {} + } + } +} \ No newline at end of file diff --git a/frontend/assets/resources/map/richsoil/BackgroundMap/Tile_W256_H256_S01.tsx b/frontend/assets/resources/map/richsoil/BackgroundMap/Tile_W256_H256_S01.tsx new file mode 100644 index 0000000..b57d090 --- /dev/null +++ b/frontend/assets/resources/map/richsoil/BackgroundMap/Tile_W256_H256_S01.tsx @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/frontend/assets/resources/map/richsoil/BackgroundMap/Tile_W256_H256_S01.tsx.meta b/frontend/assets/resources/map/richsoil/BackgroundMap/Tile_W256_H256_S01.tsx.meta new file mode 100644 index 0000000..6641c22 --- /dev/null +++ b/frontend/assets/resources/map/richsoil/BackgroundMap/Tile_W256_H256_S01.tsx.meta @@ -0,0 +1,5 @@ +{ + "ver": "2.0.0", + "uuid": "e76fd642-3e97-4917-b6c7-0fc679a17644", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/map/richsoil/BackgroundMap/Tile_W256_H256_S02.png b/frontend/assets/resources/map/richsoil/BackgroundMap/Tile_W256_H256_S02.png new file mode 100644 index 0000000..8ddf7ff Binary files /dev/null and b/frontend/assets/resources/map/richsoil/BackgroundMap/Tile_W256_H256_S02.png differ diff --git a/frontend/assets/resources/map/richsoil/BackgroundMap/Tile_W256_H256_S02.png.meta b/frontend/assets/resources/map/richsoil/BackgroundMap/Tile_W256_H256_S02.png.meta new file mode 100644 index 0000000..b6214bf --- /dev/null +++ b/frontend/assets/resources/map/richsoil/BackgroundMap/Tile_W256_H256_S02.png.meta @@ -0,0 +1,34 @@ +{ + "ver": "2.3.3", + "uuid": "2a91275b-bb80-44b8-9932-0913c465e4ea", + "type": "sprite", + "wrapMode": "clamp", + "filterMode": "bilinear", + "premultiplyAlpha": false, + "genMipmaps": false, + "packable": true, + "platformSettings": {}, + "subMetas": { + "Tile_W256_H256_S02": { + "ver": "1.0.4", + "uuid": "55ca9649-0476-4fdb-9faa-3721ec0a0d5a", + "rawTextureUuid": "2a91275b-bb80-44b8-9932-0913c465e4ea", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 19.5, + "offsetY": 3.5, + "trimX": 89, + "trimY": 0, + "width": 1409, + "height": 251, + "rawWidth": 1548, + "rawHeight": 258, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "subMetas": {} + } + } +} \ No newline at end of file diff --git a/frontend/assets/resources/map/richsoil/BackgroundMap/Tile_W256_H256_S02.tsx b/frontend/assets/resources/map/richsoil/BackgroundMap/Tile_W256_H256_S02.tsx new file mode 100644 index 0000000..0f34291 --- /dev/null +++ b/frontend/assets/resources/map/richsoil/BackgroundMap/Tile_W256_H256_S02.tsx @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/frontend/assets/resources/map/richsoil/BackgroundMap/Tile_W256_H256_S02.tsx.meta b/frontend/assets/resources/map/richsoil/BackgroundMap/Tile_W256_H256_S02.tsx.meta new file mode 100644 index 0000000..a9a32f1 --- /dev/null +++ b/frontend/assets/resources/map/richsoil/BackgroundMap/Tile_W256_H256_S02.tsx.meta @@ -0,0 +1,5 @@ +{ + "ver": "2.0.0", + "uuid": "0f6bb2a2-d39f-4055-a636-4e6dc3472a18", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/map/richsoil/BackgroundMap/map.tmx b/frontend/assets/resources/map/richsoil/BackgroundMap/map.tmx new file mode 100644 index 0000000..4b1c9cf --- /dev/null +++ b/frontend/assets/resources/map/richsoil/BackgroundMap/map.tmx @@ -0,0 +1,129 @@ + + + + + + + eJztmNsOAyEIRNXem97+/2urSU0MEbs2A9XIwzwtuocJLrjBORdMJpPJtIyeUZeKHhtiaJwWW9I+alfRuVh/ZWJoHJqZY2tpK/dJyPfWOxHcUvxa3Oi6eUUdmHd4sLLv0p570P6h4NbwfHRuzvMZuGuez8Bd83wWbur5LNyZ/fbRyNypz3PfUzR39uPesYZ7lmo692AqNDdyTatHo7mR88m3Po/ktj4/L3fr3jAyt+a5NG7974nN33y9SNzTJObvPD9wdYOS1D+VMgcujyOJaYmuR/bMWj1yefTMdNz5kfIceSZruffk/U9uLRn3etzoO5JxG/cq3P7H/bfu/QamEBWW + + + + + eJztmdEKwyAMRfsXjv7/h449CEWSNNFrvMoOlIHdktMsWtddl8xtHNb7NKx4nhhW7DaHRAk6eK9Lyh/5bCR+SxHyIvB6M+LpQUbevFmR1oP6ankX41wP0XjWOsaM5o3kA473Q+uTmTkRvHkzot2nmdH6mGlOSmtMpjdyjuxQb4mIN9OaYnkzs5t3uyduiXij9ygedqv3k6g3y/xE1zvruk7rEzZ36Xvs3X+vWEueZPxumMHfO5dTvOsYm7tnTaljbO4t1rNaZvcTnxHW82zuXic294gLwh21P4i6MNU96oF0H9mz9zr0+ve6tj02UruVfTOad5U7Iifi/0JtTOsrVL2y647MleU+I8+ddMwge55+AUD0Fwk= + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/frontend/assets/resources/map/richsoil/BackgroundMap/map.tmx.meta b/frontend/assets/resources/map/richsoil/BackgroundMap/map.tmx.meta new file mode 100644 index 0000000..31fac2c --- /dev/null +++ b/frontend/assets/resources/map/richsoil/BackgroundMap/map.tmx.meta @@ -0,0 +1,5 @@ +{ + "ver": "2.0.2", + "uuid": "e310a2ad-1d44-41ed-858a-380474175aed", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/map/richsoil/Tile_W300_H300_S01.png b/frontend/assets/resources/map/richsoil/Tile_W300_H300_S01.png new file mode 100644 index 0000000..3200517 Binary files /dev/null and b/frontend/assets/resources/map/richsoil/Tile_W300_H300_S01.png differ diff --git a/frontend/assets/resources/map/richsoil/Tile_W300_H300_S01.png.meta b/frontend/assets/resources/map/richsoil/Tile_W300_H300_S01.png.meta new file mode 100644 index 0000000..360d33c --- /dev/null +++ b/frontend/assets/resources/map/richsoil/Tile_W300_H300_S01.png.meta @@ -0,0 +1,34 @@ +{ + "ver": "2.3.3", + "uuid": "b6b4c575-6690-4f1d-8165-a0098509066c", + "type": "sprite", + "wrapMode": "clamp", + "filterMode": "bilinear", + "premultiplyAlpha": false, + "genMipmaps": false, + "packable": true, + "platformSettings": {}, + "subMetas": { + "Tile_W300_H300_S01": { + "ver": "1.0.4", + "uuid": "8844352b-c6ac-4f30-8c8a-83955b2241b1", + "rawTextureUuid": "b6b4c575-6690-4f1d-8165-a0098509066c", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 4, + "offsetY": -24.5, + "trimX": 97, + "trimY": 85, + "width": 114, + "height": 179, + "rawWidth": 300, + "rawHeight": 300, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "subMetas": {} + } + } +} \ No newline at end of file diff --git a/frontend/assets/resources/map/richsoil/Tile_W300_H300_S01.tsx b/frontend/assets/resources/map/richsoil/Tile_W300_H300_S01.tsx new file mode 100644 index 0000000..d958003 --- /dev/null +++ b/frontend/assets/resources/map/richsoil/Tile_W300_H300_S01.tsx @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/frontend/assets/resources/map/richsoil/Tile_W300_H300_S01.tsx.meta b/frontend/assets/resources/map/richsoil/Tile_W300_H300_S01.tsx.meta new file mode 100644 index 0000000..2e5add5 --- /dev/null +++ b/frontend/assets/resources/map/richsoil/Tile_W300_H300_S01.tsx.meta @@ -0,0 +1,5 @@ +{ + "ver": "2.0.0", + "uuid": "e8f0b0b6-6274-4931-bf88-af35ca68c4cc", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/map/richsoil/Tile_W64_H64_S01.png b/frontend/assets/resources/map/richsoil/Tile_W64_H64_S01.png new file mode 100644 index 0000000..1b7cb9d Binary files /dev/null and b/frontend/assets/resources/map/richsoil/Tile_W64_H64_S01.png differ diff --git a/frontend/assets/resources/map/richsoil/Tile_W64_H64_S01.png.meta b/frontend/assets/resources/map/richsoil/Tile_W64_H64_S01.png.meta new file mode 100644 index 0000000..c9d78ad --- /dev/null +++ b/frontend/assets/resources/map/richsoil/Tile_W64_H64_S01.png.meta @@ -0,0 +1,34 @@ +{ + "ver": "2.3.3", + "uuid": "a6ef7a2f-0696-49d7-8e62-d2e495a2d032", + "type": "sprite", + "wrapMode": "clamp", + "filterMode": "bilinear", + "premultiplyAlpha": false, + "genMipmaps": false, + "packable": true, + "platformSettings": {}, + "subMetas": { + "Tile_W64_H64_S01": { + "ver": "1.0.4", + "uuid": "f6779fb1-4117-459a-a175-ff9f3abf1545", + "rawTextureUuid": "a6ef7a2f-0696-49d7-8e62-d2e495a2d032", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 0, + "trimY": 0, + "width": 256, + "height": 256, + "rawWidth": 256, + "rawHeight": 256, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "subMetas": {} + } + } +} \ No newline at end of file diff --git a/frontend/assets/resources/map/richsoil/Tile_W64_H64_S01.tsx b/frontend/assets/resources/map/richsoil/Tile_W64_H64_S01.tsx new file mode 100644 index 0000000..319467a --- /dev/null +++ b/frontend/assets/resources/map/richsoil/Tile_W64_H64_S01.tsx @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/frontend/assets/resources/map/richsoil/Tile_W64_H64_S01.tsx.meta b/frontend/assets/resources/map/richsoil/Tile_W64_H64_S01.tsx.meta new file mode 100644 index 0000000..b685e20 --- /dev/null +++ b/frontend/assets/resources/map/richsoil/Tile_W64_H64_S01.tsx.meta @@ -0,0 +1,5 @@ +{ + "ver": "2.0.0", + "uuid": "04f5911f-c460-41ee-8a6c-c1fec92fdcfe", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/map/richsoil/map.tmx b/frontend/assets/resources/map/richsoil/map.tmx new file mode 100644 index 0000000..2c033f9 --- /dev/null +++ b/frontend/assets/resources/map/richsoil/map.tmx @@ -0,0 +1,334 @@ + + + + + + + eJztz0ENACAMALGR4F8zNspyjwronZm7xPlcD0sPSw9LD0sPSw9LD0sPSw9LD0sPSw9LD0sPSw9LD0sPSw9LD0sPSw9LD0sPy7bHBg/ldQwR + + + + + + + + + + + + + eJztWctuBCEMW7Vqt9v2/7+32gMSQnnYTmB6WB+ZwZmEkHHgdnuBxe8/5WLwcyHXuzH2ccAuw5Wty3j/bjyzxlC7M9iYrFxZfNbnqi/IOqAxqfow8AWOoXZmZL58k9xvzrg1L+JS9oO6LijfCR882yvWdUH5rG+KuBgfrFo42+7CJ/m+l5MWoloYjZ+CUsN2+OLVc0YDRPa9nNzhC7LPs//Xo8FuNs5wRvt2Rw7v8AXZ5zty2FvL3Xsf4e+qsVf60l1jq754MR2w8qFSY6MaqdSRJ7KYRnNWIL509iseZ4de93TyHZirwOOM1lXtC6JnSg+K2FPnVHSysr9P+4Dq8a5+Wp2jcHq5FPWgFXuZXu/sqxCuHX1cR+1BtN4A0y96/ycldiu8XOquxWhNOZ1LDFA+RCdn/4OOeFjw9nLl/5TVUPZ8YIX3bSd6z26w33zKl0xzM/xd2hvhnKFo7ox/h/ZmtOcpXzp1q6K5PXjfjPSAKJcF9jwXQdd9B8q1E8pZYUW3zlBqVYSOPRatm1XjKrUqQsUXties1qqs9kd8im5l7ovQnOzYr0wuWc+YOz7kvcq6ILkU9ZOqhmfvdj17M6rn3ayGV30YUM8qB6qxeIK9n96FaixmXOVDJ3bomRc4/AGscghn + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/frontend/assets/resources/map/richsoil/map.tmx.meta b/frontend/assets/resources/map/richsoil/map.tmx.meta new file mode 100644 index 0000000..062b61a --- /dev/null +++ b/frontend/assets/resources/map/richsoil/map.tmx.meta @@ -0,0 +1,5 @@ +{ + "ver": "2.0.2", + "uuid": "0fe4d0fd-d537-4440-93f7-fffda8897ab1", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/musicEffect.meta b/frontend/assets/resources/musicEffect.meta new file mode 100644 index 0000000..3f84f6e --- /dev/null +++ b/frontend/assets/resources/musicEffect.meta @@ -0,0 +1,7 @@ +{ + "ver": "1.0.1", + "uuid": "0d4a2516-47b9-420b-86c4-fc312599d4aa", + "isSubpackage": false, + "subpackageName": "", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/musicEffect/BGM.mp3 b/frontend/assets/resources/musicEffect/BGM.mp3 new file mode 100644 index 0000000..2fbac3b Binary files /dev/null and b/frontend/assets/resources/musicEffect/BGM.mp3 differ diff --git a/frontend/assets/resources/musicEffect/BGM.mp3.meta b/frontend/assets/resources/musicEffect/BGM.mp3.meta new file mode 100644 index 0000000..8252a3f --- /dev/null +++ b/frontend/assets/resources/musicEffect/BGM.mp3.meta @@ -0,0 +1,6 @@ +{ + "ver": "2.0.0", + "uuid": "64a79efa-97de-4cb5-b2a9-01500c60573a", + "downloadMode": 0, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/musicEffect/CrashedByTrapBullet.mp3 b/frontend/assets/resources/musicEffect/CrashedByTrapBullet.mp3 new file mode 100644 index 0000000..b6f6917 Binary files /dev/null and b/frontend/assets/resources/musicEffect/CrashedByTrapBullet.mp3 differ diff --git a/frontend/assets/resources/musicEffect/CrashedByTrapBullet.mp3.meta b/frontend/assets/resources/musicEffect/CrashedByTrapBullet.mp3.meta new file mode 100644 index 0000000..bf7b3c4 --- /dev/null +++ b/frontend/assets/resources/musicEffect/CrashedByTrapBullet.mp3.meta @@ -0,0 +1,6 @@ +{ + "ver": "2.0.0", + "uuid": "1d604e42-8cee-466f-884d-e74cae21ce3b", + "downloadMode": 0, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/musicEffect/HighScoreTreasurePicked.mp3 b/frontend/assets/resources/musicEffect/HighScoreTreasurePicked.mp3 new file mode 100644 index 0000000..7825f0c Binary files /dev/null and b/frontend/assets/resources/musicEffect/HighScoreTreasurePicked.mp3 differ diff --git a/frontend/assets/resources/musicEffect/HighScoreTreasurePicked.mp3.meta b/frontend/assets/resources/musicEffect/HighScoreTreasurePicked.mp3.meta new file mode 100644 index 0000000..f29107c --- /dev/null +++ b/frontend/assets/resources/musicEffect/HighScoreTreasurePicked.mp3.meta @@ -0,0 +1,6 @@ +{ + "ver": "2.0.0", + "uuid": "0164d22c-d965-461f-867e-b30e2d56cc5c", + "downloadMode": 0, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/musicEffect/TreasurePicked.mp3 b/frontend/assets/resources/musicEffect/TreasurePicked.mp3 new file mode 100644 index 0000000..63c6928 Binary files /dev/null and b/frontend/assets/resources/musicEffect/TreasurePicked.mp3 differ diff --git a/frontend/assets/resources/musicEffect/TreasurePicked.mp3.meta b/frontend/assets/resources/musicEffect/TreasurePicked.mp3.meta new file mode 100644 index 0000000..bb3ab0f --- /dev/null +++ b/frontend/assets/resources/musicEffect/TreasurePicked.mp3.meta @@ -0,0 +1,6 @@ +{ + "ver": "2.0.0", + "uuid": "7704b97e-6367-420c-b7af-d0750a2bbb30", + "downloadMode": 0, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/musicEffect/countDown10SecToEnd.mp3 b/frontend/assets/resources/musicEffect/countDown10SecToEnd.mp3 new file mode 100644 index 0000000..5353268 Binary files /dev/null and b/frontend/assets/resources/musicEffect/countDown10SecToEnd.mp3 differ diff --git a/frontend/assets/resources/musicEffect/countDown10SecToEnd.mp3.meta b/frontend/assets/resources/musicEffect/countDown10SecToEnd.mp3.meta new file mode 100644 index 0000000..aec8d8d --- /dev/null +++ b/frontend/assets/resources/musicEffect/countDown10SecToEnd.mp3.meta @@ -0,0 +1,6 @@ +{ + "ver": "2.0.0", + "uuid": "261d1d7d-a5cc-4cb7-a737-194427055fd4", + "downloadMode": 0, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/pbfiles.meta b/frontend/assets/resources/pbfiles.meta new file mode 100644 index 0000000..3826fca --- /dev/null +++ b/frontend/assets/resources/pbfiles.meta @@ -0,0 +1,7 @@ +{ + "ver": "1.0.1", + "uuid": "05f549db-f831-460c-a0ed-3f29c497c8b9", + "isSubpackage": false, + "subpackageName": "", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/pbfiles/room_downsync_frame.proto b/frontend/assets/resources/pbfiles/room_downsync_frame.proto new file mode 100644 index 0000000..ed1e4b4 --- /dev/null +++ b/frontend/assets/resources/pbfiles/room_downsync_frame.proto @@ -0,0 +1,167 @@ +syntax = "proto3"; +option go_package = "."; // "./" corresponds to the "--go_out" value in "protoc" command + +package treasurehunterx; + +message Direction { + int32 dx = 1; + int32 dy = 2; +} + +message Vec2D { + double x = 1; + double y = 2; +} + +message Polygon2D { + Vec2D Anchor = 1; + repeated Vec2D Points = 2; +} + +message Vec2DList { + repeated Vec2D vec2DList = 1; +} + +message Polygon2DList { + repeated Polygon2D polygon2DList = 1; +} + +message BattleColliderInfo { + int32 intervalToPing = 1; + int32 willKickIfInactiveFor = 2; + int32 boundRoomId = 3; + + string stageName = 4; + map strToVec2DListMap = 5; + map strToPolygon2DListMap = 6; + int32 StageDiscreteW = 7; + int32 StageDiscreteH = 8; + int32 StageTileW = 9; + int32 StageTileH = 10; +} + +message Player { + int32 id = 1; + double x = 2; + double y = 3; + Direction dir = 4; + int32 speed = 5; + int32 battleState = 6; + int32 lastMoveGmtMillis = 7; + int32 score = 10; + bool removed = 11; + int32 joinIndex = 12; +} + +message PlayerMeta { + int32 id = 1; + string name = 2; + string displayName = 3; + string avatar = 4; + int32 joinIndex = 5; +} + +message Treasure { + int32 id = 1; + int32 localIdInBattle = 2; + int32 score = 3; + double x = 4; + double y = 5; + bool removed = 6; + int32 type = 7; +} + +message Bullet { + int32 localIdInBattle = 1; + double linearSpeed = 2; + double x = 3; + double y = 4; + bool removed = 5; + Vec2D startAtPoint = 6; + Vec2D endAtPoint = 7; +} + +message Trap { + int32 id = 1; + int32 localIdInBattle = 2; + int32 type = 3; + double x = 4; + double y = 5; + bool removed = 6; +} + +message SpeedShoe { + int32 id = 1; + int32 localIdInBattle = 2; + double x = 3; + double y = 4; + bool removed = 5; + int32 type = 6; +} + +message Pumpkin { + int32 localIdInBattle = 1; + double linearSpeed = 2; + double x = 3; + double y = 4; + bool removed = 5; +} + +message GuardTower { + int32 id = 1; + int32 localIdInBattle = 2; + int32 type = 3; + double x = 4; + double y = 5; + bool removed = 6; +} + +message RoomDownsyncFrame { + int32 id = 1; + int32 refFrameId = 2; + map players = 3; + int64 sentAt = 4; + int64 countdownNanos = 5; + map treasures = 6; + map traps = 7; + map bullets = 8; + map speedShoes = 9; + map pumpkin = 10; + map guardTowers = 11; + map playerMetas = 12; +} + +message InputFrameUpsync { + int32 inputFrameId = 1; + int32 encodedDir = 6; +} + +message InputFrameDownsync { + int32 inputFrameId = 1; + repeated uint64 inputList = 2; // Indexed by "joinIndex", we try to compress the "single player input" into 1 word (64-bit for 64-bit Golang runtime) because atomic compare-and-swap only works on 1 word. Although CAS on custom struct is possible in Golang 1.19 https://pkg.go.dev/sync/atomic@go1.19.1#Value.CompareAndSwap, using a single word is still faster whenever possible. + uint64 confirmedList = 3; // Indexed by "joinIndex", same compression concern as above +} + +message HeartbeatUpsync { + int64 clientTimestamp = 1; +} + +message WsReq { + int32 msgId = 1; + int32 playerId = 2; + int32 act = 3; + int32 joinIndex = 4; + int32 ackingFrameId = 5; + int32 ackingInputFrameId = 6; + repeated InputFrameUpsync inputFrameUpsyncBatch = 7; + HeartbeatUpsync hb = 8; +} + +message WsResp { + int32 ret = 1; + int32 echoedMsgId = 2; + int32 act = 3; + RoomDownsyncFrame rdf = 4; + repeated InputFrameDownsync inputFrameDownsyncBatch = 5; + BattleColliderInfo bciFrame = 6; +} diff --git a/frontend/assets/resources/pbfiles/room_downsync_frame.proto.meta b/frontend/assets/resources/pbfiles/room_downsync_frame.proto.meta new file mode 100644 index 0000000..356b003 --- /dev/null +++ b/frontend/assets/resources/pbfiles/room_downsync_frame.proto.meta @@ -0,0 +1,5 @@ +{ + "ver": "2.0.0", + "uuid": "72a5a96c-5d0e-40a0-87b9-ff5274d971d5", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/prefabs.meta b/frontend/assets/resources/prefabs.meta new file mode 100644 index 0000000..d2837bb --- /dev/null +++ b/frontend/assets/resources/prefabs.meta @@ -0,0 +1,7 @@ +{ + "ver": "1.0.1", + "uuid": "6f0263fa-1a06-4133-98dc-34281dea54ce", + "isSubpackage": false, + "subpackageName": "", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/prefabs/BulletPrefab.prefab b/frontend/assets/resources/prefabs/BulletPrefab.prefab new file mode 100644 index 0000000..9cb6a58 --- /dev/null +++ b/frontend/assets/resources/prefabs/BulletPrefab.prefab @@ -0,0 +1,309 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false + }, + { + "__type__": "cc.Node", + "_name": "Bullet", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + } + ], + "_active": true, + "_level": 1, + "_components": [ + { + "__id__": 5 + }, + { + "__id__": 6 + } + ], + "_prefab": { + "__id__": 7 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 60 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.7, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Node", + "_name": "Tail", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_level": 2, + "_components": [ + { + "__id__": 3 + } + ], + "_prefab": { + "__id__": 4 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -14, + -6, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.ParticleSystem", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_srcBlendFactor": 770, + "_dstBlendFactor": 1, + "_custom": true, + "_file": { + "__uuid__": "b2687ac4-099e-403c-a192-ff477686f4f5" + }, + "_spriteFrame": { + "__uuid__": "472df5d3-35e7-4184-9e6c-7f41bee65ee3" + }, + "_texture": { + "__uuid__": "d0a82d39-bede-46c4-b698-c81ff0dedfff" + }, + "_stopped": false, + "playOnLoad": true, + "autoRemoveOnFinish": false, + "totalParticles": 200, + "duration": -1, + "emissionRate": 999.999985098839, + "life": 0.20000000298023224, + "lifeVar": 0.5, + "_startColor": { + "__type__": "cc.Color", + "r": 202, + "g": 200, + "b": 86, + "a": 163 + }, + "_startColorVar": { + "__type__": "cc.Color", + "r": 229, + "g": 255, + "b": 173, + "a": 198 + }, + "_endColor": { + "__type__": "cc.Color", + "r": 173, + "g": 161, + "b": 19, + "a": 214 + }, + "_endColorVar": { + "__type__": "cc.Color", + "r": 107, + "g": 249, + "b": 249, + "a": 188 + }, + "angle": 360, + "angleVar": 360, + "startSize": 3.369999885559082, + "startSizeVar": 50, + "endSize": 30.31999969482422, + "endSizeVar": 0, + "startSpin": -47.369998931884766, + "startSpinVar": 0, + "endSpin": -47.369998931884766, + "endSpinVar": -142.11000061035156, + "sourcePos": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "posVar": { + "__type__": "cc.Vec2", + "x": 7, + "y": 7 + }, + "positionType": 1, + "emitterMode": 0, + "gravity": { + "__type__": "cc.Vec2", + "x": -1000, + "y": 0.5 + }, + "speed": 10, + "speedVar": 190.7899932861328, + "tangentialAccel": -92.11000061035156, + "tangentialAccelVar": 65.79000091552734, + "radialAccel": -671.0499877929688, + "radialAccelVar": 65.79000091552734, + "rotationIsDir": false, + "startRadius": 0, + "startRadiusVar": 0, + "endRadius": 0, + "endRadiusVar": 0, + "rotatePerS": 0, + "rotatePerSVar": 0, + "_N$preview": true, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "7673e0e4-bebd-4caa-8a10-a6e1e86f1b2f" + }, + "fileId": "f8NGWnOBtGmZNTU+o6vnbe", + "sync": false + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "2f525bb2-80d1-4508-bdc3-d03c11587ce4" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_state": 0, + "_atlas": { + "__uuid__": "266c6cef-32d6-4545-b3e6-c2b75a895578" + }, + "_id": "" + }, + { + "__type__": "ea9650l7IJHjL2ymsB5gasO", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "localIdInBattle": null, + "linearSpeed": 0, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "7673e0e4-bebd-4caa-8a10-a6e1e86f1b2f" + }, + "fileId": "f7AuVG6IFIr5KrEg6RCeY2", + "sync": false + } +] \ No newline at end of file diff --git a/frontend/assets/resources/prefabs/BulletPrefab.prefab.meta b/frontend/assets/resources/prefabs/BulletPrefab.prefab.meta new file mode 100644 index 0000000..8dd2c5d --- /dev/null +++ b/frontend/assets/resources/prefabs/BulletPrefab.prefab.meta @@ -0,0 +1,8 @@ +{ + "ver": "1.2.5", + "uuid": "7673e0e4-bebd-4caa-8a10-a6e1e86f1b2f", + "optimizationPolicy": "AUTO", + "asyncLoadAssets": false, + "readonly": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/prefabs/ConfirmLogout.prefab b/frontend/assets/resources/prefabs/ConfirmLogout.prefab new file mode 100644 index 0000000..d775ddf --- /dev/null +++ b/frontend/assets/resources/prefabs/ConfirmLogout.prefab @@ -0,0 +1,824 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false + }, + { + "__type__": "cc.Node", + "_name": "ConfirmLogout", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + }, + { + "__id__": 5 + }, + { + "__id__": 13 + } + ], + "_active": true, + "_level": 1, + "_components": [ + { + "__id__": 21 + } + ], + "_prefab": { + "__id__": 22 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Node", + "_name": "Background", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_level": 2, + "_components": [ + { + "__id__": 3 + } + ], + "_prefab": { + "__id__": 4 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 308, + "height": 153 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "919690f3-9e98-4dca-88cf-ee33db7150cb" + }, + "_type": 0, + "_sizeMode": 1, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_state": 0, + "_atlas": { + "__uuid__": "030d9286-e8a2-40cf-98f8-baf713f0b8c4" + }, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "8e8c1a65-623d-42ba-97a7-820ce518ea11" + }, + "fileId": "56eGr3KjZCrJegxdqdZpRb", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "confirm", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 6 + } + ], + "_active": true, + "_level": 2, + "_components": [ + { + "__id__": 9 + }, + { + "__id__": 10 + } + ], + "_prefab": { + "__id__": 12 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -75, + -35, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Node", + "_name": "Label", + "_objFlags": 0, + "_parent": { + "__id__": 5 + }, + "_children": [], + "_active": true, + "_level": 0, + "_components": [ + { + "__id__": 7 + } + ], + "_prefab": { + "__id__": 8 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 6 + }, + "_enabled": true, + "_useOriginalSize": false, + "_string": "", + "_N$string": "", + "_fontSize": 20, + "_lineHeight": 40, + "_enableWrapText": false, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 1, + "_N$cacheMode": 0, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "8e8c1a65-623d-42ba-97a7-820ce518ea11" + }, + "fileId": "dbeG0vYltN7YoLIZnPQs2N", + "sync": false + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 5 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "ef0ce43c-ad0d-4f7a-adad-ccdc3b07da45" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_state": 0, + "_atlas": { + "__uuid__": "030d9286-e8a2-40cf-98f8-baf713f0b8c4" + }, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_id": "" + }, + { + "__type__": "cc.Button", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 5 + }, + "_enabled": true, + "duration": 0.1, + "zoomScale": 1.2, + "clickEvents": [ + { + "__id__": 11 + } + ], + "_N$interactable": true, + "_N$enableAutoGrayEffect": false, + "_N$transition": 2, + "transition": 2, + "_N$normalColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$pressedColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "pressedColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$disabledColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$normalSprite": { + "__uuid__": "ef0ce43c-ad0d-4f7a-adad-ccdc3b07da45" + }, + "_N$pressedSprite": { + "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a" + }, + "pressedSprite": { + "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a" + }, + "_N$hoverSprite": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "hoverSprite": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "_N$disabledSprite": { + "__uuid__": "29158224-f8dd-4661-a796-1ffab537140e" + }, + "_N$target": { + "__id__": 5 + }, + "_id": "" + }, + { + "__type__": "cc.ClickEvent", + "target": { + "__id__": 1 + }, + "component": "", + "_componentId": "e1600DLTldEvqeR4mKYtIC7", + "handler": "onButtonClick", + "customEventData": "confirm" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "8e8c1a65-623d-42ba-97a7-820ce518ea11" + }, + "fileId": "bdrXoaKQhMgaAWSFzepkD6", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "cancel", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 14 + } + ], + "_active": true, + "_level": 2, + "_components": [ + { + "__id__": 17 + }, + { + "__id__": 18 + } + ], + "_prefab": { + "__id__": 20 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 77, + -36, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Node", + "_name": "Label", + "_objFlags": 0, + "_parent": { + "__id__": 13 + }, + "_children": [], + "_active": true, + "_level": 0, + "_components": [ + { + "__id__": 15 + } + ], + "_prefab": { + "__id__": 16 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 14 + }, + "_enabled": true, + "_useOriginalSize": false, + "_string": "", + "_N$string": "", + "_fontSize": 20, + "_lineHeight": 40, + "_enableWrapText": false, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 1, + "_N$cacheMode": 0, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "8e8c1a65-623d-42ba-97a7-820ce518ea11" + }, + "fileId": "1dw+Lg0ppIepVwRAjIomoA", + "sync": false + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 13 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "08935a3f-220c-4440-bb99-5576598b3601" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_state": 0, + "_atlas": { + "__uuid__": "030d9286-e8a2-40cf-98f8-baf713f0b8c4" + }, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_id": "" + }, + { + "__type__": "cc.Button", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 13 + }, + "_enabled": true, + "duration": 0.1, + "zoomScale": 1.2, + "clickEvents": [ + { + "__id__": 19 + } + ], + "_N$interactable": true, + "_N$enableAutoGrayEffect": false, + "_N$transition": 2, + "transition": 2, + "_N$normalColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$pressedColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "pressedColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$disabledColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$normalSprite": { + "__uuid__": "08935a3f-220c-4440-bb99-5576598b3601" + }, + "_N$pressedSprite": { + "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a" + }, + "pressedSprite": { + "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a" + }, + "_N$hoverSprite": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "hoverSprite": { + "__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952" + }, + "_N$disabledSprite": { + "__uuid__": "29158224-f8dd-4661-a796-1ffab537140e" + }, + "_N$target": { + "__id__": 13 + }, + "_id": "" + }, + { + "__type__": "cc.ClickEvent", + "target": { + "__id__": 1 + }, + "component": "", + "_componentId": "e1600DLTldEvqeR4mKYtIC7", + "handler": "onButtonClick", + "customEventData": "cancel" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "8e8c1a65-623d-42ba-97a7-820ce518ea11" + }, + "fileId": "9bOMIez0RM3ot2pQj3zUrg", + "sync": false + }, + { + "__type__": "e1600DLTldEvqeR4mKYtIC7", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "mapNode": null, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "8e8c1a65-623d-42ba-97a7-820ce518ea11" + }, + "fileId": "a6VR4FZidM87nMQbU+WIm1", + "sync": false + } +] \ No newline at end of file diff --git a/frontend/assets/resources/prefabs/ConfirmLogout.prefab.meta b/frontend/assets/resources/prefabs/ConfirmLogout.prefab.meta new file mode 100644 index 0000000..06d927e --- /dev/null +++ b/frontend/assets/resources/prefabs/ConfirmLogout.prefab.meta @@ -0,0 +1,8 @@ +{ + "ver": "1.2.5", + "uuid": "8e8c1a65-623d-42ba-97a7-820ce518ea11", + "optimizationPolicy": "AUTO", + "asyncLoadAssets": false, + "readonly": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/prefabs/CountdownToBeginGame.prefab b/frontend/assets/resources/prefabs/CountdownToBeginGame.prefab new file mode 100644 index 0000000..d25e806 --- /dev/null +++ b/frontend/assets/resources/prefabs/CountdownToBeginGame.prefab @@ -0,0 +1,558 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false + }, + { + "__type__": "cc.Node", + "_name": "3Seconds Countdown", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + }, + { + "__id__": 5 + }, + { + "__id__": 8 + }, + { + "__id__": 11 + } + ], + "_active": true, + "_level": 1, + "_components": [ + { + "__id__": 14 + }, + { + "__id__": 15 + } + ], + "_prefab": { + "__id__": 16 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 1024, + "height": 1920 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Node", + "_name": "WhiteStars", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_level": 2, + "_components": [ + { + "__id__": 3 + } + ], + "_prefab": { + "__id__": 4 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 268, + "height": 112 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -16, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "1a2d934e-9d6d-45bf-83c6-564586cc8400" + }, + "_type": 0, + "_sizeMode": 1, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_state": 0, + "_atlas": { + "__uuid__": "030d9286-e8a2-40cf-98f8-baf713f0b8c4" + }, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "230eeb1f-e0f9-4a41-ab6c-05b3771cbf3e" + }, + "fileId": "50Mjaee6xFXLrZ/mSBD3P5", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "Clock", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_level": 3, + "_components": [ + { + "__id__": 6 + } + ], + "_prefab": { + "__id__": 7 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 254, + "height": 258 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 34, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 5 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "75a2c1e3-2c22-480c-9572-eb65f4a554e1" + }, + "_type": 0, + "_sizeMode": 1, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_state": 0, + "_atlas": { + "__uuid__": "030d9286-e8a2-40cf-98f8-baf713f0b8c4" + }, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "230eeb1f-e0f9-4a41-ab6c-05b3771cbf3e" + }, + "fileId": "25xfZ/LOVKl7CbmA5gs1LN", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "countDownSeconds", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_level": 2, + "_components": [ + { + "__id__": 9 + } + ], + "_prefab": { + "__id__": 10 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 170, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 111.23, + "height": 200 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 24.66667, + 0, + 0, + 0, + 0, + 1, + 0.66667, + 0.66667, + 0.66667 + ] + } + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 8 + }, + "_enabled": true, + "_useOriginalSize": false, + "_string": "3", + "_N$string": "3", + "_fontSize": 200, + "_lineHeight": 200, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 0, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "230eeb1f-e0f9-4a41-ab6c-05b3771cbf3e" + }, + "fileId": "a5NMR+eXpC3Lv65xxgtWVR", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "CountdownTitle", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_level": 2, + "_components": [ + { + "__id__": 12 + } + ], + "_prefab": { + "__id__": 13 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 232, + "height": 44 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + -111, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 11 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "637f31c2-c53e-4dec-ae11-d56c0c6177ad" + }, + "_type": 0, + "_sizeMode": 1, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_state": 0, + "_atlas": { + "__uuid__": "030d9286-e8a2-40cf-98f8-baf713f0b8c4" + }, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "230eeb1f-e0f9-4a41-ab6c-05b3771cbf3e" + }, + "fileId": "21dxpL7zlKIIDhUt+GIMbg", + "sync": false + }, + { + "__type__": "6a3d6Y6Ki1BiqAVSKIRdwRl", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "countdownSeconds": { + "__id__": 9 + }, + "_id": "" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "334d4f93-b007-49e8-9268-35891d4f4ebb" + }, + "_type": 0, + "_sizeMode": 1, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_state": 0, + "_atlas": null, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "230eeb1f-e0f9-4a41-ab6c-05b3771cbf3e" + }, + "fileId": "54L9L5Ui5AsptXFN4vyVXH", + "sync": false + } +] \ No newline at end of file diff --git a/frontend/assets/resources/prefabs/CountdownToBeginGame.prefab.meta b/frontend/assets/resources/prefabs/CountdownToBeginGame.prefab.meta new file mode 100644 index 0000000..aaa57f8 --- /dev/null +++ b/frontend/assets/resources/prefabs/CountdownToBeginGame.prefab.meta @@ -0,0 +1,8 @@ +{ + "ver": "1.2.5", + "uuid": "230eeb1f-e0f9-4a41-ab6c-05b3771cbf3e", + "optimizationPolicy": "AUTO", + "asyncLoadAssets": false, + "readonly": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/prefabs/FindingPlayer.prefab b/frontend/assets/resources/prefabs/FindingPlayer.prefab new file mode 100644 index 0000000..f8b71e7 --- /dev/null +++ b/frontend/assets/resources/prefabs/FindingPlayer.prefab @@ -0,0 +1,1978 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false + }, + { + "__type__": "cc.Node", + "_name": "FindingPlayer", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + }, + { + "__id__": 5 + }, + { + "__id__": 10 + }, + { + "__id__": 13 + }, + { + "__id__": 16 + }, + { + "__id__": 19 + }, + { + "__id__": 22 + }, + { + "__id__": 33 + }, + { + "__id__": 44 + }, + { + "__id__": 52 + } + ], + "_active": true, + "_level": 1, + "_components": [ + { + "__id__": 55 + }, + { + "__id__": 56 + } + ], + "_prefab": { + "__id__": 57 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 1024, + "height": 1920 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Node", + "_name": "pacmanright_left", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_level": 2, + "_components": [ + { + "__id__": 3 + } + ], + "_prefab": { + "__id__": 4 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 608, + "height": 114 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 9, + -608, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "3aefb317-71e0-44e1-a7f1-69d8b08e3310" + }, + "_type": 0, + "_sizeMode": 1, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_state": 0, + "_atlas": { + "__uuid__": "030d9286-e8a2-40cf-98f8-baf713f0b8c4" + }, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "3ed4c7bc-79d0-4075-a563-d5a58ae798f9" + }, + "fileId": "c6jOpJcixCA54xGceCCZUT", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "exitButton", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_level": 2, + "_components": [ + { + "__id__": 6 + }, + { + "__id__": 7 + } + ], + "_prefab": { + "__id__": 9 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 64, + "height": 64 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -353, + 743, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 5 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "bec0b8cf-0f82-47b9-808e-13bb713a3ede" + }, + "_type": 1, + "_sizeMode": 1, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_state": 0, + "_atlas": { + "__uuid__": "030d9286-e8a2-40cf-98f8-baf713f0b8c4" + }, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_id": "" + }, + { + "__type__": "cc.Button", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 5 + }, + "_enabled": true, + "duration": 0.1, + "zoomScale": 1.2, + "clickEvents": [ + { + "__id__": 8 + } + ], + "_N$interactable": true, + "_N$enableAutoGrayEffect": false, + "_N$transition": 3, + "transition": 3, + "_N$normalColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$pressedColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "pressedColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$disabledColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$normalSprite": null, + "_N$pressedSprite": null, + "pressedSprite": null, + "_N$hoverSprite": null, + "hoverSprite": null, + "_N$disabledSprite": null, + "_N$target": { + "__id__": 5 + }, + "_id": "" + }, + { + "__type__": "cc.ClickEvent", + "target": { + "__id__": 1 + }, + "component": "", + "_componentId": "ecdd3qttgFPjYWhadnScKgG", + "handler": "exitBtnOnClick", + "customEventData": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "3ed4c7bc-79d0-4075-a563-d5a58ae798f9" + }, + "fileId": "edBZaPortPW7iG2K4yiEMZ", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "player_red", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_level": 2, + "_components": [ + { + "__id__": 11 + } + ], + "_prefab": { + "__id__": 12 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 344, + "height": 210 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -276, + 179, + 0, + 0, + 0, + 0, + 1, + 1.4, + 1.4, + 1 + ] + } + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 10 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "a373e215-1826-41ed-b3f4-a9b1407739bc" + }, + "_type": 0, + "_sizeMode": 1, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_state": 0, + "_atlas": { + "__uuid__": "030d9286-e8a2-40cf-98f8-baf713f0b8c4" + }, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "3ed4c7bc-79d0-4075-a563-d5a58ae798f9" + }, + "fileId": "35MXJtWg5Nqp7/KD6F+ST4", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "player_blue", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_level": 2, + "_components": [ + { + "__id__": 14 + } + ], + "_prefab": { + "__id__": 15 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 344, + "height": 200 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 284, + -129, + 0, + 0, + 0, + 0, + 1, + 1.33, + 1.33, + 1 + ] + } + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 13 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "e5936983-59d7-4a82-9079-4c758551ece9" + }, + "_type": 0, + "_sizeMode": 1, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_state": 0, + "_atlas": { + "__uuid__": "030d9286-e8a2-40cf-98f8-baf713f0b8c4" + }, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "3ed4c7bc-79d0-4075-a563-d5a58ae798f9" + }, + "fileId": "26Rm3LWpNELqqFhJcBogV+", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "VS", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_level": 2, + "_components": [ + { + "__id__": 17 + } + ], + "_prefab": { + "__id__": 18 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 118, + "height": 134 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -4, + -6, + 0, + 0, + 0, + 0, + 1, + 1.43, + 1.43, + 1 + ] + } + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 16 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "c35d7a88-2a8b-4d5e-a6ab-599264006ecd" + }, + "_type": 0, + "_sizeMode": 1, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_state": 0, + "_atlas": { + "__uuid__": "030d9286-e8a2-40cf-98f8-baf713f0b8c4" + }, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "3ed4c7bc-79d0-4075-a563-d5a58ae798f9" + }, + "fileId": "92krQh0ARKC6N1mhY/fm1r", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "pacmanright_right", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_level": 2, + "_components": [ + { + "__id__": 20 + } + ], + "_prefab": { + "__id__": 21 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 608, + "height": 114 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 9, + 644, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 19 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "eee6cdea-8b25-4855-8b72-8d68fc3b3988" + }, + "_type": 0, + "_sizeMode": 1, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_state": 0, + "_atlas": { + "__uuid__": "030d9286-e8a2-40cf-98f8-baf713f0b8c4" + }, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "3ed4c7bc-79d0-4075-a563-d5a58ae798f9" + }, + "fileId": "77ycu9k9VIcLUjPs6JcAlr", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "SecondPlayerInfo", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 23 + }, + { + "__id__": 26 + } + ], + "_active": true, + "_level": 2, + "_components": [], + "_prefab": { + "__id__": 32 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Node", + "_name": "name", + "_objFlags": 0, + "_parent": { + "__id__": 22 + }, + "_children": [], + "_active": true, + "_level": 3, + "_components": [ + { + "__id__": 24 + } + ], + "_prefab": { + "__id__": 25 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 70 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 364, + -219, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 23 + }, + "_enabled": true, + "_useOriginalSize": false, + "_string": "", + "_N$string": "", + "_fontSize": 50, + "_lineHeight": 70, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 0, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "3ed4c7bc-79d0-4075-a563-d5a58ae798f9" + }, + "fileId": "90xQnKIJxNA4DPURYqsefM", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "avatarMask", + "_objFlags": 0, + "_parent": { + "__id__": 22 + }, + "_children": [ + { + "__id__": 27 + } + ], + "_active": true, + "_level": 3, + "_components": [ + { + "__id__": 30 + } + ], + "_prefab": { + "__id__": 31 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 200, + "height": 200 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 255, + -93, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Node", + "_name": "avatar", + "_objFlags": 0, + "_parent": { + "__id__": 26 + }, + "_children": [], + "_active": true, + "_level": 4, + "_components": [ + { + "__id__": 28 + } + ], + "_prefab": { + "__id__": 29 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 200, + "height": 200 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 27 + }, + "_enabled": true, + "_spriteFrame": null, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_state": 0, + "_atlas": null, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "3ed4c7bc-79d0-4075-a563-d5a58ae798f9" + }, + "fileId": "b4Y/QmrxNBsra2xkrDbELI", + "sync": false + }, + { + "__type__": "cc.Mask", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 26 + }, + "_enabled": true, + "_spriteFrame": null, + "_type": 1, + "_segments": 64, + "_N$alphaThreshold": 0, + "_N$inverted": false, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "3ed4c7bc-79d0-4075-a563-d5a58ae798f9" + }, + "fileId": "c1JqoPFbVFCbpnzMuJyCyk", + "sync": false + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "3ed4c7bc-79d0-4075-a563-d5a58ae798f9" + }, + "fileId": "02lkZGoSpIZLpfA90AUwj4", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "FirstPlayerfInfo", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 34 + }, + { + "__id__": 37 + } + ], + "_active": true, + "_level": 2, + "_components": [], + "_prefab": { + "__id__": 43 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Node", + "_name": "name", + "_objFlags": 0, + "_parent": { + "__id__": 33 + }, + "_children": [], + "_active": true, + "_level": 3, + "_components": [ + { + "__id__": 35 + } + ], + "_prefab": { + "__id__": 36 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 70 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -377, + 282, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 34 + }, + "_enabled": true, + "_useOriginalSize": false, + "_string": "", + "_N$string": "", + "_fontSize": 50, + "_lineHeight": 70, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 0, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "3ed4c7bc-79d0-4075-a563-d5a58ae798f9" + }, + "fileId": "cf7Bca5PZASIMK1N/ZAjKK", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "avatarMask", + "_objFlags": 0, + "_parent": { + "__id__": 33 + }, + "_children": [ + { + "__id__": 38 + } + ], + "_active": true, + "_level": 3, + "_components": [ + { + "__id__": 41 + } + ], + "_prefab": { + "__id__": 42 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 200, + "height": 200 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -238, + 151, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Node", + "_name": "avatar", + "_objFlags": 0, + "_parent": { + "__id__": 37 + }, + "_children": [], + "_active": true, + "_level": 4, + "_components": [ + { + "__id__": 39 + } + ], + "_prefab": { + "__id__": 40 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 200, + "height": 200 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0.4, + 1.2, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 38 + }, + "_enabled": true, + "_spriteFrame": null, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_state": 0, + "_atlas": null, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "3ed4c7bc-79d0-4075-a563-d5a58ae798f9" + }, + "fileId": "9fc3s0bVFKcaEBmbh/hWP0", + "sync": false + }, + { + "__type__": "cc.Mask", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 37 + }, + "_enabled": true, + "_spriteFrame": null, + "_type": 1, + "_segments": 100, + "_N$alphaThreshold": 0, + "_N$inverted": false, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "3ed4c7bc-79d0-4075-a563-d5a58ae798f9" + }, + "fileId": "4fFgWRzMNCr5W4asHKcPAO", + "sync": false + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "3ed4c7bc-79d0-4075-a563-d5a58ae798f9" + }, + "fileId": "cbo+gmLBVOBqsusjGXgzip", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "finding", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 45 + } + ], + "_active": true, + "_level": 2, + "_components": [ + { + "__id__": 49 + }, + { + "__id__": 50 + } + ], + "_prefab": { + "__id__": 51 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 500, + "height": 500 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 218, + -104, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Node", + "_name": "label", + "_objFlags": 0, + "_parent": { + "__id__": 44 + }, + "_children": [], + "_active": false, + "_level": 3, + "_components": [ + { + "__id__": 46 + }, + { + "__id__": 47 + } + ], + "_prefab": { + "__id__": 48 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 153, + "b": 41, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 391.67, + "height": 80 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 17, + -270, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 45 + }, + "_enabled": true, + "_useOriginalSize": false, + "_string": "等等我,马上到...", + "_N$string": "等等我,马上到...", + "_fontSize": 50, + "_lineHeight": 80, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 0, + "_id": "" + }, + { + "__type__": "744dcs4DCdNprNhG0xwq6FK", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 45 + }, + "_enabled": true, + "_dataID": "findingPlayer.finding", + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "3ed4c7bc-79d0-4075-a563-d5a58ae798f9" + }, + "fileId": "63s+KoH85BnpcZkEfiGzAe", + "sync": false + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 44 + }, + "_enabled": true, + "_spriteFrame": null, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_state": 0, + "_atlas": { + "__uuid__": "06710517-f4f7-46d9-873f-c7599242f7be" + }, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_id": "" + }, + { + "__type__": "cc.Animation", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 44 + }, + "_enabled": true, + "_defaultClip": { + "__uuid__": "2062218a-c5d4-4cbb-959e-77e8e5a96344" + }, + "_clips": [ + { + "__uuid__": "2062218a-c5d4-4cbb-959e-77e8e5a96344" + } + ], + "playOnLoad": true, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "3ed4c7bc-79d0-4075-a563-d5a58ae798f9" + }, + "fileId": "9aMwAVlx1KiZ2rkd5kupdx", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "MyAvatar", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_level": 2, + "_components": [ + { + "__id__": 53 + } + ], + "_prefab": { + "__id__": 54 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 40, + "height": 36 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -287, + -82, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 52 + }, + "_enabled": true, + "_spriteFrame": null, + "_type": 0, + "_sizeMode": 1, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_state": 0, + "_atlas": null, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "3ed4c7bc-79d0-4075-a563-d5a58ae798f9" + }, + "fileId": "44Bp/zGrhBvaYNV5AK8tB7", + "sync": false + }, + { + "__type__": "ecdd3qttgFPjYWhadnScKgG", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "firstPlayerInfoNode": { + "__id__": 33 + }, + "secondPlayerInfoNode": { + "__id__": 22 + }, + "findingAnimNode": { + "__id__": 44 + }, + "myAvatarNode": { + "__id__": 52 + }, + "exitBtnNode": { + "__id__": 5 + }, + "_id": "" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "7838f276-ab48-445a-b858-937dd27d9520" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_state": 0, + "_atlas": null, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "3ed4c7bc-79d0-4075-a563-d5a58ae798f9" + }, + "fileId": "71kqqvr99C9qs9lahsQcQF", + "sync": false + } +] \ No newline at end of file diff --git a/frontend/assets/resources/prefabs/FindingPlayer.prefab.meta b/frontend/assets/resources/prefabs/FindingPlayer.prefab.meta new file mode 100644 index 0000000..9934b5d --- /dev/null +++ b/frontend/assets/resources/prefabs/FindingPlayer.prefab.meta @@ -0,0 +1,8 @@ +{ + "ver": "1.2.5", + "uuid": "3ed4c7bc-79d0-4075-a563-d5a58ae798f9", + "optimizationPolicy": "AUTO", + "asyncLoadAssets": false, + "readonly": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/prefabs/GameRule.prefab b/frontend/assets/resources/prefabs/GameRule.prefab new file mode 100644 index 0000000..96adfb4 --- /dev/null +++ b/frontend/assets/resources/prefabs/GameRule.prefab @@ -0,0 +1,765 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false + }, + { + "__type__": "cc.Node", + "_name": "gameRule", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + }, + { + "__id__": 9 + }, + { + "__id__": 17 + } + ], + "_active": true, + "_level": 1, + "_components": [ + { + "__id__": 20 + }, + { + "__id__": 21 + } + ], + "_prefab": { + "__id__": 22 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 1024, + "height": 1920 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Node", + "_name": "ruleNode", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 3 + } + ], + "_active": true, + "_level": 2, + "_components": [ + { + "__id__": 7 + } + ], + "_prefab": { + "__id__": 8 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 644, + "height": 793 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 257, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Node", + "_name": "rule", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_level": 3, + "_components": [ + { + "__id__": 4 + }, + { + "__id__": 5 + } + ], + "_prefab": { + "__id__": 6 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 550, + "height": 560 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 48, + 12, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 3 + }, + "_enabled": true, + "_useOriginalSize": false, + "_string": "gameRule.tip", + "_N$string": "gameRule.tip", + "_fontSize": 38, + "_lineHeight": 70, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 1, + "_N$cacheMode": 0, + "_id": "" + }, + { + "__type__": "744dcs4DCdNprNhG0xwq6FK", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 3 + }, + "_enabled": true, + "_dataID": "gameRule.tip", + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "32b8e752-8362-4783-a4a6-1160af8b7109" + }, + "fileId": "11EBmT5DNNXbQDiC9n1CEy", + "sync": false + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "0fe43223-61fc-4cb8-95bd-bd9e8f01ce8f" + }, + "_type": 0, + "_sizeMode": 1, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_state": 0, + "_atlas": { + "__uuid__": "030d9286-e8a2-40cf-98f8-baf713f0b8c4" + }, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "32b8e752-8362-4783-a4a6-1160af8b7109" + }, + "fileId": "9exF2/yWJPwK/biWKavf16", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "modeButton", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 10 + } + ], + "_active": true, + "_level": 2, + "_components": [ + { + "__id__": 14 + }, + { + "__id__": 15 + } + ], + "_prefab": { + "__id__": 16 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 280, + "height": 130 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + -564, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Node", + "_name": "Label", + "_objFlags": 0, + "_parent": { + "__id__": 9 + }, + "_children": [], + "_active": true, + "_level": 0, + "_components": [ + { + "__id__": 11 + }, + { + "__id__": 12 + } + ], + "_prefab": { + "__id__": 13 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 146, + "g": 54, + "b": 2, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 300, + "height": 150 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 1, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 10 + }, + "_enabled": true, + "_useOriginalSize": false, + "_string": "gameRule.mode", + "_N$string": "gameRule.mode", + "_fontSize": 55, + "_lineHeight": 50, + "_enableWrapText": false, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 1, + "_N$cacheMode": 0, + "_id": "" + }, + { + "__type__": "744dcs4DCdNprNhG0xwq6FK", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 10 + }, + "_enabled": true, + "_dataID": "gameRule.mode", + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "32b8e752-8362-4783-a4a6-1160af8b7109" + }, + "fileId": "3ecZ7NyE1JYbvJj1FmTAnb", + "sync": false + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 9 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "081ad337-20ca-4313-ae3e-bb6dee3547b7" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_state": 0, + "_atlas": { + "__uuid__": "030d9286-e8a2-40cf-98f8-baf713f0b8c4" + }, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_id": "" + }, + { + "__type__": "cc.Button", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 9 + }, + "_enabled": true, + "duration": 0.1, + "zoomScale": 1.2, + "clickEvents": [], + "_N$interactable": true, + "_N$enableAutoGrayEffect": false, + "_N$transition": 2, + "transition": 2, + "_N$normalColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$pressedColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "pressedColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$disabledColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$normalSprite": { + "__uuid__": "081ad337-20ca-4313-ae3e-bb6dee3547b7" + }, + "_N$pressedSprite": null, + "pressedSprite": null, + "_N$hoverSprite": null, + "hoverSprite": null, + "_N$disabledSprite": null, + "_N$target": { + "__id__": 9 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "32b8e752-8362-4783-a4a6-1160af8b7109" + }, + "fileId": "c54lqSflFD8ogSYAhsAkKh", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "decoration", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_level": 2, + "_components": [ + { + "__id__": 18 + } + ], + "_prefab": { + "__id__": 19 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 543, + "height": 117 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + -312, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 17 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "153d890a-fc37-4d59-8779-93a8fb19fa85" + }, + "_type": 0, + "_sizeMode": 1, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_state": 0, + "_atlas": { + "__uuid__": "030d9286-e8a2-40cf-98f8-baf713f0b8c4" + }, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "32b8e752-8362-4783-a4a6-1160af8b7109" + }, + "fileId": "1bbMLAzntHZpEudL8lM/Lx", + "sync": false + }, + { + "__type__": "dd92bKVy8FJY7uq3ieoNZCZ", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "modeButton": { + "__id__": 15 + }, + "mapNode": null, + "_id": "" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "7838f276-ab48-445a-b858-937dd27d9520" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_state": 0, + "_atlas": null, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "32b8e752-8362-4783-a4a6-1160af8b7109" + }, + "fileId": "aeNQYVwQtBaZGXgzoZIthK", + "sync": false + } +] \ No newline at end of file diff --git a/frontend/assets/resources/prefabs/GameRule.prefab.meta b/frontend/assets/resources/prefabs/GameRule.prefab.meta new file mode 100644 index 0000000..b2900b6 --- /dev/null +++ b/frontend/assets/resources/prefabs/GameRule.prefab.meta @@ -0,0 +1,8 @@ +{ + "ver": "1.2.5", + "uuid": "32b8e752-8362-4783-a4a6-1160af8b7109", + "optimizationPolicy": "AUTO", + "asyncLoadAssets": false, + "readonly": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/prefabs/GuardTower.prefab b/frontend/assets/resources/prefabs/GuardTower.prefab new file mode 100644 index 0000000..e213ade --- /dev/null +++ b/frontend/assets/resources/prefabs/GuardTower.prefab @@ -0,0 +1,153 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false + }, + { + "__type__": "cc.Node", + "_name": "GuardTower", + "_objFlags": 0, + "_parent": null, + "_children": [], + "_active": true, + "_level": 1, + "_components": [ + { + "__id__": 2 + }, + { + "__id__": 3 + } + ], + "_prefab": { + "__id__": 4 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 90, + "height": 150 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": null, + "_type": 0, + "_sizeMode": 2, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": false, + "_state": 0, + "_atlas": null, + "_id": "" + }, + { + "__type__": "cc.PolygonCollider", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "tag": 0, + "_offset": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "points": [ + { + "__type__": "cc.Vec2", + "x": -50, + "y": -50 + }, + { + "__type__": "cc.Vec2", + "x": 50, + "y": -50 + }, + { + "__type__": "cc.Vec2", + "x": 50, + "y": 50 + }, + { + "__type__": "cc.Vec2", + "x": -50, + "y": 50 + } + ], + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "31a63530-7811-45bc-a4ee-571faf917e35" + }, + "fileId": "cb43NtzzhP0bpzlQHRRrkX", + "sync": false + } +] \ No newline at end of file diff --git a/frontend/assets/resources/prefabs/GuardTower.prefab.meta b/frontend/assets/resources/prefabs/GuardTower.prefab.meta new file mode 100644 index 0000000..d3fce7f --- /dev/null +++ b/frontend/assets/resources/prefabs/GuardTower.prefab.meta @@ -0,0 +1,8 @@ +{ + "ver": "1.2.5", + "uuid": "31a63530-7811-45bc-a4ee-571faf917e35", + "optimizationPolicy": "AUTO", + "asyncLoadAssets": false, + "readonly": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/prefabs/Loading.prefab b/frontend/assets/resources/prefabs/Loading.prefab new file mode 100644 index 0000000..b52db18 --- /dev/null +++ b/frontend/assets/resources/prefabs/Loading.prefab @@ -0,0 +1,338 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false + }, + { + "__type__": "cc.Node", + "_name": "Loading", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + }, + { + "__id__": 6 + } + ], + "_active": true, + "_level": 1, + "_components": [ + { + "__id__": 9 + } + ], + "_prefab": { + "__id__": 10 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "_zIndex": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 512, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Node", + "_name": "loadingLabel", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_level": 0, + "_components": [ + { + "__id__": 3 + }, + { + "__id__": 4 + } + ], + "_prefab": { + "__id__": 5 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 24, + "g": 211, + "b": 236, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 303.5, + "height": 30 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "_zIndex": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 210, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_srcBlendFactor": 1, + "_dstBlendFactor": 771, + "_useOriginalSize": false, + "_string": "login.tips.loginSuccess", + "_N$string": "login.tips.loginSuccess", + "_fontSize": 30, + "_lineHeight": 30, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_id": "" + }, + { + "__type__": "744dcs4DCdNprNhG0xwq6FK", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_dataID": "login.tips.loginSuccess", + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "f2a3cece-30bf-4f62-bc20-34d44a9ddf98" + }, + "fileId": "5duIQ1hKVN06u/sFqz8xny", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "loadingSprite", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_level": 0, + "_components": [ + { + "__id__": 7 + } + ], + "_prefab": { + "__id__": 8 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 104, + "height": 104 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "_zIndex": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 333, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 6 + }, + "_enabled": true, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": null, + "_type": 0, + "_sizeMode": 1, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_state": 0, + "_atlas": null, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "f2a3cece-30bf-4f62-bc20-34d44a9ddf98" + }, + "fileId": "b2FC2wLbpMub6QXxMtkTGF", + "sync": false + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "alignMode": 0, + "_target": null, + "_alignFlags": 20, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 0, + "_originalHeight": 0, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "f2a3cece-30bf-4f62-bc20-34d44a9ddf98" + }, + "fileId": "6dGv3uisRBTYUStWs7vcwv", + "sync": false + } +] \ No newline at end of file diff --git a/frontend/assets/resources/prefabs/Loading.prefab.meta b/frontend/assets/resources/prefabs/Loading.prefab.meta new file mode 100644 index 0000000..67069bf --- /dev/null +++ b/frontend/assets/resources/prefabs/Loading.prefab.meta @@ -0,0 +1,8 @@ +{ + "ver": "1.2.5", + "uuid": "f2a3cece-30bf-4f62-bc20-34d44a9ddf98", + "optimizationPolicy": "AUTO", + "asyncLoadAssets": false, + "readonly": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/prefabs/Pacman1.prefab b/frontend/assets/resources/prefabs/Pacman1.prefab new file mode 100644 index 0000000..bfc71fe --- /dev/null +++ b/frontend/assets/resources/prefabs/Pacman1.prefab @@ -0,0 +1,591 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false + }, + { + "__type__": "cc.Node", + "_name": "Player1", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + }, + { + "__id__": 5 + }, + { + "__id__": 8 + } + ], + "_active": true, + "_level": 1, + "_components": [ + { + "__id__": 11 + }, + { + "__id__": 12 + }, + { + "__id__": 13 + }, + { + "__id__": 14 + } + ], + "_prefab": { + "__id__": 15 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 120, + "height": 120 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 2, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 3, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Node", + "_name": "CoordinateLabel", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": false, + "_level": 0, + "_components": [ + { + "__id__": 3 + } + ], + "_prefab": { + "__id__": 4 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 93.36, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -5, + 101, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_useOriginalSize": false, + "_string": "(0, 0)", + "_N$string": "(0, 0)", + "_fontSize": 40, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 0, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "8a738d50-1dac-4b6e-99e1-d241f5ee7169" + }, + "fileId": "5apzDmIE9IuaMOyF3z06sc", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "particlesystem", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": false, + "_level": 2, + "_components": [ + { + "__id__": 6 + } + ], + "_prefab": { + "__id__": 7 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.ParticleSystem", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 5 + }, + "_enabled": true, + "_custom": true, + "_file": { + "__uuid__": "b2687ac4-099e-403c-a192-ff477686f4f5" + }, + "_spriteFrame": { + "__uuid__": "472df5d3-35e7-4184-9e6c-7f41bee65ee3" + }, + "_texture": null, + "_srcBlendFactor": 770, + "_dstBlendFactor": 1, + "_stopped": false, + "playOnLoad": true, + "autoRemoveOnFinish": false, + "totalParticles": 200, + "duration": -1, + "emissionRate": 999.999985098839, + "life": 0.20000000298023224, + "lifeVar": 0.5, + "_startColor": { + "__type__": "cc.Color", + "r": 202, + "g": 200, + "b": 86, + "a": 163 + }, + "_startColorVar": { + "__type__": "cc.Color", + "r": 229, + "g": 255, + "b": 173, + "a": 198 + }, + "_endColor": { + "__type__": "cc.Color", + "r": 173, + "g": 161, + "b": 19, + "a": 214 + }, + "_endColorVar": { + "__type__": "cc.Color", + "r": 107, + "g": 249, + "b": 249, + "a": 188 + }, + "angle": 360, + "angleVar": 360, + "startSize": 3.369999885559082, + "startSizeVar": 50, + "endSize": 30.31999969482422, + "endSizeVar": 0, + "startSpin": -47.369998931884766, + "startSpinVar": 0, + "endSpin": -47.369998931884766, + "endSpinVar": -142.11000061035156, + "sourcePos": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "posVar": { + "__type__": "cc.Vec2", + "x": 7, + "y": 7 + }, + "positionType": 1, + "emitterMode": 0, + "gravity": { + "__type__": "cc.Vec2", + "x": 0.25, + "y": 0.8600000143051147 + }, + "speed": 0, + "speedVar": 190.7899932861328, + "tangentialAccel": -92.11000061035156, + "tangentialAccelVar": 65.79000091552734, + "radialAccel": -671.0499877929688, + "radialAccelVar": 65.79000091552734, + "rotationIsDir": false, + "startRadius": 0, + "startRadiusVar": 0, + "endRadius": 0, + "endRadiusVar": 0, + "rotatePerS": 0, + "rotatePerSVar": 0, + "_N$preview": true, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "8a738d50-1dac-4b6e-99e1-d241f5ee7169" + }, + "fileId": "04uxaznclAmLRL13XKszPJ", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "arrowTip", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_level": 2, + "_components": [ + { + "__id__": 9 + } + ], + "_prefab": { + "__id__": 10 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 76, + "height": 84 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 3, + 182, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 8 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "a2170e4c-df31-41ef-be73-f4f605e75821" + }, + "_type": 0, + "_sizeMode": 1, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_state": 0, + "_atlas": { + "__uuid__": "030d9286-e8a2-40cf-98f8-baf713f0b8c4" + }, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "8a738d50-1dac-4b6e-99e1-d241f5ee7169" + }, + "fileId": "e4mum5GwxNiZ0T8ouw95jJ", + "sync": false + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_spriteFrame": null, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_state": 0, + "_atlas": null, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_id": "" + }, + { + "__type__": "cc.Animation", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_defaultClip": { + "__uuid__": "28194c48-ae3b-4197-8263-0d474ae8b9bc" + }, + "_clips": [ + { + "__uuid__": "28194c48-ae3b-4197-8263-0d474ae8b9bc" + }, + { + "__uuid__": "e1c45a36-2022-4b18-a2db-b5e2e0a120ed" + }, + { + "__uuid__": "126dff26-0ace-439d-89b5-b888aa52d159" + }, + { + "__uuid__": "95c2d541-8f99-446a-a7e0-094130ce6d41" + }, + { + "__uuid__": "380f5fa0-f77f-434a-8f39-d545ee6823c5" + }, + { + "__uuid__": "a306c6de-ccd8-492b-bfec-c6be0a4cbde2" + }, + { + "__uuid__": "f496072b-51fd-4406-abbd-9885ac23f7a9" + }, + { + "__uuid__": "6405ad8b-3084-4b67-8c2e-9b4d34fa3d09" + }, + { + "__uuid__": "af16cdcb-6e82-4be6-806d-9fc52ae99fff" + }, + { + "__uuid__": "02eba566-4d22-4fa7-99d7-f032f5845421" + } + ], + "playOnLoad": true, + "_id": "" + }, + { + "__type__": "b74b05YDqZFRo4OkZRFZX8k", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "animComp": null, + "baseSpeed": 300, + "speed": 200, + "lastMovedAt": 0, + "eps": 0.1, + "magicLeanLowerBound": 0.414, + "magicLeanUpperBound": 2.414, + "arrowTipNode": { + "__id__": 8 + }, + "_id": "" + }, + { + "__type__": "cc.CircleCollider", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "tag": 0, + "_offset": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_radius": 12, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "8a738d50-1dac-4b6e-99e1-d241f5ee7169" + }, + "fileId": "4cx75uwJJFa7U8QL187QCL", + "sync": false + } +] \ No newline at end of file diff --git a/frontend/assets/resources/prefabs/Pacman1.prefab.meta b/frontend/assets/resources/prefabs/Pacman1.prefab.meta new file mode 100644 index 0000000..582f762 --- /dev/null +++ b/frontend/assets/resources/prefabs/Pacman1.prefab.meta @@ -0,0 +1,8 @@ +{ + "ver": "1.2.5", + "uuid": "8a738d50-1dac-4b6e-99e1-d241f5ee7169", + "optimizationPolicy": "AUTO", + "asyncLoadAssets": false, + "readonly": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/prefabs/Pacman2.prefab b/frontend/assets/resources/prefabs/Pacman2.prefab new file mode 100644 index 0000000..84058c2 --- /dev/null +++ b/frontend/assets/resources/prefabs/Pacman2.prefab @@ -0,0 +1,591 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false + }, + { + "__type__": "cc.Node", + "_name": "Player2", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + }, + { + "__id__": 5 + }, + { + "__id__": 8 + } + ], + "_active": true, + "_level": 1, + "_components": [ + { + "__id__": 11 + }, + { + "__id__": 12 + }, + { + "__id__": 13 + }, + { + "__id__": 14 + } + ], + "_prefab": { + "__id__": 15 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 120, + "height": 120 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 2, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 3, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Node", + "_name": "CoordinateLabel", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": false, + "_level": 0, + "_components": [ + { + "__id__": 3 + } + ], + "_prefab": { + "__id__": 4 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 93.36, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -5, + 101, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_useOriginalSize": false, + "_string": "(0, 0)", + "_N$string": "(0, 0)", + "_fontSize": 40, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 0, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "1f479636-9eb8-4612-8f97-371964d6eae3" + }, + "fileId": "5apzDmIE9IuaMOyF3z06sc", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "particlesystem", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": false, + "_level": 2, + "_components": [ + { + "__id__": 6 + } + ], + "_prefab": { + "__id__": 7 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.ParticleSystem", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 5 + }, + "_enabled": true, + "_custom": true, + "_file": { + "__uuid__": "b2687ac4-099e-403c-a192-ff477686f4f5" + }, + "_spriteFrame": { + "__uuid__": "472df5d3-35e7-4184-9e6c-7f41bee65ee3" + }, + "_texture": null, + "_srcBlendFactor": 770, + "_dstBlendFactor": 1, + "_stopped": false, + "playOnLoad": true, + "autoRemoveOnFinish": false, + "totalParticles": 200, + "duration": -1, + "emissionRate": 999.999985098839, + "life": 0.20000000298023224, + "lifeVar": 0.5, + "_startColor": { + "__type__": "cc.Color", + "r": 202, + "g": 200, + "b": 86, + "a": 163 + }, + "_startColorVar": { + "__type__": "cc.Color", + "r": 229, + "g": 255, + "b": 173, + "a": 198 + }, + "_endColor": { + "__type__": "cc.Color", + "r": 173, + "g": 161, + "b": 19, + "a": 214 + }, + "_endColorVar": { + "__type__": "cc.Color", + "r": 107, + "g": 249, + "b": 249, + "a": 188 + }, + "angle": 360, + "angleVar": 360, + "startSize": 3.369999885559082, + "startSizeVar": 50, + "endSize": 30.31999969482422, + "endSizeVar": 0, + "startSpin": -47.369998931884766, + "startSpinVar": 0, + "endSpin": -47.369998931884766, + "endSpinVar": -142.11000061035156, + "sourcePos": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "posVar": { + "__type__": "cc.Vec2", + "x": 7, + "y": 7 + }, + "positionType": 1, + "emitterMode": 0, + "gravity": { + "__type__": "cc.Vec2", + "x": 0.25, + "y": 0.8600000143051147 + }, + "speed": 0, + "speedVar": 190.7899932861328, + "tangentialAccel": -92.11000061035156, + "tangentialAccelVar": 65.79000091552734, + "radialAccel": -671.0499877929688, + "radialAccelVar": 65.79000091552734, + "rotationIsDir": false, + "startRadius": 0, + "startRadiusVar": 0, + "endRadius": 0, + "endRadiusVar": 0, + "rotatePerS": 0, + "rotatePerSVar": 0, + "_N$preview": true, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "1f479636-9eb8-4612-8f97-371964d6eae3" + }, + "fileId": "04uxaznclAmLRL13XKszPJ", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "arrowTip", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_level": 2, + "_components": [ + { + "__id__": 9 + } + ], + "_prefab": { + "__id__": 10 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 76, + "height": 84 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 177, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 8 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "a2170e4c-df31-41ef-be73-f4f605e75821" + }, + "_type": 0, + "_sizeMode": 1, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_state": 0, + "_atlas": { + "__uuid__": "030d9286-e8a2-40cf-98f8-baf713f0b8c4" + }, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "1f479636-9eb8-4612-8f97-371964d6eae3" + }, + "fileId": "6bwyYXs/lD7ba69sgDrsn5", + "sync": false + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_spriteFrame": null, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_state": 0, + "_atlas": null, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_id": "" + }, + { + "__type__": "cc.Animation", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_defaultClip": { + "__uuid__": "115ea7bb-d47f-4d3c-a52a-f46584346c3f" + }, + "_clips": [ + { + "__uuid__": "a1bf7c7c-b9f7-4b65-86e3-f86a9e798fb6" + }, + { + "__uuid__": "115ea7bb-d47f-4d3c-a52a-f46584346c3f" + }, + { + "__uuid__": "d5af527a-9f0c-4398-b2dd-84426be7bd32" + }, + { + "__uuid__": "b60618d7-569d-4f13-bdeb-f20341fbadb6" + }, + { + "__uuid__": "0b3fb38e-9110-4191-9b72-6b64a224d049" + }, + { + "__uuid__": "1bc6de53-800b-4da3-ab8e-4a45e3aa4230" + }, + { + "__uuid__": "ee0d670c-893e-4e4d-96dd-5571db18ee97" + }, + { + "__uuid__": "596df84a-2e4e-4f1d-967c-a82649f564a8" + }, + { + "__uuid__": "8acc4e9f-3c47-4b66-9a9d-d012709680f6" + }, + { + "__uuid__": "c7cda0cd-dbce-4722-abd2-aeca28263a21" + } + ], + "playOnLoad": true, + "_id": "" + }, + { + "__type__": "b74b05YDqZFRo4OkZRFZX8k", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "animComp": null, + "baseSpeed": 300, + "speed": 200, + "lastMovedAt": 0, + "eps": 0.1, + "magicLeanLowerBound": 0.414, + "magicLeanUpperBound": 2.414, + "arrowTipNode": { + "__id__": 8 + }, + "_id": "" + }, + { + "__type__": "cc.CircleCollider", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "tag": 0, + "_offset": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_radius": 12, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "1f479636-9eb8-4612-8f97-371964d6eae3" + }, + "fileId": "4cx75uwJJFa7U8QL187QCL", + "sync": false + } +] \ No newline at end of file diff --git a/frontend/assets/resources/prefabs/Pacman2.prefab.meta b/frontend/assets/resources/prefabs/Pacman2.prefab.meta new file mode 100644 index 0000000..392527f --- /dev/null +++ b/frontend/assets/resources/prefabs/Pacman2.prefab.meta @@ -0,0 +1,8 @@ +{ + "ver": "1.2.5", + "uuid": "1f479636-9eb8-4612-8f97-371964d6eae3", + "optimizationPolicy": "AUTO", + "asyncLoadAssets": false, + "readonly": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/prefabs/PlayersInfo.prefab b/frontend/assets/resources/prefabs/PlayersInfo.prefab new file mode 100644 index 0000000..1e08fbd --- /dev/null +++ b/frontend/assets/resources/prefabs/PlayersInfo.prefab @@ -0,0 +1,908 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false + }, + { + "__type__": "cc.Node", + "_name": "PlayersInfo", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + }, + { + "__id__": 13 + } + ], + "_active": true, + "_level": 1, + "_components": [ + { + "__id__": 25 + } + ], + "_prefab": { + "__id__": 26 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 2, + 513, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Node", + "_name": "player1", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 3 + }, + { + "__id__": 6 + }, + { + "__id__": 9 + } + ], + "_active": true, + "_level": 3, + "_components": [], + "_prefab": { + "__id__": 12 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 330, + "height": 180 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -277, + 168, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Node", + "_name": "bg", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_level": 4, + "_components": [ + { + "__id__": 4 + } + ], + "_prefab": { + "__id__": 5 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 357, + "height": 141 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -36, + -9, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 3 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "9af48a68-a401-4c92-aa12-2936e69dd5e3" + }, + "_type": 0, + "_sizeMode": 1, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_state": 0, + "_atlas": { + "__uuid__": "030d9286-e8a2-40cf-98f8-baf713f0b8c4" + }, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "b4e519f4-e698-4403-9ff2-47b8dacb077e" + }, + "fileId": "16LFzV+hNEK7ksHPHY8zCh", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "score", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_level": 4, + "_components": [ + { + "__id__": 7 + } + ], + "_prefab": { + "__id__": 8 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 27.81, + "height": 70 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -149, + -1, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 6 + }, + "_enabled": true, + "_useOriginalSize": false, + "_string": "0", + "_N$string": "0", + "_fontSize": 50, + "_lineHeight": 70, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 0, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "b4e519f4-e698-4403-9ff2-47b8dacb077e" + }, + "fileId": "a8XXWk5nxPCZio8sfjmikd", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "name", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_level": 4, + "_components": [ + { + "__id__": 10 + } + ], + "_prefab": { + "__id__": 11 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 30 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 19, + -11, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 9 + }, + "_enabled": true, + "_useOriginalSize": false, + "_string": "", + "_N$string": "", + "_fontSize": 30, + "_lineHeight": 30, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 0, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "b4e519f4-e698-4403-9ff2-47b8dacb077e" + }, + "fileId": "85KsWr7QxIrreeHO2C0Cyj", + "sync": false + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "b4e519f4-e698-4403-9ff2-47b8dacb077e" + }, + "fileId": "401bNraERKcaxXXs6JaVdv", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "player2", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 14 + }, + { + "__id__": 17 + }, + { + "__id__": 20 + } + ], + "_active": true, + "_level": 3, + "_components": [ + { + "__id__": 23 + } + ], + "_prefab": { + "__id__": 24 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 380, + "height": 120 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 277, + 168, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Node", + "_name": "bg", + "_objFlags": 0, + "_parent": { + "__id__": 13 + }, + "_children": [], + "_active": true, + "_level": 4, + "_components": [ + { + "__id__": 15 + } + ], + "_prefab": { + "__id__": 16 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 359, + "height": 141 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 26, + -5, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 14 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "d7a9288a-d75a-4a4a-b018-0cda2d7639c7" + }, + "_type": 0, + "_sizeMode": 1, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_state": 0, + "_atlas": { + "__uuid__": "030d9286-e8a2-40cf-98f8-baf713f0b8c4" + }, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "b4e519f4-e698-4403-9ff2-47b8dacb077e" + }, + "fileId": "6aSYOggzdN3ZX0UFP7La6c", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "name", + "_objFlags": 0, + "_parent": { + "__id__": 13 + }, + "_children": [], + "_active": true, + "_level": 4, + "_components": [ + { + "__id__": 18 + } + ], + "_prefab": { + "__id__": 19 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 30 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -23, + -5, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 17 + }, + "_enabled": true, + "_useOriginalSize": false, + "_string": "", + "_N$string": "", + "_fontSize": 30, + "_lineHeight": 30, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 0, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "b4e519f4-e698-4403-9ff2-47b8dacb077e" + }, + "fileId": "8fIS+5y4VH1Judzkmr05Dk", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "score", + "_objFlags": 0, + "_parent": { + "__id__": 13 + }, + "_children": [], + "_active": true, + "_level": 4, + "_components": [ + { + "__id__": 21 + } + ], + "_prefab": { + "__id__": 22 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 27.81, + "height": 70 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 138, + -1, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 20 + }, + "_enabled": true, + "_useOriginalSize": false, + "_string": "0", + "_N$string": "0", + "_fontSize": 50, + "_lineHeight": 70, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 0, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "b4e519f4-e698-4403-9ff2-47b8dacb077e" + }, + "fileId": "0dAb81oshNK6woq2NifJyV", + "sync": false + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 13 + }, + "_enabled": true, + "_spriteFrame": null, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_state": 0, + "_atlas": null, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "b4e519f4-e698-4403-9ff2-47b8dacb077e" + }, + "fileId": "73UFkggN5HlIQhMQ3KNDTg", + "sync": false + }, + { + "__type__": "846ce5FTKlDg4p0xqjzw1YX", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "listNode": { + "__id__": 1 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "b4e519f4-e698-4403-9ff2-47b8dacb077e" + }, + "fileId": "d1Tw1Z/HNMVLabn02wPcAF", + "sync": false + } +] \ No newline at end of file diff --git a/frontend/assets/resources/prefabs/PlayersInfo.prefab.meta b/frontend/assets/resources/prefabs/PlayersInfo.prefab.meta new file mode 100644 index 0000000..6d74be9 --- /dev/null +++ b/frontend/assets/resources/prefabs/PlayersInfo.prefab.meta @@ -0,0 +1,8 @@ +{ + "ver": "1.2.5", + "uuid": "b4e519f4-e698-4403-9ff2-47b8dacb077e", + "optimizationPolicy": "AUTO", + "asyncLoadAssets": false, + "readonly": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/prefabs/PolygonBoundaryBarrier.prefab b/frontend/assets/resources/prefabs/PolygonBoundaryBarrier.prefab new file mode 100644 index 0000000..e1360ec --- /dev/null +++ b/frontend/assets/resources/prefabs/PolygonBoundaryBarrier.prefab @@ -0,0 +1,118 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "", + "_objFlags": 0, + "_rawFiles": null, + "data": { + "__id__": 1 + } + }, + { + "__type__": "cc.Node", + "_name": "PolygonBoundaryBarrier", + "_objFlags": 0, + "_parent": null, + "_children": [], + "_tag": -1, + "_active": true, + "_components": [ + { + "__id__": 2 + } + ], + "_prefab": { + "__id__": 3 + }, + "_id": "", + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_cascadeOpacityEnabled": true, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_localZOrder": 0, + "_globalZOrder": 0, + "_opacityModifyRGB": false, + "groupIndex": 1, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.PolygonCollider", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "tag": 0, + "_offset": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "points": [ + { + "__type__": "cc.Vec2", + "x": -50, + "y": -50 + }, + { + "__type__": "cc.Vec2", + "x": 50, + "y": -50 + }, + { + "__type__": "cc.Vec2", + "x": 50, + "y": 50 + }, + { + "__type__": "cc.Vec2", + "x": -50, + "y": 50 + } + ] + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "e6gF9LdulAgYGTgO3/Pye8", + "sync": false + } +] \ No newline at end of file diff --git a/frontend/assets/resources/prefabs/PolygonBoundaryBarrier.prefab.meta b/frontend/assets/resources/prefabs/PolygonBoundaryBarrier.prefab.meta new file mode 100644 index 0000000..94cdc63 --- /dev/null +++ b/frontend/assets/resources/prefabs/PolygonBoundaryBarrier.prefab.meta @@ -0,0 +1,8 @@ +{ + "ver": "1.2.5", + "uuid": "4154eec0-d644-482f-a889-c00ae6b69958", + "optimizationPolicy": "AUTO", + "asyncLoadAssets": false, + "readonly": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/prefabs/PolygonBoundaryShelter.prefab b/frontend/assets/resources/prefabs/PolygonBoundaryShelter.prefab new file mode 100644 index 0000000..84e3c21 --- /dev/null +++ b/frontend/assets/resources/prefabs/PolygonBoundaryShelter.prefab @@ -0,0 +1,125 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false + }, + { + "__type__": "cc.Node", + "_name": "PolygonBoundaryShelter", + "_objFlags": 0, + "_parent": null, + "_children": [], + "_active": true, + "_level": 1, + "_components": [ + { + "__id__": 2 + } + ], + "_prefab": { + "__id__": 3 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "_zIndex": 0, + "groupIndex": 4, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -192, + 43, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.PolygonCollider", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "tag": 0, + "_offset": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "points": [ + { + "__type__": "cc.Vec2", + "x": -50, + "y": -50 + }, + { + "__type__": "cc.Vec2", + "x": 50, + "y": -50 + }, + { + "__type__": "cc.Vec2", + "x": 50, + "y": 50 + }, + { + "__type__": "cc.Vec2", + "x": -50, + "y": 50 + } + ], + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "f820a6ec-e7a9-46cf-9b8a-331aa3e21487" + }, + "fileId": "f8scmoFllMboAtkaldeiym", + "sync": false + } +] \ No newline at end of file diff --git a/frontend/assets/resources/prefabs/PolygonBoundaryShelter.prefab.meta b/frontend/assets/resources/prefabs/PolygonBoundaryShelter.prefab.meta new file mode 100644 index 0000000..599227e --- /dev/null +++ b/frontend/assets/resources/prefabs/PolygonBoundaryShelter.prefab.meta @@ -0,0 +1,8 @@ +{ + "ver": "1.2.5", + "uuid": "f820a6ec-e7a9-46cf-9b8a-331aa3e21487", + "optimizationPolicy": "AUTO", + "asyncLoadAssets": false, + "readonly": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/prefabs/PolygonBoundaryShelterZReducer.prefab b/frontend/assets/resources/prefabs/PolygonBoundaryShelterZReducer.prefab new file mode 100644 index 0000000..5fd5fd2 --- /dev/null +++ b/frontend/assets/resources/prefabs/PolygonBoundaryShelterZReducer.prefab @@ -0,0 +1,125 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false + }, + { + "__type__": "cc.Node", + "_name": "PolygonBoundaryShelterZReducer", + "_objFlags": 0, + "_parent": null, + "_children": [], + "_active": true, + "_level": 1, + "_components": [ + { + "__id__": 2 + } + ], + "_prefab": { + "__id__": 3 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "_zIndex": 0, + "groupIndex": 3, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.PolygonCollider", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "tag": 0, + "_offset": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "points": [ + { + "__type__": "cc.Vec2", + "x": -50, + "y": -50 + }, + { + "__type__": "cc.Vec2", + "x": 50, + "y": -50 + }, + { + "__type__": "cc.Vec2", + "x": 50, + "y": 50 + }, + { + "__type__": "cc.Vec2", + "x": -50, + "y": 50 + } + ], + "_id": "e6q3kwlllDC425mW1I4/O5" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "a36d024b-a979-4d18-b089-19af313ffb82" + }, + "fileId": "fajJ28qMxI0YDyTCPlWINd", + "sync": false + } +] \ No newline at end of file diff --git a/frontend/assets/resources/prefabs/PolygonBoundaryShelterZReducer.prefab.meta b/frontend/assets/resources/prefabs/PolygonBoundaryShelterZReducer.prefab.meta new file mode 100644 index 0000000..7fb9ed4 --- /dev/null +++ b/frontend/assets/resources/prefabs/PolygonBoundaryShelterZReducer.prefab.meta @@ -0,0 +1,8 @@ +{ + "ver": "1.2.5", + "uuid": "a36d024b-a979-4d18-b089-19af313ffb82", + "optimizationPolicy": "AUTO", + "asyncLoadAssets": false, + "readonly": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/prefabs/ResultPanel.prefab b/frontend/assets/resources/prefabs/ResultPanel.prefab new file mode 100644 index 0000000..d67c42c --- /dev/null +++ b/frontend/assets/resources/prefabs/ResultPanel.prefab @@ -0,0 +1,2772 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false + }, + { + "__type__": "cc.Node", + "_name": "resultPanel", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + }, + { + "__id__": 5 + }, + { + "__id__": 43 + }, + { + "__id__": 63 + } + ], + "_active": true, + "_level": 1, + "_components": [ + { + "__id__": 77 + }, + { + "__id__": 78 + } + ], + "_prefab": { + "__id__": 79 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 1024, + "height": 1920 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Node", + "_name": "backboard", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_level": 2, + "_components": [ + { + "__id__": 3 + } + ], + "_prefab": { + "__id__": 4 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 573, + "height": 356 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -16, + 210, + 0, + 0, + 0, + 0, + 1, + 1.5, + 1.5, + 1.53 + ] + } + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "07225a7f-587f-4e0e-907a-ca9f06cf77a5" + }, + "_type": 0, + "_sizeMode": 1, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_state": 0, + "_atlas": { + "__uuid__": "030d9286-e8a2-40cf-98f8-baf713f0b8c4" + }, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "c4cfe3bd-c59e-4d5b-95cb-c933b120e184" + }, + "fileId": "00oozpIChF6J3Dj7IRtJ7Y", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "Ranking", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 6 + }, + { + "__id__": 15 + }, + { + "__id__": 24 + }, + { + "__id__": 33 + } + ], + "_active": true, + "_level": 2, + "_components": [], + "_prefab": { + "__id__": 42 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Node", + "_name": "gold", + "_objFlags": 0, + "_parent": { + "__id__": 5 + }, + "_children": [ + { + "__id__": 7 + }, + { + "__id__": 10 + } + ], + "_active": true, + "_level": 3, + "_components": [ + { + "__id__": 13 + } + ], + "_prefab": { + "__id__": 14 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 600, + "height": 120 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 190, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Node", + "_name": "name", + "_objFlags": 0, + "_parent": { + "__id__": 6 + }, + "_children": [], + "_active": true, + "_level": 4, + "_components": [ + { + "__id__": 8 + } + ], + "_prefab": { + "__id__": 9 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 44.49, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -170, + 23, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 7 + }, + "_enabled": true, + "_useOriginalSize": false, + "_string": "dd", + "_N$string": "dd", + "_fontSize": 40, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_N$horizontalAlign": 0, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 0, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "c4cfe3bd-c59e-4d5b-95cb-c933b120e184" + }, + "fileId": "c7CzbBbTVAuIyqd0lFL3Db", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "score", + "_objFlags": 0, + "_parent": { + "__id__": 6 + }, + "_children": [], + "_active": true, + "_level": 4, + "_components": [ + { + "__id__": 11 + } + ], + "_prefab": { + "__id__": 12 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 44.49, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -170, + -20, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 10 + }, + "_enabled": true, + "_useOriginalSize": false, + "_string": "dd", + "_N$string": "dd", + "_fontSize": 40, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_N$horizontalAlign": 0, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 0, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "c4cfe3bd-c59e-4d5b-95cb-c933b120e184" + }, + "fileId": "58fPz+v9VAfqnS3LxY39Zj", + "sync": false + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 6 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "9fc079f3-756f-4a2a-91d8-0bfff986bf3b" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_state": 0, + "_atlas": { + "__uuid__": "030d9286-e8a2-40cf-98f8-baf713f0b8c4" + }, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "c4cfe3bd-c59e-4d5b-95cb-c933b120e184" + }, + "fileId": "43I6tYsddHqJA8Sg1Fwg2A", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "silver", + "_objFlags": 0, + "_parent": { + "__id__": 5 + }, + "_children": [ + { + "__id__": 16 + }, + { + "__id__": 19 + } + ], + "_active": true, + "_level": 3, + "_components": [ + { + "__id__": 22 + } + ], + "_prefab": { + "__id__": 23 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 600, + "height": 120 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 43, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Node", + "_name": "name", + "_objFlags": 0, + "_parent": { + "__id__": 15 + }, + "_children": [], + "_active": true, + "_level": 4, + "_components": [ + { + "__id__": 17 + } + ], + "_prefab": { + "__id__": 18 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 44.49, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -173, + 35, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 16 + }, + "_enabled": true, + "_useOriginalSize": false, + "_string": "dd", + "_N$string": "dd", + "_fontSize": 40, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_N$horizontalAlign": 0, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 0, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "c4cfe3bd-c59e-4d5b-95cb-c933b120e184" + }, + "fileId": "baqmavXnBE0Y5BBUlfMGYI", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "score", + "_objFlags": 0, + "_parent": { + "__id__": 15 + }, + "_children": [], + "_active": true, + "_level": 4, + "_components": [ + { + "__id__": 20 + } + ], + "_prefab": { + "__id__": 21 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 44.49, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -172, + -15, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 19 + }, + "_enabled": true, + "_useOriginalSize": false, + "_string": "dd", + "_N$string": "dd", + "_fontSize": 40, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_N$horizontalAlign": 0, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 0, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "c4cfe3bd-c59e-4d5b-95cb-c933b120e184" + }, + "fileId": "9eyD+X789AVJjHMYhcnA2U", + "sync": false + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 15 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "72e26a0c-7b83-4e74-a8d2-e5597b16214d" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_state": 0, + "_atlas": { + "__uuid__": "030d9286-e8a2-40cf-98f8-baf713f0b8c4" + }, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "c4cfe3bd-c59e-4d5b-95cb-c933b120e184" + }, + "fileId": "69MNqX4qtOZ4XHtSJesKn8", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "copper", + "_objFlags": 0, + "_parent": { + "__id__": 5 + }, + "_children": [ + { + "__id__": 25 + }, + { + "__id__": 28 + } + ], + "_active": false, + "_level": 3, + "_components": [ + { + "__id__": 31 + } + ], + "_prefab": { + "__id__": 32 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 600, + "height": 120 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + -122, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Node", + "_name": "name", + "_objFlags": 0, + "_parent": { + "__id__": 24 + }, + "_children": [], + "_active": true, + "_level": 4, + "_components": [ + { + "__id__": 26 + } + ], + "_prefab": { + "__id__": 27 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -162, + -8, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 25 + }, + "_enabled": true, + "_useOriginalSize": false, + "_string": "", + "_N$string": "", + "_fontSize": 40, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_N$horizontalAlign": 0, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 0, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "c4cfe3bd-c59e-4d5b-95cb-c933b120e184" + }, + "fileId": "93czETEv1CSYL7rrsxik0r", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "score", + "_objFlags": 0, + "_parent": { + "__id__": 24 + }, + "_children": [], + "_active": true, + "_level": 4, + "_components": [ + { + "__id__": 29 + } + ], + "_prefab": { + "__id__": 30 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 72, + -8, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 28 + }, + "_enabled": true, + "_useOriginalSize": false, + "_string": "", + "_N$string": "", + "_fontSize": 40, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 0, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "c4cfe3bd-c59e-4d5b-95cb-c933b120e184" + }, + "fileId": "d7oshWbpxD3LYOUR2mDF6O", + "sync": false + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 24 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "70dae15c-39ae-4d74-96bb-8dde66090ba6" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_state": 0, + "_atlas": { + "__uuid__": "030d9286-e8a2-40cf-98f8-baf713f0b8c4" + }, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "c4cfe3bd-c59e-4d5b-95cb-c933b120e184" + }, + "fileId": "24H09n0XpCyq6dwfITSkx8", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "iron", + "_objFlags": 0, + "_parent": { + "__id__": 5 + }, + "_children": [ + { + "__id__": 34 + }, + { + "__id__": 37 + } + ], + "_active": false, + "_level": 3, + "_components": [ + { + "__id__": 40 + } + ], + "_prefab": { + "__id__": 41 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 600, + "height": 120 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + -250, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Node", + "_name": "name", + "_objFlags": 0, + "_parent": { + "__id__": 33 + }, + "_children": [], + "_active": true, + "_level": 4, + "_components": [ + { + "__id__": 35 + } + ], + "_prefab": { + "__id__": 36 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -162, + -19, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 34 + }, + "_enabled": true, + "_useOriginalSize": false, + "_string": "", + "_N$string": "", + "_fontSize": 40, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_N$horizontalAlign": 0, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 0, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "c4cfe3bd-c59e-4d5b-95cb-c933b120e184" + }, + "fileId": "5c5uzwJ8tAB6MlPag/xqa6", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "score", + "_objFlags": 0, + "_parent": { + "__id__": 33 + }, + "_children": [], + "_active": true, + "_level": 4, + "_components": [ + { + "__id__": 38 + } + ], + "_prefab": { + "__id__": 39 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 83, + -19, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 37 + }, + "_enabled": true, + "_useOriginalSize": false, + "_string": "", + "_N$string": "", + "_fontSize": 40, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 0, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "c4cfe3bd-c59e-4d5b-95cb-c933b120e184" + }, + "fileId": "ecHq0bWcNIJrRnpa0IC0Nf", + "sync": false + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 33 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "551d804b-78b0-46ff-a374-a74063af4444" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_state": 0, + "_atlas": { + "__uuid__": "030d9286-e8a2-40cf-98f8-baf713f0b8c4" + }, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "c4cfe3bd-c59e-4d5b-95cb-c933b120e184" + }, + "fileId": "f574j7pApPP7sPMscfUHHp", + "sync": false + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "c4cfe3bd-c59e-4d5b-95cb-c933b120e184" + }, + "fileId": "9322/5qIVLWa1s6+6rqKHn", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "buttons", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 44 + }, + { + "__id__": 53 + } + ], + "_active": true, + "_level": 2, + "_components": [], + "_prefab": { + "__id__": 62 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Node", + "_name": "againBtn", + "_objFlags": 0, + "_parent": { + "__id__": 43 + }, + "_children": [ + { + "__id__": 45 + } + ], + "_active": true, + "_level": 3, + "_components": [ + { + "__id__": 49 + }, + { + "__id__": 50 + } + ], + "_prefab": { + "__id__": 52 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 200, + "height": 120 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -232, + -266, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Node", + "_name": "label", + "_objFlags": 0, + "_parent": { + "__id__": 44 + }, + "_children": [], + "_active": true, + "_level": 3, + "_components": [ + { + "__id__": 46 + }, + { + "__id__": 47 + } + ], + "_prefab": { + "__id__": 48 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 146, + "g": 54, + "b": 2, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 700.52, + "height": 70 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 0.6666667, + 0.6666667, + 1 + ] + } + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 45 + }, + "_enabled": true, + "_useOriginalSize": false, + "_string": "resultPanel.againBtnLabel", + "_N$string": "resultPanel.againBtnLabel", + "_fontSize": 60, + "_lineHeight": 70, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 0, + "_id": "" + }, + { + "__type__": "744dcs4DCdNprNhG0xwq6FK", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 45 + }, + "_enabled": true, + "_dataID": "resultPanel.againBtnLabel", + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "c4cfe3bd-c59e-4d5b-95cb-c933b120e184" + }, + "fileId": "88IQoE2WxJK5XdtNDqEZxq", + "sync": false + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 44 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "37cdf925-4518-44e0-98b4-9d0423bd7989" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_state": 0, + "_atlas": { + "__uuid__": "030d9286-e8a2-40cf-98f8-baf713f0b8c4" + }, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_id": "" + }, + { + "__type__": "cc.Button", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 44 + }, + "_enabled": true, + "duration": 0.1, + "zoomScale": 1.2, + "clickEvents": [ + { + "__id__": 51 + } + ], + "_N$interactable": true, + "_N$enableAutoGrayEffect": false, + "_N$transition": 0, + "transition": 0, + "_N$normalColor": { + "__type__": "cc.Color", + "r": 214, + "g": 214, + "b": 214, + "a": 255 + }, + "_N$pressedColor": { + "__type__": "cc.Color", + "r": 211, + "g": 211, + "b": 211, + "a": 255 + }, + "pressedColor": { + "__type__": "cc.Color", + "r": 211, + "g": 211, + "b": 211, + "a": 255 + }, + "_N$hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$disabledColor": { + "__type__": "cc.Color", + "r": 124, + "g": 124, + "b": 124, + "a": 255 + }, + "_N$normalSprite": null, + "_N$pressedSprite": null, + "pressedSprite": null, + "_N$hoverSprite": null, + "hoverSprite": null, + "_N$disabledSprite": null, + "_N$target": { + "__id__": 44 + }, + "_id": "" + }, + { + "__type__": "cc.ClickEvent", + "target": { + "__id__": 1 + }, + "component": "", + "_componentId": "5ae77T7T5xEXaBXXTJSK5dd", + "handler": "againBtnOnClick", + "customEventData": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "c4cfe3bd-c59e-4d5b-95cb-c933b120e184" + }, + "fileId": "f1bmtKG1RKeKq78G2aMa3q", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "homeBtn", + "_objFlags": 0, + "_parent": { + "__id__": 43 + }, + "_children": [ + { + "__id__": 54 + } + ], + "_active": true, + "_level": 3, + "_components": [ + { + "__id__": 58 + }, + { + "__id__": 59 + } + ], + "_prefab": { + "__id__": 61 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 200, + "height": 120 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 204, + -266, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Node", + "_name": "label", + "_objFlags": 0, + "_parent": { + "__id__": 53 + }, + "_children": [], + "_active": true, + "_level": 3, + "_components": [ + { + "__id__": 55 + }, + { + "__id__": 56 + } + ], + "_prefab": { + "__id__": 57 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 146, + "g": 54, + "b": 2, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 703.8, + "height": 70 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 0.6666667, + 0.6666667, + 1 + ] + } + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 54 + }, + "_enabled": true, + "_useOriginalSize": false, + "_string": "resultPanel.homeBtnLabel", + "_N$string": "resultPanel.homeBtnLabel", + "_fontSize": 60, + "_lineHeight": 70, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 0, + "_id": "" + }, + { + "__type__": "744dcs4DCdNprNhG0xwq6FK", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 54 + }, + "_enabled": true, + "_dataID": "resultPanel.homeBtnLabel", + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "c4cfe3bd-c59e-4d5b-95cb-c933b120e184" + }, + "fileId": "988w9F3JZFQr5nv6rlQWM0", + "sync": false + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 53 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "88d833ba-15fb-4a42-95ee-c55fe6628ed2" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_state": 0, + "_atlas": { + "__uuid__": "030d9286-e8a2-40cf-98f8-baf713f0b8c4" + }, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_id": "" + }, + { + "__type__": "cc.Button", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 53 + }, + "_enabled": true, + "duration": 0.1, + "zoomScale": 1.2, + "clickEvents": [ + { + "__id__": 60 + } + ], + "_N$interactable": true, + "_N$enableAutoGrayEffect": false, + "_N$transition": 0, + "transition": 0, + "_N$normalColor": { + "__type__": "cc.Color", + "r": 214, + "g": 214, + "b": 214, + "a": 255 + }, + "_N$pressedColor": { + "__type__": "cc.Color", + "r": 211, + "g": 211, + "b": 211, + "a": 255 + }, + "pressedColor": { + "__type__": "cc.Color", + "r": 211, + "g": 211, + "b": 211, + "a": 255 + }, + "_N$hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$disabledColor": { + "__type__": "cc.Color", + "r": 124, + "g": 124, + "b": 124, + "a": 255 + }, + "_N$normalSprite": null, + "_N$pressedSprite": null, + "pressedSprite": null, + "_N$hoverSprite": null, + "hoverSprite": null, + "_N$disabledSprite": null, + "_N$target": { + "__id__": 53 + }, + "_id": "" + }, + { + "__type__": "cc.ClickEvent", + "target": { + "__id__": 1 + }, + "component": "", + "_componentId": "5ae77T7T5xEXaBXXTJSK5dd", + "handler": "homeBtnOnClick", + "customEventData": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "c4cfe3bd-c59e-4d5b-95cb-c933b120e184" + }, + "fileId": "efWFr2GsNI8peDAW8e70MB", + "sync": false + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "c4cfe3bd-c59e-4d5b-95cb-c933b120e184" + }, + "fileId": "90Xr8NlPVC3r01ICbiFejb", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "myInfo", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 64 + }, + { + "__id__": 70 + }, + { + "__id__": 73 + } + ], + "_active": true, + "_level": 2, + "_components": [], + "_prefab": { + "__id__": 76 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Node", + "_name": "myAvatarMask", + "_objFlags": 0, + "_parent": { + "__id__": 63 + }, + "_children": [ + { + "__id__": 65 + } + ], + "_active": true, + "_level": 3, + "_components": [ + { + "__id__": 68 + } + ], + "_prefab": { + "__id__": 69 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 200, + "height": 200 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -254, + 402, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Node", + "_name": "myAvatar", + "_objFlags": 0, + "_parent": { + "__id__": 64 + }, + "_children": [], + "_active": true, + "_level": 3, + "_components": [ + { + "__id__": 66 + } + ], + "_prefab": { + "__id__": 67 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 200, + "height": 200 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 1, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 65 + }, + "_enabled": true, + "_spriteFrame": null, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_state": 0, + "_atlas": null, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "c4cfe3bd-c59e-4d5b-95cb-c933b120e184" + }, + "fileId": "f8KrXebthNf6t5HYvJi2B7", + "sync": false + }, + { + "__type__": "cc.Mask", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 64 + }, + "_enabled": true, + "_spriteFrame": null, + "_type": 1, + "_segments": 64, + "_N$alphaThreshold": 0, + "_N$inverted": false, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "c4cfe3bd-c59e-4d5b-95cb-c933b120e184" + }, + "fileId": "bfFernzI9ODJeETYu3hB2e", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "myName", + "_objFlags": 0, + "_parent": { + "__id__": 63 + }, + "_children": [], + "_active": true, + "_level": 3, + "_components": [ + { + "__id__": 71 + } + ], + "_prefab": { + "__id__": 72 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 200, + "height": 30 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -136, + 328, + 0, + 0, + 0, + 0, + 1, + 1.52, + 1.52, + 1.52 + ] + } + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 70 + }, + "_enabled": true, + "_useOriginalSize": false, + "_string": "dd", + "_N$string": "dd", + "_fontSize": 30, + "_lineHeight": 30, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_N$horizontalAlign": 0, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 1, + "_N$cacheMode": 0, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "c4cfe3bd-c59e-4d5b-95cb-c933b120e184" + }, + "fileId": "cdixzdHmJGEL8fJFOKU/wv", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "win", + "_objFlags": 0, + "_parent": { + "__id__": 63 + }, + "_children": [], + "_active": true, + "_level": 3, + "_components": [ + { + "__id__": 74 + } + ], + "_prefab": { + "__id__": 75 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 222, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 136.07, + "height": 60 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -139, + 429, + 0, + 0, + 0, + 0, + 1, + 1.52, + 1.52, + 1.52 + ] + } + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 73 + }, + "_enabled": true, + "_useOriginalSize": false, + "_string": "WIN", + "_N$string": "WIN", + "_fontSize": 70, + "_lineHeight": 60, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_N$horizontalAlign": 0, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 0, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "c4cfe3bd-c59e-4d5b-95cb-c933b120e184" + }, + "fileId": "2d205JFRdLgr8UW9PbXu3d", + "sync": false + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "c4cfe3bd-c59e-4d5b-95cb-c933b120e184" + }, + "fileId": "3atwQdzNpEuZR1dv28k52f", + "sync": false + }, + { + "__type__": "5ae77T7T5xEXaBXXTJSK5dd", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "onCloseDelegate": null, + "onAgainClicked": null, + "myAvatarNode": { + "__id__": 65 + }, + "myNameNode": { + "__id__": 70 + }, + "rankingNodes": [ + { + "__id__": 6 + }, + { + "__id__": 15 + }, + { + "__id__": 24 + }, + { + "__id__": 33 + } + ], + "winNode": { + "__id__": 73 + }, + "_id": "" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "334d4f93-b007-49e8-9268-35891d4f4ebb" + }, + "_type": 0, + "_sizeMode": 1, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": false, + "_state": 0, + "_atlas": null, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "c4cfe3bd-c59e-4d5b-95cb-c933b120e184" + }, + "fileId": "52RRrGucpHNq2ULHnlwhwO", + "sync": false + } +] \ No newline at end of file diff --git a/frontend/assets/resources/prefabs/ResultPanel.prefab.meta b/frontend/assets/resources/prefabs/ResultPanel.prefab.meta new file mode 100644 index 0000000..00571f4 --- /dev/null +++ b/frontend/assets/resources/prefabs/ResultPanel.prefab.meta @@ -0,0 +1,8 @@ +{ + "ver": "1.2.5", + "uuid": "c4cfe3bd-c59e-4d5b-95cb-c933b120e184", + "optimizationPolicy": "AUTO", + "asyncLoadAssets": false, + "readonly": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/prefabs/SimplePressToGoDialog.prefab b/frontend/assets/resources/prefabs/SimplePressToGoDialog.prefab new file mode 100644 index 0000000..f269235 --- /dev/null +++ b/frontend/assets/resources/prefabs/SimplePressToGoDialog.prefab @@ -0,0 +1,601 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false + }, + { + "__type__": "cc.Node", + "_name": "SimplePressToGoDialog", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + }, + { + "__id__": 5 + }, + { + "__id__": 8 + } + ], + "_active": true, + "_level": 1, + "_components": [ + { + "__id__": 15 + } + ], + "_prefab": { + "__id__": 16 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 234, + "g": 16, + "b": 16, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 320, + "height": 240 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 128, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Node", + "_name": "DialogBkg", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_level": 0, + "_components": [ + { + "__id__": 3 + } + ], + "_prefab": { + "__id__": 4 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 750, + "height": 480 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "919690f3-9e98-4dca-88cf-ee33db7150cb" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_state": 0, + "_atlas": { + "__uuid__": "030d9286-e8a2-40cf-98f8-baf713f0b8c4" + }, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "670b477e-61a1-4778-879b-35913f7c79d2" + }, + "fileId": "b9X0mFnqdDvKPPGYJdihrm", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "Hint", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_level": 0, + "_components": [ + { + "__id__": 6 + } + ], + "_prefab": { + "__id__": 7 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 36, + "g": 36, + "b": 36, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 650, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 34, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 5 + }, + "_enabled": true, + "_useOriginalSize": false, + "_string": "Hint here", + "_N$string": "Hint here", + "_fontSize": 30, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 3, + "_N$cacheMode": 0, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "670b477e-61a1-4778-879b-35913f7c79d2" + }, + "fileId": "38Nd2fBbpLBY6i4nPCvCAX", + "sync": false + }, + { + "__type__": "cc.Node", + "_name": "Yes", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 9 + } + ], + "_active": true, + "_level": 0, + "_components": [ + { + "__id__": 12 + }, + { + "__id__": 13 + } + ], + "_prefab": { + "__id__": 14 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 250, + "height": 80 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 4, + -128, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Node", + "_name": "Label", + "_objFlags": 0, + "_parent": { + "__id__": 8 + }, + "_children": [], + "_active": true, + "_level": 0, + "_components": [ + { + "__id__": 10 + } + ], + "_prefab": { + "__id__": 11 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 9 + }, + "_enabled": true, + "_useOriginalSize": false, + "_string": "OK", + "_N$string": "OK", + "_fontSize": 30, + "_lineHeight": 40, + "_enableWrapText": false, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 1, + "_N$cacheMode": 0, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "670b477e-61a1-4778-879b-35913f7c79d2" + }, + "fileId": "d9MNZPA8xFCKn46rBXRk5f", + "sync": false + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 8 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "ef0ce43c-ad0d-4f7a-adad-ccdc3b07da45" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_state": 0, + "_atlas": { + "__uuid__": "030d9286-e8a2-40cf-98f8-baf713f0b8c4" + }, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_id": "" + }, + { + "__type__": "cc.Button", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 8 + }, + "_enabled": true, + "duration": 0.1, + "zoomScale": 1.2, + "clickEvents": [], + "_N$interactable": true, + "_N$enableAutoGrayEffect": false, + "_N$transition": 3, + "transition": 3, + "_N$normalColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$pressedColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "pressedColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$disabledColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$normalSprite": null, + "_N$pressedSprite": { + "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a" + }, + "pressedSprite": { + "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a" + }, + "_N$hoverSprite": { + "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a" + }, + "hoverSprite": { + "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a" + }, + "_N$disabledSprite": { + "__uuid__": "29158224-f8dd-4661-a796-1ffab537140e" + }, + "_N$target": { + "__id__": 8 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "670b477e-61a1-4778-879b-35913f7c79d2" + }, + "fileId": "69T8fB6OpGU7U2rxqDObZL", + "sync": false + }, + { + "__type__": "27562q//mhCf7WYuOU6ym6H", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "670b477e-61a1-4778-879b-35913f7c79d2" + }, + "fileId": "638C2pu7FByp80ZXrwZ0V6", + "sync": false + } +] \ No newline at end of file diff --git a/frontend/assets/resources/prefabs/SimplePressToGoDialog.prefab.meta b/frontend/assets/resources/prefabs/SimplePressToGoDialog.prefab.meta new file mode 100644 index 0000000..d81792a --- /dev/null +++ b/frontend/assets/resources/prefabs/SimplePressToGoDialog.prefab.meta @@ -0,0 +1,8 @@ +{ + "ver": "1.2.5", + "uuid": "670b477e-61a1-4778-879b-35913f7c79d2", + "optimizationPolicy": "AUTO", + "asyncLoadAssets": false, + "readonly": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/prefabs/SmsWaitcountdown.prefab b/frontend/assets/resources/prefabs/SmsWaitcountdown.prefab new file mode 100644 index 0000000..f6a4a07 --- /dev/null +++ b/frontend/assets/resources/prefabs/SmsWaitcountdown.prefab @@ -0,0 +1,220 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false + }, + { + "__type__": "cc.Node", + "_name": "SmsWaitcountdown", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + } + ], + "_active": true, + "_level": 1, + "_components": [ + { + "__id__": 5 + } + ], + "_prefab": { + "__id__": 6 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 120, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Node", + "_name": "WaitTimeLabel", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_level": 0, + "_components": [ + { + "__id__": 3 + } + ], + "_prefab": { + "__id__": 4 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 33.37, + "height": 30 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_useOriginalSize": false, + "_string": "20", + "_N$string": "20", + "_fontSize": 30, + "_lineHeight": 30, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_N$horizontalAlign": 0, + "_N$verticalAlign": 0, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 0, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "2c0101b8-c15a-4501-9fce-cd5a014af8bf" + }, + "fileId": "11bo4oQudPVI0baR+ZvdkC", + "sync": false + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "ab4283be-3935-44c5-b12a-9458aef99953" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_state": 0, + "_atlas": { + "__uuid__": "030d9286-e8a2-40cf-98f8-baf713f0b8c4" + }, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "2c0101b8-c15a-4501-9fce-cd5a014af8bf" + }, + "fileId": "2f7h1UAHdNxZ+ZWyiaOblT", + "sync": false + } +] \ No newline at end of file diff --git a/frontend/assets/resources/prefabs/SmsWaitcountdown.prefab.meta b/frontend/assets/resources/prefabs/SmsWaitcountdown.prefab.meta new file mode 100644 index 0000000..134b5aa --- /dev/null +++ b/frontend/assets/resources/prefabs/SmsWaitcountdown.prefab.meta @@ -0,0 +1,8 @@ +{ + "ver": "1.2.5", + "uuid": "2c0101b8-c15a-4501-9fce-cd5a014af8bf", + "optimizationPolicy": "AUTO", + "asyncLoadAssets": false, + "readonly": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/prefabs/TiledAnim.prefab b/frontend/assets/resources/prefabs/TiledAnim.prefab new file mode 100644 index 0000000..72543a6 --- /dev/null +++ b/frontend/assets/resources/prefabs/TiledAnim.prefab @@ -0,0 +1,132 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false + }, + { + "__type__": "cc.Node", + "_name": "TiledAnim", + "_objFlags": 0, + "_parent": null, + "_children": [], + "_active": true, + "_level": 1, + "_components": [ + { + "__id__": 2 + }, + { + "__id__": 3 + } + ], + "_prefab": { + "__id__": 4 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 56, + "height": 58 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "cc1486e4-5c38-4a73-a0d3-70416d0dd57f" + }, + "_type": 0, + "_sizeMode": 1, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_state": 0, + "_atlas": { + "__uuid__": "030d9286-e8a2-40cf-98f8-baf713f0b8c4" + }, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_id": "" + }, + { + "__type__": "cc.Animation", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_defaultClip": null, + "_clips": [], + "playOnLoad": true, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "1c02b0a0-859a-4467-86b3-ca39c30d1e19" + }, + "fileId": "60dCvhukpIsL1FtdnqBIor", + "sync": false + } +] \ No newline at end of file diff --git a/frontend/assets/resources/prefabs/TiledAnim.prefab.meta b/frontend/assets/resources/prefabs/TiledAnim.prefab.meta new file mode 100644 index 0000000..6aaa513 --- /dev/null +++ b/frontend/assets/resources/prefabs/TiledAnim.prefab.meta @@ -0,0 +1,8 @@ +{ + "ver": "1.2.5", + "uuid": "1c02b0a0-859a-4467-86b3-ca39c30d1e19", + "optimizationPolicy": "AUTO", + "asyncLoadAssets": false, + "readonly": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/prefabs/TrapPrefab.prefab b/frontend/assets/resources/prefabs/TrapPrefab.prefab new file mode 100644 index 0000000..7f70cd1 --- /dev/null +++ b/frontend/assets/resources/prefabs/TrapPrefab.prefab @@ -0,0 +1,157 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false + }, + { + "__type__": "cc.Node", + "_name": "treasureNodePrefab", + "_objFlags": 0, + "_parent": null, + "_children": [], + "_active": true, + "_level": 1, + "_components": [ + { + "__id__": 2 + }, + { + "__id__": 3 + } + ], + "_prefab": { + "__id__": 4 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 100 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_quat": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_skewX": 0, + "_skewY": 0, + "groupIndex": 0, + "_id": "", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 441, + 814, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_spriteFrame": { + "__uuid__": "350fd890-3d28-4e53-9dfa-1bf00d857737" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_state": 0, + "_atlas": { + "__uuid__": "030d9286-e8a2-40cf-98f8-baf713f0b8c4" + }, + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_id": "" + }, + { + "__type__": "cc.PolygonCollider", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "tag": 0, + "_offset": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "points": [ + { + "__type__": "cc.Vec2", + "x": -50, + "y": -50 + }, + { + "__type__": "cc.Vec2", + "x": 50, + "y": -50 + }, + { + "__type__": "cc.Vec2", + "x": 50, + "y": 50 + }, + { + "__type__": "cc.Vec2", + "x": -50, + "y": 50 + } + ], + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "9f340a31-ddfa-46c2-94c7-d11615aedcb1" + }, + "fileId": "dc8aAweIBDDYuXBJblR5IA", + "sync": false + } +] \ No newline at end of file diff --git a/frontend/assets/resources/prefabs/TrapPrefab.prefab.meta b/frontend/assets/resources/prefabs/TrapPrefab.prefab.meta new file mode 100644 index 0000000..6da7b43 --- /dev/null +++ b/frontend/assets/resources/prefabs/TrapPrefab.prefab.meta @@ -0,0 +1,8 @@ +{ + "ver": "1.2.5", + "uuid": "9f340a31-ddfa-46c2-94c7-d11615aedcb1", + "optimizationPolicy": "AUTO", + "asyncLoadAssets": false, + "readonly": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/prefabs/TreasurePrefab.prefab b/frontend/assets/resources/prefabs/TreasurePrefab.prefab new file mode 100644 index 0000000..7dcdd94 --- /dev/null +++ b/frontend/assets/resources/prefabs/TreasurePrefab.prefab @@ -0,0 +1,167 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false, + "readonly": false + }, + { + "__type__": "cc.Node", + "_name": "treasureNodePrefab", + "_objFlags": 0, + "_parent": null, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 2 + }, + { + "__id__": 3 + }, + { + "__id__": 4 + } + ], + "_prefab": { + "__id__": 5 + }, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 64, + "height": 64 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_materials": [], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": null, + "_type": 0, + "_sizeMode": 2, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "" + }, + { + "__type__": "cc.PolygonCollider", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "tag": 0, + "_offset": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "points": [ + { + "__type__": "cc.Vec2", + "x": -50, + "y": -50 + }, + { + "__type__": "cc.Vec2", + "x": 50, + "y": -50 + }, + { + "__type__": "cc.Vec2", + "x": 50, + "y": 50 + }, + { + "__type__": "cc.Vec2", + "x": -50, + "y": 50 + } + ], + "_id": "" + }, + { + "__type__": "5eea6zlA0NHdoCk/M1pvQmb", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__uuid__": "ec3f3234-9b84-43c2-a3cd-58b924cce8e5" + }, + "fileId": "dc8aAweIBDDYuXBJblR5IA", + "sync": false + } +] \ No newline at end of file diff --git a/frontend/assets/resources/prefabs/TreasurePrefab.prefab.meta b/frontend/assets/resources/prefabs/TreasurePrefab.prefab.meta new file mode 100644 index 0000000..15cddb0 --- /dev/null +++ b/frontend/assets/resources/prefabs/TreasurePrefab.prefab.meta @@ -0,0 +1,8 @@ +{ + "ver": "1.2.5", + "uuid": "ec3f3234-9b84-43c2-a3cd-58b924cce8e5", + "optimizationPolicy": "AUTO", + "asyncLoadAssets": false, + "readonly": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/textures.meta b/frontend/assets/resources/textures.meta new file mode 100644 index 0000000..377ac3d --- /dev/null +++ b/frontend/assets/resources/textures.meta @@ -0,0 +1,5 @@ +{ + "ver": "1.0.1", + "uuid": "6f2b53ec-565c-4a83-9a8c-27e5ae02d46f", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/resources/textures/GuiElements_0.plist b/frontend/assets/resources/textures/GuiElements_0.plist new file mode 100644 index 0000000..2b24c01 --- /dev/null +++ b/frontend/assets/resources/textures/GuiElements_0.plist @@ -0,0 +1,656 @@ + + + + + frames + + BaseBoard.png + + aliases + + spriteOffset + {0,0} + spriteSize + {232,44} + spriteSourceSize + {232,44} + textureRect + {{1460,751},{232,44}} + textureRotated + + + ButtonActive.png + + aliases + + spriteOffset + {0,0} + spriteSize + {94,44} + spriteSourceSize + {94,44} + textureRect + {{1583,323},{94,44}} + textureRotated + + + ButtonNegative.png + + aliases + + spriteOffset + {0,0} + spriteSize + {90,40} + spriteSourceSize + {90,40} + textureRect + {{1525,608},{90,40}} + textureRotated + + + Captcha.png + + aliases + + spriteOffset + {0,0} + spriteSize + {299,71} + spriteSourceSize + {299,71} + textureRect + {{1525,651},{299,71}} + textureRotated + + + Clock.png + + aliases + + spriteOffset + {0,0} + spriteSize + {254,258} + spriteSourceSize + {254,258} + textureRect + {{1767,117},{254,258}} + textureRotated + + + FindingPlayer_DecorationDown.png + + aliases + + spriteOffset + {0,0} + spriteSize + {608,114} + spriteSourceSize + {608,114} + textureRect + {{1,796},{608,114}} + textureRotated + + + FindingPlayer_DecorationUp.png + + aliases + + spriteOffset + {0,0} + spriteSize + {608,114} + spriteSourceSize + {608,114} + textureRect + {{1222,1},{608,114}} + textureRotated + + + FindingPlayer_PlayerLeft.png + + aliases + + spriteOffset + {0,0} + spriteSize + {344,200} + spriteSourceSize + {344,200} + textureRect + {{1114,764},{344,200}} + textureRotated + + + FindingPlayer_PlayerRight.png + + aliases + + spriteOffset + {0,0} + spriteSize + {344,210} + spriteSourceSize + {344,210} + textureRect + {{647,779},{344,210}} + textureRotated + + + FindingPlayer_vs.png + + aliases + + spriteOffset + {0,0} + spriteSize + {118,134} + spriteSourceSize + {118,134} + textureRect + {{1637,236},{118,134}} + textureRotated + + + GameRule_Blackboard.png + + aliases + + spriteOffset + {0,0} + spriteSize + {644,793} + spriteSourceSize + {644,793} + textureRect + {{1,1},{644,793}} + textureRotated + + + GameRule_Button.png + + aliases + + spriteOffset + {0,0} + spriteSize + {210,119} + spriteSourceSize + {210,119} + textureRect + {{993,779},{210,119}} + textureRotated + + + GameRule_Decoration.png + + aliases + + spriteOffset + {0,1} + spriteSize + {543,117} + spriteSourceSize + {543,169} + textureRect + {{1222,117},{543,117}} + textureRotated + + + InGame_HighScoreTreasure.png + + aliases + + spriteOffset + {0,-1} + spriteSize + {56,58} + spriteSourceSize + {58,60} + textureRect + {{1162,359},{56,58}} + textureRotated + + + InGame_InfoBG.jpg + + aliases + + spriteOffset + {0,23} + spriteSize + {424,72} + spriteSourceSize + {500,500} + textureRect + {{1,912},{424,72}} + textureRotated + + + InGame_Joystick.png + + aliases + + spriteOffset + {0,0} + spriteSize + {48,48} + spriteSourceSize + {48,48} + textureRect + {{1805,923},{48,48}} + textureRotated + + + InGame_Joystick_bottom.png + + aliases + + spriteOffset + {0,0} + spriteSize + {80,80} + spriteSourceSize + {80,80} + textureRect + {{1928,849},{80,80}} + textureRotated + + + InGame_LowScoreTreasure.png + + aliases + + spriteOffset + {2,0} + spriteSize + {56,64} + spriteSourceSize + {64,64} + textureRect + {{1952,580},{56,64}} + textureRotated + + + InGame_ResultPanel_AgainButton.png + + aliases + + spriteOffset + {0,0} + spriteSize + {105,60} + spriteSourceSize + {105,60} + textureRect + {{1698,916},{105,60}} + textureRotated + + + InGame_ResultPanel_Background.png + + aliases + + spriteOffset + {0,0} + spriteSize + {287,272} + spriteSourceSize + {287,272} + textureRect + {{1663,377},{287,272}} + textureRotated + + + InGame_ResultPanel_HomeButton.png + + aliases + + spriteOffset + {0,0} + spriteSize + {105,60} + spriteSourceSize + {105,60} + textureRect + {{1842,783},{105,60}} + textureRotated + + + InGame_StatusBar_Blue.png + + aliases + + spriteOffset + {0,0} + spriteSize + {359,141} + spriteSourceSize + {359,141} + textureRect + {{1222,323},{359,141}} + textureRotated + + + InGame_StatusBar_Red.png + + aliases + + spriteOffset + {0,0} + spriteSize + {357,141} + spriteSourceSize + {357,141} + textureRect + {{1162,466},{357,141}} + textureRotated + + + InGame_Tower2.png + + aliases + + spriteOffset + {1,0} + spriteSize + {130,189} + spriteSourceSize + {132,189} + textureRect + {{1826,651},{130,189}} + textureRotated + + + Login_Logo.png + + aliases + + spriteOffset + {0,0} + spriteSize + {424,168} + spriteSourceSize + {424,168} + textureRect + {{647,609},{424,168}} + textureRotated + + + Login_Pacman.png + + aliases + + spriteOffset + {0,0} + spriteSize + {248,513} + spriteSourceSize + {366,513} + textureRect + {{647,359},{248,513}} + textureRotated + + + Players_Avatar1.jpg + + aliases + + spriteOffset + {0,0} + spriteSize + {140,140} + spriteSourceSize + {140,140} + textureRect + {{1383,609},{140,140}} + textureRotated + + + Players_Avatar2.jpg + + aliases + + spriteOffset + {0,0} + spriteSize + {140,140} + spriteSourceSize + {140,140} + textureRect + {{1521,466},{140,140}} + textureRotated + + + Players_Baseball.jpg + + aliases + + spriteOffset + {0,0} + spriteSize + {42,46} + spriteSourceSize + {42,46} + textureRect + {{1162,417},{42,46}} + textureRotated + + + Players_arrowTip.png + + aliases + + spriteOffset + {0,0} + spriteSize + {76,84} + spriteSourceSize + {76,84} + textureRect + {{1842,845},{76,84}} + textureRotated + + + PopupBg.png + + aliases + + spriteOffset + {0,0} + spriteSize + {308,153} + spriteSourceSize + {308,153} + textureRect + {{1073,609},{308,153}} + textureRotated + + + ResultPanel_Bg1v1.png + + aliases + + spriteOffset + {0,0} + spriteSize + {573,356} + spriteSourceSize + {573,356} + textureRect + {{647,1},{573,356}} + textureRotated + + + ResultPanel_Copper.png + + aliases + + spriteOffset + {0,0} + spriteSize + {206,42} + spriteSourceSize + {206,42} + textureRect + {{1506,751},{206,42}} + textureRotated + + + ResultPanel_Gold.png + + aliases + + spriteOffset + {0,0} + spriteSize + {207,43} + spriteSourceSize + {207,43} + textureRect + {{427,912},{207,43}} + textureRotated + + + ResultPanel_Iron.png + + aliases + + spriteOffset + {0,0} + spriteSize + {201,39} + spriteSourceSize + {201,39} + textureRect + {{1952,377},{201,39}} + textureRotated + + + ResultPanel_Silver.png + + aliases + + spriteOffset + {0,0} + spriteSize + {413,85} + spriteSourceSize + {413,85} + textureRect + {{1222,236},{413,85}} + textureRotated + + + Verification_Code.png + + aliases + + spriteOffset + {0,0} + spriteSize + {189,56} + spriteSourceSize + {189,56} + textureRect + {{1832,1},{189,56}} + textureRotated + + + Verification_Code_Grey.png + + aliases + + spriteOffset + {0,0} + spriteSize + {189,56} + spriteSourceSize + {189,56} + textureRect + {{1832,59},{189,56}} + textureRotated + + + WhiteStars.png + + aliases + + spriteOffset + {0,0} + spriteSize + {268,112} + spriteSourceSize + {268,112} + textureRect + {{1550,724},{268,112}} + textureRotated + + + exit.jpg + + aliases + + spriteOffset + {0,0} + spriteSize + {64,64} + spriteSourceSize + {64,64} + textureRect + {{1949,783},{64,64}} + textureRotated + + + login2.png + + aliases + + spriteOffset + {0,0} + spriteSize + {146,59} + spriteSourceSize + {146,59} + textureRect + {{1550,916},{146,59}} + textureRotated + + + phone.png + + aliases + + spriteOffset + {0,0} + spriteSize + {290,76} + spriteSourceSize + {290,76} + textureRect + {{1550,838},{290,76}} + textureRotated + + + + metadata + + format + 3 + pixelFormat + RGBA8888 + premultiplyAlpha + + realTextureFileName + GuiElements_0.png + size + {2022,990} + smartupdate + $TexturePacker:SmartUpdate:e5e4012d3a559f9501f4cb19a7bea3c5:821d635fecb489cec5f6ffd15d091ea2:dc9a5be97839fbd50fd8575bd48970fd$ + textureFileName + GuiElements_0.png + + + diff --git a/frontend/assets/resources/textures/GuiElements_0.plist.meta b/frontend/assets/resources/textures/GuiElements_0.plist.meta new file mode 100644 index 0000000..272b217 --- /dev/null +++ b/frontend/assets/resources/textures/GuiElements_0.plist.meta @@ -0,0 +1,936 @@ +{ + "ver": "1.2.4", + "uuid": "030d9286-e8a2-40cf-98f8-baf713f0b8c4", + "rawTextureUuid": "8f30ce68-ec25-459e-b6e4-3eb4f3a211a5", + "size": { + "width": 2022, + "height": 990 + }, + "type": "Texture Packer", + "subMetas": { + "BaseBoard.png": { + "ver": "1.0.4", + "uuid": "637f31c2-c53e-4dec-ae11-d56c0c6177ad", + "rawTextureUuid": "8f30ce68-ec25-459e-b6e4-3eb4f3a211a5", + "trimType": "auto", + "trimThreshold": 1, + "rotated": true, + "offsetX": 0, + "offsetY": 0, + "trimX": 1460, + "trimY": 751, + "width": 232, + "height": 44, + "rawWidth": 232, + "rawHeight": 44, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "ButtonActive.png": { + "ver": "1.0.4", + "uuid": "ef0ce43c-ad0d-4f7a-adad-ccdc3b07da45", + "rawTextureUuid": "8f30ce68-ec25-459e-b6e4-3eb4f3a211a5", + "trimType": "auto", + "trimThreshold": 1, + "rotated": true, + "offsetX": 0, + "offsetY": 0, + "trimX": 1583, + "trimY": 323, + "width": 94, + "height": 44, + "rawWidth": 94, + "rawHeight": 44, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "ButtonNegative.png": { + "ver": "1.0.4", + "uuid": "08935a3f-220c-4440-bb99-5576598b3601", + "rawTextureUuid": "8f30ce68-ec25-459e-b6e4-3eb4f3a211a5", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1525, + "trimY": 608, + "width": 90, + "height": 40, + "rawWidth": 90, + "rawHeight": 40, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "Captcha.png": { + "ver": "1.0.4", + "uuid": "1be42d0a-f3c9-4368-a6cb-c55164166f80", + "rawTextureUuid": "8f30ce68-ec25-459e-b6e4-3eb4f3a211a5", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1525, + "trimY": 651, + "width": 299, + "height": 71, + "rawWidth": 299, + "rawHeight": 71, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "Clock.png": { + "ver": "1.0.4", + "uuid": "75a2c1e3-2c22-480c-9572-eb65f4a554e1", + "rawTextureUuid": "8f30ce68-ec25-459e-b6e4-3eb4f3a211a5", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1767, + "trimY": 117, + "width": 254, + "height": 258, + "rawWidth": 254, + "rawHeight": 258, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "FindingPlayer_DecorationDown.png": { + "ver": "1.0.4", + "uuid": "3aefb317-71e0-44e1-a7f1-69d8b08e3310", + "rawTextureUuid": "8f30ce68-ec25-459e-b6e4-3eb4f3a211a5", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1, + "trimY": 796, + "width": 608, + "height": 114, + "rawWidth": 608, + "rawHeight": 114, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "FindingPlayer_DecorationUp.png": { + "ver": "1.0.4", + "uuid": "eee6cdea-8b25-4855-8b72-8d68fc3b3988", + "rawTextureUuid": "8f30ce68-ec25-459e-b6e4-3eb4f3a211a5", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1222, + "trimY": 1, + "width": 608, + "height": 114, + "rawWidth": 608, + "rawHeight": 114, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "FindingPlayer_PlayerLeft.png": { + "ver": "1.0.4", + "uuid": "e5936983-59d7-4a82-9079-4c758551ece9", + "rawTextureUuid": "8f30ce68-ec25-459e-b6e4-3eb4f3a211a5", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1114, + "trimY": 764, + "width": 344, + "height": 200, + "rawWidth": 344, + "rawHeight": 200, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "FindingPlayer_PlayerRight.png": { + "ver": "1.0.4", + "uuid": "a373e215-1826-41ed-b3f4-a9b1407739bc", + "rawTextureUuid": "8f30ce68-ec25-459e-b6e4-3eb4f3a211a5", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 647, + "trimY": 779, + "width": 344, + "height": 210, + "rawWidth": 344, + "rawHeight": 210, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "FindingPlayer_vs.png": { + "ver": "1.0.4", + "uuid": "c35d7a88-2a8b-4d5e-a6ab-599264006ecd", + "rawTextureUuid": "8f30ce68-ec25-459e-b6e4-3eb4f3a211a5", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1637, + "trimY": 236, + "width": 118, + "height": 134, + "rawWidth": 118, + "rawHeight": 134, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "GameRule_Blackboard.png": { + "ver": "1.0.4", + "uuid": "0fe43223-61fc-4cb8-95bd-bd9e8f01ce8f", + "rawTextureUuid": "8f30ce68-ec25-459e-b6e4-3eb4f3a211a5", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1, + "trimY": 1, + "width": 644, + "height": 793, + "rawWidth": 644, + "rawHeight": 793, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "GameRule_Button.png": { + "ver": "1.0.4", + "uuid": "081ad337-20ca-4313-ae3e-bb6dee3547b7", + "rawTextureUuid": "8f30ce68-ec25-459e-b6e4-3eb4f3a211a5", + "trimType": "auto", + "trimThreshold": 1, + "rotated": true, + "offsetX": 0, + "offsetY": 0, + "trimX": 993, + "trimY": 779, + "width": 210, + "height": 119, + "rawWidth": 210, + "rawHeight": 119, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "GameRule_Decoration.png": { + "ver": "1.0.4", + "uuid": "153d890a-fc37-4d59-8779-93a8fb19fa85", + "rawTextureUuid": "8f30ce68-ec25-459e-b6e4-3eb4f3a211a5", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 1, + "trimX": 1222, + "trimY": 117, + "width": 543, + "height": 117, + "rawWidth": 543, + "rawHeight": 169, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "InGame_HighScoreTreasure.png": { + "ver": "1.0.4", + "uuid": "cc1486e4-5c38-4a73-a0d3-70416d0dd57f", + "rawTextureUuid": "8f30ce68-ec25-459e-b6e4-3eb4f3a211a5", + "trimType": "auto", + "trimThreshold": 1, + "rotated": true, + "offsetX": 0, + "offsetY": -1, + "trimX": 1162, + "trimY": 359, + "width": 56, + "height": 58, + "rawWidth": 58, + "rawHeight": 60, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "InGame_InfoBG.jpg": { + "ver": "1.0.4", + "uuid": "d812cf3d-1f87-4ca6-a435-c2b5c5e4ed1e", + "rawTextureUuid": "8f30ce68-ec25-459e-b6e4-3eb4f3a211a5", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 23, + "trimX": 1, + "trimY": 912, + "width": 424, + "height": 72, + "rawWidth": 500, + "rawHeight": 500, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "InGame_Joystick.png": { + "ver": "1.0.4", + "uuid": "7d4baacd-294c-4a5d-9cd6-5d36e4394c9e", + "rawTextureUuid": "8f30ce68-ec25-459e-b6e4-3eb4f3a211a5", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1805, + "trimY": 923, + "width": 48, + "height": 48, + "rawWidth": 48, + "rawHeight": 48, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "InGame_Joystick_bottom.png": { + "ver": "1.0.4", + "uuid": "447f7cfe-e678-4424-be03-0afdab8659de", + "rawTextureUuid": "8f30ce68-ec25-459e-b6e4-3eb4f3a211a5", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1928, + "trimY": 849, + "width": 80, + "height": 80, + "rawWidth": 80, + "rawHeight": 80, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "InGame_LowScoreTreasure.png": { + "ver": "1.0.4", + "uuid": "69fa5b02-211c-4f30-8518-764440265567", + "rawTextureUuid": "8f30ce68-ec25-459e-b6e4-3eb4f3a211a5", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 2, + "offsetY": 0, + "trimX": 1952, + "trimY": 580, + "width": 56, + "height": 64, + "rawWidth": 64, + "rawHeight": 64, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "InGame_ResultPanel_AgainButton.png": { + "ver": "1.0.4", + "uuid": "37cdf925-4518-44e0-98b4-9d0423bd7989", + "rawTextureUuid": "8f30ce68-ec25-459e-b6e4-3eb4f3a211a5", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1698, + "trimY": 916, + "width": 105, + "height": 60, + "rawWidth": 105, + "rawHeight": 60, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "InGame_ResultPanel_Background.png": { + "ver": "1.0.4", + "uuid": "d1581e56-4a64-466f-beb9-5f09319bcf5e", + "rawTextureUuid": "8f30ce68-ec25-459e-b6e4-3eb4f3a211a5", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1663, + "trimY": 377, + "width": 287, + "height": 272, + "rawWidth": 287, + "rawHeight": 272, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "InGame_ResultPanel_HomeButton.png": { + "ver": "1.0.4", + "uuid": "88d833ba-15fb-4a42-95ee-c55fe6628ed2", + "rawTextureUuid": "8f30ce68-ec25-459e-b6e4-3eb4f3a211a5", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1842, + "trimY": 783, + "width": 105, + "height": 60, + "rawWidth": 105, + "rawHeight": 60, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "InGame_StatusBar_Blue.png": { + "ver": "1.0.4", + "uuid": "d7a9288a-d75a-4a4a-b018-0cda2d7639c7", + "rawTextureUuid": "8f30ce68-ec25-459e-b6e4-3eb4f3a211a5", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1222, + "trimY": 323, + "width": 359, + "height": 141, + "rawWidth": 359, + "rawHeight": 141, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "InGame_StatusBar_Red.png": { + "ver": "1.0.4", + "uuid": "9af48a68-a401-4c92-aa12-2936e69dd5e3", + "rawTextureUuid": "8f30ce68-ec25-459e-b6e4-3eb4f3a211a5", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1162, + "trimY": 466, + "width": 357, + "height": 141, + "rawWidth": 357, + "rawHeight": 141, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "InGame_Tower2.png": { + "ver": "1.0.4", + "uuid": "8d6a4551-03cc-406a-93e5-aa2edd79dce4", + "rawTextureUuid": "8f30ce68-ec25-459e-b6e4-3eb4f3a211a5", + "trimType": "auto", + "trimThreshold": 1, + "rotated": true, + "offsetX": 1, + "offsetY": 0, + "trimX": 1826, + "trimY": 651, + "width": 130, + "height": 189, + "rawWidth": 132, + "rawHeight": 189, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "Login_Logo.png": { + "ver": "1.0.4", + "uuid": "9e564509-0a36-4f01-a833-79ff8f2e8328", + "rawTextureUuid": "8f30ce68-ec25-459e-b6e4-3eb4f3a211a5", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 647, + "trimY": 609, + "width": 424, + "height": 168, + "rawWidth": 424, + "rawHeight": 168, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "Login_Pacman.png": { + "ver": "1.0.4", + "uuid": "2158ddd8-02de-47c2-ade8-f701288c22e5", + "rawTextureUuid": "8f30ce68-ec25-459e-b6e4-3eb4f3a211a5", + "trimType": "auto", + "trimThreshold": 1, + "rotated": true, + "offsetX": 0, + "offsetY": 0, + "trimX": 647, + "trimY": 359, + "width": 248, + "height": 513, + "rawWidth": 366, + "rawHeight": 513, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "Players_Avatar1.jpg": { + "ver": "1.0.4", + "uuid": "2c1cb245-613a-4b30-bcdc-87b4a4214bb0", + "rawTextureUuid": "8f30ce68-ec25-459e-b6e4-3eb4f3a211a5", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1383, + "trimY": 609, + "width": 140, + "height": 140, + "rawWidth": 140, + "rawHeight": 140, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "Players_Avatar2.jpg": { + "ver": "1.0.4", + "uuid": "36708165-94a2-43d1-b5f3-1cfc4555ee2a", + "rawTextureUuid": "8f30ce68-ec25-459e-b6e4-3eb4f3a211a5", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1521, + "trimY": 466, + "width": 140, + "height": 140, + "rawWidth": 140, + "rawHeight": 140, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "Players_Baseball.jpg": { + "ver": "1.0.4", + "uuid": "350fd890-3d28-4e53-9dfa-1bf00d857737", + "rawTextureUuid": "8f30ce68-ec25-459e-b6e4-3eb4f3a211a5", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1162, + "trimY": 417, + "width": 42, + "height": 46, + "rawWidth": 42, + "rawHeight": 46, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "Players_arrowTip.png": { + "ver": "1.0.4", + "uuid": "a2170e4c-df31-41ef-be73-f4f605e75821", + "rawTextureUuid": "8f30ce68-ec25-459e-b6e4-3eb4f3a211a5", + "trimType": "auto", + "trimThreshold": 1, + "rotated": true, + "offsetX": 0, + "offsetY": 0, + "trimX": 1842, + "trimY": 845, + "width": 76, + "height": 84, + "rawWidth": 76, + "rawHeight": 84, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "PopupBg.png": { + "ver": "1.0.4", + "uuid": "919690f3-9e98-4dca-88cf-ee33db7150cb", + "rawTextureUuid": "8f30ce68-ec25-459e-b6e4-3eb4f3a211a5", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1073, + "trimY": 609, + "width": 308, + "height": 153, + "rawWidth": 308, + "rawHeight": 153, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "ResultPanel_Bg1v1.png": { + "ver": "1.0.4", + "uuid": "07225a7f-587f-4e0e-907a-ca9f06cf77a5", + "rawTextureUuid": "8f30ce68-ec25-459e-b6e4-3eb4f3a211a5", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 647, + "trimY": 1, + "width": 573, + "height": 356, + "rawWidth": 573, + "rawHeight": 356, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "ResultPanel_Copper.png": { + "ver": "1.0.4", + "uuid": "70dae15c-39ae-4d74-96bb-8dde66090ba6", + "rawTextureUuid": "8f30ce68-ec25-459e-b6e4-3eb4f3a211a5", + "trimType": "auto", + "trimThreshold": 1, + "rotated": true, + "offsetX": 0, + "offsetY": 0, + "trimX": 1506, + "trimY": 751, + "width": 206, + "height": 42, + "rawWidth": 206, + "rawHeight": 42, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "ResultPanel_Gold.png": { + "ver": "1.0.4", + "uuid": "9fc079f3-756f-4a2a-91d8-0bfff986bf3b", + "rawTextureUuid": "8f30ce68-ec25-459e-b6e4-3eb4f3a211a5", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 427, + "trimY": 912, + "width": 207, + "height": 43, + "rawWidth": 207, + "rawHeight": 43, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "ResultPanel_Iron.png": { + "ver": "1.0.4", + "uuid": "551d804b-78b0-46ff-a374-a74063af4444", + "rawTextureUuid": "8f30ce68-ec25-459e-b6e4-3eb4f3a211a5", + "trimType": "auto", + "trimThreshold": 1, + "rotated": true, + "offsetX": 0, + "offsetY": 0, + "trimX": 1952, + "trimY": 377, + "width": 201, + "height": 39, + "rawWidth": 201, + "rawHeight": 39, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "ResultPanel_Silver.png": { + "ver": "1.0.4", + "uuid": "72e26a0c-7b83-4e74-a8d2-e5597b16214d", + "rawTextureUuid": "8f30ce68-ec25-459e-b6e4-3eb4f3a211a5", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1222, + "trimY": 236, + "width": 413, + "height": 85, + "rawWidth": 413, + "rawHeight": 85, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "Verification_Code.png": { + "ver": "1.0.4", + "uuid": "137d0749-cf08-459d-8976-ebe5bd052637", + "rawTextureUuid": "8f30ce68-ec25-459e-b6e4-3eb4f3a211a5", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1832, + "trimY": 1, + "width": 189, + "height": 56, + "rawWidth": 189, + "rawHeight": 56, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "Verification_Code_Grey.png": { + "ver": "1.0.4", + "uuid": "ab4283be-3935-44c5-b12a-9458aef99953", + "rawTextureUuid": "8f30ce68-ec25-459e-b6e4-3eb4f3a211a5", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1832, + "trimY": 59, + "width": 189, + "height": 56, + "rawWidth": 189, + "rawHeight": 56, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "WhiteStars.png": { + "ver": "1.0.4", + "uuid": "1a2d934e-9d6d-45bf-83c6-564586cc8400", + "rawTextureUuid": "8f30ce68-ec25-459e-b6e4-3eb4f3a211a5", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1550, + "trimY": 724, + "width": 268, + "height": 112, + "rawWidth": 268, + "rawHeight": 112, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "exit.jpg": { + "ver": "1.0.4", + "uuid": "bec0b8cf-0f82-47b9-808e-13bb713a3ede", + "rawTextureUuid": "8f30ce68-ec25-459e-b6e4-3eb4f3a211a5", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1949, + "trimY": 783, + "width": 64, + "height": 64, + "rawWidth": 64, + "rawHeight": 64, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "login2.png": { + "ver": "1.0.4", + "uuid": "04ebd3d5-0550-409e-b815-81219667f1fa", + "rawTextureUuid": "8f30ce68-ec25-459e-b6e4-3eb4f3a211a5", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1550, + "trimY": 916, + "width": 146, + "height": 59, + "rawWidth": 146, + "rawHeight": 59, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "phone.png": { + "ver": "1.0.4", + "uuid": "75a4d771-f3f7-4ff2-8e23-e7b3d54e7bea", + "rawTextureUuid": "8f30ce68-ec25-459e-b6e4-3eb4f3a211a5", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 1550, + "trimY": 838, + "width": 290, + "height": 76, + "rawWidth": 290, + "rawHeight": 76, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + } + } +} \ No newline at end of file diff --git a/frontend/assets/resources/textures/GuiElements_0.png b/frontend/assets/resources/textures/GuiElements_0.png new file mode 100644 index 0000000..050cd94 Binary files /dev/null and b/frontend/assets/resources/textures/GuiElements_0.png differ diff --git a/frontend/assets/resources/textures/GuiElements_0.png.meta b/frontend/assets/resources/textures/GuiElements_0.png.meta new file mode 100644 index 0000000..66ac6f2 --- /dev/null +++ b/frontend/assets/resources/textures/GuiElements_0.png.meta @@ -0,0 +1,34 @@ +{ + "ver": "2.3.3", + "uuid": "8f30ce68-ec25-459e-b6e4-3eb4f3a211a5", + "type": "sprite", + "wrapMode": "clamp", + "filterMode": "bilinear", + "premultiplyAlpha": false, + "genMipmaps": false, + "packable": true, + "platformSettings": {}, + "subMetas": { + "GuiElements_0": { + "ver": "1.0.4", + "uuid": "f94dc513-abd3-40ff-ae77-70bf09e6f553", + "rawTextureUuid": "8f30ce68-ec25-459e-b6e4-3eb4f3a211a5", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 0, + "trimY": 0, + "width": 2022, + "height": 990, + "rawWidth": 2022, + "rawHeight": 990, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "subMetas": {} + } + } +} \ No newline at end of file diff --git a/frontend/assets/resources/textures/MiniGame_Background.png b/frontend/assets/resources/textures/MiniGame_Background.png new file mode 100644 index 0000000..9be7f77 Binary files /dev/null and b/frontend/assets/resources/textures/MiniGame_Background.png differ diff --git a/frontend/assets/resources/textures/MiniGame_Background.png.meta b/frontend/assets/resources/textures/MiniGame_Background.png.meta new file mode 100644 index 0000000..258952a --- /dev/null +++ b/frontend/assets/resources/textures/MiniGame_Background.png.meta @@ -0,0 +1,34 @@ +{ + "ver": "2.3.3", + "uuid": "825df908-a4cb-449d-9731-8ef53f3fd44f", + "type": "sprite", + "wrapMode": "clamp", + "filterMode": "bilinear", + "premultiplyAlpha": false, + "genMipmaps": false, + "packable": true, + "platformSettings": {}, + "subMetas": { + "MiniGame_Background": { + "ver": "1.0.4", + "uuid": "7838f276-ab48-445a-b858-937dd27d9520", + "rawTextureUuid": "825df908-a4cb-449d-9731-8ef53f3fd44f", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 0, + "trimY": 0, + "width": 750, + "height": 1624, + "rawWidth": 750, + "rawHeight": 1624, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "subMetas": {} + } + } +} \ No newline at end of file diff --git a/frontend/assets/resources/textures/MiniGame_Blackboard.png b/frontend/assets/resources/textures/MiniGame_Blackboard.png new file mode 100644 index 0000000..85ff815 Binary files /dev/null and b/frontend/assets/resources/textures/MiniGame_Blackboard.png differ diff --git a/frontend/assets/resources/textures/MiniGame_Blackboard.png.meta b/frontend/assets/resources/textures/MiniGame_Blackboard.png.meta new file mode 100644 index 0000000..c9b2518 --- /dev/null +++ b/frontend/assets/resources/textures/MiniGame_Blackboard.png.meta @@ -0,0 +1,34 @@ +{ + "ver": "2.3.3", + "uuid": "94b8bb09-e8ac-4402-a933-b79f01b5a813", + "type": "sprite", + "wrapMode": "clamp", + "filterMode": "bilinear", + "premultiplyAlpha": false, + "genMipmaps": false, + "packable": true, + "platformSettings": {}, + "subMetas": { + "MiniGame_Blackboard": { + "ver": "1.0.4", + "uuid": "334d4f93-b007-49e8-9268-35891d4f4ebb", + "rawTextureUuid": "94b8bb09-e8ac-4402-a933-b79f01b5a813", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 0, + "trimY": 0, + "width": 1024, + "height": 1920, + "rawWidth": 1024, + "rawHeight": 1920, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "subMetas": {} + } + } +} \ No newline at end of file diff --git a/frontend/assets/scenes.meta b/frontend/assets/scenes.meta new file mode 100644 index 0000000..b3ab967 --- /dev/null +++ b/frontend/assets/scenes.meta @@ -0,0 +1,5 @@ +{ + "ver": "1.0.1", + "uuid": "8c047451-39ef-4152-8134-b019287bff60", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/scenes/default_map.fire b/frontend/assets/scenes/default_map.fire new file mode 100644 index 0000000..dd082a9 --- /dev/null +++ b/frontend/assets/scenes/default_map.fire @@ -0,0 +1,1652 @@ +[ + { + "__type__": "cc.SceneAsset", + "_name": "", + "_objFlags": 0, + "_native": "", + "scene": { + "__id__": 1 + } + }, + { + "__type__": "cc.Scene", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + } + ], + "_active": false, + "_components": [], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_is3DNode": true, + "_groupIndex": 0, + "groupIndex": 0, + "autoReleaseAssets": false, + "_id": "92160186-3e0d-4e0a-ae20-97286170ba58" + }, + { + "__type__": "cc.Node", + "_name": "Canvas", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 3 + }, + { + "__id__": 5 + }, + { + "__id__": 10 + } + ], + "_active": true, + "_components": [ + { + "__id__": 34 + }, + { + "__id__": 35 + }, + { + "__id__": 36 + }, + { + "__id__": 37 + }, + { + "__id__": 38 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 1024, + "height": 1920 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 512, + 960, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "daDUxCjRFEHak7fx7LvgSJ" + }, + { + "__type__": "cc.Node", + "_name": "BackgroundMap", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 4 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "e5aYJXDGZJFIN3+Qa0Msap" + }, + { + "__type__": "cc.TiledMap", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 3 + }, + "_enabled": true, + "_tmxFile": null, + "_id": "19rX2IPNVFHLVxuIoHEHCh" + }, + { + "__type__": "cc.Node", + "_name": "Map", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 6 + }, + { + "__id__": 7 + }, + { + "__id__": 33 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 3200, + "height": 3200 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "79f0Sv9OVGwbY3M3efHnGf" + }, + { + "__type__": "cc.TiledMap", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 5 + }, + "_enabled": true, + "_tmxFile": null, + "_id": "c8MqKDLJdKz7VhPwMjScDw" + }, + { + "__type__": "41d30TOamhNLZKrUhneboY4", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 5 + }, + "_enabled": true, + "useDiffFrameAlgo": true, + "canvasNode": { + "__id__": 2 + }, + "tiledAnimPrefab": { + "__uuid__": "1c02b0a0-859a-4467-86b3-ca39c30d1e19" + }, + "player1Prefab": { + "__uuid__": "8a738d50-1dac-4b6e-99e1-d241f5ee7169" + }, + "player2Prefab": { + "__uuid__": "1f479636-9eb8-4612-8f97-371964d6eae3" + }, + "treasurePrefab": { + "__uuid__": "ec3f3234-9b84-43c2-a3cd-58b924cce8e5" + }, + "trapPrefab": { + "__uuid__": "9f340a31-ddfa-46c2-94c7-d11615aedcb1" + }, + "speedShoePrefab": null, + "polygonBoundaryBarrierPrefab": { + "__uuid__": "4154eec0-d644-482f-a889-c00ae6b69958" + }, + "polygonBoundaryShelterPrefab": { + "__uuid__": "f820a6ec-e7a9-46cf-9b8a-331aa3e21487" + }, + "polygonBoundaryShelterZReducerPrefab": { + "__uuid__": "a36d024b-a979-4d18-b089-19af313ffb82" + }, + "keyboardInputControllerNode": { + "__id__": 8 + }, + "joystickInputControllerNode": { + "__id__": 22 + }, + "confirmLogoutPrefab": { + "__uuid__": "8e8c1a65-623d-42ba-97a7-820ce518ea11" + }, + "simplePressToGoDialogPrefab": { + "__uuid__": "670b477e-61a1-4778-879b-35913f7c79d2" + }, + "boundRoomIdLabel": { + "__id__": 17 + }, + "countdownLabel": { + "__id__": 30 + }, + "trapBulletPrefab": { + "__uuid__": "7673e0e4-bebd-4caa-8a10-a6e1e86f1b2f" + }, + "resultPanelPrefab": { + "__uuid__": "c4cfe3bd-c59e-4d5b-95cb-c933b120e184" + }, + "gameRulePrefab": { + "__uuid__": "32b8e752-8362-4783-a4a6-1160af8b7109" + }, + "findingPlayerPrefab": { + "__uuid__": "3ed4c7bc-79d0-4075-a563-d5a58ae798f9" + }, + "countdownToBeginGamePrefab": { + "__uuid__": "230eeb1f-e0f9-4a41-ab6c-05b3771cbf3e" + }, + "playersInfoPrefab": { + "__uuid__": "b4e519f4-e698-4403-9ff2-47b8dacb077e" + }, + "guardTowerPrefab": { + "__uuid__": "31a63530-7811-45bc-a4ee-571faf917e35" + }, + "forceBigEndianFloatingNumDecoding": false, + "backgroundMapTiledIns": { + "__id__": 4 + }, + "_id": "d12gkAmppNlIzqcRDELa91" + }, + { + "__type__": "cc.Node", + "_name": "KeyboardControlsMount", + "_objFlags": 0, + "_parent": { + "__id__": 9 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 31 + }, + { + "__id__": 32 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 50.4 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -341.33333, + -640, + 0, + 0, + 0, + 0, + 1, + 0.66667, + 0.66667, + 0.66667 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "e6nL+1zEhLmLSaT8R/9UgD" + }, + { + "__type__": "cc.Node", + "_name": "WidgetsAboveAll", + "_objFlags": 0, + "_parent": { + "__id__": 10 + }, + "_children": [ + { + "__id__": 12 + }, + { + "__id__": 8 + }, + { + "__id__": 22 + }, + { + "__id__": 29 + } + ], + "_active": true, + "_components": [], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "c6fPdAUURDX69j0zTeIFZv" + }, + { + "__type__": "cc.Node", + "_name": "Main Camera", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 9 + } + ], + "_active": true, + "_components": [ + { + "__id__": 11 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 217.54856073274254, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "76BOk0enxN+b20dtIJ3uk2" + }, + { + "__type__": "cc.Camera", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 10 + }, + "_enabled": true, + "_cullingMask": 4294967295, + "_clearFlags": 7, + "_backgroundColor": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_depth": -1, + "_zoomRatio": 1.5, + "_targetTexture": null, + "_fov": 60, + "_orthoSize": 10, + "_nearClip": 1, + "_farClip": 4096, + "_ortho": true, + "_rect": { + "__type__": "cc.Rect", + "x": 0, + "y": 0, + "width": 1, + "height": 1 + }, + "_renderStages": 1, + "_alignWithScreen": true, + "_id": "50qiPTLS9NhbPa+JZU0jOP" + }, + { + "__type__": "cc.Node", + "_name": "DebugInfo", + "_objFlags": 0, + "_parent": { + "__id__": 9 + }, + "_children": [ + { + "__id__": 13 + } + ], + "_active": true, + "_components": [ + { + "__id__": 20 + }, + { + "__id__": 21 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 350, + "height": 200 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -478, + 627, + 0, + 0, + 0, + 0, + 1, + 0.6666667, + 0.6666667, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "35scg40jVAnKrTPiei5ckg" + }, + { + "__type__": "cc.Node", + "_name": "RoomIdIndicator", + "_objFlags": 0, + "_parent": { + "__id__": 12 + }, + "_children": [ + { + "__id__": 14 + }, + { + "__id__": 16 + } + ], + "_active": false, + "_components": [ + { + "__id__": 18 + }, + { + "__id__": 19 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 350, + "height": 69 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 65.5, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "42q39o7JdDeo44PqyG5huG" + }, + { + "__type__": "cc.Node", + "_name": "label", + "_objFlags": 0, + "_parent": { + "__id__": 13 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 15 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 224.89, + "height": 28.44 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 25, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "58Hi1zcmtKhqBS3igsy6A6" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 14 + }, + "_enabled": true, + "_materials": [], + "_useOriginalSize": false, + "_string": "BoundRoomId: ", + "_N$string": "BoundRoomId: ", + "_fontSize": 32, + "_lineHeight": 32, + "_enableWrapText": true, + "_N$file": { + "__uuid__": "a564b3db-b8cb-48b4-952e-25bb56949116" + }, + "_isSystemFontUsed": false, + "_spacingX": 0, + "_batchAsBitmap": false, + "_N$horizontalAlign": 0, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 0, + "_id": "3eXMEBhBtGNrfp77JYEDbI" + }, + { + "__type__": "cc.Node", + "_name": "BoundRoomIdLabel", + "_objFlags": 0, + "_parent": { + "__id__": 13 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 17 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 79.11, + "height": 35.56 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 249.89, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "b74SOaDMVKbJWsJamlu76I" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 16 + }, + "_enabled": true, + "_materials": [], + "_useOriginalSize": false, + "_string": "1000", + "_N$string": "1000", + "_fontSize": 32, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": { + "__uuid__": "a564b3db-b8cb-48b4-952e-25bb56949116" + }, + "_isSystemFontUsed": false, + "_spacingX": 0, + "_batchAsBitmap": false, + "_N$horizontalAlign": 0, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 0, + "_id": "33t25REwBHiIuGC98Wghck" + }, + { + "__type__": "cc.Layout", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 13 + }, + "_enabled": true, + "_layoutSize": { + "__type__": "cc.Size", + "width": 350, + "height": 69 + }, + "_resize": 0, + "_N$layoutType": 1, + "_N$padding": 0, + "_N$cellSize": { + "__type__": "cc.Size", + "width": 40, + "height": 40 + }, + "_N$startAxis": 0, + "_N$paddingLeft": 25, + "_N$paddingRight": 0, + "_N$paddingTop": 0, + "_N$paddingBottom": 0, + "_N$spacingX": 0, + "_N$spacingY": 0, + "_N$verticalDirection": 1, + "_N$horizontalDirection": 0, + "_N$affectedByScale": false, + "_id": "200jOhipFAE4kpEfemNUPq" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 13 + }, + "_enabled": true, + "_materials": [], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "08935a3f-220c-4440-bb99-5576598b3601" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": { + "__uuid__": "030d9286-e8a2-40cf-98f8-baf713f0b8c4" + }, + "_id": "9d6b07ezVMV7QyD2GbJACM" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 12 + }, + "_enabled": true, + "_materials": [], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": null, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "23J6kOj4pKwZepTEB56AgU" + }, + { + "__type__": "cc.Layout", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 12 + }, + "_enabled": true, + "_layoutSize": { + "__type__": "cc.Size", + "width": 350, + "height": 200 + }, + "_resize": 0, + "_N$layoutType": 2, + "_N$padding": 0, + "_N$cellSize": { + "__type__": "cc.Size", + "width": 40, + "height": 40 + }, + "_N$startAxis": 0, + "_N$paddingLeft": 0, + "_N$paddingRight": 0, + "_N$paddingTop": 0, + "_N$paddingBottom": 0, + "_N$spacingX": 0, + "_N$spacingY": 0, + "_N$verticalDirection": 1, + "_N$horizontalDirection": 0, + "_N$affectedByScale": false, + "_id": "f6GkgYwn9JvKLqbGG1zmeD" + }, + { + "__type__": "cc.Node", + "_name": "JoystickContainer", + "_objFlags": 0, + "_parent": { + "__id__": 9 + }, + "_children": [ + { + "__id__": 23 + } + ], + "_active": true, + "_components": [ + { + "__id__": 28 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 1280, + "height": 640 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + -500, + 0, + 0, + 0, + 0, + 1, + 0.66667, + 0.66667, + 0.66667 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "81iBXkC0lFt5FFUUD0k3xE" + }, + { + "__type__": "cc.Node", + "_name": "JoystickBG", + "_objFlags": 0, + "_parent": { + "__id__": 22 + }, + "_children": [ + { + "__id__": 24 + } + ], + "_active": true, + "_components": [ + { + "__id__": 26 + }, + { + "__id__": 27 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 400, + "height": 400 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "88u3wQvvdO8pbrNWhs3ifP" + }, + { + "__type__": "cc.Node", + "_name": "Joystick", + "_objFlags": 0, + "_parent": { + "__id__": 23 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 25 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 150, + "height": 150 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 0.8, + 0.8, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "3eybpdW/JK3aDeXxdE86VD" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 24 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "7d4baacd-294c-4a5d-9cd6-5d36e4394c9e" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": { + "__uuid__": "030d9286-e8a2-40cf-98f8-baf713f0b8c4" + }, + "_id": "7dr8DOX01K7YFqWlRy1ATp" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 23 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "447f7cfe-e678-4424-be03-0afdab8659de" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": { + "__uuid__": "030d9286-e8a2-40cf-98f8-baf713f0b8c4" + }, + "_id": "b28Bh9ZcpM+7K3Bd3bmNf0" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 23 + }, + "_enabled": true, + "alignMode": 0, + "_target": null, + "_alignFlags": 0, + "_left": 40, + "_right": 0, + "_top": 0, + "_bottom": 10, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 0, + "_originalHeight": 0, + "_id": "c0cEsj4LpMcZZEldELidxy" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 22 + }, + "_enabled": true, + "alignMode": 0, + "_target": null, + "_alignFlags": 0, + "_left": 278, + "_right": 480.0000000000002, + "_top": 544, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 480, + "_originalHeight": 0, + "_id": "2cxYjEIwNO6rUtXX4WcfnV" + }, + { + "__type__": "cc.Node", + "_name": "CountdownSeconds", + "_objFlags": 0, + "_parent": { + "__id__": 9 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 30 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 88.2 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 591, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "f6HMd9ebFPppe/Lu0Ry/qk" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 29 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_useOriginalSize": false, + "_string": "", + "_N$string": "", + "_fontSize": 70, + "_lineHeight": 70, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 0, + "_id": "dfxSFl+shLcY+0v45FJtGo" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 8 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_useOriginalSize": false, + "_string": "", + "_N$string": "", + "_fontSize": 40, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 0, + "_id": "9cS5BRd+NKJIvGQiojJtIs" + }, + { + "__type__": "4561aFzv9JPZLe6iIzODk2d", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 8 + }, + "_enabled": true, + "_id": "5ahzSYC8pCCLVPCBYyCRfZ" + }, + { + "__type__": "09e1b/tEy5K2qaPIpqHDbae", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 5 + }, + "_enabled": true, + "BGMEffect": { + "__uuid__": "64a79efa-97de-4cb5-b2a9-01500c60573a" + }, + "crashedByTrapBullet": { + "__uuid__": "1d604e42-8cee-466f-884d-e74cae21ce3b" + }, + "highScoreTreasurePicked": { + "__uuid__": "0164d22c-d965-461f-867e-b30e2d56cc5c" + }, + "treasurePicked": { + "__uuid__": "7704b97e-6367-420c-b7af-d0750a2bbb30" + }, + "countDown10SecToEnd": { + "__uuid__": "261d1d7d-a5cc-4cb7-a737-194427055fd4" + }, + "mapNode": { + "__id__": 5 + }, + "_id": "3crA1nz5xPSLAnCSLQIPOq" + }, + { + "__type__": "cc.Canvas", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_designResolution": { + "__type__": "cc.Size", + "width": 1024, + "height": 1920 + }, + "_fitWidth": true, + "_fitHeight": false, + "_id": "94aSq7GcJJZ7A6IzMerm1J" + }, + { + "__type__": "8ac08Cb+Y1M/6ZsO9niGOzW", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "map": { + "__id__": 5 + }, + "_id": "84o2sgpN1NRqlN9x7mSzBj" + }, + { + "__type__": "78830/HTiVJoaf8n504g/J4", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "mapNode": { + "__id__": 5 + }, + "_id": "76ImpM7XtPSbiLHDXdsJa+" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "alignMode": 0, + "_target": null, + "_alignFlags": 0, + "_left": 6240, + "_right": -4000, + "_top": -8320, + "_bottom": 10880, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 960, + "_originalHeight": 640, + "_id": "a8lQ6mB8RMRajCXQCzw1kG" + }, + { + "__type__": "d34e3c4jd5NqYtg8ltL9QST", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "translationListenerNode": { + "__id__": 22 + }, + "zoomingListenerNode": { + "__id__": 5 + }, + "stickhead": { + "__id__": 24 + }, + "base": { + "__id__": 23 + }, + "joyStickEps": 0.1, + "magicLeanLowerBound": 0.414, + "magicLeanUpperBound": 2.414, + "pollerFps": 24, + "linearScaleFacBase": 1, + "minScale": 1, + "maxScale": 2, + "maxMovingBufferLength": 1, + "zoomingScaleFacBase": 0.1, + "zoomingSpeedBase": 4, + "linearSpeedBase": 320, + "canvasNode": { + "__id__": 2 + }, + "mapNode": { + "__id__": 5 + }, + "linearMovingEps": 0.1, + "scaleByEps": 0.0375, + "_id": "e9oVYTr7ROlpp/IrNjBUmR" + } +] \ No newline at end of file diff --git a/frontend/assets/scenes/default_map.fire.meta b/frontend/assets/scenes/default_map.fire.meta new file mode 100644 index 0000000..e140965 --- /dev/null +++ b/frontend/assets/scenes/default_map.fire.meta @@ -0,0 +1,7 @@ +{ + "ver": "1.2.5", + "uuid": "92160186-3e0d-4e0a-ae20-97286170ba58", + "asyncLoadAssets": false, + "autoReleaseAssets": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/scenes/login.fire b/frontend/assets/scenes/login.fire new file mode 100644 index 0000000..c6d4630 --- /dev/null +++ b/frontend/assets/scenes/login.fire @@ -0,0 +1,3044 @@ +[ + { + "__type__": "cc.SceneAsset", + "_name": "", + "_objFlags": 0, + "_native": "", + "scene": { + "__id__": 1 + } + }, + { + "__type__": "cc.Scene", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + } + ], + "_active": false, + "_components": [], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_is3DNode": true, + "_groupIndex": 0, + "groupIndex": 0, + "autoReleaseAssets": false, + "_id": "2ff474d9-0c9e-4fe3-87ec-fbff7cae85b4" + }, + { + "__type__": "cc.Node", + "_name": "Canvas", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 3 + }, + { + "__id__": 8 + }, + { + "__id__": 10 + } + ], + "_active": true, + "_components": [ + { + "__id__": 70 + }, + { + "__id__": 71 + }, + { + "__id__": 72 + }, + { + "__id__": 73 + }, + { + "__id__": 74 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 640, + "height": 960 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 320, + 480, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "88kscZWXFCIZtNFekdSP/o" + }, + { + "__type__": "cc.Node", + "_name": "Decorations", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 4 + }, + { + "__id__": 6 + } + ], + "_active": true, + "_components": [], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "543eYqjvJG+ZKirhLh4W2Y" + }, + { + "__type__": "cc.Node", + "_name": "Logo", + "_objFlags": 0, + "_parent": { + "__id__": 3 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 5 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 424, + "height": 168 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 280, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "b3iZA6nbJCvZ1rubgteVCn" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 4 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "9e564509-0a36-4f01-a833-79ff8f2e8328" + }, + "_type": 0, + "_sizeMode": 1, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": { + "__uuid__": "030d9286-e8a2-40cf-98f8-baf713f0b8c4" + }, + "_id": "8fNj4PkghOn4w9Pdy4dg/s" + }, + { + "__type__": "cc.Node", + "_name": "Pacman", + "_objFlags": 0, + "_parent": { + "__id__": 3 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 7 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 248, + "height": 513 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + -150, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "32QiJ7pbBM6YIX0w74cobD" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 6 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "2158ddd8-02de-47c2-ade8-f701288c22e5" + }, + "_type": 0, + "_sizeMode": 1, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": { + "__uuid__": "030d9286-e8a2-40cf-98f8-baf713f0b8c4" + }, + "_id": "30H49kyIhA3KVLCwuh/Lai" + }, + { + "__type__": "cc.Node", + "_name": "Main Camera", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 9 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 216.05530045313827, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "f1+7GE/nBJIrtiDgZie30q" + }, + { + "__type__": "cc.Camera", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 8 + }, + "_enabled": true, + "_cullingMask": 4294967295, + "_clearFlags": 0, + "_backgroundColor": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_depth": 0, + "_zoomRatio": 1, + "_targetTexture": null, + "_fov": 60, + "_orthoSize": 10, + "_nearClip": 1, + "_farClip": 4096, + "_ortho": true, + "_rect": { + "__type__": "cc.Rect", + "x": 0, + "y": 0, + "width": 1, + "height": 1 + }, + "_renderStages": 1, + "_alignWithScreen": true, + "_id": "7eS1XfnvVCVJh7J5AVbnd8" + }, + { + "__type__": "cc.Node", + "_name": "Content", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 11 + } + ], + "_active": true, + "_components": [ + { + "__id__": 69 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 640, + "height": 960 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "48KGkhVOtLobQ30k4nLOjt" + }, + { + "__type__": "cc.Node", + "_name": "InteractiveControls", + "_objFlags": 0, + "_parent": { + "__id__": 10 + }, + "_children": [ + { + "__id__": 12 + }, + { + "__id__": 20 + }, + { + "__id__": 25 + }, + { + "__id__": 34 + }, + { + "__id__": 39 + }, + { + "__id__": 48 + }, + { + "__id__": 56 + }, + { + "__id__": 63 + }, + { + "__id__": 65 + }, + { + "__id__": 67 + } + ], + "_active": true, + "_components": [], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + -532, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "19Dwzc6fRA1bpT9nM9X+eH" + }, + { + "__type__": "cc.Node", + "_name": "phoneCountryCodeInput", + "_objFlags": 0, + "_parent": { + "__id__": 11 + }, + "_children": [ + { + "__id__": 13 + }, + { + "__id__": 15 + }, + { + "__id__": 17 + } + ], + "_active": true, + "_components": [ + { + "__id__": 19 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 50, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -29, + 297, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "10oeHJMitLgZfpp0+7h0Mp" + }, + { + "__type__": "cc.Node", + "_name": "BACKGROUND_SPRITE", + "_objFlags": 0, + "_parent": { + "__id__": 12 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 14 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 50, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "c9nLK54alKXLhW3UDlF3XE" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 13 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "67e68bc9-dad5-4ad9-a2d8-7e03d458e32f" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "87udZUmzFOw4EDXrhHuPsB" + }, + { + "__type__": "cc.Node", + "_name": "TEXT_LABEL", + "_objFlags": 0, + "_parent": { + "__id__": 12 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 16 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 48, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 1 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -23, + 20, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "7eCINxaS5EObF0HZZWCZm4" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 15 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_useOriginalSize": false, + "_string": "86", + "_N$string": "86", + "_fontSize": 30, + "_lineHeight": 40, + "_enableWrapText": false, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_N$horizontalAlign": 0, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 1, + "_N$cacheMode": 0, + "_id": "62R5SboSRC3YbmRo5d+Pwt" + }, + { + "__type__": "cc.Node", + "_name": "PLACEHOLDER_LABEL", + "_objFlags": 0, + "_parent": { + "__id__": 12 + }, + "_children": [], + "_active": false, + "_components": [ + { + "__id__": 18 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 127, + "g": 127, + "b": 127, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 48, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 1 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -23, + 20, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "f6R/9Y+vBO2IlrbsduaxI/" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 17 + }, + "_enabled": true, + "_materials": [], + "_useOriginalSize": true, + "_string": "86", + "_N$string": "86", + "_fontSize": 16, + "_lineHeight": 40, + "_enableWrapText": false, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_N$horizontalAlign": 0, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 1, + "_N$cacheMode": 0, + "_id": "0eQY5lUhVEEYi5Dt3xMRlC" + }, + { + "__type__": "cc.EditBox", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 12 + }, + "_enabled": true, + "_useOriginalSize": false, + "_string": "86", + "returnType": 0, + "maxLength": 3, + "_tabIndex": 0, + "editingDidBegan": [], + "textChanged": [], + "editingDidEnded": [], + "editingReturn": [], + "_N$textLabel": { + "__id__": 16 + }, + "_N$placeholderLabel": { + "__id__": 18 + }, + "_N$background": { + "__id__": 14 + }, + "_N$inputFlag": 5, + "_N$inputMode": 3, + "_N$stayOnTop": false, + "_id": "71XNi5FQFCw7l6JryYXUTi" + }, + { + "__type__": "cc.Node", + "_name": "phoneLabel", + "_objFlags": 0, + "_parent": { + "__id__": 11 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 21 + }, + { + "__id__": 22 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 200, + "height": 50 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -172, + 304, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "e2HPaXYzlLsroEsJVRx00u" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 20 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "75a4d771-f3f7-4ff2-8e23-e7b3d54e7bea" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": { + "__uuid__": "030d9286-e8a2-40cf-98f8-baf713f0b8c4" + }, + "_id": "d4v7QgJWBFY4GJfIHTQrt6" + }, + { + "__type__": "f34ac2GGiVOBbG6XlfvgYP4", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 20 + }, + "_enabled": true, + "spriteFrameSet": [ + { + "__id__": 23 + }, + { + "__id__": 24 + } + ], + "_id": "87LFMyQI9EG79QU5V08l92" + }, + { + "__type__": "SpriteFrameSet", + "language": "zh", + "spriteFrame": { + "__uuid__": "75a4d771-f3f7-4ff2-8e23-e7b3d54e7bea" + } + }, + { + "__type__": "SpriteFrameSet", + "language": "en", + "spriteFrame": { + "__uuid__": "75a4d771-f3f7-4ff2-8e23-e7b3d54e7bea" + } + }, + { + "__type__": "cc.Node", + "_name": "phoneNumberInput", + "_objFlags": 0, + "_parent": { + "__id__": 11 + }, + "_children": [ + { + "__id__": 26 + }, + { + "__id__": 28 + }, + { + "__id__": 30 + } + ], + "_active": true, + "_components": [ + { + "__id__": 33 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 220, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 118, + 297, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "f4uA8VaoZK+KlLm0IVdbgM" + }, + { + "__type__": "cc.Node", + "_name": "BACKGROUND_SPRITE", + "_objFlags": 0, + "_parent": { + "__id__": 25 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 27 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 220, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "3dTQ9DoJ9HN4d0EOLbLkbi" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 26 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "67e68bc9-dad5-4ad9-a2d8-7e03d458e32f" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "278kNAtk5HO4FU0/Be1ZdK" + }, + { + "__type__": "cc.Node", + "_name": "TEXT_LABEL", + "_objFlags": 0, + "_parent": { + "__id__": 25 + }, + "_children": [], + "_active": false, + "_components": [ + { + "__id__": 29 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 218, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 1 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -108, + 20, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "c7TcdPC+xDP5KvDPM8g5Kv" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 28 + }, + "_enabled": true, + "_materials": [], + "_useOriginalSize": true, + "_string": "", + "_N$string": "", + "_fontSize": 30, + "_lineHeight": 40, + "_enableWrapText": false, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_N$horizontalAlign": 0, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 1, + "_N$cacheMode": 0, + "_id": "ca09O5EFVNBZEXLjIgKglZ" + }, + { + "__type__": "cc.Node", + "_name": "PLACEHOLDER_LABEL", + "_objFlags": 0, + "_parent": { + "__id__": 25 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 31 + }, + { + "__id__": 32 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 127, + "g": 127, + "b": 127, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 218, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 1 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -108, + 20, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "dcJcVMULhEbLUfXQ2CduE2" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 30 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_useOriginalSize": false, + "_string": "login.hint.phoneInputHint", + "_N$string": "login.hint.phoneInputHint", + "_fontSize": 14, + "_lineHeight": 40, + "_enableWrapText": false, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_N$horizontalAlign": 0, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 1, + "_N$cacheMode": 0, + "_id": "b2UQqbnDtBFYAVGkwKQTcC" + }, + { + "__type__": "744dcs4DCdNprNhG0xwq6FK", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 30 + }, + "_enabled": true, + "_dataID": "login.hint.phoneInputHint", + "_id": "3b2gd3LGBL+poY2CHLsrcv" + }, + { + "__type__": "cc.EditBox", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 25 + }, + "_enabled": true, + "_useOriginalSize": false, + "_string": "", + "returnType": 0, + "maxLength": 11, + "_tabIndex": 0, + "editingDidBegan": [], + "textChanged": [], + "editingDidEnded": [], + "editingReturn": [], + "_N$textLabel": { + "__id__": 29 + }, + "_N$placeholderLabel": { + "__id__": 31 + }, + "_N$background": { + "__id__": 27 + }, + "_N$inputFlag": 5, + "_N$inputMode": 1, + "_N$stayOnTop": false, + "_id": "a3uaCqba1Ha6RZRtWvIMXG" + }, + { + "__type__": "cc.Node", + "_name": " smsLoginCaptchaLabel", + "_objFlags": 0, + "_parent": { + "__id__": 11 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 35 + }, + { + "__id__": 36 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 200, + "height": 50 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -172, + 243, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "2ffLf+D7hMeJm835QKJKge" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 34 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "1be42d0a-f3c9-4368-a6cb-c55164166f80" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": { + "__uuid__": "030d9286-e8a2-40cf-98f8-baf713f0b8c4" + }, + "_id": "fcHNW5ckRCOIFqx3pn/ZLm" + }, + { + "__type__": "f34ac2GGiVOBbG6XlfvgYP4", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 34 + }, + "_enabled": true, + "spriteFrameSet": [ + { + "__id__": 37 + }, + { + "__id__": 38 + } + ], + "_id": "8cphKUQq9BfrwG/vX1I3DS" + }, + { + "__type__": "SpriteFrameSet", + "language": "zh", + "spriteFrame": { + "__uuid__": "1be42d0a-f3c9-4368-a6cb-c55164166f80" + } + }, + { + "__type__": "SpriteFrameSet", + "language": "en", + "spriteFrame": { + "__uuid__": "1be42d0a-f3c9-4368-a6cb-c55164166f80" + } + }, + { + "__type__": "cc.Node", + "_name": "smsLoginCaptchaInput", + "_objFlags": 0, + "_parent": { + "__id__": 11 + }, + "_children": [ + { + "__id__": 40 + }, + { + "__id__": 42 + }, + { + "__id__": 44 + } + ], + "_active": true, + "_components": [ + { + "__id__": 47 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -5, + 238, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "d0fzkgCKhJO7iVD6Rf3Zdu" + }, + { + "__type__": "cc.Node", + "_name": "BACKGROUND_SPRITE", + "_objFlags": 0, + "_parent": { + "__id__": 39 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 41 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "46sv1FCr5A25lZ9u8CQrXf" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 40 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "67e68bc9-dad5-4ad9-a2d8-7e03d458e32f" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "04+xBtZJhCR4Zo8X3zMsNT" + }, + { + "__type__": "cc.Node", + "_name": "TEXT_LABEL", + "_objFlags": 0, + "_parent": { + "__id__": 39 + }, + "_children": [], + "_active": false, + "_components": [ + { + "__id__": 43 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 98, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 1 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -48, + 20, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "99wKqz67ZGVadaQ6SAukxX" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 42 + }, + "_enabled": true, + "_materials": [], + "_useOriginalSize": true, + "_string": "", + "_N$string": "", + "_fontSize": 30, + "_lineHeight": 40, + "_enableWrapText": false, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_N$horizontalAlign": 0, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 1, + "_N$cacheMode": 0, + "_id": "9eREqpFS9Gy5AUSAsiiqEF" + }, + { + "__type__": "cc.Node", + "_name": "PLACEHOLDER_LABEL", + "_objFlags": 0, + "_parent": { + "__id__": 39 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 45 + }, + { + "__id__": 46 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 127, + "g": 127, + "b": 127, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 98, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 1 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -48, + 20, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "9fy2BHwl9Bg7nCP+2DirNn" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 44 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_useOriginalSize": false, + "_string": "login.hint.captchaInputHint", + "_N$string": "login.hint.captchaInputHint", + "_fontSize": 14, + "_lineHeight": 40, + "_enableWrapText": false, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_N$horizontalAlign": 0, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 1, + "_N$cacheMode": 0, + "_id": "1cE4h4vfZA/KQDPXgNvT7G" + }, + { + "__type__": "744dcs4DCdNprNhG0xwq6FK", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 44 + }, + "_enabled": true, + "_dataID": "login.hint.captchaInputHint", + "_id": "50XeFuWTxCZIWBFCbKNwdE" + }, + { + "__type__": "cc.EditBox", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 39 + }, + "_enabled": true, + "_useOriginalSize": false, + "_string": "", + "returnType": 0, + "maxLength": 4, + "_tabIndex": 0, + "editingDidBegan": [], + "textChanged": [], + "editingDidEnded": [], + "editingReturn": [], + "_N$textLabel": { + "__id__": 43 + }, + "_N$placeholderLabel": { + "__id__": 45 + }, + "_N$background": { + "__id__": 41 + }, + "_N$inputFlag": 5, + "_N$inputMode": 2, + "_N$stayOnTop": false, + "_id": "0d3TEbYQRAR4dV0lEQIqI8" + }, + { + "__type__": "cc.Node", + "_name": "smsLoginCaptchaButton", + "_objFlags": 0, + "_parent": { + "__id__": 11 + }, + "_children": [ + { + "__id__": 49 + } + ], + "_active": true, + "_components": [ + { + "__id__": 54 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 120, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 110, + 238, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "59MUtkIYBH76fdJeMBt8Ho" + }, + { + "__type__": "cc.Node", + "_name": "smsGetCaptcha", + "_objFlags": 0, + "_parent": { + "__id__": 48 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 50 + }, + { + "__id__": 51 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 120, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 6, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "d8dU5jhbZDx4boqyyH9s5U" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 49 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "137d0749-cf08-459d-8976-ebe5bd052637" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": { + "__uuid__": "030d9286-e8a2-40cf-98f8-baf713f0b8c4" + }, + "_id": "8fh6IBW1ZAvZUD8jf0Dq4v" + }, + { + "__type__": "f34ac2GGiVOBbG6XlfvgYP4", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 49 + }, + "_enabled": true, + "spriteFrameSet": [ + { + "__id__": 52 + }, + { + "__id__": 53 + } + ], + "_id": "d0J2IhMFZKOoOJhKxen8Vy" + }, + { + "__type__": "SpriteFrameSet", + "language": "zh", + "spriteFrame": { + "__uuid__": "137d0749-cf08-459d-8976-ebe5bd052637" + } + }, + { + "__type__": "SpriteFrameSet", + "language": "en", + "spriteFrame": { + "__uuid__": "137d0749-cf08-459d-8976-ebe5bd052637" + } + }, + { + "__type__": "cc.Button", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 48 + }, + "_enabled": true, + "_normalMaterial": null, + "_grayMaterial": null, + "duration": 0.1, + "zoomScale": 1.1, + "clickEvents": [ + { + "__id__": 55 + } + ], + "_N$interactable": true, + "_N$enableAutoGrayEffect": false, + "_N$transition": 0, + "transition": 0, + "_N$normalColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$pressedColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "pressedColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$disabledColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$normalSprite": null, + "_N$pressedSprite": { + "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a" + }, + "pressedSprite": { + "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a" + }, + "_N$hoverSprite": { + "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a" + }, + "hoverSprite": { + "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a" + }, + "_N$disabledSprite": { + "__uuid__": "29158224-f8dd-4661-a796-1ffab537140e" + }, + "_N$target": { + "__id__": 48 + }, + "_id": "96L9tbxW9DHJHU5hUi9oNc" + }, + { + "__type__": "cc.ClickEvent", + "target": { + "__id__": 2 + }, + "component": "", + "_componentId": "12a3dlNVr1C0oou2h0nFomA", + "handler": "getSMSLoginCaptchaCode", + "customEventData": "" + }, + { + "__type__": "cc.Node", + "_name": "loginButton", + "_objFlags": 0, + "_parent": { + "__id__": 11 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 57 + }, + { + "__id__": 58 + }, + { + "__id__": 60 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 200, + "height": 80 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 150, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "d5nsff3tFCOKjuM6oupUHd" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 56 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "04ebd3d5-0550-409e-b815-81219667f1fa" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": { + "__uuid__": "030d9286-e8a2-40cf-98f8-baf713f0b8c4" + }, + "_id": "6ekufEU+xBuLddYFdx39u+" + }, + { + "__type__": "cc.Button", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 56 + }, + "_enabled": true, + "_normalMaterial": null, + "_grayMaterial": null, + "duration": 0.1, + "zoomScale": 1.2, + "clickEvents": [ + { + "__id__": 59 + } + ], + "_N$interactable": true, + "_N$enableAutoGrayEffect": false, + "_N$transition": 3, + "transition": 3, + "_N$normalColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$pressedColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "pressedColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "hoverColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$disabledColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_N$normalSprite": null, + "_N$pressedSprite": { + "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a" + }, + "pressedSprite": { + "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a" + }, + "_N$hoverSprite": { + "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a" + }, + "hoverSprite": { + "__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a" + }, + "_N$disabledSprite": { + "__uuid__": "29158224-f8dd-4661-a796-1ffab537140e" + }, + "_N$target": { + "__id__": 56 + }, + "_id": "0dQu3M5+hO8Ia4FD67Br39" + }, + { + "__type__": "cc.ClickEvent", + "target": { + "__id__": 2 + }, + "component": "", + "_componentId": "12a3dlNVr1C0oou2h0nFomA", + "handler": "onLoginButtonClicked", + "customEventData": "" + }, + { + "__type__": "f34ac2GGiVOBbG6XlfvgYP4", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 56 + }, + "_enabled": true, + "spriteFrameSet": [ + { + "__id__": 61 + }, + { + "__id__": 62 + } + ], + "_id": "90vplO+/9FtKP39p/BNUN6" + }, + { + "__type__": "SpriteFrameSet", + "language": "zh", + "spriteFrame": { + "__uuid__": "04ebd3d5-0550-409e-b815-81219667f1fa" + } + }, + { + "__type__": "SpriteFrameSet", + "language": "en", + "spriteFrame": { + "__uuid__": "04ebd3d5-0550-409e-b815-81219667f1fa" + } + }, + { + "__type__": "cc.Node", + "_name": "phoneNumberTips", + "_objFlags": 0, + "_parent": { + "__id__": 11 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 64 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 224, + "g": 33, + "b": 33, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 20.16 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 101, + 332, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "70UgXE6TxF9p/Egaz78eO0" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 63 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_useOriginalSize": false, + "_string": "", + "_N$string": "", + "_fontSize": 16, + "_lineHeight": 16, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_N$horizontalAlign": 0, + "_N$verticalAlign": 0, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 0, + "_id": "bbTAgBxGNPPpi+WBUCNQkz" + }, + { + "__type__": "cc.Node", + "_name": "captchaTips", + "_objFlags": 0, + "_parent": { + "__id__": 11 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 66 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 224, + "g": 33, + "b": 33, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 20.16 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -15, + 208, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "77KgL7wX1AMI2ySJGIxw8p" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 65 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_useOriginalSize": false, + "_string": "", + "_N$string": "", + "_fontSize": 16, + "_lineHeight": 16, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_N$horizontalAlign": 0, + "_N$verticalAlign": 0, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 0, + "_id": "77guIevytGdbACP6/swyRf" + }, + { + "__type__": "cc.Node", + "_name": "wechatLoginTips", + "_objFlags": 0, + "_parent": { + "__id__": 11 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 68 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 224, + "g": 33, + "b": 33, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 25.2 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 510, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "a1x0dpCpNDCZFF3Z+uMoWd" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 67 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_useOriginalSize": false, + "_string": "", + "_N$string": "", + "_fontSize": 20, + "_lineHeight": 20, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_N$horizontalAlign": 0, + "_N$verticalAlign": 0, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 0, + "_id": "9eaPcp3+lDpL8fBz6ohCMN" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 10 + }, + "_enabled": false, + "alignMode": 0, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 640, + "_originalHeight": 960, + "_id": "16D4pNjGpCg5pXcLsPfYKe" + }, + { + "__type__": "cc.Canvas", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_designResolution": { + "__type__": "cc.Size", + "width": 640, + "height": 960 + }, + "_fitWidth": true, + "_fitHeight": false, + "_id": "45irrwnU1MAaF3kwQFnJ++" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": false, + "alignMode": 0, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 640, + "_originalHeight": 960, + "_id": "femrjqTNREkZw7OPQcF2dD" + }, + { + "__type__": "12a3dlNVr1C0oou2h0nFomA", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "cavasNode": { + "__id__": 2 + }, + "backgroundNode": { + "__id__": 10 + }, + "interactiveControls": { + "__id__": 11 + }, + "phoneLabel": { + "__id__": 20 + }, + "smsLoginCaptchaLabel": { + "__id__": 34 + }, + "phoneCountryCodeInput": { + "__id__": 12 + }, + "phoneNumberInput": { + "__id__": 25 + }, + "phoneNumberTips": { + "__id__": 63 + }, + "smsLoginCaptchaInput": { + "__id__": 39 + }, + "smsLoginCaptchaButton": { + "__id__": 48 + }, + "captchaTips": { + "__id__": 65 + }, + "loginButton": { + "__id__": 56 + }, + "smsWaitCountdownPrefab": { + "__uuid__": "2c0101b8-c15a-4501-9fce-cd5a014af8bf" + }, + "loadingPrefab": { + "__uuid__": "f2a3cece-30bf-4f62-bc20-34d44a9ddf98" + }, + "wechatLoginTips": { + "__id__": 68 + }, + "_id": "51YNpecnJBea8vzAxGdkv2" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "7838f276-ab48-445a-b858-937dd27d9520" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": false, + "_atlas": null, + "_id": "e2yoOcT3ND2YHlCSRJKZ5q" + }, + { + "__type__": "cc.Animation", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": false, + "_defaultClip": null, + "_clips": [], + "playOnLoad": false, + "_id": "6alecFaoZH7KcP4/4bsDru" + } +] \ No newline at end of file diff --git a/frontend/assets/scenes/login.fire.meta b/frontend/assets/scenes/login.fire.meta new file mode 100644 index 0000000..5651792 --- /dev/null +++ b/frontend/assets/scenes/login.fire.meta @@ -0,0 +1,7 @@ +{ + "ver": "1.2.5", + "uuid": "2ff474d9-0c9e-4fe3-87ec-fbff7cae85b4", + "asyncLoadAssets": false, + "autoReleaseAssets": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/scenes/wechatGameLogin.fire b/frontend/assets/scenes/wechatGameLogin.fire new file mode 100644 index 0000000..141f368 --- /dev/null +++ b/frontend/assets/scenes/wechatGameLogin.fire @@ -0,0 +1,1706 @@ +[ + { + "__type__": "cc.SceneAsset", + "_name": "", + "_objFlags": 0, + "_native": "", + "scene": { + "__id__": 1 + } + }, + { + "__type__": "cc.Scene", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + } + ], + "_active": false, + "_level": 0, + "_components": [], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_is3DNode": true, + "groupIndex": 0, + "autoReleaseAssets": false, + "_id": "475b849b-44b3-4390-982d-bd0d9e695093", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Node", + "_name": "Canvas", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 3 + }, + { + "__id__": 5 + }, + { + "__id__": 7 + }, + { + "__id__": 12 + }, + { + "__id__": 23 + } + ], + "_active": true, + "_level": 1, + "_components": [ + { + "__id__": 34 + }, + { + "__id__": 35 + }, + { + "__id__": 36 + }, + { + "__id__": 37 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 640, + "height": 960 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "groupIndex": 0, + "_id": "88kscZWXFCIZtNFekdSP/o", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 320, + 480, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Node", + "_name": "Main Camera", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_level": 0, + "_components": [ + { + "__id__": 4 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "groupIndex": 0, + "_id": "f1+7GE/nBJIrtiDgZie30q", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 202.36995509211857, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Camera", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 3 + }, + "_enabled": true, + "_cullingMask": 4294967295, + "_clearFlags": 0, + "_backgroundColor": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_depth": 0, + "_zoomRatio": 1, + "_targetTexture": null, + "_fov": 60, + "_orthoSize": 10, + "_nearClip": 1, + "_farClip": 4096, + "_ortho": true, + "_rect": { + "__type__": "cc.Rect", + "x": 0, + "y": 0, + "width": 1, + "height": 1 + }, + "_renderStages": 1, + "_id": "7eS1XfnvVCVJh7J5AVbnd8" + }, + { + "__type__": "cc.Node", + "_name": "Tips", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_level": 2, + "_components": [ + { + "__id__": 6 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 600, + "height": 50.4 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "groupIndex": 0, + "_id": "a282mCIUBOmqmf3o22ZSKE", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 125, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 5 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_useOriginalSize": false, + "_string": "", + "_N$string": "", + "_fontSize": 32, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 3, + "_N$cacheMode": 0, + "_id": "3ejZjl6HVA1rSY1hSxd8H8" + }, + { + "__type__": "cc.Node", + "_name": "Decorations", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 8 + }, + { + "__id__": 10 + } + ], + "_active": true, + "_level": 2, + "_components": [], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "groupIndex": 0, + "_id": "c3AZmU3YpOTYhMw/8haSH8", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Node", + "_name": "Logo", + "_objFlags": 0, + "_parent": { + "__id__": 7 + }, + "_children": [], + "_active": true, + "_level": 3, + "_components": [ + { + "__id__": 9 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 424, + "height": 168 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "groupIndex": 0, + "_id": "9bq54961lFtqOPk3DEyZTr", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 260, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 8 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "9e564509-0a36-4f01-a833-79ff8f2e8328" + }, + "_type": 0, + "_sizeMode": 1, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": { + "__uuid__": "030d9286-e8a2-40cf-98f8-baf713f0b8c4" + }, + "_id": "25w02YAVpPTKm8JUfP1Iyn" + }, + { + "__type__": "cc.Node", + "_name": "Bolldozer", + "_objFlags": 0, + "_parent": { + "__id__": 7 + }, + "_children": [], + "_active": true, + "_level": 3, + "_components": [ + { + "__id__": 11 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 248, + "height": 513 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "groupIndex": 0, + "_id": "94YmH2GARPAoCvyPWeCbBo", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + -180, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 10 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "2158ddd8-02de-47c2-ade8-f701288c22e5" + }, + "_type": 0, + "_sizeMode": 1, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": { + "__uuid__": "030d9286-e8a2-40cf-98f8-baf713f0b8c4" + }, + "_id": "b4I8o4N61CJYbad3GUjAvQ" + }, + { + "__type__": "cc.Node", + "_name": "DownloadProgress", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 13 + }, + { + "__id__": 15 + }, + { + "__id__": 17 + }, + { + "__id__": 19 + } + ], + "_active": true, + "_level": 2, + "_components": [ + { + "__id__": 21 + }, + { + "__id__": 22 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 300, + "height": 32 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "groupIndex": 0, + "_id": "abQHOjM2dO5rBkz6fGiJKP", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + -435, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Node", + "_name": "bar", + "_objFlags": 0, + "_parent": { + "__id__": 12 + }, + "_children": [], + "_active": true, + "_level": 0, + "_components": [ + { + "__id__": 14 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 19, + "g": 148, + "b": 35, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 32 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0.5 + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "groupIndex": 0, + "_id": "35HX0AAMpMCYACcb2fdXjq", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -150, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 13 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "67e68bc9-dad5-4ad9-a2d8-7e03d458e32f" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "65DRQh2TdB24L0axkKhYyy" + }, + { + "__type__": "cc.Node", + "_name": "Written", + "_objFlags": 0, + "_parent": { + "__id__": 12 + }, + "_children": [], + "_active": true, + "_level": 3, + "_components": [ + { + "__id__": 16 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 10.66, + "height": 50.4 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 1, + "y": 0.5 + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "groupIndex": 0, + "_id": "38DI8Gj5lAEapdfbgcQHRE", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -15, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 15 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_useOriginalSize": false, + "_string": "-", + "_N$string": "-", + "_fontSize": 32, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 0, + "_id": "95L3mPi11Ovojqz7HD7nmk" + }, + { + "__type__": "cc.Node", + "_name": "Separater", + "_objFlags": 0, + "_parent": { + "__id__": 12 + }, + "_children": [], + "_active": true, + "_level": 3, + "_components": [ + { + "__id__": 18 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 8.89, + "height": 50.4 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "groupIndex": 0, + "_id": "31gp1c7+hPTacRYMQzCtoI", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 17 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_useOriginalSize": false, + "_string": "/", + "_N$string": "/", + "_fontSize": 32, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 0, + "_id": "759pNtiHdIB5widXzhhIdV" + }, + { + "__type__": "cc.Node", + "_name": "ExpectedToWrite", + "_objFlags": 0, + "_parent": { + "__id__": 12 + }, + "_children": [], + "_active": true, + "_level": 3, + "_components": [ + { + "__id__": 20 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 10.66, + "height": 50.4 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0.5 + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "groupIndex": 0, + "_id": "20R1sB1uNPf5gsMbmFaHxZ", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 10, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 19 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_useOriginalSize": false, + "_string": "-", + "_N$string": "-", + "_fontSize": 32, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 0, + "_id": "dbFyA15cdL+btd6rNGJcWg" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 12 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "88e79fd5-96b4-4a77-a1f4-312467171014" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "593TaHj0FJc7dURtmLMIk/" + }, + { + "__type__": "cc.ProgressBar", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 12 + }, + "_enabled": true, + "_N$totalLength": 300, + "_N$barSprite": { + "__id__": 14 + }, + "_N$mode": 0, + "_N$progress": 0, + "_N$reverse": false, + "_id": "09vvE4cMRJZ7N0o2D6SeTZ" + }, + { + "__type__": "cc.Node", + "_name": "HandlerProgress", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 24 + }, + { + "__id__": 26 + }, + { + "__id__": 28 + }, + { + "__id__": 30 + } + ], + "_active": true, + "_level": 2, + "_components": [ + { + "__id__": 32 + }, + { + "__id__": 33 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 300, + "height": 30 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "groupIndex": 0, + "_id": "c0nxsTzCtKa4OX78IBsR0Q", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + -367, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Node", + "_name": "bar", + "_objFlags": 0, + "_parent": { + "__id__": 23 + }, + "_children": [], + "_active": true, + "_level": 0, + "_components": [ + { + "__id__": 25 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 202, + "g": 115, + "b": 21, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 32 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0.5 + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "groupIndex": 0, + "_id": "24ZKpM0FdNQZYiIRF0KyjW", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -150, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 24 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "67e68bc9-dad5-4ad9-a2d8-7e03d458e32f" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "15MJsSQ2RBcYNOlHOGBVtf" + }, + { + "__type__": "cc.Node", + "_name": "Handled", + "_objFlags": 0, + "_parent": { + "__id__": 23 + }, + "_children": [], + "_active": true, + "_level": 3, + "_components": [ + { + "__id__": 27 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 10.66, + "height": 50.4 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 1, + "y": 0.5 + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "groupIndex": 0, + "_id": "8fupG1MHNARIAlsizaxHZ4", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -15, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 26 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_useOriginalSize": false, + "_string": "-", + "_N$string": "-", + "_fontSize": 32, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 0, + "_id": "ddll07J9hAoZQDGbNbZK/r" + }, + { + "__type__": "cc.Node", + "_name": "Separater", + "_objFlags": 0, + "_parent": { + "__id__": 23 + }, + "_children": [], + "_active": true, + "_level": 3, + "_components": [ + { + "__id__": 29 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 8.89, + "height": 50.4 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "groupIndex": 0, + "_id": "3c/av+sOZLMbxWRhODcKmG", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 28 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_useOriginalSize": false, + "_string": "/", + "_N$string": "/", + "_fontSize": 32, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 0, + "_id": "c8z9PIEA1ObK11KdTNPVIP" + }, + { + "__type__": "cc.Node", + "_name": "ToHandle", + "_objFlags": 0, + "_parent": { + "__id__": 23 + }, + "_children": [], + "_active": true, + "_level": 3, + "_components": [ + { + "__id__": 31 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 10.66, + "height": 50.4 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0.5 + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "groupIndex": 0, + "_id": "18hLtXEjBMMbL7WX1voVDu", + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 10, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + } + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 30 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_useOriginalSize": false, + "_string": "-", + "_N$string": "-", + "_fontSize": 32, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 0, + "_id": "5b+RrNshNILbBAjAAyqvfN" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 23 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "88e79fd5-96b4-4a77-a1f4-312467171014" + }, + "_type": 1, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": null, + "_id": "b1H93UoY9CpalSJVXUvObw" + }, + { + "__type__": "cc.ProgressBar", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 23 + }, + "_enabled": true, + "_N$totalLength": 300, + "_N$barSprite": { + "__id__": 25 + }, + "_N$mode": 0, + "_N$progress": 0, + "_N$reverse": false, + "_id": "d44CusjQ1NeL3CU/6/pYju" + }, + { + "__type__": "cc.Canvas", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_designResolution": { + "__type__": "cc.Size", + "width": 640, + "height": 960 + }, + "_fitWidth": true, + "_fitHeight": false, + "_id": "45irrwnU1MAaF3kwQFnJ++" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": false, + "alignMode": 0, + "_target": null, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 640, + "_originalHeight": 960, + "_id": "femrjqTNREkZw7OPQcF2dD" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "7838f276-ab48-445a-b858-937dd27d9520" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": false, + "_atlas": null, + "_id": "e2yoOcT3ND2YHlCSRJKZ5q" + }, + { + "__type__": "8264fty40hF5JqzW/+5pWHu", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "cavasNode": { + "__id__": 2 + }, + "backgroundNode": { + "__id__": 2 + }, + "loadingPrefab": { + "__uuid__": "f2a3cece-30bf-4f62-bc20-34d44a9ddf98" + }, + "tipsLabel": { + "__id__": 6 + }, + "downloadProgress": { + "__id__": 22 + }, + "writtenBytes": { + "__id__": 16 + }, + "expectedToWriteBytes": { + "__id__": 20 + }, + "handlerProgress": { + "__id__": 33 + }, + "handledUrlsCount": { + "__id__": 27 + }, + "toHandledUrlsCount": { + "__id__": 31 + }, + "_id": "c0EVg/B8RMWLA48jmAqxQr" + } +] \ No newline at end of file diff --git a/frontend/assets/scenes/wechatGameLogin.fire.meta b/frontend/assets/scenes/wechatGameLogin.fire.meta new file mode 100644 index 0000000..2f2638d --- /dev/null +++ b/frontend/assets/scenes/wechatGameLogin.fire.meta @@ -0,0 +1,7 @@ +{ + "ver": "1.2.5", + "uuid": "475b849b-44b3-4390-982d-bd0d9e695093", + "asyncLoadAssets": false, + "autoReleaseAssets": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/scripts.meta b/frontend/assets/scripts.meta new file mode 100644 index 0000000..d222e12 --- /dev/null +++ b/frontend/assets/scripts.meta @@ -0,0 +1,5 @@ +{ + "ver": "1.0.1", + "uuid": "d93f9ded-a211-4fb3-a151-f4498c40cf38", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/scripts/BasePlayer.js b/frontend/assets/scripts/BasePlayer.js new file mode 100644 index 0000000..f0a19f8 --- /dev/null +++ b/frontend/assets/scripts/BasePlayer.js @@ -0,0 +1,471 @@ +module.export = cc.Class({ + extends: cc.Component, + + properties: { + animComp: { + type: cc.Animation, + default: null, + }, + baseSpeed: { + type: cc.Float, + default: 300, + }, + speed: { + type: cc.Float, + default: 300 + }, + lastMovedAt: { + type: cc.Float, + default: 0 // In "GMT milliseconds" + }, + eps: { + default: 0.10, + type: cc.Float + }, + magicLeanLowerBound: { + default: 0.414, // Tangent of (PI/8). + type: cc.Float + }, + magicLeanUpperBound: { + default: 2.414, // Tangent of (3*PI/8). + type: cc.Float + }, + }, + + // LIFE-CYCLE CALLBACKS: + start() { + const self = this; + self.contactedControlledPlayers = []; + self.contactedNPCPlayers = []; + self.coveringShelterZReducers = []; + + self.computedNewDifferentPosLocalToParentWithinCurrentFrame = null; + self.actionMangerSingleton = new cc.ActionManager(); + self.scheduledDirection = { + dx: 0, + dy: 0 + }; + + self.activeDirection = { + dx: 0, + dy: 0 + }; + }, + + onLoad() { + const self = this; + self.clips = { + '01': 'Top', + '0-1': 'Bottom', + '-20': 'Left', + '20': 'Right', + '-21': 'TopLeft', + '21': 'TopRight', + '-2-1': 'BottomLeft', + '2-1': 'BottomRight' + }; + const canvasNode = self.mapNode.parent; + self.contactedBarriers = []; + const joystickInputControllerScriptIns = canvasNode.getComponent("TouchEventsManager"); + self.ctrl = joystickInputControllerScriptIns; + self.animComp = self.node.getComponent(cc.Animation); + self.animComp.play(); + }, + + scheduleNewDirection(newScheduledDirection, forceAnimSwitch) { + if (!newScheduledDirection) { + return; + } + + if (forceAnimSwitch || null == this.scheduledDirection || (newScheduledDirection.dx != this.scheduledDirection.dx || newScheduledDirection.dy != this.scheduledDirection.dy)) { + this.scheduledDirection = newScheduledDirection; + const clipKey = newScheduledDirection.dx.toString() + newScheduledDirection.dy.toString(); + const clips = (this.attacked ? this.attackedClips : this.clips); + let clip = clips[clipKey]; + if (!clip) { + // Keep playing the current anim. + if (0 !== newScheduledDirection.dx || 0 !== newScheduledDirection.dy) { + cc.warn('Clip for clipKey === ' + clipKey + ' is invalid: ' + clip + '.'); + } + } else { + this.animComp.play(clip); + if (this.attacked) { + cc.log(`Attacked, switching to play clipKey = ${clipKey}, clip == ${clip}, this.activeDirection == ${JSON.stringify(this.activeDirection)}, this.scheduledDirection == ${JSON.stringify(this.scheduledDirection)}.`); + } + } + } + }, + + _addCoveringShelterZReducer(comp) { + const self = this; + for (let coveringShelterZReducer of self.coveringShelterZReducers) { + if (coveringShelterZReducer._id == comp._id) { + return false; + } + } + self.coveringShelterZReducers.push(comp); + return true; + }, + + _removeCoveringShelterZReducer(comp) { + const self = this; + self.coveringShelterZReducers = self.coveringShelterZReducers.filter((coveringShelterZReducer) => { + return coveringShelterZReducer._id != comp._id; + }); + return true; + }, + + _addContactedBarrier(collider) { + const self = this; + if (!self.contactedBarriers) { + cc.log("self.contactedBarriers is null or undefined" + self.contactedBarriers) + } + for (let contactedBarrier of self.contactedBarriers) { + if (contactedBarrier._id == collider._id) { + return false; + } + } + self.contactedBarriers.push(collider); + return true; + }, + + _removeContactedBarrier(collider) { + const self = this; + self.contactedBarriers = self.contactedBarriers.filter((contactedBarrier) => { + return contactedBarrier._id != collider._id; + }); + return true; + }, + + _addContactedControlledPlayers(comp) { + const self = this; + for (let aComp of self.contactedControlledPlayers) { + if (aComp.uuid == comp.uuid) { + return false; + } + } + self.contactedControlledPlayers.push(comp); + return true; + }, + + _removeContactedControlledPlayer(comp) { + const self = this; + self.contactedControlledPlayers = self.contactedControlledPlayers.filter((aComp) => { + return aComp.uuid != comp.uuid; + }); + return true; + }, + + _addContactedNPCPlayers(comp) { + const self = this; + for (let aComp of self.contactedNPCPlayers) { + if (aComp.uuid == comp.uuid) { + return false; + } + } + self.contactedNPCPlayers.push(comp); + return true; + }, + + _removeContactedNPCPlayer(comp) { + const self = this; + self.contactedNPCPlayers = self.contactedNPCPlayers.filter((aComp) => { + return aComp.uuid != comp.uuid; + }); + return true; + }, + + _canMoveBy(vecToMoveBy) { + const self = this; + const computedNewDifferentPosLocalToParentWithinCurrentFrame = self.node.position.add(vecToMoveBy); + self.computedNewDifferentPosLocalToParentWithinCurrentFrame = computedNewDifferentPosLocalToParentWithinCurrentFrame; + + if (tileCollisionManager.isOutOfMapNode(self.mapNode, computedNewDifferentPosLocalToParentWithinCurrentFrame)) { + return false; + } + + const currentSelfColliderCircle = self.node.getComponent(cc.CircleCollider); + let nextSelfColliderCircle = null; + if (0 < self.contactedBarriers.length) { + /* To avoid unexpected buckling. */ + const mutatedVecToMoveBy = vecToMoveBy.mul(5); // To help it escape the engaged `contactedBarriers`. + nextSelfColliderCircle = { + position: self.node.position.add(mutatedVecToMoveBy).add(currentSelfColliderCircle.offset), + radius: currentSelfColliderCircle.radius, + }; + } else { + nextSelfColliderCircle = { + position: computedNewDifferentPosLocalToParentWithinCurrentFrame.add(currentSelfColliderCircle.offset), + radius: currentSelfColliderCircle.radius, + }; + } + + for (let contactedBarrier of self.contactedBarriers) { + let contactedBarrierPolygonLocalToParentWithinCurrentFrame = []; + for (let p of contactedBarrier.points) { + contactedBarrierPolygonLocalToParentWithinCurrentFrame.push(contactedBarrier.node.position.add(p)); + } + if (cc.Intersection.pointInPolygon(nextSelfColliderCircle.position, contactedBarrierPolygonLocalToParentWithinCurrentFrame)) { + // Make sure that the player is "leaving" the PolygonCollider. + return false; + } + if (cc.Intersection.polygonCircle(contactedBarrierPolygonLocalToParentWithinCurrentFrame, nextSelfColliderCircle)) { + if (null == self.firstContactedEdge) { + return false; + } + if (null != self.firstContactedEdge && self.firstContactedEdge.associatedBarrier != contactedBarrier) { + const res = self._calculateTangentialMovementAttrs(nextSelfColliderCircle, contactedBarrier); + if (null == res.contactedEdge) { + // Otherwise, the current movement is going to transit smoothly onto the next PolygonCollider. + return false; + } + } + } + } + + return true; + + /* + * In a subclass, use + * + * _canMoveBy(vecToMoveBy) { + * BasePlayer.prototype._canMoveBy.call(this, vecToMoveBy); + * // Customized codes. + * } + * + * Reference http://www.cocos2d-x.org/docs/creator/manual/en/scripting/reference/class.html#override + */ + }, + + _calculateTangentialMovementAttrs(currentSelfColliderCircle, contactedBarrier) { + /* + * Theoretically when the `contactedBarrier` is a convex polygon and the `PlayerCollider` is a circle, there can be only 1 `contactedEdge` for each `contactedBarrier`. Except only for around the corner. + * + * We should avoid the possibility of players hitting the "corners of convex polygons" by map design wherever & whenever possible. + * + */ + const self = this; + const sDir = self.activeDirection; + const currentSelfColliderCircleCentrePos = (currentSelfColliderCircle.position ? currentSelfColliderCircle.position : self.node.position.add(currentSelfColliderCircle.offset)); + const currentSelfColliderCircleRadius = currentSelfColliderCircle.radius; + let contactedEdgeCandidateList = []; + let skinDepthThreshold = 0.45*currentSelfColliderCircleRadius; + for (let i = 0; i < contactedBarrier.points.length; ++i) { + const stPoint = contactedBarrier.points[i].add(contactedBarrier.offset).add(contactedBarrier.node.position); + const edPoint = (i == contactedBarrier.points.length - 1 ? contactedBarrier.points[0].add(contactedBarrier.offset).add(contactedBarrier.node.position) : contactedBarrier.points[1 + i].add(contactedBarrier.offset).add(contactedBarrier.node.position)); + const tmpVSt = stPoint.sub(currentSelfColliderCircleCentrePos); + const tmpVEd = edPoint.sub(currentSelfColliderCircleCentrePos); + const crossProdScalar = tmpVSt.cross(tmpVEd); + if (0 < crossProdScalar) { + // If moving parallel along `st <-> ed`, the trajectory of `currentSelfColliderCircleCentrePos` will cut inside the polygon. + continue; + } + const dis = cc.Intersection.pointLineDistance(currentSelfColliderCircleCentrePos, stPoint, edPoint, true); + if (dis > currentSelfColliderCircleRadius) continue; + if (dis < skinDepthThreshold) continue; + contactedEdgeCandidateList.push({ + st: stPoint, + ed: edPoint, + associatedBarrier: contactedBarrier, + }); + } + let contactedEdge = null; + let contactedEdgeDir = null; + let largestInnerProdAbs = Number.MIN_VALUE; + + if (0 < contactedEdgeCandidateList.length) { + const sDirMag = Math.sqrt(sDir.dx * sDir.dx + sDir.dy * sDir.dy); + for (let contactedEdgeCandidate of contactedEdgeCandidateList) { + const tmp = contactedEdgeCandidate.ed.sub(contactedEdgeCandidate.st); + const contactedEdgeDirCandidate = { + dx: tmp.x, + dy: tmp.y, + }; + const contactedEdgeDirCandidateMag = Math.sqrt(contactedEdgeDirCandidate.dx * contactedEdgeDirCandidate.dx + contactedEdgeDirCandidate.dy * contactedEdgeDirCandidate.dy); + const innerDotProd = (sDir.dx * contactedEdgeDirCandidate.dx + sDir.dy * contactedEdgeDirCandidate.dy)/(sDirMag * contactedEdgeDirCandidateMag); + const innerDotProdThresholdMag = 0.7; + if ((0 > innerDotProd && innerDotProd > -innerDotProdThresholdMag) || (0 < innerDotProd && innerDotProd < innerDotProdThresholdMag)) { + // Intentionally left blank, in this case the player is trying to escape from the `contactedEdge`. + continue; + } else if (innerDotProd > 0) { + const abs = Math.abs(innerDotProd); + if (abs > largestInnerProdAbs) { + contactedEdgeDir = contactedEdgeDirCandidate; + contactedEdge = contactedEdgeCandidate; + } + } else { + const abs = Math.abs(innerDotProd); + if (abs > largestInnerProdAbs) { + contactedEdgeDir = { + dx: -contactedEdgeDirCandidate.dx, + dy: -contactedEdgeDirCandidate.dy, + }; + contactedEdge = contactedEdgeCandidate; + } + } + } + } + return { + contactedEdgeDir: contactedEdgeDir, + contactedEdge: contactedEdge, + }; + }, + + _calculateVecToMoveByWithChosenDir(elapsedTime, sDir) { + if (0 == sDir.dx && 0 == sDir.dy) { + return cc.v2(); + } + const self = this; + const distanceToMove = (self.speed * elapsedTime); + const denominator = Math.sqrt(sDir.dx * sDir.dx + sDir.dy * sDir.dy); + const unitProjDx = (sDir.dx / denominator); + const unitProjDy = (sDir.dy / denominator); + return cc.v2( + distanceToMove * unitProjDx, + distanceToMove * unitProjDy, + ); + }, + + _calculateVecToMoveBy(elapsedTime) { + const self = this; + // Note that `sDir` used in this method MUST BE a copy in RAM. + let sDir = { + dx: self.activeDirection.dx, + dy: self.activeDirection.dy, + }; + + if (0 == sDir.dx && 0 == sDir.dy) { + return cc.v2(); + } + + self.firstContactedEdge = null; // Reset everytime (temporary algorithm design, might change later). + if (0 < self.contactedBarriers.length) { + /* + * Hardcoded to take care of only the 1st `contactedEdge` of the 1st `contactedBarrier` for now. Each `contactedBarrier` must be "counterclockwisely convex polygonal", otherwise sliding doesn't work! + * + */ + const contactedBarrier = self.contactedBarriers[0]; + const currentSelfColliderCircle = self.node.getComponent(cc.CircleCollider); + const res = self._calculateTangentialMovementAttrs(currentSelfColliderCircle, contactedBarrier); + if (res.contactedEdge) { + self.firstContactedEdge = res.contactedEdge; + sDir = res.contactedEdgeDir; + } + } + return self._calculateVecToMoveByWithChosenDir(elapsedTime, sDir); + }, + + update(dt) { + const self = this; + const vecToMoveBy = self._calculateVecToMoveBy(dt); + // console.log("activeDirection=", self.activeDirection, "vecToMoveBy=", vecToMoveBy, ", computedNewDifferentPosLocalToParentWithinCurrentFrame=", self.computedNewDifferentPosLocalToParentWithinCurrentFrame); + if (self._canMoveBy(vecToMoveBy)) { + self.node.position = self.computedNewDifferentPosLocalToParentWithinCurrentFrame; + } + }, + + lateUpdate(dt) { + const self = this; + self.activeDirection.dx = self.scheduledDirection.dx; + self.activeDirection.dy = self.scheduledDirection.dy; + const now = new Date().getTime(); + self.lastMovedAt = now; + }, + + onCollisionEnter(other, self) { + const playerScriptIns = self.node.getComponent("SelfPlayer"); + switch (other.node.name) { + case "NPCPlayer": + if ("NPCPlayer" != self.node.name) { + other.node.getComponent('NPCPlayer').showProfileTrigger(); + } + playerScriptIns._addContactedNPCPlayers(other); + break; + case "PolygonBoundaryBarrier": + playerScriptIns._addContactedBarrier(other); + break; + case "PolygonBoundaryShelter": + break; + case "PolygonBoundaryShelterZReducer": + playerScriptIns._addCoveringShelterZReducer(other); + if (1 == playerScriptIns.coveringShelterZReducers.length) { + setLocalZOrder(self.node, 2); + } + break; + default: + break; + } + }, + + onCollisionStay(other, self) { + // TBD. + }, + + onCollisionExit(other, self) { + const playerScriptIns = self.getComponent("SelfPlayer"); + switch (other.node.name) { + case "NPCPlayer": + other.node.getComponent('NPCPlayer').hideProfileTrigger(); + playerScriptIns._removeContactedNPCPlayer(other); + break; + case "PolygonBoundaryBarrier": + playerScriptIns._removeContactedBarrier(other); + break; + case "PolygonBoundaryShelter": + break; + case "PolygonBoundaryShelterZReducer": + playerScriptIns._removeCoveringShelterZReducer(other); + if (0 == playerScriptIns.coveringShelterZReducers.length) { + setLocalZOrder(self.node, 5); + } + break; + default: + break; + } + }, + + _generateRandomDirection() { + return ALL_DISCRETE_DIRECTIONS_CLOCKWISE[Math.floor(Math.random() * ALL_DISCRETE_DIRECTIONS_CLOCKWISE.length)]; + }, + + _generateRandomDirectionExcluding(toExcludeDx, toExcludeDy) { + let randomDirectionList = []; + let exactIdx = null; + for (let ii = 0; ii < ALL_DISCRETE_DIRECTIONS_CLOCKWISE.length; ++ii) { + if (toExcludeDx != ALL_DISCRETE_DIRECTIONS_CLOCKWISE[ii].dx || toExcludeDy != ALL_DISCRETE_DIRECTIONS_CLOCKWISE[ii].dy) continue; + exactIdx = ii; + break; + } + if (null == exactIdx) { + return this._generateRandomDirection(); + } + + for (let ii = 0; ii < ALL_DISCRETE_DIRECTIONS_CLOCKWISE.length; ++ii) { + if (ii == exactIdx || ((ii - 1) % ALL_DISCRETE_DIRECTIONS_CLOCKWISE.length) == exactIdx || ((ii + 1) % ALL_DISCRETE_DIRECTIONS_CLOCKWISE.length) == exactIdx) continue; + randomDirectionList.push(ALL_DISCRETE_DIRECTIONS_CLOCKWISE[ii]); + } + return randomDirectionList[Math.floor(Math.random() * randomDirectionList.length)] + }, + + updateSpeed(proposedSpeed) { + if (0 == proposedSpeed && 0 < this.speed) { + this.startFrozenDisplay(); + } + if (0 < proposedSpeed && 0 == this.speed) { + this.stopFrozenDisplay(); + } + this.speed = proposedSpeed; + }, + + startFrozenDisplay() { + const self = this; + self.attacked = true; + self.scheduleNewDirection(self.scheduledDirection, true); + }, + + stopFrozenDisplay() { + const self = this; + self.attacked = false; + self.scheduleNewDirection(self.scheduledDirection, true); + }, +}); diff --git a/frontend/assets/scripts/BasePlayer.js.meta b/frontend/assets/scripts/BasePlayer.js.meta new file mode 100644 index 0000000..ccaa3d5 --- /dev/null +++ b/frontend/assets/scripts/BasePlayer.js.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.5", + "uuid": "2fa4ffbb-5654-4c7a-b7f3-a27d1303b019", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/scripts/Bullet.js b/frontend/assets/scripts/Bullet.js new file mode 100644 index 0000000..18c69dc --- /dev/null +++ b/frontend/assets/scripts/Bullet.js @@ -0,0 +1,201 @@ + module.export = cc.Class({ + extends: cc.Component, + + properties: { + localIdInBattle: { + default: null, + }, + linearSpeed: { + default: 0.0, + }, + }, + + ctor() { + this.ctrl = null; + this.activeDirection = null; + }, + + onLoad() { + }, + + _calculateVecToMoveByWithChosenDir(elapsedTime, sDir) { + if (0 == sDir.dx && 0 == sDir.dy) { + return cc.v2(); + } + const self = this; + const distanceToMove = (self.linearSpeed * elapsedTime); + const denominator = Math.sqrt(sDir.dx * sDir.dx + sDir.dy * sDir.dy); + const unitProjDx = (sDir.dx / denominator); + const unitProjDy = (sDir.dy / denominator); + return cc.v2( + distanceToMove * unitProjDx, + distanceToMove * unitProjDy, + ); + }, + + _calculateVecToMoveBy(elapsedTime) { + const self = this; + if (null == self.activeDirection) { + return null; + } + // Note that `sDir` used in this method MUST BE a copy in RAM. + let sDir = { + dx: self.activeDirection.dx, + dy: self.activeDirection.dy, + }; + + if (0 == sDir.dx && 0 == sDir.dy) { + return cc.v2(); + } + + return self._calculateVecToMoveByWithChosenDir(elapsedTime, sDir); + }, + + _canMoveBy(vecToMoveBy) { + return true; + }, + + update(dt) { + // Used only for EXTRAPOLATING the position of this bullet. The position might be corrected within `setData` as well. + const self = this; + if (null != self.bulletMaxDist) { + const dxMoved = self.node.position.x - self.startAtPoint.x; + const dyMoved = self.node.position.y - self.startAtPoint.y; + const distanceMoved = Math.sqrt(dxMoved * dxMoved + dyMoved * dyMoved) + self.node.opacity = 255*(1 - distanceMoved/self.bulletMaxDist); + } + + const vecToMoveBy = self._calculateVecToMoveBy(dt); + if (null == vecToMoveBy) { + return; + } + if (self._canMoveBy(vecToMoveBy)) { + self.node.position = self.node.position.add(vecToMoveBy); + } + }, + + _calculateAngle(dx, dy) { + if (dx == 0) { + if (dy > 0) { + return 90; + } + if (dy < 0) { + return -90; + } + } + + if (dx > 0) { + if (dy == 0) { + return 0; + } + if (dy > 0) { + return 45; + } + if (dy < 0) { + return -45; + } + } + + if (dx < 0) { + if (dy == 0) { + return 180; + } + if (dy > 0) { + return 135; + } + if (dy < 0) { + return -135; + } + } + + return null; + }, + + setData(bulletLocalIdInBattle, bulletInfo, dtFromMapUpdate) { + const targetNode = this.node; + + if (true == bulletInfo.removed) { + return false; + } + + if (null == bulletInfo.startAtPoint || null == bulletInfo.endAtPoint) { + console.error(`Init bullet direction error, startAtPoint:${bulletInfo.startAtPoint}, endAtPoint:${bulletInfo.endAtPoint}`); + return false; + } + + this.localIdInBattle = bulletLocalIdInBattle; + this.linearSpeed = bulletInfo.linearSpeed * 1000000000; // The `bullet.LinearSpeed` on server-side is denoted in pts/nanoseconds. + + const dx = bulletInfo.endAtPoint.x - bulletInfo.startAtPoint.x; + const dy = bulletInfo.endAtPoint.y - bulletInfo.startAtPoint.y; + + const discretizedDir = this.ctrl.discretizeDirection(dx, dy, this.ctrl.joyStickEps); + const baseAngle = 0; + const angleToRotate = baseAngle - this._calculateAngle(discretizedDir.dx, discretizedDir.dy); + if (null == angleToRotate) { + return false; + } + set2dRotation(targetNode, angleToRotate); + + const newPos = cc.v2( + bulletInfo.x, + bulletInfo.y + ); + + if (null == this.activeDirection) { + // Initialization. + this.startAtPoint = bulletInfo.startAtPoint; + this.endAtPoint = bulletInfo.endAtPoint; + this.bulletMaxDist = 600.0; // Hardcoded temporarily, matching that in "/models/room.go". -- YFLu, 2019-09-05. + targetNode.setPosition(newPos); + this.activeDirection = { + dx: 0, + dy: 0, + }; + return true; + } + + const oldPos = cc.v2( + targetNode.x, + targetNode.y, + ); + const toMoveByVec = newPos.sub(oldPos); + const toMoveByVecMag = toMoveByVec.mag(); + const toTeleportDisThreshold = (this.linearSpeed * dtFromMapUpdate * 100); + const notToMoveDisThreshold = (this.linearSpeed * dtFromMapUpdate * 0.5); + if (toMoveByVecMag < notToMoveDisThreshold) { + // To stop extrapolated moving. + this.activeDirection = { + dx: 0, + dy: 0, + }; + } else { + if (toMoveByVecMag > toTeleportDisThreshold) { + console.log("Bullet ", bulletLocalIdInBattle, " is teleporting! Having toMoveByVecMag == ", toMoveByVecMag, ", toTeleportDisThreshold == ", toTeleportDisThreshold); + // To stop extrapolated moving. + this.activeDirection = { + dx: 0, + dy: 0 + }; + // Deliberately NOT using `cc.Action`. -- YFLu, 2019-09-04 + targetNode.setPosition(newPos); + } else { + // The common case which is suitable for interpolation. + const normalizedDir = { + dx: toMoveByVec.x / toMoveByVecMag, + dy: toMoveByVec.y / toMoveByVecMag, + }; + if (isNaN(normalizedDir.dx) || isNaN(normalizedDir.dy)) { + this.activeDirection = { + dx: 0, + dy: 0, + }; + } else { + this.activeDirection = normalizedDir; + } + } + } + + return true; + }, +}); diff --git a/frontend/assets/scripts/Bullet.js.meta b/frontend/assets/scripts/Bullet.js.meta new file mode 100644 index 0000000..b6b5ea9 --- /dev/null +++ b/frontend/assets/scripts/Bullet.js.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.5", + "uuid": "ea965d25-ec82-478c-bdb2-9ac07981ab0e", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/scripts/CameraTracker.js b/frontend/assets/scripts/CameraTracker.js new file mode 100644 index 0000000..37ab4c9 --- /dev/null +++ b/frontend/assets/scripts/CameraTracker.js @@ -0,0 +1,31 @@ +cc.Class({ + extends: cc.Component, + + properties: { + mapNode: { + type: cc.Node, + default: null + }, + + }, + + onLoad () { + this.mainCamera = this.mapNode.parent.getChildByName("Main Camera").getComponent(cc.Camera); + this.mapScriptIns = this.mapNode.getComponent("Map"); + }, + + start() {}, + + update(dt) { + const self = this; + if (!self.mainCamera) return; + if (!self.mapScriptIns) return; + if (!self.mapScriptIns.selfPlayerInfo) return; + if (!self.mapScriptIns.playerRichInfoDict) return; + const selfPlayerRichInfo = self.mapScriptIns.playerRichInfoDict[self.mapScriptIns.selfPlayerInfo.id]; + if (!selfPlayerRichInfo) return; + const selfPlayerNode = selfPlayerRichInfo.node; + if (!selfPlayerNode) return; + self.mainCamera.node.setPosition(selfPlayerNode.position); + } +}); diff --git a/frontend/assets/scripts/CameraTracker.js.meta b/frontend/assets/scripts/CameraTracker.js.meta new file mode 100644 index 0000000..38e8b99 --- /dev/null +++ b/frontend/assets/scripts/CameraTracker.js.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.5", + "uuid": "78830fc7-4e25-49a1-a7fc-9f9d3883f278", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/scripts/Canvas.js b/frontend/assets/scripts/Canvas.js new file mode 100644 index 0000000..85eaac8 --- /dev/null +++ b/frontend/assets/scripts/Canvas.js @@ -0,0 +1,16 @@ +cc.Class({ + extends: cc.Component, + + properties: { + map: { + type: cc.Node, + default: null + } + }, + + // LIFE-CYCLE CALLBACKS: + + onLoad() { + + } +}); diff --git a/frontend/assets/scripts/Canvas.js.meta b/frontend/assets/scripts/Canvas.js.meta new file mode 100644 index 0000000..0d33a7d --- /dev/null +++ b/frontend/assets/scripts/Canvas.js.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.5", + "uuid": "8ac0809b-f98d-4cff-a66c-3bd9e218ecd6", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/scripts/ConfirmLogout.js b/frontend/assets/scripts/ConfirmLogout.js new file mode 100644 index 0000000..bac6b23 --- /dev/null +++ b/frontend/assets/scripts/ConfirmLogout.js @@ -0,0 +1,29 @@ +cc.Class({ + extends: cc.Component, + + properties: { + mapNode: { + type: cc.Node, + default: null, + } + }, + + onButtonClick(event, customData) { + const mapScriptIns = this.mapNode.getComponent('Map'); + switch (customData) { + case 'confirm': + mapScriptIns.logout.bind(mapScriptIns)(true, false); + break; + case 'cancel': + mapScriptIns.onLogoutConfirmationDismissed.bind(mapScriptIns)(); + break; + default: + break; + } + }, + // LIFE-CYCLE CALLBACKS: + + onLoad() { + + } +}); diff --git a/frontend/assets/scripts/ConfirmLogout.js.meta b/frontend/assets/scripts/ConfirmLogout.js.meta new file mode 100644 index 0000000..cc238b2 --- /dev/null +++ b/frontend/assets/scripts/ConfirmLogout.js.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.5", + "uuid": "e16000cb-4e57-44be-a791-e26298b480bb", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/scripts/CountdownToBeginGame.js b/frontend/assets/scripts/CountdownToBeginGame.js new file mode 100644 index 0000000..2634fa3 --- /dev/null +++ b/frontend/assets/scripts/CountdownToBeginGame.js @@ -0,0 +1,32 @@ +cc.Class({ + extends: cc.Component, + + properties: { + countdownSeconds : { + type: cc.Label, + default: null + }, + }, + + // LIFE-CYCLE CALLBACKS: + onLoad() { + }, + + setData() { + this.startedMillis = Date.now(); + this.durationMillis = 3000; + }, + + update() { + const currentGMTMillis = Date.now(); + const elapsedMillis = currentGMTMillis - this.startedMillis; + let remainingMillis = this.durationMillis - elapsedMillis; + if (remainingMillis <= 0) { + remainingMillis = 0; + } + let remaingHint = "" + Math.round(remainingMillis / 1000 ); + if (remaingHint != this.countdownSeconds.string) { + this.countdownSeconds.string = remaingHint; + } + } +}); diff --git a/frontend/assets/scripts/CountdownToBeginGame.js.meta b/frontend/assets/scripts/CountdownToBeginGame.js.meta new file mode 100644 index 0000000..e92521a --- /dev/null +++ b/frontend/assets/scripts/CountdownToBeginGame.js.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.5", + "uuid": "6a3d663a-2a2d-418a-a015-48a211770465", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/scripts/FindingPlayer.js b/frontend/assets/scripts/FindingPlayer.js new file mode 100644 index 0000000..e6f145b --- /dev/null +++ b/frontend/assets/scripts/FindingPlayer.js @@ -0,0 +1,146 @@ +cc.Class({ + extends: cc.Component, + + properties: { + firstPlayerInfoNode: { + type: cc.Node, + default: null + }, + secondPlayerInfoNode: { + type: cc.Node, + default: null + }, + findingAnimNode: { + type: cc.Node, + default: null + }, + myAvatarNode: { + type: cc.Node, + default: null + }, + exitBtnNode: { + type: cc.Node, + default: null + } + }, + + // LIFE-CYCLE CALLBACKS: + onLoad() { + // WARNING: 不能保证在ws连接成功并且拿到boundRoomId后才运行到此处。 + if (cc.sys.platform == cc.sys.WECHAT_GAME) { + const boundRoomId = window.getBoundRoomIdFromPersistentStorage(); + const wxToShareMessage = { + title: '夺宝大作战', + imageUrl: 'https://mmocgame.qpic.cn/wechatgame/ibxA6JVNslX02zq6aAWCZiaWTXLYGorrVgUszo3WH1oL1CFDcFU7VKPRXPFiadxagMR/0', + imageUrlId: 'FiLZpa5FT5GgEeEagzGBsA', + query: 'expectedRoomId=' + boundRoomId, + }; + console.warn("The boundRoomId for sharing: ", boundRoomId, " wxToShareMessage ", wxToShareMessage); + wx.showShareMenu(); + wx.onShareAppMessage(() => (wxToShareMessage)); + } + }, + + init() { + if (null != this.firstPlayerInfoNode) { + this.firstPlayerInfoNode.active = false; + } + if (null != this.secondPlayerInfoNode) { + this.secondPlayerInfoNode.active = false; + } + this.playersInfoNode = {}; + Object.assign(this.playersInfoNode, { + 1: this.firstPlayerInfoNode + }); + Object.assign(this.playersInfoNode, { + 2: this.secondPlayerInfoNode + }); + + if (null != this.findingAnimNode) { + this.findingAnimNode.active = true; + } + + window.firstPlayerInfoNode = this.firstPlayerInfoNode; + }, + + hideExitButton() { + if (null == this.exitBtnNode != null) { + return; + } + this.exitBtnNode.active = false; + }, + + exitBtnOnClick(evt) { + window.clearBoundRoomIdInBothVolatileAndPersistentStorage(); + window.closeWSConnection(); + if (cc.sys.platform == cc.sys.WECHAT_GAME) { + cc.director.loadScene('wechatGameLogin'); + } else { + cc.director.loadScene('login'); + } + }, + + updatePlayersInfo(playerMetas) { + if (null == playerMetas) return; + for (let i in playerMetas) { + const playerMeta = playerMetas[i]; + const playerInfoNode = this.playersInfoNode[playerMeta.joinIndex]; + if (null == playerInfoNode) { + cc.error("There's no playerInfoNode for joinIndex == ", joinIndex, ", as `this.playerInfoNode` is currently ", this.playersInfoNode); + } + playerInfoNode.active = true; + if (2 == playerMeta.joinIndex) { + if (null != this.findingAnimNode) { + this.findingAnimNode.active = false; + } + } + } + + //显示自己的头像名称以及他人的头像名称 + for (let i in playerMetas) { + const playerMeta = playerMetas[i]; + console.log("Showing playerMeta:", playerMeta); + const playerInfoNode = this.playersInfoNode[playerMeta.joinIndex]; + + (() => { //远程加载头像 + let remoteUrl = playerMeta.avatar; + if (remoteUrl == null || remoteUrl == '') { + cc.log(`No avatar to show for :`); + cc.log(playerMeta); + remoteUrl = 'http://wx.qlogo.cn/mmopen/PiajxSqBRaEJUWib5D85KXWHumaxhU4E9XOn9bUpCNKF3F4ibfOj8JYHCiaoosvoXCkTmOQE1r2AKKs8ObMaz76EdA/0' + } + cc.loader.load({ + url: remoteUrl, + type: 'jpg' + }, function(err, texture) { + if (null != err ) { + console.error(err); + } else { + if (null == texture) { + return; + } + const sf = new cc.SpriteFrame(); + sf.setTexture(texture); + playerInfoNode.getChildByName('avatarMask').getChildByName('avatar').getComponent(cc.Sprite).spriteFrame = sf; + } + }); + })(); + + function isEmptyString(str) { + return str == null || str == '' + } + + const nameNode = playerInfoNode.getChildByName("name"); + const nameToDisplay = (() => { + if (!isEmptyString(playerMeta.displayName)) { + return playerMeta.displayName + } else if (!isEmptyString(playerMeta.name)) { + return playerMeta.name + } else { + return "" + } + })(); + nameNode.getComponent(cc.Label).string = nameToDisplay; + } + }, +}); diff --git a/frontend/assets/scripts/FindingPlayer.js.meta b/frontend/assets/scripts/FindingPlayer.js.meta new file mode 100644 index 0000000..2a37832 --- /dev/null +++ b/frontend/assets/scripts/FindingPlayer.js.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.5", + "uuid": "ecdd3aad-b601-4f8d-85a1-69d9d270a806", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/scripts/GameRule.js b/frontend/assets/scripts/GameRule.js new file mode 100644 index 0000000..5934d8d --- /dev/null +++ b/frontend/assets/scripts/GameRule.js @@ -0,0 +1,24 @@ +cc.Class({ + extends: cc.Component, + + properties: { + modeButton: { + type: cc.Button, + default: null + }, + mapNode: { + type: cc.Node, + default: null + }, + }, + + // LIFE-CYCLE CALLBACKS: + onLoad() { + const modeBtnClickEventHandler = new cc.Component.EventHandler(); + modeBtnClickEventHandler.target = this.mapNode; + modeBtnClickEventHandler.component = "Map"; + modeBtnClickEventHandler.handler = "onGameRule1v1ModeClicked"; + this.modeButton.clickEvents.push(modeBtnClickEventHandler); + } + +}); diff --git a/frontend/assets/scripts/GameRule.js.meta b/frontend/assets/scripts/GameRule.js.meta new file mode 100644 index 0000000..dacac68 --- /dev/null +++ b/frontend/assets/scripts/GameRule.js.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.5", + "uuid": "dd92b295-cbc1-4963-bbaa-de27a8359099", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/scripts/Heap.js b/frontend/assets/scripts/Heap.js new file mode 100644 index 0000000..c5501d7 --- /dev/null +++ b/frontend/assets/scripts/Heap.js @@ -0,0 +1,243 @@ +/** + * Creates a binary heap. + * + * @constructor + * @param {function} customCompare An optional custom node comparison + * function. + */ +var BinaryHeap = function (customCompare) { + /** + * The backing data of the heap. + * @type {Object[]} + * @private + */ + this.list = []; + + if (customCompare) { + this.compare = customCompare; + } +}; + +/** + * Builds a heap with the provided keys and values, this will discard the + * heap's current data. + * + * @param {Array} keys An array of keys. + * @param {Array} values An array of values. This must be the same size as the + * key array. + */ +BinaryHeap.prototype.buildHeap = function (keys, values) { + if (typeof values !== 'undefined' && values.length !== keys.length) { + throw new Error('Key array must be the same length as value array'); + } + + var nodeArray = []; + + for (var i = 0; i < keys.length; i++) { + nodeArray.push(new Node(keys[i], values ? values[i] : undefined)); + } + + buildHeapFromNodeArray(this, nodeArray); +}; + +/** + * Clears the heap's data, making it an empty heap. + */ +BinaryHeap.prototype.clear = function () { + this.list.length = 0; +}; + +/** + * Extracts and returns the minimum node from the heap. + * + * @return {Node} node The heap's minimum node or undefined if the heap is + * empty. + */ +BinaryHeap.prototype.extractMinimum = function () { + if (!this.list.length) { + return undefined; + } + if (this.list.length === 1) { + return this.list.shift(); + } + var min = this.list[0]; + this.list[0] = this.list.pop(); + heapify(this, 0); + return min; +}; + +/** + * Returns the minimum node from the heap. + * + * @return {Node} node The heap's minimum node or undefined if the heap is + * empty. + */ +BinaryHeap.prototype.findMinimum = function () { + return this.isEmpty() ? undefined : this.list[0]; +}; + +/** + * Inserts a new key-value pair into the heap. + * + * @param {Object} key The key to insert. + * @param {Object} value The value to insert. + * @return {Node} node The inserted node. + */ +BinaryHeap.prototype.insert = function (key, value) { + var i = this.list.length; + var node = new Node(key, value); + this.list.push(node); + var parent = getParent(i); + while (typeof parent !== 'undefined' && + this.compare(this.list[i], this.list[parent]) < 0) { + swap(this.list, i, parent); + i = parent; + parent = getParent(i); + } + return node; +}; + +/** + * @return {boolean} Whether the heap is empty. + */ +BinaryHeap.prototype.isEmpty = function () { + return !this.list.length; +}; + +/** + * @return {number} The size of the heap. + */ +BinaryHeap.prototype.size = function () { + return this.list.length; +}; + +/** + * Joins another heap to this one. + * + * @param {BinaryHeap} otherHeap The other heap. + */ +BinaryHeap.prototype.union = function (otherHeap) { + var array = this.list.concat(otherHeap.list); + buildHeapFromNodeArray(this, array); +}; + +/** + * Compares two nodes with each other. + * + * @private + * @param {Object} a The first key to compare. + * @param {Object} b The second key to compare. + * @return -1, 0 or 1 if a < b, a == b or a > b respectively. + */ +BinaryHeap.prototype.compare = function (a, b) { + if (a.key > b.key) { + return 1; + } + if (a.key < b.key) { + return -1; + } + return 0; +}; + +/** + * Heapifies a node. + * + * @private + * @param {BinaryHeap} heap The heap containing the node to heapify. + * @param {number} i The index of the node to heapify. + */ +function heapify(heap, i) { + var l = getLeft(i); + var r = getRight(i); + var smallest = i; + if (l < heap.list.length && + heap.compare(heap.list[l], heap.list[i]) < 0) { + smallest = l; + } + if (r < heap.list.length && + heap.compare(heap.list[r], heap.list[smallest]) < 0) { + smallest = r; + } + if (smallest !== i) { + swap(heap.list, i, smallest); + heapify(heap, smallest); + } +} + +/** + * Builds a heap from a node array, this will discard the heap's current data. + * + * @private + * @param {BinaryHeap} heap The heap to override. + * @param {Node[]} nodeArray The array of nodes for the new heap. + */ +function buildHeapFromNodeArray(heap, nodeArray) { + heap.list = nodeArray; + for (var i = Math.floor(heap.list.length / 2); i >= 0; i--) { + heapify(heap, i); + } +} + +/** + * Swaps two values in an array. + * + * @private + * @param {Array} array The array to swap on. + * @param {number} a The index of the first element. + * @param {number} b The index of the second element. + */ +function swap(array, a, b) { + var temp = array[a]; + array[a] = array[b]; + array[b] = temp; +} + +/** + * Gets the index of a node's parent. + * + * @private + * @param {number} i The index of the node to get the parent of. + * @return {number} The index of the node's parent. + */ +function getParent(i) { + if (i === 0) { + return undefined; + } + return Math.floor((i - 1) / 2); +} + +/** + * Gets the index of a node's left child. + * + * @private + * @param {number} i The index of the node to get the left child of. + * @return {number} The index of the node's left child. + */ +function getLeft(i) { + return 2 * i + 1; +} + +/** + * Gets the index of a node's right child. + * + * @private + * @param {number} i The index of the node to get the right child of. + * @return {number} The index of the node's right child. + */ +function getRight(i) { + return 2 * i + 2; +} + +/** + * Creates a node. + * + * @constructor + * @param {Object} key The key of the new node. + * @param {Object} value The value of the new node. + */ +function Node(key, value) { + this.key = key; + this.value = value; +} + +module.exports = BinaryHeap; diff --git a/frontend/assets/scripts/Heap.js.meta b/frontend/assets/scripts/Heap.js.meta new file mode 100644 index 0000000..91cf7da --- /dev/null +++ b/frontend/assets/scripts/Heap.js.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.5", + "uuid": "247b7613-6c6e-4f01-b1d6-5f8f041b5688", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/scripts/KeyboardControls.js b/frontend/assets/scripts/KeyboardControls.js new file mode 100644 index 0000000..d40ba44 --- /dev/null +++ b/frontend/assets/scripts/KeyboardControls.js @@ -0,0 +1,69 @@ +cc.Class({ + extends: cc.Component, + + properties: {}, + + setInputControls: function() { + const self = this; + // add keyboard event listener + // When there is a key being pressed down, judge if it's the designated directional button and set up acceleration in the corresponding direction + cc.systemEvent.on(cc.SystemEvent.EventType.KEY_DOWN, function(event) { + switch (event.keyCode) { + case cc.macro.KEY.w: + self.activeDirection.dPjY = +1.0; + break; + case cc.macro.KEY.s: + self.activeDirection.dPjY = -1.0; + break; + case cc.macro.KEY.a: + self.activeDirection.dPjX = -2.0; + break; + case cc.macro.KEY.d: + self.activeDirection.dPjX = +2.0; + break; + default: + break; + } + }, self.node); + + // when releasing the button, stop acceleration in this direction + cc.systemEvent.on(cc.SystemEvent.EventType.KEY_UP, function(event) { + switch (event.keyCode) { + case cc.macro.KEY.w: + if (+1.0 == self.activeDirection.dPjY) { + self.activeDirection.dPjY = 0.0; + } + break; + case cc.macro.KEY.s: + if (-1.0 == self.activeDirection.dPjY) { + self.activeDirection.dPjY = 0.0; + } + break; + case cc.macro.KEY.a: + if (-2.0 == self.activeDirection.dPjX) { + self.activeDirection.dPjX = 0.0; + } + break; + case cc.macro.KEY.d: + if (+2.0 == self.activeDirection.dPjX) { + self.activeDirection.dPjX = 0.0; + } + break; + default: + break; + } + }, self.node); + }, + + // LIFE-CYCLE CALLBACKS: + + onLoad() { + // Properties deliberately hidden from GUI panel. + this.activeDirection = { + dPjY: 0.0, + dPjX: 0.0 + }; + this.setInputControls(); + } +}); + diff --git a/frontend/assets/scripts/KeyboardControls.js.meta b/frontend/assets/scripts/KeyboardControls.js.meta new file mode 100644 index 0000000..f8aa05c --- /dev/null +++ b/frontend/assets/scripts/KeyboardControls.js.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.5", + "uuid": "4561a173-bfd2-4f64-b7ba-888cce0e4d9d", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/scripts/Login.js b/frontend/assets/scripts/Login.js new file mode 100644 index 0000000..cd46436 --- /dev/null +++ b/frontend/assets/scripts/Login.js @@ -0,0 +1,555 @@ +const i18n = require('LanguageData'); +i18n.init(window.language); // languageID should be equal to the one we input in New Language ID input field +cc.Class({ + extends: cc.Component, + + properties: { + cavasNode: { + default: null, + type: cc.Node + }, + backgroundNode: { + default: null, + type: cc.Node + }, + interactiveControls: { + default: null, + type: cc.Node + }, + phoneLabel: { + default: null, + type: cc.Node + }, + smsLoginCaptchaLabel: { + default: null, + type: cc.Node + }, + phoneCountryCodeInput: { + default: null, + type: cc.Node + }, + phoneNumberInput: { + type: cc.Node, + default: null + }, + phoneNumberTips: { + type: cc.Node, + default: null + }, + smsLoginCaptchaInput: { + type: cc.Node, + default: null + }, + smsLoginCaptchaButton: { + type: cc.Node, + default: null + }, + captchaTips: { + type: cc.Node, + default: null + }, + loginButton: { + type: cc.Node, + default: null + }, + smsWaitCountdownPrefab: { + default: null, + type: cc.Prefab + }, + loadingPrefab: { + default: null, + type: cc.Prefab + }, + wechatLoginTips: { + default: null, + type: cc.Label, + }, + }, + + // LIFE-CYCLE CALLBACKS: + + onLoad() { + + //kobako: 腾讯统计代码 + //WARN: 打包到微信小游戏的时候会导致出错 + /* + (function() { + var mta = document.createElement("script"); + mta.src = "//pingjs.qq.com/h5/stats.js?v2.0.4"; + mta.setAttribute("name", "MTAH5"); + mta.setAttribute("sid", "500674632"); + var s = document.getElementsByTagName("script")[0]; + s.parentNode.insertBefore(mta, s); + })(); + */ + + window.atFirstLocationHref = window.location.href.split('#')[0]; + const self = this; + self.getRetCodeList(); + self.getRegexList(); + + const isUsingX5BlinkKernelOrWebkitWeChatKernel = window.isUsingX5BlinkKernelOrWebkitWeChatKernel(); + //const isUsingX5BlinkKernelOrWebkitWeChatKernel = true; + if (!CC_DEBUG) { + self.phoneNumberTips.active = !isUsingX5BlinkKernelOrWebkitWeChatKernel; + self.smsLoginCaptchaButton.active = !isUsingX5BlinkKernelOrWebkitWeChatKernel; + + self.captchaTips.active = !isUsingX5BlinkKernelOrWebkitWeChatKernel; + self.phoneCountryCodeInput.active = !isUsingX5BlinkKernelOrWebkitWeChatKernel; + self.phoneNumberInput.active = !isUsingX5BlinkKernelOrWebkitWeChatKernel; + self.smsLoginCaptchaInput.active = !isUsingX5BlinkKernelOrWebkitWeChatKernel; + + self.phoneLabel.active = !isUsingX5BlinkKernelOrWebkitWeChatKernel; + self.smsLoginCaptchaLabel.active = !isUsingX5BlinkKernelOrWebkitWeChatKernel; + + self.loginButton.active = !isUsingX5BlinkKernelOrWebkitWeChatKernel; + } + self.checkPhoneNumber = self.checkPhoneNumber.bind(self); + self.checkIntAuthTokenExpire = self.checkIntAuthTokenExpire.bind(self); + self.checkCaptcha = self.checkCaptcha.bind(self); + self.onSMSCaptchaGetButtonClicked = self.onSMSCaptchaGetButtonClicked.bind(self); + self.smsLoginCaptchaButton.on('click', self.onSMSCaptchaGetButtonClicked); + + self.loadingNode = cc.instantiate(this.loadingPrefab); + self.smsGetCaptchaNode = self.smsLoginCaptchaButton.getChildByName('smsGetCaptcha'); + self.smsWaitCountdownNode = cc.instantiate(self.smsWaitCountdownPrefab); + + const qDict = window.getQueryParamDict(); + if (null != qDict && qDict["expectedRoomId"]) { + window.clearBoundRoomIdInBothVolatileAndPersistentStorage(); + } + + cc.loader.loadRes("pbfiles/room_downsync_frame", function(err, textAsset /* cc.TextAsset */ ) { + if (err) { + cc.error(err.message || err); + return; + } + if (false == (cc.sys.platform == cc.sys.WECHAT_GAME)) { + // Otherwise, `window.RoomDownsyncFrame` is already assigned. + let protoRoot = new protobuf.Root; + window.protobuf.parse(textAsset.text, protoRoot); + window.RoomDownsyncFrame = protoRoot.lookupType("treasurehunterx.RoomDownsyncFrame"); + window.BattleColliderInfo = protoRoot.lookupType("treasurehunterx.BattleColliderInfo"); + window.WsReq = protoRoot.lookupType("treasurehunterx.WsReq"); + window.WsResp = protoRoot.lookupType("treasurehunterx.WsResp"); + } + self.checkIntAuthTokenExpire().then( + () => { + const intAuthToken = JSON.parse(cc.sys.localStorage.getItem('selfPlayer')).intAuthToken; + self.useTokenLogin(intAuthToken); + }, + () => { + window.clearBoundRoomIdInBothVolatileAndPersistentStorage(); + if ( (CC_DEBUG || isUsingX5BlinkKernelOrWebkitWeChatKernel) ) { + if (null != qDict && qDict["code"]) { + const code = qDict["code"]; + console.log("Got the wx authcode: ", code, "while at full url: " + window.location.href); + self.useWXCodeLogin(code); + } else { + if (isUsingX5BlinkKernelOrWebkitWeChatKernel) { + self.getWechatCode(null); + } else { + // Deliberately left blank. + } + } + } + } + ); + }); + }, + + getRetCodeList() { + const self = this; + self.retCodeDict = constants.RET_CODE; + }, + + getRegexList() { + const self = this; + self.regexList = { + EMAIL: /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/, + PHONE: /^\+?[0-9]{8,14}$/, + STREET_META: /^.{5,100}$/, + LNG_LAT_TEXT: /^[0-9]+(\.[0-9]{4,6})$/, + SEO_KEYWORD: /^.{2,50}$/, + PASSWORD: /^.{6,50}$/, + SMS_CAPTCHA_CODE: /^[0-9]{4}$/, + ADMIN_HANDLE: /^.{4,50}$/, + }; + }, + + onSMSCaptchaGetButtonClicked(evt) { + var timerEnable = true; + const self = this; + if (!self.checkPhoneNumber('getCaptcha')) { + return; + } + NetworkUtils.ajax({ + url: backendAddress.PROTOCOL + '://' + backendAddress.HOST + ':' + backendAddress.PORT + constants.ROUTE_PATH.API + constants.ROUTE_PATH.PLAYER + + constants.ROUTE_PATH.VERSION + constants.ROUTE_PATH.SMS_CAPTCHA + constants.ROUTE_PATH.GET, + type: 'GET', + data: { + phoneCountryCode: self.phoneCountryCodeInput.getComponent(cc.EditBox).string, + phoneNum: self.phoneNumberInput.getComponent(cc.EditBox).string + }, + success: function(res) { + switch (res.ret) { + case self.retCodeDict.OK: + self.phoneNumberTips.getComponent(cc.Label).string = ''; + self.captchaTips.getComponent(cc.Label).string = ''; + break; + case self.retCodeDict.DUPLICATED: + self.phoneNumberTips.getComponent(cc.Label).string = constants.ALERT.TIP_LABEL.LOG_OUT; + break; + case self.retCodeDict.INCORRECT_PHONE_COUNTRY_CODE_OR_NUMBER: + self.captchaTips.getComponent(cc.Label).string = i18n.t("login.tips.PHONE_ERR"); + break; + case self.retCodeDict.IS_TEST_ACC: + self.smsLoginCaptchaInput.getComponent(cc.EditBox).string = res.smsLoginCaptcha; + self.captchaTips.getComponent(cc.Label).string = i18n.t("login.tips.TEST_USER"); + timerEnable = false; + // clearInterval(self.countdownTimer); + break; + case self.retCodeDict.SMS_CAPTCHA_REQUESTED_TOO_FREQUENTLY: + self.captchaTips.getComponent(cc.Label).string = i18n.t("login.tips.SMS_CAPTCHA_FREEQUENT_REQUIRE"); + default: + break; + } + if (timerEnable) + self.countdownTime(self); + } + }); + }, + + countdownTime(self) { + self.smsLoginCaptchaButton.off('click', self.onSMSCaptchaGetButtonClicked); + self.smsLoginCaptchaButton.removeChild(self.smsGetCaptchaNode); + self.smsWaitCountdownNode.parent = self.smsLoginCaptchaButton; + var total = 20; // Magic number + self.countdownTimer = setInterval(function() { + if (total === 0) { + self.smsWaitCountdownNode.parent.removeChild(self.smsWaitCountdownNode); + self.smsGetCaptchaNode.parent = self.smsLoginCaptchaButton; + self.smsWaitCountdownNode.getChildByName('WaitTimeLabel').getComponent(cc.Label).string = 20; + self.smsLoginCaptchaButton.on('click', self.onSMSCaptchaGetButtonClicked); + clearInterval(self.countdownTimer); + } else { + total--; + self.smsWaitCountdownNode.getChildByName('WaitTimeLabel').getComponent(cc.Label).string = total; + } + }, 1000) + + }, + + checkIntAuthTokenExpire() { + return new Promise((resolve, reject) => { + if (!cc.sys.localStorage.getItem('selfPlayer')) { + reject(); + return; + } + const selfPlayer = JSON.parse(cc.sys.localStorage.getItem('selfPlayer')); + (selfPlayer.intAuthToken && new Date().getTime() < selfPlayer.expiresAt) ? resolve() : reject(); + }) + }, + + checkPhoneNumber(type) { + const self = this; + const phoneNumberRegexp = self.regexList.PHONE; + var phoneNumberString = self.phoneNumberInput.getComponent(cc.EditBox).string; + if (phoneNumberString) { + return true; + if (!phoneNumberRegexp.test(phoneNumberString)) { + self.captchaTips.getComponent(cc.Label).string = i18n.t("login.tips.PHONE_ERR"); + return false; + } else { + return true; + } + } else { + if (type === 'getCaptcha' || type === 'login') { + self.captchaTips.getComponent(cc.Label).string = i18n.t("login.tips.PHONE_ERR"); + } + return false; + } + }, + + checkCaptcha(type) { + const self = this; + const captchaRegexp = self.regexList.SMS_CAPTCHA_CODE; + var captchaString = self.smsLoginCaptchaInput.getComponent(cc.EditBox).string; + + if (captchaString) { + if (self.smsLoginCaptchaInput.getComponent(cc.EditBox).string.length !== 4 || (!captchaRegexp.test(captchaString))) { + self.captchaTips.getComponent(cc.Label).string = i18n.t("login.tips.CAPTCHA_ERR"); + return false; + } else { + return true; + } + } else { + if ('login' == type) { + self.captchaTips.getComponent(cc.Label).string = i18n.t("login.tips.CAPTCHA_ERR"); + } + return false; + } + }, + + useTokenLogin(_intAuthToken) { + var self = this; + NetworkUtils.ajax({ + url: backendAddress.PROTOCOL + '://' + backendAddress.HOST + ':' + backendAddress.PORT + constants.ROUTE_PATH.API + constants.ROUTE_PATH.PLAYER + constants.ROUTE_PATH.VERSION + constants.ROUTE_PATH.INT_AUTH_TOKEN + constants.ROUTE_PATH.LOGIN, + type: "POST", + data: { + intAuthToken: _intAuthToken + }, + success: function(resp) { + self.onLoggedIn(resp); + }, + error: function(xhr, status, errMsg) { + console.log("Login attempt `useTokenLogin` failed, about to execute `clearBoundRoomIdInBothVolatileAndPersistentStorage`."); + window.clearBoundRoomIdInBothVolatileAndPersistentStorage() + }, + timeout: function() { + self.enableInteractiveControls(true); + }, + }); + }, + + enableInteractiveControls(enabled) { + this.smsLoginCaptchaButton.getComponent(cc.Button).interactable = enabled; + this.loginButton.getComponent(cc.Button).interactable = enabled; + this.phoneCountryCodeInput.getComponent(cc.EditBox).enabled = enabled; + this.phoneNumberInput.getComponent(cc.EditBox).enabled = enabled; + this.smsLoginCaptchaInput.getComponent(cc.EditBox).enabled = enabled; + if (enabled) { + setVisible(this.interactiveControls); + } else { + setInvisible(this.interactiveControls); + } + }, + + onLoginButtonClicked(evt) { + const self = this; + if (!self.checkPhoneNumber('login') || !self.checkCaptcha('login')) { + return; + } + self.loginParams = { + phoneCountryCode: self.phoneCountryCodeInput.getComponent(cc.EditBox).string, + phoneNum: self.phoneNumberInput.getComponent(cc.EditBox).string, + smsLoginCaptcha: self.smsLoginCaptchaInput.getComponent(cc.EditBox).string + }; + self.enableInteractiveControls(false); + + NetworkUtils.ajax({ + url: backendAddress.PROTOCOL + '://' + backendAddress.HOST + ':' + backendAddress.PORT + constants.ROUTE_PATH.API + constants.ROUTE_PATH.PLAYER + + constants.ROUTE_PATH.VERSION + constants.ROUTE_PATH.SMS_CAPTCHA + constants.ROUTE_PATH.LOGIN, + type: "POST", + data: self.loginParams, + success: function(resp) { + self.onLoggedIn(resp); + }, + error: function(xhr, status, errMsg) { + console.log("Login attempt `onLoginButtonClicked` failed, about to execute `clearBoundRoomIdInBothVolatileAndPersistentStorage`."); + window.clearBoundRoomIdInBothVolatileAndPersistentStorage() + }, + timeout: function() { + self.enableInteractiveControls(true); + } + }); + }, + + onWechatLoggedIn(res) { + const self = this; + if (res.ret === self.retCodeDict.OK) { + self.enableInteractiveControls(false); + const date = Number(res.expiresAt); + const selfPlayer = { + expiresAt: date, + playerId: res.playerId, + intAuthToken: res.intAuthToken, + displayName: res.displayName, + avatar: res.avatar, + } + cc.sys.localStorage.setItem('selfPlayer', JSON.stringify(selfPlayer)); + + const qDict = window.getQueryParamDict(); + const expectedRoomId = qDict["expectedRoomId"]; + if (null != expectedRoomId) { + console.log("onWechatLoggedIn using expectedRoomId == " + expectedRoomId); + window.clearBoundRoomIdInBothVolatileAndPersistentStorage(); + } + // To remove "code=XXX" in "query string". + window.history.replaceState(qDict, null, window.location.pathname); + self.useTokenLogin(res.intAuthToken); + } else { + cc.sys.localStorage.removeItem("selfPlayer"); + window.clearBoundRoomIdInBothVolatileAndPersistentStorage(); + self.wechatLoginTips.string = constants.ALERT.TIP_LABEL.WECHAT_LOGIN_FAILS + ", errorCode = " + res.ret; + // To remove "code=XXX" in "query string". + window.history.replaceState({}, null, window.location.pathname); + } + }, + + onLoggedIn(res) { + const self = this; + cc.log(`OnLoggedIn ${JSON.stringify(res)}.`) + if (res.ret === self.retCodeDict.OK) { + if(window.isUsingX5BlinkKernelOrWebkitWeChatKernel()) { + window.initWxSdk = self.initWxSdk.bind(self); + window.initWxSdk(); + } + self.enableInteractiveControls(false); + const date = Number(res.expiresAt); + const selfPlayer = { + expiresAt: date, + playerId: res.playerId, + intAuthToken: res.intAuthToken, + avatar: res.avatar, + displayName: res.displayName, + name: res.name, + } + cc.sys.localStorage.setItem('selfPlayer', JSON.stringify(selfPlayer)); + console.log("cc.sys.localStorage.selfPlayer = ", cc.sys.localStorage.getItem('selfPlayer')); + if (self.countdownTimer) { + clearInterval(self.countdownTimer); + } + const inputControls = self.backgroundNode.getChildByName("InteractiveControls"); + self.backgroundNode.removeChild(inputControls); + safelyAddChild(self.backgroundNode, self.loadingNode); + self.loadingNode.getChildByName('loadingSprite').runAction( + cc.repeatForever(cc.rotateBy(1.0, 360)) + ); + cc.director.loadScene('default_map'); + } else { + cc.sys.localStorage.removeItem("selfPlayer"); + window.clearBoundRoomIdInBothVolatileAndPersistentStorage(); + self.enableInteractiveControls(true); + switch (res.ret) { + case self.retCodeDict.DUPLICATED: + this.phoneNumberTips.getComponent(cc.Label).string = constants.ALERT.TIP_LABEL.LOG_OUT; + break; + case this.retCodeDict.TOKEN_EXPIRED: + this.captchaTips.getComponent(cc.Label).string = constants.ALERT.TIP_LABEL.TOKEN_EXPIRED; + break; + case this.retCodeDict.SMS_CAPTCHA_NOT_MATCH: + self.captchaTips.getComponent(cc.Label).string = i18n.t("login.tips.SMS_CAPTCHA_NOT_MATCH"); + break; + case this.retCodeDict.INCORRECT_CAPTCHA: + self.captchaTips.getComponent(cc.Label).string = i18n.t("login.tips.SMS_CAPTCHA_NOT_MATCH"); + break; + case this.retCodeDict.SMS_CAPTCHA_CODE_NOT_EXISTING: + self.captchaTips.getComponent(cc.Label).string = i18n.t("login.tips.SMS_CAPTCHA_NOT_MATCH"); + break; + case this.retCodeDict.INCORRECT_PHONE_NUMBER: + self.captchaTips.getComponent(cc.Label).string = i18n.t("login.tips.INCORRECT_PHONE_NUMBER"); + break; + case this.retCodeDict.INVALID_REQUEST_PARAM: + self.captchaTips.getComponent(cc.Label).string = i18n.t("login.tips.INCORRECT_PHONE_NUMBER"); + break; + case this.retCodeDict.INCORRECT_PHONE_COUNTRY_CODE: + this.captchaTips.getComponent(cc.Label).string = constants.ALERT.TIP_LABEL.INCORRECT_PHONE_COUNTRY_CODE; + break; + default: + break; + } + } + }, + + useWXCodeLogin(_code) { + const self = this; + NetworkUtils.ajax({ + url: backendAddress.PROTOCOL + '://' + backendAddress.HOST + ':' + backendAddress.PORT + constants.ROUTE_PATH.API + constants.ROUTE_PATH.PLAYER + constants.ROUTE_PATH.VERSION + constants.ROUTE_PATH.WECHAT + constants.ROUTE_PATH.LOGIN, + type: "POST", + data: { + code: _code + }, + success: function(res) { + self.onWechatLoggedIn(res); + }, + error: function(xhr, status, errMsg) { + console.log("Login attempt `useWXCodeLogin` failed, about to execute `clearBoundRoomIdInBothVolatileAndPersistentStorage`."); + cc.sys.localStorage.removeItem("selfPlayer"); + window.clearBoundRoomIdInBothVolatileAndPersistentStorage(); + self.wechatLoginTips.string = constants.ALERT.TIP_LABEL.WECHAT_LOGIN_FAILS + ", errorMsg =" + errMsg; + window.history.replaceState({}, null, window.location.pathname); + }, + }); + }, + + getWechatCode(evt) { + let self = this; + self.wechatLoginTips.string = ""; + const wechatServerEndpoint = wechatAddress.PROTOCOL + "://" + wechatAddress.HOST + ((null != wechatAddress.PORT && "" != wechatAddress.PORT.trim()) ? (":" + wechatAddress.PORT) : ""); + const url = wechatServerEndpoint + constants.WECHAT.AUTHORIZE_PATH + "?" + wechatAddress.APPID_LITERAL + "&" + constants.WECHAT.REDIRECT_RUI_KEY + NetworkUtils.encode(window.location.href) + "&" + constants.WECHAT.RESPONSE_TYPE + "&" + constants.WECHAT.SCOPE + constants.WECHAT.FIN; + console.log("To visit wechat auth addr: " + url); + window.location.href = url; + }, + + initWxSdk() { + const selfPlayer = JSON.parse(cc.sys.localStorage.getItem('selfPlayer')); + const origUrl = window.location.protocol + "//" + window.location.host + window.location.pathname; + /* + * The `shareLink` must + * - have its 2nd-order-domain registered as trusted 2nd-order under the targetd `res.jsConfig.app_id`, and + * - extracted from current window.location.href. + */ + const shareLink = origUrl; + const updateAppMsgShareDataObj = { + type: 'link', // 分享类型,music、video或link,不填默认为link + dataUrl: '', // 如果type是music或video,则要提供数据链接,默认为空 + title: document.title, // 分享标题 + desc: 'Let\'s play together!', // 分享描述 + link: shareLink + (cc.sys.localStorage.getItem('boundRoomId') ? "" : ("?expectedRoomId=" + cc.sys.localStorage.getItem('boundRoomId'))), + imgUrl: origUrl + "/favicon.ico", // 分享图标 + success: function() { + // 设置成功 + } + }; + const menuShareTimelineObj = { + title: document.title, // 分享标题 + link: shareLink + (cc.sys.localStorage.getItem('boundRoomId') ? "" : ("?expectedRoomId=" + cc.sys.localStorage.getItem('boundRoomId'))), + imgUrl: origUrl + "/favicon.ico", // 分享图标 + success: function() {} + }; + + const wxConfigUrl = (window.isUsingWebkitWechatKernel() ? window.atFirstLocationHref : window.location.href); + //接入微信登录接口 + NetworkUtils.ajax({ + "url": backendAddress.PROTOCOL + '://' + backendAddress.HOST + ':' + backendAddress.PORT + constants.ROUTE_PATH.API + constants.ROUTE_PATH.PLAYER + constants.ROUTE_PATH.VERSION + constants.ROUTE_PATH.WECHAT + constants.ROUTE_PATH.JSCONFIG, + type: "POST", + data: { + "url": wxConfigUrl, + "intAuthToken": selfPlayer.intAuthToken, + }, + success: function(res) { + if (constants.RET_CODE.OK != res.ret) { + console.log("cannot get the wsConfig. retCode == " + res.ret); + return; + } + const jsConfig = res.jsConfig; + console.log(updateAppMsgShareDataObj); + const configData = { + debug: CC_DEBUG, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。 + appId: jsConfig.app_id, // 必填,公众号的唯一标识 + timestamp: jsConfig.timestamp.toString(), // 必填,生成签名的时间戳 + nonceStr: jsConfig.nonce_str, // 必填,生成签名的随机串 + jsApiList: ['onMenuShareAppMessage', 'onMenuShareTimeline'], + signature: jsConfig.signature, // 必填,签名 + }; + console.log("config url: " + wxConfigUrl); + console.log("wx.config: "); + console.log(configData); + wx.config(configData); + console.log("Current window.location.href: " + window.location.href); + wx.ready(function() { + console.log("Here is wx.ready.") + wx.onMenuShareAppMessage(updateAppMsgShareDataObj); + wx.onMenuShareTimeline(menuShareTimelineObj); + }); + wx.error(function(res) { + console.error("wx config fails and error is " + JSON.stringify(res)); + }); + }, + error: function(xhr, status, errMsg) { + console.log("cannot get the wsConfig. errMsg == " + errMsg); + }, + }); + }, +}); diff --git a/frontend/assets/scripts/Login.js.meta b/frontend/assets/scripts/Login.js.meta new file mode 100644 index 0000000..89b0a57 --- /dev/null +++ b/frontend/assets/scripts/Login.js.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.5", + "uuid": "12a3d94d-56bd-42d2-8a2e-da1d27168980", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/scripts/Map.js b/frontend/assets/scripts/Map.js new file mode 100644 index 0000000..743ecb9 --- /dev/null +++ b/frontend/assets/scripts/Map.js @@ -0,0 +1,1011 @@ +const i18n = require('LanguageData'); +i18n.init(window.language); // languageID should be equal to the one we input in New Language ID input field + +window.ALL_MAP_STATES = { + VISUAL: 0, // For free dragging & zooming. + EDITING_BELONGING: 1, + SHOWING_MODAL_POPUP: 2, +}; + +window.ALL_BATTLE_STATES = { + WAITING: 0, + IN_BATTLE: 1, + IN_SETTLEMENT: 2, + IN_DISMISSAL: 3, +}; + +window.MAGIC_ROOM_DOWNSYNC_FRAME_ID = { + BATTLE_READY_TO_START: -99, + PLAYER_ADDED_AND_ACKED: -98, + PLAYER_READDED_AND_ACKED: -97, +}; + +cc.Class({ + extends: cc.Component, + + properties: { + canvasNode: { + type: cc.Node, + default: null, + }, + tiledAnimPrefab: { + type: cc.Prefab, + default: null, + }, + player1Prefab: { + type: cc.Prefab, + default: null, + }, + player2Prefab: { + type: cc.Prefab, + default: null, + }, + treasurePrefab: { + type: cc.Prefab, + default: null, + }, + trapPrefab: { + type: cc.Prefab, + default: null, + }, + speedShoePrefab: { + type: cc.Prefab, + default: null, + }, + polygonBoundaryBarrierPrefab: { + type: cc.Prefab, + default: null, + }, + polygonBoundaryShelterPrefab: { + type: cc.Prefab, + default: null, + }, + polygonBoundaryShelterZReducerPrefab: { + type: cc.Prefab, + default: null, + }, + keyboardInputControllerNode: { + type: cc.Node, + default: null + }, + joystickInputControllerNode: { + type: cc.Node, + default: null + }, + confirmLogoutPrefab: { + type: cc.Prefab, + default: null + }, + simplePressToGoDialogPrefab: { + type: cc.Prefab, + default: null + }, + boundRoomIdLabel: { + type: cc.Label, + default: null + }, + countdownLabel: { + type: cc.Label, + default: null + }, + trapBulletPrefab: { + type: cc.Prefab, + default: null + }, + resultPanelPrefab: { + type: cc.Prefab, + default: null + }, + gameRulePrefab: { + type: cc.Prefab, + default: null + }, + findingPlayerPrefab: { + type: cc.Prefab, + default: null + }, + countdownToBeginGamePrefab: { + type: cc.Prefab, + default: null + }, + playersInfoPrefab: { + type: cc.Prefab, + default: null + }, + guardTowerPrefab: { + type: cc.Prefab, + default: null + }, + forceBigEndianFloatingNumDecoding: { + default: false, + }, + backgroundMapTiledIns: { + type: cc.TiledMap, + default: null + }, + }, + + _inputFrameIdDebuggable(inputFrameId) { + return (0 == inputFrameId%10); + }, + + _dumpToFullFrameCache: function(fullFrame) { + const self = this; + while (self.recentFrameCacheCurrentSize >= self.recentFrameCacheMaxCount) { + const toDelFrameId = Object.keys(self.recentFrameCache)[0]; + delete self.recentFrameCache[toDelFrameId]; + --self.recentFrameCacheCurrentSize; + } + self.recentFrameCache[fullFrame.id] = fullFrame; + ++self.recentFrameCacheCurrentSize; + }, + + _dumpToInputCache: function(inputFrameDownsync) { + const self = this; + while (self.recentInputCacheCurrentSize >= self.recentInputCacheMaxCount) { + const toDelFrameId = Object.keys(self.recentInputCache)[0]; + // console.log("Deleting toDelFrameId=", toDelFrameId, " from recentInputCache"); + delete self.recentInputCache[toDelFrameId]; + --self.recentInputCacheCurrentSize; + } + self.recentInputCache[inputFrameDownsync.inputFrameId] = inputFrameDownsync; + ++self.recentInputCacheCurrentSize; + }, + + _convertToInputFrameId(renderFrameId, inputDelayFrames) { + if (renderFrameId < inputDelayFrames) return 0; + const inputScaleFrames = 2; + return ((renderFrameId - inputDelayFrames) >> inputScaleFrames); + }, + + _convertToRenderFrameId(inputFrameId, inputDelayFrames) { + const inputScaleFrames = 2; + return ((inputFrameId << inputScaleFrames) + inputDelayFrames); + }, + + _shouldGenerateInputFrameUpsync(renderFrameId) { + return ((renderFrameId & 3) == 0); // 3 is 0x0011 + }, + + _generateInputFrameUpsync(inputFrameId) { + const instance = this; + if ( + null == instance.ctrl || + null == instance.selfPlayerInfo + ) { + return [null, null]; + } + + const discreteDir = instance.ctrl.getDiscretizedDirection(); + let prefabbedInputList = null; + let selfPlayerLastInputFrameInput = 0; + if (0 == instance.lastLocalInputFrameId) { + prefabbedInputList = new Array(Object.keys(instance.playersNode).length).fill(0); + } else { + if (null == instance.recentInputCache || null == instance.recentInputCache[instance.lastLocalInputFrameId-1]) { + console.warn("_generateInputFrameUpsync: recentInputCache is NOT having inputFrameId=", instance.lastLocalInputFrameId-1, "; recentInputCache=", instance._stringifyRecentInputCache(false)); + prefabbedInputList = new Array(Object.keys(instance.playersNode).length).fill(0); + } else { + prefabbedInputList = Array.from(instance.recentInputCache[instance.lastLocalInputFrameId-1].inputList); + selfPlayerLastInputFrameInput = prefabbedInputList[(instance.selfPlayerInfo.joinIndex-1)]; // it's an integer, thus making a copy here, not impacted by later assignments + } + } + + prefabbedInputList[(instance.selfPlayerInfo.joinIndex-1)] = discreteDir.encodedIdx; + + const prefabbedInputFrameDownsync = { + inputFrameId: inputFrameId, + inputList: prefabbedInputList, + confirmedList: (1 << (instance.selfPlayerInfo.joinIndex-1)) + }; + + instance._dumpToInputCache(prefabbedInputFrameDownsync); // A prefabbed inputFrame, would certainly be adding a new inputFrame to the cache, because server only downsyncs "all-confirmed inputFrames" + + return [selfPlayerLastInputFrameInput, discreteDir.encodedIdx]; + }, + + _shouldSendInputFrameUpsyncBatch(prevSelfInput, currSelfInput, lastUpsyncInputFrameId, currInputFrameId) { + /* + For a 2-player-battle, this "shouldUpsyncForEarlyAllConfirmedOnServer" can be omitted, however for more players in a same battle, to avoid a "long time non-moving player" jamming the downsync of other moving players, we should use this flag. + */ + if (null == currSelfInput) return false; + const shouldUpsyncForEarlyAllConfirmedOnServer = (currInputFrameId - lastUpsyncInputFrameId >= this.inputFrameUpsyncDelayTolerance); + return shouldUpsyncForEarlyAllConfirmedOnServer || (prevSelfInput != currSelfInput); + }, + + _sendInputFrameUpsyncBatch(inputFrameId) { + // [WARNING] Why not just send the latest input? Because different player would have a different "inputFrameId" of changing its last input, and that could make the server not recognizing any "all-confirmed inputFrame"! + const instance = this; + let inputFrameUpsyncBatch = []; + for (let i = instance.lastUpsyncInputFrameId+1; i <= inputFrameId; ++i) { + const inputFrameDownsync = instance.recentInputCache[i]; + if (null == inputFrameDownsync) { + console.warn("_sendInputFrameUpsyncBatch: recentInputCache is NOT having inputFrameId=", i, "; recentInputCache=", JSON.stringify(instance.recentInputCache)); + } else { + const inputFrameUpsync = { + inputFrameId: i, + encodedDir: inputFrameDownsync.inputList[instance.selfPlayerInfo.joinIndex-1], + }; + inputFrameUpsyncBatch.push(inputFrameUpsync); + } + } + const reqData = window.WsReq.encode({ + msgId: Date.now(), + playerId: instance.selfPlayerInfo.id, + act: window.UPSYNC_MSG_ACT_PLAYER_CMD, + joinIndex: instance.selfPlayerInfo.joinIndex, + ackingFrameId: instance.lastRoomDownsyncFrameId, + ackingInputFrameId: instance.lastDownsyncInputFrameId, + inputFrameUpsyncBatch: inputFrameUpsyncBatch, + }).finish(); + window.sendSafely(reqData); + instance.lastUpsyncInputFrameId = inputFrameId; + }, + + onEnable() { + cc.log("+++++++ Map onEnable()"); + }, + + onDisable() { + cc.log("+++++++ Map onDisable()"); + }, + + onDestroy() { + const self = this; + console.warn("+++++++ Map onDestroy()"); + if (null == self.battleState || ALL_BATTLE_STATES.WAITING == self.battleState) { + window.clearBoundRoomIdInBothVolatileAndPersistentStorage(); + } + if (null != window.handleRoomDownsyncFrame) { + window.handleRoomDownsyncFrame = null; + } + if (null != window.handleInputFrameDownsyncBatch) { + window.handleInputFrameDownsyncBatch = null; + } + if (null != window.handleBattleColliderInfo) { + window.handleBattleColliderInfo = null; + } + if (null != window.handleClientSessionCloseOrError) { + window.handleClientSessionCloseOrError = null; + } + if (self.inputControlTimer) { + clearInterval(self.inputControlTimer); + } + }, + + popupSimplePressToGo(labelString, hideYesButton) { + const self = this; + self.state = ALL_MAP_STATES.SHOWING_MODAL_POPUP; + + const canvasNode = self.canvasNode; + const simplePressToGoDialogNode = cc.instantiate(self.simplePressToGoDialogPrefab); + simplePressToGoDialogNode.setPosition(cc.v2(0, 0)); + simplePressToGoDialogNode.setScale(1 / canvasNode.scale); + const simplePressToGoDialogScriptIns = simplePressToGoDialogNode.getComponent("SimplePressToGoDialog"); + const yesButton = simplePressToGoDialogNode.getChildByName("Yes"); + const postDismissalByYes = () => { + self.transitToState(ALL_MAP_STATES.VISUAL); + canvasNode.removeChild(simplePressToGoDialogNode); + } + simplePressToGoDialogNode.getChildByName("Hint").getComponent(cc.Label).string = labelString; + yesButton.once("click", simplePressToGoDialogScriptIns.dismissDialog.bind(simplePressToGoDialogScriptIns, postDismissalByYes)); + yesButton.getChildByName("Label").getComponent(cc.Label).string = "OK"; + + if (true == hideYesButton) { + yesButton.active = false; + } + + self.transitToState(ALL_MAP_STATES.SHOWING_MODAL_POPUP); + safelyAddChild(self.widgetsAboveAllNode, simplePressToGoDialogNode); + setLocalZOrder(simplePressToGoDialogNode, 20); + return simplePressToGoDialogNode; + }, + + alertForGoingBackToLoginScene(labelString, mapIns, shouldRetainBoundRoomIdInBothVolatileAndPersistentStorage) { + const millisToGo = 3000; + mapIns.popupSimplePressToGo(cc.js.formatStr("%s will logout in %s seconds.", labelString, millisToGo / 1000)); + setTimeout(() => { + mapIns.logout(false, shouldRetainBoundRoomIdInBothVolatileAndPersistentStorage); + }, millisToGo); + }, + + _resetCurrentMatch() { + const self = this; + const mapNode = self.node; + const canvasNode = mapNode.parent; + self.countdownLabel.string = ""; + self.countdownNanos = null; + + // Clearing previous info of all players. [BEGINS] + for (let joinIndex in self.playersNode) { + const node = self.playersNode[joinIndex]; + if (node.parent) { + node.parent.removeChild(node); + } + } + self.playerRichInfoDict = {}; + // Clearing previous info of all players. [ENDS] + + self.lastRoomDownsyncFrameId = 0; + self.renderFrameId = 0; // After battle started + self.inputDelayFrames = 4; + self.inputScaleFrames = 2; + self.lastLocalInputFrameId = 0; + self.lastDownsyncInputFrameId = -1; + self.lastAllConfirmedInputFrameId = -1; + self.lastUpsyncInputFrameId = -1; + self.inputFrameUpsyncDelayTolerance = 1; + + self.recentFrameCache = {}; + self.recentFrameCacheCurrentSize = 0; + self.recentFrameCacheMaxCount = 2048; + + self.selfPlayerInfo = null; // This field is kept for distinguishing "self" and "others". + self.recentInputCache = {}; // TODO: Use a ringbuf instead + self.recentInputCacheCurrentSize = 0; + self.recentInputCacheMaxCount = 1024; + self.rollbackEstimatedDt = 1.0/60; + self.transitToState(ALL_MAP_STATES.VISUAL); + + self.battleState = ALL_BATTLE_STATES.WAITING; + + if (self.findingPlayerNode) { + const findingPlayerScriptIns = self.findingPlayerNode.getComponent("FindingPlayer"); + findingPlayerScriptIns.init(); + } + safelyAddChild(self.widgetsAboveAllNode, self.playersInfoNode); + safelyAddChild(self.widgetsAboveAllNode, self.findingPlayerNode); + }, + + onLoad() { + const self = this; + window.mapIns = self; + window.forceBigEndianFloatingNumDecoding = self.forceBigEndianFloatingNumDecoding; + + console.warn("+++++++ Map onLoad()"); + window.handleClientSessionCloseOrError = function() { + console.warn('+++++++ Common handleClientSessionCloseOrError()'); + + if (ALL_BATTLE_STATES.IN_SETTLEMENT == self.battleState) { //如果是游戏时间结束引起的断连 + console.log("游戏结束引起的断连, 不需要回到登录页面"); + } else { + console.warn("意外断连,即将回到登录页面"); + window.clearLocalStorageAndBackToLoginScene(true); + } + }; + + const mapNode = self.node; + const canvasNode = mapNode.parent; + cc.director.getCollisionManager().enabled = true; + cc.director.getCollisionManager().enabledDebugDraw = CC_DEBUG; + // self.musicEffectManagerScriptIns = self.node.getComponent("MusicEffectManager"); + self.musicEffectManagerScriptIns = null; + + /** Init required prefab started. */ + self.confirmLogoutNode = cc.instantiate(self.confirmLogoutPrefab); + self.confirmLogoutNode.getComponent("ConfirmLogout").mapNode = self.node; + + // Initializes Result panel. + self.resultPanelNode = cc.instantiate(self.resultPanelPrefab); + self.resultPanelNode.width = self.canvasNode.width; + self.resultPanelNode.height = self.canvasNode.height; + + const resultPanelScriptIns = self.resultPanelNode.getComponent("ResultPanel"); + resultPanelScriptIns.mapScriptIns = self; + resultPanelScriptIns.onAgainClicked = () => { + self.battleState = ALL_BATTLE_STATES.WAITING; + window.clearBoundRoomIdInBothVolatileAndPersistentStorage(); + window.initPersistentSessionClient(self.initAfterWSConnected, null /* Deliberately NOT passing in any `expectedRoomId`. -- YFLu */ ); + }; + resultPanelScriptIns.onCloseDelegate = () => { + + }; + + self.gameRuleNode = cc.instantiate(self.gameRulePrefab); + self.gameRuleNode.width = self.canvasNode.width; + self.gameRuleNode.height = self.canvasNode.height; + + self.gameRuleScriptIns = self.gameRuleNode.getComponent("GameRule"); + self.gameRuleScriptIns.mapNode = self.node; + + self.findingPlayerNode = cc.instantiate(self.findingPlayerPrefab); + self.findingPlayerNode.width = self.canvasNode.width; + self.findingPlayerNode.height = self.canvasNode.height; + const findingPlayerScriptIns = self.findingPlayerNode.getComponent("FindingPlayer"); + findingPlayerScriptIns.init(); + + self.playersInfoNode = cc.instantiate(self.playersInfoPrefab); + + self.countdownToBeginGameNode = cc.instantiate(self.countdownToBeginGamePrefab); + self.countdownToBeginGameNode.width = self.canvasNode.width; + self.countdownToBeginGameNode.height = self.canvasNode.height; + + self.mainCameraNode = canvasNode.getChildByName("Main Camera"); + self.mainCamera = self.mainCameraNode.getComponent(cc.Camera); + for (let child of self.mainCameraNode.children) { + child.setScale(1 / self.mainCamera.zoomRatio); + } + self.widgetsAboveAllNode = self.mainCameraNode.getChildByName("WidgetsAboveAll"); + self.mainCameraNode.setPosition(cc.v2()); + + self.playersNode = {}; + const player1Node = cc.instantiate(self.player1Prefab); + const player2Node = cc.instantiate(self.player2Prefab); + Object.assign(self.playersNode, { + 1: player1Node + }); + Object.assign(self.playersNode, { + 2: player2Node + }); + + /** Init required prefab ended. */ + + self.clientUpsyncFps = 60; + + window.handleBattleColliderInfo = function(parsedBattleColliderInfo) { + console.log(parsedBattleColliderInfo); + + self.battleColliderInfo = parsedBattleColliderInfo; + const tiledMapIns = self.node.getComponent(cc.TiledMap); + + const fullPathOfTmxFile = cc.js.formatStr("map/%s/map", parsedBattleColliderInfo.stageName); + cc.loader.loadRes(fullPathOfTmxFile, cc.TiledMapAsset, (err, tmxAsset) => { + if (null != err) { + console.error(err); + return; + } + + /* + [WARNING] + + - The order of the following statements is important, because we should have finished "_resetCurrentMatch" before the first "RoomDownsyncFrame". + - It's important to assign new "tmxAsset" before "extractBoundaryObjects => initMapNodeByTiledBoundaries", to ensure that the correct tilesets are used. + - To ensure clearance, put destruction of the "cc.TiledMap" component preceding that of "mapNode.destroyAllChildren()". + + -- YFLu, 2019-09-07 + + */ + + tiledMapIns.tmxAsset = null; + mapNode.removeAllChildren(); + self._resetCurrentMatch(); + + tiledMapIns.tmxAsset = tmxAsset; + const newMapSize = tiledMapIns.getMapSize(); + const newTileSize = tiledMapIns.getTileSize(); + self.node.setContentSize(newMapSize.width*newTileSize.width, newMapSize.height*newTileSize.height); + self.node.setPosition(cc.v2(0, 0)); + /* + * Deliberately hiding "ImageLayer"s. This dirty fix is specific to "CocosCreator v2.2.1", where it got back the rendering capability of "ImageLayer of Tiled", yet made incorrectly. In this game our "markers of ImageLayers" are rendered by dedicated prefabs with associated colliders. + * + * -- YFLu, 2020-01-23 + */ + const existingImageLayers = tiledMapIns.getObjectGroups(); + for (let singleImageLayer of existingImageLayers) { + singleImageLayer.node.opacity = 0; + } + + const boundaryObjs = tileCollisionManager.extractBoundaryObjects(self.node); + tileCollisionManager.initMapNodeByTiledBoundaries(self, mapNode, boundaryObjs); + + + self.selfPlayerInfo = JSON.parse(cc.sys.localStorage.getItem('selfPlayer')); + Object.assign(self.selfPlayerInfo, { + id: self.selfPlayerInfo.playerId + }); + + const fullPathOfBackgroundMapTmxFile = cc.js.formatStr("map/%s/BackgroundMap/map", parsedBattleColliderInfo.stageName); + cc.loader.loadRes(fullPathOfBackgroundMapTmxFile, cc.TiledMapAsset, (err, backgroundMapTmxAsset) => { + if (null != err) { + console.error(err); + return; + } + + self.backgroundMapTiledIns.tmxAsset = null; + self.backgroundMapTiledIns.node.removeAllChildren(); + self.backgroundMapTiledIns.tmxAsset = backgroundMapTmxAsset; + const newBackgroundMapSize = self.backgroundMapTiledIns.getMapSize(); + const newBackgroundMapTileSize = self.backgroundMapTiledIns.getTileSize(); + self.backgroundMapTiledIns.node.setContentSize(newBackgroundMapSize.width*newBackgroundMapTileSize.width, newBackgroundMapSize.height*newBackgroundMapTileSize.height); + self.backgroundMapTiledIns.node.setPosition(cc.v2(0, 0)); + + const reqData = window.WsReq.encode({ + msgId: Date.now(), + act: window.UPSYNC_MSG_ACT_PLAYER_COLLIDER_ACK, + }).finish(); + window.sendSafely(reqData); + }); + }); + }; + + self.initAfterWSConnected = () => { + const self = window.mapIns; + self.hideGameRuleNode(); + self.transitToState(ALL_MAP_STATES.WAITING); + self._inputControlEnabled = false; + + let findingPlayerScriptIns = null; + window.handleRoomDownsyncFrame = function(rdf) { + if (ALL_BATTLE_STATES.WAITING != self.battleState + && ALL_BATTLE_STATES.IN_BATTLE != self.battleState + && ALL_BATTLE_STATES.IN_SETTLEMENT != self.battleState) { + return; + } + // Right upon establishment of the "PersistentSessionClient", we should receive an initial signal "BattleColliderInfo" earlier than any "RoomDownsyncFrame" containing "PlayerMeta" data. + const refFrameId = rdf.refFrameId; + switch (refFrameId) { + case window.MAGIC_ROOM_DOWNSYNC_FRAME_ID.BATTLE_READY_TO_START: + // 显示倒计时 + self.playersMatched(rdf.playerMetas); + // 隐藏返回按钮 + findingPlayerScriptIns = self.findingPlayerNode.getComponent("FindingPlayer"); + findingPlayerScriptIns.hideExitButton(); + return; + case window.MAGIC_ROOM_DOWNSYNC_FRAME_ID.PLAYER_ADDED_AND_ACKED: + self._initPlayerRichInfoDict(rdf.players, rdf.playerMetas); + // 显示匹配玩家 + findingPlayerScriptIns = self.findingPlayerNode.getComponent("FindingPlayer"); + if (!self.findingPlayerNode.parent) { + self.showPopupInCanvas(self.findingPlayerNode); + } + findingPlayerScriptIns.updatePlayersInfo(rdf.playerMetas); + return; + case window.MAGIC_ROOM_DOWNSYNC_FRAME_ID.PLAYER_READDED_AND_ACKED: + self._initPlayerRichInfoDict(rdf.players, rdf.playerMetas); + // In this case, we're definitely in an active battle, thus the "self.findingPlayerNode" should be hidden if being presented. + if (self.findingPlayerNode && self.findingPlayerNode.parent) { + self.findingPlayerNode.parent.removeChild(self.findingPlayerNode); + self.transitToState(ALL_MAP_STATES.VISUAL); + if (self.playersInfoNode) { + for (let playerId in rdf.playerMetas) { + const playerMeta = rdf.playerMetas[playerId]; + const playersInfoScriptIns = self.playersInfoNode.getComponent("PlayersInfo"); + playersInfoScriptIns.updateData(playerMeta); + } + } + } + return; + } + + const frameId = rdf.id; + if (0 == self.lastRoomDownsyncFrameId) { + if (1 == frameId) { + // No need to prompt upon rejoined. + self.popupSimplePressToGo(i18n.t("gameTip.start")); + } + self.onBattleStarted(rdf.players, rdf.playerMetas); + self._applyRoomDownsyncFrameDynamics(rdf); + self.battleState = ALL_BATTLE_STATES.IN_BATTLE; // Starts the increment of "self.renderFrameId" in "self.update(dt)" + } + + self._dumpToFullFrameCache(rdf); + self.lastRoomDownsyncFrameId = frameId; + // TODO: Inject a NetworkDoctor as introduced in https://app.yinxiang.com/shard/s61/nl/13267014/5c575124-01db-419b-9c02-ec81f78c6ddc/. + }; + + window.handleInputFrameDownsyncBatch = function(batch) { + if (ALL_BATTLE_STATES.IN_BATTLE != self.battleState + && ALL_BATTLE_STATES.IN_SETTLEMENT != self.battleState) { + return; + } + + let firstPredictedYetIncorrectInputFrameId = -1; + let firstPredictedYetIncorrectInputFrameJoinIndex = -1; + for (let k in batch) { + const inputFrameDownsync = batch[k]; + const inputFrameDownsyncId = inputFrameDownsync.inputFrameId; + const localInputFrame = self.recentInputCache[inputFrameDownsyncId]; + if (null == localInputFrame) { + console.warn("handleInputFrameDownsyncBatch: recentInputCache is NOT having inputFrameDownsyncId=", inputFrameDownsyncId, "; now recentInputCache=", self._stringifyRecentInputCache(false)); + } else { + if (-1 == firstPredictedYetIncorrectInputFrameId) { + for (let i in localInputFrame.inputList) { + if (localInputFrame.inputList[i] != inputFrameDownsync.inputList[i]) { + firstPredictedYetIncorrectInputFrameId = inputFrameDownsyncId; + firstPredictedYetIncorrectInputFrameJoinIndex = (parseInt(i)+1); + break; + } + } + } + } + self._dumpToInputCache(inputFrameDownsync); + // [WARNING] Currently "lastDownsyncInputFrameId" and "lastAllConfirmedInputFrameId" are identical, but they (their definitions) are prone to changes in the future + self.lastDownsyncInputFrameId = inputFrameDownsyncId; + self.lastAllConfirmedInputFrameId = inputFrameDownsyncId; + if (self._inputFrameIdDebuggable(inputFrameDownsyncId)) { + console.log("Received inputFrameDownsyncId=", inputFrameDownsyncId); + } + } + + if (-1 != firstPredictedYetIncorrectInputFrameId) { + const renderFrameId2 = self.renderFrameId; + const inputFrameId2 = self._convertToInputFrameId(renderFrameId2, self.inputDelayFrames); + const inputFrameId1 = firstPredictedYetIncorrectInputFrameId; + const renderFrameId1 = self._convertToRenderFrameId(inputFrameId1, self.inputDelayFrames); // a.k.a. "firstRenderFrameIdUsingIncorrectInputFrameId" + if (renderFrameId1 <= renderFrameId2) { + console.warn("Mismatched input! inputFrameId1=", inputFrameId1, ", renderFrameId1=", renderFrameId1, ": at least 1 incorrect input predicted for joinIndex=", firstPredictedYetIncorrectInputFrameJoinIndex, ", inputFrameId2 = ", inputFrameId2, ", renderFrameId2=", renderFrameId2); + self._rollback(inputFrameId1, renderFrameId1, inputFrameId2, renderFrameId2); + } else { + console.log("Mismatched input yet no rollback needed. inputFrameId1=", inputFrameId1, ", renderFrameId1=", renderFrameId1, ": at least 1 incorrect input predicted for joinIndex=", firstPredictedYetIncorrectInputFrameJoinIndex, ", inputFrameId2 = ", inputFrameId2, ", renderFrameId2=", renderFrameId2); + } + } + }; + } + + // The player is now viewing "self.gameRuleNode" with button(s) to start an actual battle. -- YFLu + const expectedRoomId = window.getExpectedRoomIdSync(); + const boundRoomId = window.getBoundRoomIdFromPersistentStorage(); + + console.warn("Map.onLoad, expectedRoomId == ", expectedRoomId, ", boundRoomId == ", boundRoomId); + + if (null != expectedRoomId) { + self.disableGameRuleNode(); + + // The player is now possibly viewing "self.gameRuleNode" with no button, and should wait for `self.initAfterWSConnected` to be called. + self.battleState = ALL_BATTLE_STATES.WAITING; + window.initPersistentSessionClient(self.initAfterWSConnected, expectedRoomId); + } else if (null != boundRoomId) { + self.disableGameRuleNode(); + self.battleState = ALL_BATTLE_STATES.WAITING; + window.initPersistentSessionClient(self.initAfterWSConnected, expectedRoomId); + } else { + self.showPopupInCanvas(self.gameRuleNode); + // Deliberately left blank. -- YFLu + } + }, + + disableGameRuleNode() { + const self = window.mapIns; + if (null == self.gameRuleNode) { + return; + } + if (null == self.gameRuleScriptIns) { + return; + } + if (null == self.gameRuleScriptIns.modeButton) { + return; + } + self.gameRuleScriptIns.modeButton.active = false; + }, + + hideGameRuleNode() { + const self = window.mapIns; + if (null == self.gameRuleNode) { + return; + } + self.gameRuleNode.active = false; + }, + + enableInputControls() { + this._inputControlEnabled = true; + }, + + disableInputControls() { + this._inputControlEnabled = false; + }, + + onBattleStarted(players, playerMetas) { + console.log('On battle started!'); + const self = window.mapIns; + if (null != self.musicEffectManagerScriptIns) { + self.musicEffectManagerScriptIns.playBGM(); + } + const canvasNode = self.canvasNode; + self.ctrl = canvasNode.getComponent("TouchEventsManager"); + self.enableInputControls(); + if (self.countdownToBeginGameNode.parent) { + self.countdownToBeginGameNode.parent.removeChild(self.countdownToBeginGameNode); + } + self.transitToState(ALL_MAP_STATES.VISUAL); + }, + + logBattleStats() { + const self = this; + let s = []; + s.push("Battle stats: lastUpsyncInputFrameId=" + self.lastUpsyncInputFrameId + ", lastDownsyncInputFrameId=" + self.lastDownsyncInputFrameId + ", lastAllConfirmedInputFrameId=" + self.lastAllConfirmedInputFrameId + ", lastDownsyncInputFrameId=" + self.lastDownsyncInputFrameId); + + for (let inputFrameDownsyncId in self.recentInputCache) { + const inputFrameDownsync = self.recentInputCache[inputFrameDownsyncId]; + s.push(JSON.stringify(inputFrameDownsync)); + } + + console.log(s.join('\n')); + }, + + onBattleStopped() { + const self = this; + self.countdownNanos = null; + self.logBattleStats(); + if (self.musicEffectManagerScriptIns) { + self.musicEffectManagerScriptIns.stopAllMusic(); + } + const canvasNode = self.canvasNode; + const resultPanelNode = self.resultPanelNode; + const resultPanelScriptIns = resultPanelNode.getComponent("ResultPanel"); + resultPanelScriptIns.showPlayerInfo(self.playerRichInfoDict); + window.clearBoundRoomIdInBothVolatileAndPersistentStorage(); + self.battleState = ALL_BATTLE_STATES.IN_SETTLEMENT; + self.showPopupInCanvas(resultPanelNode); + + // Clear player info + self.playersInfoNode.getComponent("PlayersInfo").clearInfo(); + }, + + spawnPlayerNode(joinIndex, x, y) { + const instance = this; + const newPlayerNode = instance.playersNode[joinIndex]; + newPlayerNode.setPosition(cc.v2(x, y)); + newPlayerNode.getComponent("SelfPlayer").mapNode = instance.node; + + safelyAddChild(instance.node, newPlayerNode); + setLocalZOrder(newPlayerNode, 5); + + newPlayerNode.active = true; + const playerScriptIns = newPlayerNode.getComponent("SelfPlayer"); + playerScriptIns.scheduleNewDirection({dx: 0, dy: 0}, true); + + return [newPlayerNode, playerScriptIns]; + }, + + update(dt) { + const self = this; + try { + let inputs = new Array(Object.keys(self.playersNode).length).fill({ + dx: 0, + dy: 0 + }); + if (ALL_BATTLE_STATES.IN_BATTLE == self.battleState) { + let prevSelfInput = null, currSelfInput = null; + const noDelayInputFrameId = self._convertToInputFrameId(self.renderFrameId, 0); // It's important that "inputDelayFrames == 0" here + if (self._shouldGenerateInputFrameUpsync(self.renderFrameId)) { + const prevAndCurrInputs = self._generateInputFrameUpsync(noDelayInputFrameId); + prevSelfInput = prevAndCurrInputs[0]; + currSelfInput = prevAndCurrInputs[1]; + } + if (self._shouldSendInputFrameUpsyncBatch(prevSelfInput, currSelfInput, self.lastUpsyncInputFrameId, noDelayInputFrameId)) { + // TODO: Is the following statement run asynchronously in an implicit manner? Should I explicitly run it asynchronously? + self._sendInputFrameUpsyncBatch(noDelayInputFrameId); + } + ++self.renderFrameId; + const delayedInputFrameId = self._convertToInputFrameId(self.renderFrameId, self.inputDelayFrames); // The "inputFrameId" to use at current "renderFrameId" + const delayedInputFrameDownsync = self.recentInputCache[delayedInputFrameId]; + if (null == delayedInputFrameDownsync) { + console.warn("update(dt): recentInputCache is NOT having inputFrameId=", delayedInputFrameId, "; recentInputCache=", instance._stringifyRecentInputCache(false)); + } else { + self._applyInputFrameDownsyncDynamics(delayedInputFrameDownsync, false); + } + } + const mapNode = self.node; + const canvasNode = mapNode.parent; + const canvasParentNode = canvasNode.parent; + if (null != window.boundRoomId) { + self.boundRoomIdLabel.string = window.boundRoomId; + } + + // update countdown + if (null != self.countdownNanos) { + self.countdownNanos -= dt*1000000000; + if (self.countdownNanos <= 0) { + self.onBattleStopped(self.playerRichInfoDict); + return; + } + + const countdownSeconds = parseInt(self.countdownNanos / 1000000000); + if (isNaN(countdownSeconds)) { + console.warn(`countdownSeconds is NaN for countdownNanos == ${self.countdownNanos}.`); + } + self.countdownLabel.string = countdownSeconds; + } + } catch (err) { + console.error("Error during Map.update", err); + } + if (null != self.ctrl) { + self.ctrl.justifyMapNodePosAndScale(self.ctrl.linearSpeedBase, self.ctrl.zoomingSpeedBase); + self._createRoomDownsyncFrameLocally(); + } + }, + + transitToState(s) { + const self = this; + self.state = s; + }, + + logout(byClick /* The case where this param is "true" will be triggered within `ConfirmLogout.js`.*/ , shouldRetainBoundRoomIdInBothVolatileAndPersistentStorage) { + const self = this; + const localClearance = () => { + window.clearLocalStorageAndBackToLoginScene(shouldRetainBoundRoomIdInBothVolatileAndPersistentStorage); + } + + const selfPlayerStr = cc.sys.localStorage.getItem("selfPlayer"); + if (null == selfPlayerStr) { + localClearance(); + return; + } + const selfPlayerInfo = JSON.parse(selfPlayerStr); + try { + NetworkUtils.ajax({ + url: backendAddress.PROTOCOL + '://' + backendAddress.HOST + ':' + backendAddress.PORT + constants.ROUTE_PATH.API + constants.ROUTE_PATH.PLAYER + constants.ROUTE_PATH.VERSION + constants.ROUTE_PATH.INT_AUTH_TOKEN + constants.ROUTE_PATH.LOGOUT, + type: "POST", + data: { intAuthToken: selfPlayerInfo.intAuthToken }, + success: function(res) { + if (res.ret != constants.RET_CODE.OK) { + console.log("Logout failed: ", res); + } + localClearance(); + }, + error: function(xhr, status, errMsg) { + localClearance(); + }, + timeout: function() { + localClearance(); + } + }); + } catch (e) {} finally { + // For Safari (both desktop and mobile). + localClearance(); + } + }, + + onLogoutClicked(evt) { + const self = this; + self.showPopupInCanvas(self.confirmLogoutNode); + }, + + onLogoutConfirmationDismissed() { + const self = this; + self.transitToState(ALL_MAP_STATES.VISUAL); + const canvasNode = self.canvasNode; + canvasNode.removeChild(self.confirmLogoutNode); + self.enableInputControls(); + }, + + onGameRule1v1ModeClicked(evt, cb) { + const self = this; + self.battleState = ALL_BATTLE_STATES.WAITING; + window.initPersistentSessionClient(self.initAfterWSConnected, null /* Deliberately NOT passing in any `expectedRoomId`. -- YFLu */ ); + self.hideGameRuleNode(); + }, + + showPopupInCanvas(toShowNode) { + const self = this; + self.disableInputControls(); + self.transitToState(ALL_MAP_STATES.SHOWING_MODAL_POPUP); + safelyAddChild(self.widgetsAboveAllNode, toShowNode); + setLocalZOrder(toShowNode, 10); + }, + + playersMatched(playerMetas) { + console.log("Calling `playersMatched` with:", playerMetas); + + const self = this; + const findingPlayerScriptIns = self.findingPlayerNode.getComponent("FindingPlayer"); + findingPlayerScriptIns.updatePlayersInfo(playerMetas); + window.setTimeout(() => { + if (null != self.findingPlayerNode.parent) { + self.findingPlayerNode.parent.removeChild(self.findingPlayerNode); + self.transitToState(ALL_MAP_STATES.VISUAL); + const playersInfoScriptIns = self.playersInfoNode.getComponent("PlayersInfo"); + for (let i in playerMetas) { + const playerMeta = playerMetas[i]; + playersInfoScriptIns.updateData(playerMeta); + } + } + const countDownScriptIns = self.countdownToBeginGameNode.getComponent("CountdownToBeginGame"); + countDownScriptIns.setData(); + self.showPopupInCanvas(self.countdownToBeginGameNode); + return; + }, 2000); + }, + + _createRoomDownsyncFrameLocally() { + const self = this; + const rdf = { + id: self.renderFrameId, + refFrameId: self.renderFrameId, + players: {}, + countdownNanos: self.countdownNanos + }; + + for (let playerId in self.playerRichInfoDict) { + const playerRichInfo = self.playerRichInfoDict[playerId]; + const joinIndex = playerRichInfo.joinIndex; + const playerNode = playerRichInfo.node; + const playerScriptIns = playerRichInfo.scriptIns; + rdf.players[playerRichInfo.id] = { + id: playerRichInfo.id, + x: playerNode.position.x, + y: playerNode.position.y, + dir: playerScriptIns.activeDirection, + speed: playerScriptIns.speed, + joinIndex: joinIndex + }; + } + self._dumpToFullFrameCache(rdf); + }, + + _applyRoomDownsyncFrameDynamics(rdf) { + const self = this; + if (null != rdf.countdownNanos) { + self.countdownNanos = rdf.countdownNanos; + } + + for (let playerId in self.playerRichInfoDict) { + const playerRichInfo = self.playerRichInfoDict[playerId]; + const immediatePlayerInfo = rdf.players[playerId]; + playerRichInfo.node.setPosition(immediatePlayerInfo.x, immediatePlayerInfo.y); + playerRichInfo.scriptIns.scheduleNewDirection(immediatePlayerInfo.dir, true); + playerRichInfo.scriptIns.updateSpeed(immediatePlayerInfo.speed); + } + }, + + _applyInputFrameDownsyncDynamics(inputFrameDownsync, invokeUpdateToo) { + // This application DOESN'T use a "full physics engine", but only "collider detection" of "box2d", thus when resetting room state, there's no need of resetting "momentums". + const self = this; + const inputs = inputFrameDownsync.inputList; + // Update controlled player nodes + for (let playerId in self.playerRichInfoDict) { + const playerRichInfo = self.playerRichInfoDict[playerId]; + const joinIndex = playerRichInfo.joinIndex; + const playerScriptIns = playerRichInfo.scriptIns; + const decodedInput = self.ctrl.decodeDirection(inputs[joinIndex-1]); + playerScriptIns.scheduleNewDirection(decodedInput, true); + if (invokeUpdateToo) { + playerScriptIns.update(self.rollbackEstimatedDt); + } + } + }, + + _rollback(inputFrameId1, renderFrameId1, inputFrameId2, renderFrameId2) { + const self = this; + const rdf1 = self.recentFrameCache[renderFrameId1]; + if (null == rdf1) { + const recentFrameCacheKeys = Object.keys(self.recentFrameCache); + console.warn("renderFrameId1=", renderFrameId1, "doesn't exist in recentFrameCache ", self._stringifyRecentFrameCache(false), ": COULDN'T ROLLBACK!"); + return; + } + self._applyRoomDownsyncFrameDynamics(rdf1); + for (let renderFrameId = renderFrameId1; renderFrameId <= renderFrameId2; ++renderFrameId) { + const delayedInputFrameId = self._convertToInputFrameId(renderFrameId, self.inputDelayFrames); + const delayedInputFrame = self.recentInputCache[delayedInputFrameId]; + self._applyInputFrameDownsyncDynamics(delayedInputFrame, true); + } + }, + + _initPlayerRichInfoDict(players, playerMetas) { + const self = this; + for (let k in players) { + const playerId = parseInt(k); + if (self.playerRichInfoDict.hasOwnProperty(playerId)) continue; + const immediatePlayerInfo = players[playerId]; + const immediatePlayerMeta = playerMetas[playerId]; + const nodeAndScriptIns = self.spawnPlayerNode(immediatePlayerInfo.joinIndex, immediatePlayerInfo.x, immediatePlayerInfo.y); + self.playerRichInfoDict[playerId] = immediatePlayerInfo; + + Object.assign(self.playerRichInfoDict[playerId], { + node: nodeAndScriptIns[0], + scriptIns: nodeAndScriptIns[1] + }); + + if (self.selfPlayerInfo.id == playerId) { + self.selfPlayerInfo = Object.assign(self.selfPlayerInfo, immediatePlayerInfo); + nodeAndScriptIns[1].showArrowTipNode(); + } + } + }, + + _stringifyRecentFrameCache(usefullOutput) { + if (true == usefullOutput) { + return JSON.stringify(this.recentFrameCache); + } + const keys = Object.keys(this.recentInputCache); + return "[stIRenderFrameId=" + keys[0] + ", edRenderFrameId=" + keys[keys.length-1] + "]"; + }, + + _stringifyRecentInputCache(usefullOutput) { + if (true == usefullOutput) { + return JSON.stringify(this.recentInputCache); + } + const keys = Object.keys(this.recentInputCache); + return "[stInputFrameId=" + keys[0] + ", edInputFrameId=" + keys[keys.length-1] + "]"; + }, +}); diff --git a/frontend/assets/scripts/Map.js.meta b/frontend/assets/scripts/Map.js.meta new file mode 100644 index 0000000..e3bf140 --- /dev/null +++ b/frontend/assets/scripts/Map.js.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.5", + "uuid": "41d304ce-6a68-4d2d-92ab-5219de6e8638", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/scripts/MusicEffectManager.js b/frontend/assets/scripts/MusicEffectManager.js new file mode 100644 index 0000000..50714c3 --- /dev/null +++ b/frontend/assets/scripts/MusicEffectManager.js @@ -0,0 +1,66 @@ +cc.Class({ + extends: cc.Component, + + properties: { + BGMEffect: { + type: cc.AudioClip, + default: null + }, + crashedByTrapBullet: { + type: cc.AudioClip, + default: null + }, + highScoreTreasurePicked: { + type: cc.AudioClip, + default: null + }, + treasurePicked: { + type: cc.AudioClip, + default: null + }, + countDown10SecToEnd: { + type: cc.AudioClip, + default: null + }, + mapNode: { + type: cc.Node, + default: null + }, + }, + + // LIFE-CYCLE CALLBACKS: + + onLoad() { + cc.audioEngine.setEffectsVolume(1); + cc.audioEngine.setMusicVolume(0.5); + }, + stopAllMusic() { + cc.audioEngine.stopAll(); + }, + playBGM() { + if(this.BGMEffect) { + cc.audioEngine.playMusic(this.BGMEffect, true); + } + }, + playCrashedByTrapBullet() { + if(this.crashedByTrapBullet) { + cc.audioEngine.playEffect(this.crashedByTrapBullet, false); + } + }, + playHighScoreTreasurePicked() { + if(this.highScoreTreasurePicked) { + cc.audioEngine.playEffect(this.highScoreTreasurePicked, false); + } + }, + playTreasurePicked() { + if(this.treasurePicked) { + cc.audioEngine.playEffect(this.treasurePicked, false); + } + }, + playCountDown10SecToEnd() { + if(this.countDown10SecToEnd) { + cc.audioEngine.playEffect(this.countDown10SecToEnd, false); + } + }, +}); + diff --git a/frontend/assets/scripts/MusicEffectManager.js.meta b/frontend/assets/scripts/MusicEffectManager.js.meta new file mode 100644 index 0000000..d8f8bde --- /dev/null +++ b/frontend/assets/scripts/MusicEffectManager.js.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.5", + "uuid": "09e1bfed-132e-4ada-a68f-229a870db69e", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/scripts/NPCPlayer.js b/frontend/assets/scripts/NPCPlayer.js new file mode 100644 index 0000000..872e80c --- /dev/null +++ b/frontend/assets/scripts/NPCPlayer.js @@ -0,0 +1,337 @@ +const COLLISION_WITH_PLAYER_STATE = { + WALKING_COLLIDABLE: 0, + STILL_NEAR_SELF_PLAYER_ONLY_PLAYING_ANIM: 1, + STILL_NEAR_SELF_PLAYER_ONLY_PLAYED_ANIM: 2, + STILL_NEAR_OTHER_PLAYER_ONLY_PLAYING_ANIM: 3, + STILL_NEAR_OTHER_PLAYER_ONLY_PLAYED_ANIM: 4, + STILL_NEAR_SELF_PLAYER_NEAR_OTHER_PLAYER_PLAYING_ANIM: 5, + STILL_NEAR_SELF_PLAYER_NEAR_OTHER_PLAYER_PLAYED_ANIM: 6, + WALKING_COLLIDABLE_WITH_SELF_PLAYER_BUT_NOT_OTHER_PLAYER: 7, + STILL_NEAR_NOBODY_PLAYING_ANIM: 8, +}; + +const STILL_NEAR_SELF_PLAYER_STATE_SET = new Set(); +STILL_NEAR_SELF_PLAYER_STATE_SET.add(COLLISION_WITH_PLAYER_STATE.STILL_NEAR_SELF_PLAYER_ONLY_PLAYING_ANIM); +STILL_NEAR_SELF_PLAYER_STATE_SET.add(COLLISION_WITH_PLAYER_STATE.STILL_NEAR_SELF_PLAYER_ONLY_PLAYED_ANIM); +STILL_NEAR_SELF_PLAYER_STATE_SET.add(COLLISION_WITH_PLAYER_STATE.STILL_NEAR_SELF_PLAYER_NEAR_OTHER_PLAYER_PLAYING_ANIM); +STILL_NEAR_SELF_PLAYER_STATE_SET.add(COLLISION_WITH_PLAYER_STATE.STILL_NEAR_SELF_PLAYER_NEAR_OTHER_PLAYER_PLAYED_ANIM); + +const STILL_NEAR_OTHER_PLAYER_STATE_SET = new Set(); +STILL_NEAR_OTHER_PLAYER_STATE_SET.add(COLLISION_WITH_PLAYER_STATE.STILL_NEAR_OTHER_PLAYER_ONLY_PLAYING_ANIM); +STILL_NEAR_OTHER_PLAYER_STATE_SET.add(COLLISION_WITH_PLAYER_STATE.STILL_NEAR_OTHER_PLAYER_ONLY_PLAYED_ANIM); +STILL_NEAR_OTHER_PLAYER_STATE_SET.add(COLLISION_WITH_PLAYER_STATE.STILL_NEAR_SELF_PLAYER_NEAR_OTHER_PLAYER_PLAYING_ANIM); +STILL_NEAR_OTHER_PLAYER_STATE_SET.add(COLLISION_WITH_PLAYER_STATE.STILL_NEAR_SELF_PLAYER_NEAR_OTHER_PLAYER_PLAYED_ANIM); + +const STILL_SHOULD_NOT_PLAY_STUNNED_ANIM_SET = new Set(); +STILL_SHOULD_NOT_PLAY_STUNNED_ANIM_SET.add(COLLISION_WITH_PLAYER_STATE.STILL_NEAR_SELF_PLAYER_ONLY_PLAYING_ANIM); +STILL_SHOULD_NOT_PLAY_STUNNED_ANIM_SET.add(COLLISION_WITH_PLAYER_STATE.STILL_NEAR_SELF_PLAYER_ONLY_PLAYED_ANIM); +STILL_SHOULD_NOT_PLAY_STUNNED_ANIM_SET.add(COLLISION_WITH_PLAYER_STATE.STILL_NEAR_OTHER_PLAYER_ONLY_PLAYING_ANIM); +STILL_SHOULD_NOT_PLAY_STUNNED_ANIM_SET.add(COLLISION_WITH_PLAYER_STATE.STILL_NEAR_OTHER_PLAYER_ONLY_PLAYED_ANIM); +STILL_SHOULD_NOT_PLAY_STUNNED_ANIM_SET.add(COLLISION_WITH_PLAYER_STATE.STILL_NEAR_SELF_PLAYER_NEAR_OTHER_PLAYER_PLAYING_ANIM); +STILL_SHOULD_NOT_PLAY_STUNNED_ANIM_SET.add(COLLISION_WITH_PLAYER_STATE.STILL_NEAR_SELF_PLAYER_NEAR_OTHER_PLAYER_PLAYED_ANIM); +STILL_SHOULD_NOT_PLAY_STUNNED_ANIM_SET.add(COLLISION_WITH_PLAYER_STATE.STILL_NEAR_NOBODY_PLAYING_ANIM); + +function transitWalkingConditionallyCollidableToUnconditionallyCollidable(currentCollisionWithPlayerState) { + switch (currentCollisionWithPlayerState) { + case COLLISION_WITH_PLAYER_STATE.WALKING_COLLIDABLE_WITH_SELF_PLAYER_BUT_NOT_OTHER_PLAYER: + return COLLISION_WITH_PLAYER_STATE.WALKING_COLLIDABLE; + } + + return currentCollisionWithPlayerState; +} + +function transitUponSelfPlayerLeftProximityArea(currentCollisionWithPlayerState) { + switch (currentCollisionWithPlayerState) { + case COLLISION_WITH_PLAYER_STATE.STILL_NEAR_SELF_PLAYER_ONLY_PLAYING_ANIM: + return COLLISION_WITH_PLAYER_STATE.STILL_NEAR_NOBODY_PLAYING_ANIM; + + case COLLISION_WITH_PLAYER_STATE.STILL_NEAR_SELF_PLAYER_ONLY_PLAYED_ANIM: + return COLLISION_WITH_PLAYER_STATE.WALKING_COLLIDABLE; + + case COLLISION_WITH_PLAYER_STATE.STILL_NEAR_SELF_PLAYER_NEAR_OTHER_PLAYER_PLAYING_ANIM: + return COLLISION_WITH_PLAYER_STATE.STILL_NEAR_OTHER_PLAYER_ONLY_PLAYING_ANIM; + + case COLLISION_WITH_PLAYER_STATE.STILL_NEAR_SELF_PLAYER_NEAR_OTHER_PLAYER_PLAYED_ANIM: + return COLLISION_WITH_PLAYER_STATE.WALKING_COLLIDABLE_WITH_SELF_PLAYER_BUT_NOT_OTHER_PLAYER; + } + return currentCollisionWithPlayerState; +} + +function transitDueToNoBodyInProximityArea(currentCollisionWithPlayerState) { + switch (currentCollisionWithPlayerState) { + case COLLISION_WITH_PLAYER_STATE.STILL_NEAR_SELF_PLAYER_ONLY_PLAYING_ANIM: + case COLLISION_WITH_PLAYER_STATE.STILL_NEAR_OTHER_PLAYER_ONLY_PLAYING_ANIM: + case COLLISION_WITH_PLAYER_STATE.STILL_NEAR_SELF_PLAYER_NEAR_OTHER_PLAYER_PLAYING_ANIM: + return COLLISION_WITH_PLAYER_STATE.STILL_NEAR_NOBODY_PLAYING_ANIM; + + case COLLISION_WITH_PLAYER_STATE.STILL_NEAR_SELF_PLAYER_ONLY_PLAYED_ANIM: + case COLLISION_WITH_PLAYER_STATE.STILL_NEAR_OTHER_PLAYER_ONLY_PLAYED_ANIM: + case COLLISION_WITH_PLAYER_STATE.STILL_NEAR_SELF_PLAYER_NEAR_OTHER_PLAYER_PLAYED_ANIM: + return COLLISION_WITH_PLAYER_STATE.WALKING_COLLIDABLE_WITH_SELF_PLAYER_BUT_NOT_OTHER_PLAYER; + } + return currentCollisionWithPlayerState; +} + +function transitToPlayingStunnedAnim(currentCollisionWithPlayerState, dueToSelfPlayer, dueToOtherPlayer) { + if (dueToSelfPlayer) { + switch (currentCollisionWithPlayerState) { + case COLLISION_WITH_PLAYER_STATE.WALKING_COLLIDABLE: + case COLLISION_WITH_PLAYER_STATE.WALKING_COLLIDABLE_WITH_SELF_PLAYER_BUT_NOT_OTHER_PLAYER: + return COLLISION_WITH_PLAYER_STATE.STILL_NEAR_SELF_PLAYER_ONLY_PLAYING_ANIM; + } + } + + if (dueToOtherPlayer) { + switch (currentCollisionWithPlayerState) { + case COLLISION_WITH_PLAYER_STATE.WALKING_COLLIDABLE: + return COLLISION_WITH_PLAYER_STATE.STILL_NEAR_OTHER_PLAYER_ONLY_PLAYING_ANIM; + } + } + // TODO: Any error to throw? + return currentCollisionWithPlayerState; +} + +function transitDuringPlayingStunnedAnim(currentCollisionWithPlayerState, dueToSelfPlayerComesIntoProximity, dueToOtherPlayerComesIntoProximity) { + if (dueToSelfPlayerComesIntoProximity) { + switch (currentCollisionWithPlayerState) { + case COLLISION_WITH_PLAYER_STATE.STILL_NEAR_OTHER_PLAYER_ONLY_PLAYING_ANIM: + return COLLISION_WITH_PLAYER_STATE.STILL_NEAR_SELF_PLAYER_NEAR_OTHER_PLAYER_PLAYING_ANIM; + + case COLLISION_WITH_PLAYER_STATE.STILL_NEAR_NOBODY_PLAYING_ANIM: + return COLLISION_WITH_PLAYER_STATE.STILL_NEAR_SELF_PLAYER_ONLY_PLAYING_ANIM; + } + } + + if (dueToOtherPlayerComesIntoProximity) { + switch (currentCollisionWithPlayerState) { + case COLLISION_WITH_PLAYER_STATE.STILL_NEAR_SELF_PLAYER_ONLY_PLAYING_ANIM: + return COLLISION_WITH_PLAYER_STATE.STILL_NEAR_SELF_PLAYER_NEAR_OTHER_PLAYER_PLAYING_ANIM; + + case COLLISION_WITH_PLAYER_STATE.STILL_NEAR_NOBODY_PLAYING_ANIM: + return COLLISION_WITH_PLAYER_STATE.STILL_NEAR_OTHER_PLAYER_ONLY_PLAYING_ANIM; + } + } + // TODO: Any error to throw? + return currentCollisionWithPlayerState; +} + +function transitStunnedAnimPlayingToPlayed(currentCollisionWithPlayerState, forceNotCollidableWithOtherPlayer) { + switch (currentCollisionWithPlayerState) { + case COLLISION_WITH_PLAYER_STATE.STILL_NEAR_SELF_PLAYER_ONLY_PLAYING_ANIM: + return COLLISION_WITH_PLAYER_STATE.STILL_NEAR_SELF_PLAYER_ONLY_PLAYED_ANIM; + + case COLLISION_WITH_PLAYER_STATE.STILL_NEAR_OTHER_PLAYER_ONLY_PLAYING_ANIM: + return COLLISION_WITH_PLAYER_STATE.STILL_NEAR_OTHER_PLAYER_ONLY_PLAYED_ANIM; + + case COLLISION_WITH_PLAYER_STATE.STILL_NEAR_SELF_PLAYER_NEAR_OTHER_PLAYER_PLAYING_ANIM: + return COLLISION_WITH_PLAYER_STATE.STILL_NEAR_SELF_PLAYER_NEAR_OTHER_PLAYER_PLAYED_ANIM; + + case COLLISION_WITH_PLAYER_STATE.STILL_NEAR_NOBODY_PLAYING_ANIM: + return (true == forceNotCollidableWithOtherPlayer ? COLLISION_WITH_PLAYER_STATE.WALKING_COLLIDABLE_WITH_SELF_PLAYER_BUT_NOT_OTHER_PLAYER : COLLISION_WITH_PLAYER_STATE.WALKING_COLLIDABLE); + } + // TODO: Any error to throw? + return currentCollisionWithPlayerState; +} + +function transitStunnedAnimPlayedToWalking(currentCollisionWithPlayerState) { + /* + * Intentionally NOT transiting for + * + * - STILL_NEAR_SELF_PLAYER_NEAR_OTHER_PLAYER_PLAYED_ANIM, or + * - STILL_NEAR_SELF_PLAYER_ONLY_PLAYED_ANIM, + * + * which should be transited upon leaving of "SelfPlayer". + */ + switch (currentCollisionWithPlayerState) { + case COLLISION_WITH_PLAYER_STATE.STILL_NEAR_OTHER_PLAYER_ONLY_PLAYED_ANIM: + return COLLISION_WITH_PLAYER_STATE.WALKING_COLLIDABLE_WITH_SELF_PLAYER_BUT_NOT_OTHER_PLAYER; + } + // TODO: Any error to throw? + return currentCollisionWithPlayerState; +} + +const BasePlayer = require("./BasePlayer"); + +cc.Class({ + extends: BasePlayer, + + // LIFE-CYCLE CALLBACKS: + start() { + BasePlayer.prototype.start.call(this); + + this.scheduleNewDirection(this._generateRandomDirectionExcluding(0, 0)); + }, + + onLoad() { + BasePlayer.prototype.onLoad.call(this); + const self = this; + + this.collisionWithPlayerState = COLLISION_WITH_PLAYER_STATE.WALKING_COLLIDABLE; + + this.clips = { + '01': 'FlatHeadSisterRunTop', + '0-1': 'FlatHeadSisterRunBottom', + '-20': 'FlatHeadSisterRunLeft', + '20': 'FlatHeadSisterRunRight', + '-21': 'FlatHeadSisterRunTopLeft', + '21': 'FlatHeadSisterRunTopRight', + '-2-1': 'FlatHeadSisterRunBottomLeft', + '2-1': 'FlatHeadSisterRunBottomRight' + }; + + + self.onStunnedAnimPlayedSafe = () => { + const oldCollisionWithPlayerState = self.collisionWithPlayerState; + self.collisionWithPlayerState = transitStunnedAnimPlayingToPlayed(this.collisionWithPlayerState, true); + if (oldCollisionWithPlayerState == self.collisionWithPlayerState || !self.node) return; + + // TODO: Be more specific with "toExcludeDx" and "toExcludeDy". + self.scheduleNewDirection(self._generateRandomDirectionExcluding(0, 0)); + self.collisionWithPlayerState = transitStunnedAnimPlayedToWalking(self.collisionWithPlayerState); + setTimeout(() => { + self.collisionWithPlayerState = transitWalkingConditionallyCollidableToUnconditionallyCollidable(self.collisionWithPlayerState); + }, 5000); + }; + + self.onStunnedAnimPlayedSafeAction = cc.callFunc(self.onStunnedAnimPlayedSafe, self); + + self.playStunnedAnim = () => { + let colliededAction1 = cc.rotateTo(0.2, -15); + let colliededAction2 = cc.rotateTo(0.3, 15); + let colliededAction3 = cc.rotateTo(0.2, 0); + + self.node.runAction(cc.sequence( + cc.callFunc(() => { + self.player.pause() + }, self), + colliededAction1, + colliededAction2, + colliededAction3, + cc.callFunc(() => { + self.player.resume() + }, self), + self.onStunnedAnimPlayedSafeAction + )); + + // NOTE: Use .on('stop', self.onStunnedAnimPlayedSafe) if necessary. + } + }, + + _canMoveBy(vecToMoveBy) { + if (COLLISION_WITH_PLAYER_STATE.WALKING_COLLIDABLE_WITH_SELF_PLAYER_BUT_NOT_OTHER_PLAYER != this.collisionWithPlayerState && COLLISION_WITH_PLAYER_STATE.WALKING_COLLIDABLE != this.collisionWithPlayerState) { + return false; + } + + const superRet = BasePlayer.prototype._canMoveBy.call(this, vecToMoveBy); + const self = this; + + const computedNewDifferentPosLocalToParentWithinCurrentFrame = self.node.position.add(vecToMoveBy); + + const currentSelfColliderCircle = self.node.getComponent("cc.CircleCollider"); + let nextSelfColliderCircle = null; + if (0 < self.contactedBarriers.length || 0 < self.contactedNPCPlayers.length || 0 < self.contactedControlledPlayers) { + /* To avoid unexpected buckling. */ + const mutatedVecToMoveBy = vecToMoveBy.mul(2); + nextSelfColliderCircle = { + position: self.node.position.add(vecToMoveBy.mul(2)).add(currentSelfColliderCircle.offset), + radius: currentSelfColliderCircle.radius, + }; + } else { + nextSelfColliderCircle = { + position: computedNewDifferentPosLocalToParentWithinCurrentFrame.add(currentSelfColliderCircle.offset), + radius: currentSelfColliderCircle.radius, + }; + } + + for (let aCircleCollider of self.contactedControlledPlayers) { + let contactedCircleLocalToParentWithinCurrentFrame = { + position: aCircleCollider.node.position.add(aCircleCollider.offset), + radius: aCircleCollider.radius, + }; + if (cc.Intersection.circleCircle(contactedCircleLocalToParentWithinCurrentFrame, nextSelfColliderCircle)) { + return false; + } + } + + return superRet; + }, + + update(dt) { + const self = this; + + BasePlayer.prototype.update.call(this, dt); + + if (0 < self.contactedBarriers.length) { + self.scheduleNewDirection(self._generateRandomDirectionExcluding(self.scheduledDirection.dx, self.scheduledDirection.dy)); + } + + if (tileCollisionManager.isOutOfMapNode(self.mapNode, self.computedNewDifferentPosLocalToParentWithinCurrentFrame)) { + self.scheduleNewDirection(self._generateRandomDirectionExcluding(self.scheduledDirection.dx, self.scheduledDirection.dy)); + } + }, + + onCollisionEnter(other, self) { + BasePlayer.prototype.onCollisionEnter.call(this, other, self); + const playerScriptIns = self.getComponent(self.node.name); + switch (other.node.name) { + case "SelfPlayer": + playerScriptIns._addContactedControlledPlayers(other); + if (1 == playerScriptIns.contactedControlledPlayers.length) { + // When "SelfPlayer" comes into proximity area. + if (!STILL_SHOULD_NOT_PLAY_STUNNED_ANIM_SET.has(playerScriptIns.collisionWithPlayerState)) { + playerScriptIns.collisionWithPlayerState = transitToPlayingStunnedAnim(playerScriptIns.collisionWithPlayerState, true, false); + playerScriptIns.playStunnedAnim(); + } else { + playerScriptIns.collisionWithPlayerState = transitDuringPlayingStunnedAnim(playerScriptIns.collisionWithPlayerState, true, false); + } + } + break; + case "NPCPlayer": + if (1 == playerScriptIns.contactedNPCPlayers.length) { + // When one of the other "OtherPlayer"s comes into proximity area. + if (!STILL_SHOULD_NOT_PLAY_STUNNED_ANIM_SET.has(playerScriptIns.collisionWithPlayerState)) { + const oldState = playerScriptIns.collisionWithPlayerState; + playerScriptIns.collisionWithPlayerState = transitToPlayingStunnedAnim(oldState, false, true); + if (playerScriptIns.collisionWithPlayerState != oldState) { + playerScriptIns.playStunnedAnim(); + } + } else { + playerScriptIns.collisionWithPlayerState = transitDuringPlayingStunnedAnim(playerScriptIns.collisionWithPlayerState, false, true); + } + } + break; + default: + break; + } + }, + + onCollisionStay(other, self) { + // TBD. + }, + + onCollisionExit(other, self) { + BasePlayer.prototype.onCollisionExit.call(this, other, self); + const playerScriptIns = self.getComponent(self.node.name); + switch (other.node.name) { + case "SelfPlayer": + playerScriptIns._removeContactedControlledPlayer(other); + if (0 == playerScriptIns.contactedControlledPlayers.length) { + // Special release step. + if (STILL_NEAR_SELF_PLAYER_STATE_SET.has(playerScriptIns.collisionWithPlayerState)) { + playerScriptIns.collisionWithPlayerState = transitUponSelfPlayerLeftProximityArea(playerScriptIns.collisionWithPlayerState); + } + } + if (0 == playerScriptIns.contactedControlledPlayers.length && 0 == playerScriptIns.contactedNPCPlayers.length) { + transitDueToNoBodyInProximityArea(playerScriptIns.collisionWithPlayerState); + } + break; + case "NPCPlayer": + if (0 == playerScriptIns.contactedControlledPlayers.length && 0 == playerScriptIns.contactedNPCPlayers.length) { + transitDueToNoBodyInProximityArea(playerScriptIns.collisionWithPlayerState); + } + break; + default: + break; + } + }, +}); diff --git a/frontend/assets/scripts/NPCPlayer.js.meta b/frontend/assets/scripts/NPCPlayer.js.meta new file mode 100644 index 0000000..baf568c --- /dev/null +++ b/frontend/assets/scripts/NPCPlayer.js.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.5", + "uuid": "17759956-1f8c-421f-bac2-7f4dd7ccdcda", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/scripts/PlayersInfo.js b/frontend/assets/scripts/PlayersInfo.js new file mode 100644 index 0000000..ab981a6 --- /dev/null +++ b/frontend/assets/scripts/PlayersInfo.js @@ -0,0 +1,53 @@ +cc.Class({ + extends: cc.Component, + + properties: { + listNode: { + type: cc.Node, + default: null, + } + }, + + // LIFE-CYCLE CALLBACKS: + updateData(playerMeta) { + const joinIndex = playerMeta.joinIndex; + const playerNode = this.listNode.getChildByName("player" + joinIndex); + if (!playerNode) { + return; + } + const playerNameLabelNode = playerNode.getChildByName("name"); + + function isEmptyString(str) { + return str == null || str == '' + } + + const nameToDisplay = (() => { + if (!isEmptyString(playerMeta.displayName)) { + return playerMeta.displayName; + } else if (!isEmptyString(playerMeta.name)) { + return playerMeta.name; + } else { + return "" + } + })(); + + playerNameLabelNode.getComponent(cc.Label).string = nameToDisplay; + + const score = (playerMeta.score ? playerMeta.score : 0); + const playerScoreLabelNode = playerNode.getChildByName("score"); + playerScoreLabelNode.getComponent(cc.Label).string = score; + }, + + onLoad() {}, + + clearInfo() { + for (let i = 1; i < 3; i++) { + const playerNode = this.listNode.getChildByName('player' + i); + const playerScoreLabelNode = playerNode.getChildByName("score"); + const playerNameLabelNode = playerNode.getChildByName("name"); + playerScoreLabelNode.getComponent(cc.Label).string = ''; + playerNameLabelNode.getComponent(cc.Label).string = ''; + } + }, + +}); diff --git a/frontend/assets/scripts/PlayersInfo.js.meta b/frontend/assets/scripts/PlayersInfo.js.meta new file mode 100644 index 0000000..1f86fb1 --- /dev/null +++ b/frontend/assets/scripts/PlayersInfo.js.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.5", + "uuid": "846cee45-4ca9-4383-8a74-c6a8f3c35617", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/scripts/Pumpkin.js b/frontend/assets/scripts/Pumpkin.js new file mode 100644 index 0000000..427723a --- /dev/null +++ b/frontend/assets/scripts/Pumpkin.js @@ -0,0 +1,13 @@ +const Bullet = require("./Bullet"); + +cc.Class({ + extends: Bullet, + // LIFE-CYCLE CALLBACKS: + properties: { + }, + + onLoad() { + Bullet.prototype.onLoad.call(this); + }, + +}); diff --git a/frontend/assets/scripts/Pumpkin.js.meta b/frontend/assets/scripts/Pumpkin.js.meta new file mode 100644 index 0000000..fd6f9b6 --- /dev/null +++ b/frontend/assets/scripts/Pumpkin.js.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.5", + "uuid": "c3bb6519-af90-4641-bb5e-5abbbcdfa6da", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/scripts/ResultPanel.js b/frontend/assets/scripts/ResultPanel.js new file mode 100644 index 0000000..3a357e3 --- /dev/null +++ b/frontend/assets/scripts/ResultPanel.js @@ -0,0 +1,163 @@ +const i18n = require('LanguageData'); +i18n.init(window.language); // languageID should be equal to the one we input in New Language ID input field +cc.Class({ + extends: cc.Component, + properties: { + onCloseDelegate: { + type: cc.Object, + default: null + }, + onAgainClicked: { + type: cc.Object, + default: null + }, + myAvatarNode: { + type: cc.Node, + default: null, + }, + myNameNode: { + type: cc.Node, + default: null, + }, + rankingNodes: { + type: [cc.Node], + default: [], + }, + winNode: { + type: cc.Node, + default: null, + }, + }, + + // LIFE-CYCLE CALLBACKS: + onLoad() { + }, + + againBtnOnClick(evt) { + this.onClose(); + if (!this.onAgainClicked) return; + this.onAgainClicked(); + }, + + homeBtnOnClick(evt) { + this.onClose(); + window.clearLocalStorageAndBackToLoginScene(); + }, + + showPlayerInfo(playerRichInfoDict) { + this.showRanking(playerRichInfoDict); + this.showMyAvatar(); + this.showMyName(); + }, + + showMyName() { + const selfPlayerInfo = JSON.parse(cc.sys.localStorage.getItem('selfPlayer')); + let name = 'No name'; + if (null == selfPlayerInfo.displayName || "" == selfPlayerInfo.displayName) { + name = selfPlayerInfo.name; + } else { + name = selfPlayerInfo.displayName; + } + if (!this.myNameNode) return; + const myNameNodeLabel = this.myNameNode.getComponent(cc.Label); + if (!myNameNodeLabel || null == name) return; + myNameNodeLabel.string = name; + }, + + showRanking(playerRichInfoDict) { + const self = this; + const sortablePlayers = []; + + for (let playerId in playerRichInfoDict) { + const p = playerRichInfoDict[playerId]; + p.id = playerId; + if (null == p.score) { + p.score = playerRichInfoDict[playerId].score; + } + if (null == p.score) { + p.score = 0; + } + sortablePlayers.push(p); + } + const sortedPlayers = sortablePlayers.sort((a, b) => { + if (a.score != b.score) { + return (b.score - a.score); + } else { + return (a.id > b.id); + } + }); + + const selfPlayerInfo = JSON.parse(cc.sys.localStorage.getItem('selfPlayer')); + for (let k in sortedPlayers) { + const p = sortedPlayers[k]; + const nameToDisplay = (() => { + function isEmptyString(str) { + return str == null || str == ''; + } + if (!isEmptyString(p.displayName)) { + return p.displayName; + } else if (!isEmptyString(p.name)) { + return p.name; + } else { + return ""; + } + })(); + + if (selfPlayerInfo.playerId == p.id) { + const rank = k + 1; + if (1 != rank && null != self.winNode) { + self.winNode.active = false; + } + } + + self.rankingNodes[k].getChildByName('name').getComponent(cc.Label).string = nameToDisplay; + self.rankingNodes[k].getChildByName('score').getComponent(cc.Label).string = playerRichInfoDict[p.id].score; + } + }, + + showMyAvatar() { + const self = this; + const selfPlayerInfo = JSON.parse(cc.sys.localStorage.getItem('selfPlayer')); + let remoteUrl = selfPlayerInfo.avatar; + if (remoteUrl == null || remoteUrl == '') { + cc.log(`No avatar to show for myself, check storage.`); + return; + } else { + cc.loader.load({ + url: remoteUrl, + type: 'jpg' + }, function(err, texture) { + if (err != null || texture == null) { + console.log(err); + } else { + const sf = new cc.SpriteFrame(); + sf.setTexture(texture); + self.myAvatarNode.getComponent(cc.Sprite).spriteFrame = sf; + } + }); + } + }, + + showRibbon(winnerInfo, ribbonNode) { + const selfPlayerInfo = JSON.parse(cc.sys.localStorage.getItem('selfPlayer')); + const texture = (selfPlayerInfo.playerId == winnerInfo.id) ? "textures/resultPanel/WinRibbon" : "textures/resultPanel/loseRibbon"; + cc.loader.loadRes(texture, cc.SpriteFrame, function(err, spriteFrame) { + if (err) { + console.log(err); + return; + } + ribbonNode.getComponent(cc.Sprite).spriteFrame = spriteFrame; + }); + + }, + + onClose(evt) { + if (this.node.parent) { + this.node.parent.removeChild(this.node); + } + if (!this.onCloseDelegate) { + return; + } + this.onCloseDelegate(); + } +}); diff --git a/frontend/assets/scripts/ResultPanel.js.meta b/frontend/assets/scripts/ResultPanel.js.meta new file mode 100644 index 0000000..1ac185d --- /dev/null +++ b/frontend/assets/scripts/ResultPanel.js.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.5", + "uuid": "5ae774fb-4f9c-445d-a057-5d32522b975d", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/scripts/SelfPlayer.js b/frontend/assets/scripts/SelfPlayer.js new file mode 100644 index 0000000..9025a24 --- /dev/null +++ b/frontend/assets/scripts/SelfPlayer.js @@ -0,0 +1,49 @@ +const BasePlayer = require("./BasePlayer"); + +cc.Class({ + extends: BasePlayer, + // LIFE-CYCLE CALLBACKS: + properties: { + arrowTipNode: { + type: cc.Node, + default: null + } + }, + start() { + BasePlayer.prototype.start.call(this); + }, + + onLoad() { + BasePlayer.prototype.onLoad.call(this); + this.attackedClips = { + '01': 'attackedLeft', + '0-1': 'attackedRight', + '-20': 'attackedLeft', + '20': 'attackedRight', + '-21': 'attackedLeft', + '21': 'attackedRight', + '-2-1': 'attackedLeft', + '2-1': 'attackedRight' + }; + this.arrowTipNode.active = false; + }, + + showArrowTipNode() { + const self = this; + if (null == self.arrowTipNode) { + return; + } + self.arrowTipNode.active = true; + window.setTimeout(function(){ + if (null == self.arrowTipNode) { + return; + } + self.arrowTipNode.active = false; + }, 3000) + }, + + update(dt) { + BasePlayer.prototype.update.call(this, dt); + }, + +}); diff --git a/frontend/assets/scripts/SelfPlayer.js.meta b/frontend/assets/scripts/SelfPlayer.js.meta new file mode 100644 index 0000000..4d05ebb --- /dev/null +++ b/frontend/assets/scripts/SelfPlayer.js.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.5", + "uuid": "b74b0e58-0ea6-4546-8e0e-919445657f24", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/scripts/SimplePressToGoDialog.js b/frontend/assets/scripts/SimplePressToGoDialog.js new file mode 100644 index 0000000..a8d9f2f --- /dev/null +++ b/frontend/assets/scripts/SimplePressToGoDialog.js @@ -0,0 +1,26 @@ +cc.Class({ + extends: cc.Component, + properties: { + + }, + + start() { + + }, + + onLoad() { + }, + + update(dt) { + }, + + dismissDialog(postDismissalByYes, evt) { + const self = this; + const target = evt.target; + self.node.parent.removeChild(self.node); + if ("Yes" == target._name) { + // This is a dirty hack! + postDismissalByYes(); + } + } +}); diff --git a/frontend/assets/scripts/SimplePressToGoDialog.js.meta b/frontend/assets/scripts/SimplePressToGoDialog.js.meta new file mode 100644 index 0000000..56ed3e1 --- /dev/null +++ b/frontend/assets/scripts/SimplePressToGoDialog.js.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.5", + "uuid": "27562abf-fe68-427f-b598-b8e53aca6e87", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/scripts/TileCollisionManagerSingleton.js b/frontend/assets/scripts/TileCollisionManagerSingleton.js new file mode 100644 index 0000000..1d710b0 --- /dev/null +++ b/frontend/assets/scripts/TileCollisionManagerSingleton.js @@ -0,0 +1,784 @@ +"use strict"; + +window.ALL_DISCRETE_DIRECTIONS_CLOCKWISE = [{ + dx: 0, + dy: 1 +}, { + dx: 2, + dy: 1 +}, { + dx: 2, + dy: 0 +}, { + dx: 2, + dy: -1 +}, { + dx: 0, + dy: -1 +}, { + dx: -2, + dy: -1 +}, { + dx: -2, + dy: 0 +}, { + dx: -2, + dy: 1 +}]; + +function TileCollisionManager() { } + +TileCollisionManager.prototype._continuousFromCentreOfDiscreteTile = function (tiledMapNode, tiledMapIns, layerIns, discretePosX, discretePosY) { + var mapOrientation = tiledMapIns.getMapOrientation(); + var mapTileRectilinearSize = tiledMapIns.getTileSize(); + var mapAnchorOffset = cc.v2(0, 0); + var tileSize = { + width: 0, + height: 0 + }; + var layerOffset = cc.v2(0, 0); + + switch (mapOrientation) { + case cc.TiledMap.Orientation.ORTHO: + return null; + + case cc.TiledMap.Orientation.ISO: + var tileSizeUnifiedLength = Math.sqrt(mapTileRectilinearSize.width * mapTileRectilinearSize.width / 4 + mapTileRectilinearSize.height * mapTileRectilinearSize.height / 4); + tileSize = { + width: tileSizeUnifiedLength, + height: tileSizeUnifiedLength + }; + var cosineThetaRadian = mapTileRectilinearSize.width / 2 / tileSizeUnifiedLength; + var sineThetaRadian = mapTileRectilinearSize.height / 2 / tileSizeUnifiedLength; + mapAnchorOffset = cc.v2( + tiledMapNode.getContentSize().width * (0.5 - tiledMapNode.getAnchorPoint().x), + tiledMapNode.getContentSize().height * (1 - tiledMapNode.getAnchorPoint().y) + ); + layerOffset = cc.v2(0, 0); + var transMat = [ + [cosineThetaRadian, -cosineThetaRadian], + [-sineThetaRadian, -sineThetaRadian] + ]; + var tmpContinuousX = (parseFloat(discretePosX) + 0.5) * tileSizeUnifiedLength; + var tmpContinuousY = (parseFloat(discretePosY) + 0.5) * tileSizeUnifiedLength; + var dContinuousXWrtMapNode = transMat[0][0] * tmpContinuousX + transMat[0][1] * tmpContinuousY; + var dContinuousYWrtMapNode = transMat[1][0] * tmpContinuousX + transMat[1][1] * tmpContinuousY; + return cc.v2(dContinuousXWrtMapNode, dContinuousYWrtMapNode).add(mapAnchorOffset); + + default: + return null; + } +}; + +TileCollisionManager.prototype._continuousToDiscrete = function (tiledMapNode, tiledMapIns, continuousNewPosLocalToMap, continuousOldPosLocalToMap) { + /* + * References + * - http://cocos2d-x.org/docs/api-ref/creator/v1.5/classes/TiledMap.html + * - http://cocos2d-x.org/docs/api-ref/creator/v1.5/classes/TiledLayer.html + * - http://docs.mapeditor.org/en/stable/reference/tmx-map-format/?highlight=orientation#map + */ + var mapOrientation = tiledMapIns.getMapOrientation(); + var mapTileRectilinearSize = tiledMapIns.getTileSize(); + var mapAnchorOffset = { + x: 0, + y: 0 + }; + var tileSize = { + width: 0, + height: 0 + }; + var layerOffset = { + x: 0, + y: 0 + }; + var convertedContinuousOldXInTileCoordinates = null; + var convertedContinuousOldYInTileCoordinates = null; + var convertedContinuousNewXInTileCoordinates = null; + var convertedContinuousNewYInTileCoordinates = null; + var oldWholeMultipleX = 0; + var oldWholeMultipleY = 0; + var newWholeMultipleX = 0; + var newWholeMultipleY = 0; + var discretePosX = 0; + var discretePosY = 0; + var exactBorderX = 0; + var exactBorderY = 0; // These tmp variables are NOT NECESSARILY useful. + + var oldTmpX = 0; + var oldTmpY = 0; + var newTmpX = 0; + var newTmpY = 0; + + switch (mapOrientation) { + case cc.TiledMap.Orientation.ORTHO: + mapAnchorOffset = { + x: -(tiledMapNode.getContentSize().width * tiledMapNode.getAnchorPoint().x), + y: tiledMapNode.getContentSize().height * (1 - tiledMapNode.getAnchorPoint().y) + }; + layerOffset = { + x: 0, + y: 0 + }; + tileSize = mapTileRectilinearSize; + convertedContinuousOldXInTileCoordinates = continuousOldPosLocalToMap.x - layerOffset.x - mapAnchorOffset.x; + convertedContinuousOldYInTileCoordinates = mapAnchorOffset.y - (continuousOldPosLocalToMap.y - layerOffset.y); + convertedContinuousNewXInTileCoordinates = continuousNewPosLocalToMap.x - layerOffset.x - mapAnchorOffset.x; + convertedContinuousNewYInTileCoordinates = mapAnchorOffset.y - (continuousNewPosLocalToMap.y - layerOffset.y); + break; + + case cc.TiledMap.Orientation.ISO: + var tileSizeUnifiedLength = Math.sqrt(mapTileRectilinearSize.width * mapTileRectilinearSize.width / 4 + mapTileRectilinearSize.height * mapTileRectilinearSize.height / 4); + tileSize = { + width: tileSizeUnifiedLength, + height: tileSizeUnifiedLength + }; + var cosineThetaRadian = mapTileRectilinearSize.width / 2 / tileSizeUnifiedLength; + var sineThetaRadian = mapTileRectilinearSize.height / 2 / tileSizeUnifiedLength; + mapAnchorOffset = { + x: tiledMapNode.getContentSize().width * (0.5 - tiledMapNode.getAnchorPoint().x), + y: tiledMapNode.getContentSize().height * (1 - tiledMapNode.getAnchorPoint().y) + }; + layerOffset = { + x: 0, + y: 0 + }; + oldTmpX = continuousOldPosLocalToMap.x - layerOffset.x - mapAnchorOffset.x; + oldTmpY = continuousOldPosLocalToMap.y - layerOffset.y - mapAnchorOffset.y; + newTmpX = continuousNewPosLocalToMap.x - layerOffset.x - mapAnchorOffset.x; + newTmpY = continuousNewPosLocalToMap.y - layerOffset.y - mapAnchorOffset.y; + var transMat = [[1 / (2 * cosineThetaRadian), -1 / (2 * sineThetaRadian)], [-1 / (2 * cosineThetaRadian), -1 / (2 * sineThetaRadian)]]; + convertedContinuousOldXInTileCoordinates = transMat[0][0] * oldTmpX + transMat[0][1] * oldTmpY; + convertedContinuousOldYInTileCoordinates = transMat[1][0] * oldTmpX + transMat[1][1] * oldTmpY; + convertedContinuousNewXInTileCoordinates = transMat[0][0] * newTmpX + transMat[0][1] * newTmpY; + convertedContinuousNewYInTileCoordinates = transMat[1][0] * newTmpX + transMat[1][1] * newTmpY; + break; + + default: + break; + } + + if (null == convertedContinuousOldXInTileCoordinates || null == convertedContinuousOldYInTileCoordinates || null == convertedContinuousNewXInTileCoordinates || null == convertedContinuousNewYInTileCoordinates) { + return null; + } + + oldWholeMultipleX = Math.floor(convertedContinuousOldXInTileCoordinates / tileSize.width); + oldWholeMultipleY = Math.floor(convertedContinuousOldYInTileCoordinates / tileSize.height); + newWholeMultipleX = Math.floor(convertedContinuousNewXInTileCoordinates / tileSize.width); + newWholeMultipleY = Math.floor(convertedContinuousNewYInTileCoordinates / tileSize.height); // Mind that the calculation of `exactBorderY` is different for `convertedContinuousOldYInTileCoordinates <> convertedContinuousNewYInTileCoordinates`. + + if (convertedContinuousOldYInTileCoordinates < convertedContinuousNewYInTileCoordinates) { + exactBorderY = newWholeMultipleY * tileSize.height; + + if (convertedContinuousNewYInTileCoordinates > exactBorderY && convertedContinuousOldYInTileCoordinates <= exactBorderY) { + // Will try to cross the border if (newWholeMultipleY != oldWholeMultipleY). + discretePosY = newWholeMultipleY; + } else { + discretePosY = oldWholeMultipleY; + } + } else if (convertedContinuousOldYInTileCoordinates > convertedContinuousNewYInTileCoordinates) { + exactBorderY = oldWholeMultipleY * tileSize.height; + + if (convertedContinuousNewYInTileCoordinates < exactBorderY && convertedContinuousOldYInTileCoordinates >= exactBorderY) { + // Will try to cross the border if (newWholeMultipleY != oldWholeMultipleY). + discretePosY = newWholeMultipleY; + } else { + discretePosY = oldWholeMultipleY; + } + } else { + discretePosY = oldWholeMultipleY; + } // Mind that the calculation of `exactBorderX` is different for `convertedContinuousOldXInTileCoordinates <> convertedContinuousNewXInTileCoordinates`. + + + if (convertedContinuousOldXInTileCoordinates < convertedContinuousNewXInTileCoordinates) { + exactBorderX = newWholeMultipleX * tileSize.width; + + if (convertedContinuousNewXInTileCoordinates > exactBorderX && convertedContinuousOldXInTileCoordinates <= exactBorderX) { + // Will cross the border if (newWholeMultipleX != oldWholeMultipleX). + discretePosX = newWholeMultipleX; + } else { + discretePosX = oldWholeMultipleX; + } + } else if (convertedContinuousOldXInTileCoordinates > convertedContinuousNewXInTileCoordinates) { + exactBorderX = oldWholeMultipleX * tileSize.width; + + if (convertedContinuousNewXInTileCoordinates < exactBorderX && convertedContinuousOldXInTileCoordinates >= exactBorderX) { + // Will cross the border if (newWholeMultipleX != oldWholeMultipleX). + discretePosX = newWholeMultipleX; + } else { + discretePosX = oldWholeMultipleX; + } + } else { + discretePosX = oldWholeMultipleX; + } + + return { + x: discretePosX, + y: discretePosY + }; +}; + +TileCollisionManager.prototype.continuousMapNodeVecToContinuousObjLayerVec = function (withTiledMapNode, continuousMapNodeVec) { + var tiledMapIns = withTiledMapNode.getComponent(cc.TiledMap); + + var mapOrientation = tiledMapIns.getMapOrientation(); + var mapTileRectilinearSize = tiledMapIns.getTileSize(); + + switch (mapOrientation) { + case cc.TiledMap.Orientation.ORTHO: + // TODO + return null; + + case cc.TiledMap.Orientation.ISO: + var tileSizeUnifiedLength = Math.sqrt(mapTileRectilinearSize.width * mapTileRectilinearSize.width * 0.25 + mapTileRectilinearSize.height * mapTileRectilinearSize.height * 0.25); + var isometricObjectLayerPointOffsetScaleFactor = (tileSizeUnifiedLength / mapTileRectilinearSize.height); + var inverseIsometricObjectLayerPointOffsetScaleFactor = 1 / isometricObjectLayerPointOffsetScaleFactor; + + var cosineThetaRadian = (mapTileRectilinearSize.width * 0.5) / tileSizeUnifiedLength; + var sineThetaRadian = (mapTileRectilinearSize.height * 0.5) / tileSizeUnifiedLength; + + var inverseTransMat = [ + [inverseIsometricObjectLayerPointOffsetScaleFactor * 0.5 * (1 / cosineThetaRadian), - inverseIsometricObjectLayerPointOffsetScaleFactor * 0.5 * (1 / sineThetaRadian)], + [- inverseIsometricObjectLayerPointOffsetScaleFactor * 0.5 * (1 / cosineThetaRadian), - inverseIsometricObjectLayerPointOffsetScaleFactor * 0.5 * (1 / sineThetaRadian)] + ]; + var convertedVecX = inverseTransMat[0][0] * continuousMapNodeVec.x + inverseTransMat[0][1] * continuousMapNodeVec.y; + var convertedVecY = inverseTransMat[1][0] * continuousMapNodeVec.x + inverseTransMat[1][1] * continuousMapNodeVec.y; + + return cc.v2(convertedVecX, convertedVecY); + + default: + return null; + } +} + +TileCollisionManager.prototype.continuousObjLayerVecToContinuousMapNodeVec = function (withTiledMapNode, continuousObjLayerVec) { + var tiledMapIns = withTiledMapNode.getComponent(cc.TiledMap); + + var mapOrientation = tiledMapIns.getMapOrientation(); + var mapTileRectilinearSize = tiledMapIns.getTileSize(); + + switch (mapOrientation) { + case cc.TiledMap.Orientation.ORTHO: + // TODO + return null; + + case cc.TiledMap.Orientation.ISO: + var tileSizeUnifiedLength = Math.sqrt(mapTileRectilinearSize.width * mapTileRectilinearSize.width * 0.25 + mapTileRectilinearSize.height * mapTileRectilinearSize.height * 0.25); + var isometricObjectLayerPointOffsetScaleFactor = (tileSizeUnifiedLength / mapTileRectilinearSize.height); + + var cosineThetaRadian = (mapTileRectilinearSize.width * 0.5) / tileSizeUnifiedLength; + var sineThetaRadian = (mapTileRectilinearSize.height * 0.5) / tileSizeUnifiedLength; + + var transMat = [ + [isometricObjectLayerPointOffsetScaleFactor * cosineThetaRadian, - isometricObjectLayerPointOffsetScaleFactor * cosineThetaRadian], + [- isometricObjectLayerPointOffsetScaleFactor * sineThetaRadian, - isometricObjectLayerPointOffsetScaleFactor * sineThetaRadian] + ]; + var convertedVecX = transMat[0][0] * continuousObjLayerVec.x + transMat[0][1] * continuousObjLayerVec.y; + var convertedVecY = transMat[1][0] * continuousObjLayerVec.x + transMat[1][1] * continuousObjLayerVec.y; + + return cc.v2(convertedVecX, convertedVecY); + + default: + return null; + } +} + +TileCollisionManager.prototype.continuousObjLayerOffsetToContinuousMapNodePos = function (withTiledMapNode, continuousObjLayerOffset) { + var tiledMapIns = withTiledMapNode.getComponent(cc.TiledMap); + + var mapOrientation = tiledMapIns.getMapOrientation(); + + switch (mapOrientation) { + case cc.TiledMap.Orientation.ORTHO: + // TODO + return null; + + case cc.TiledMap.Orientation.ISO: + const calibratedVec = continuousObjLayerOffset; // TODO: Respect the real offsets! + + // The immediately following statement takes a magic assumption that the anchor of `withTiledMapNode` is (0.5, 0.5) which is NOT NECESSARILY true. + const layerOffset = cc.v2(0, +(withTiledMapNode.getContentSize().height * 0.5)); + + return layerOffset.add(this.continuousObjLayerVecToContinuousMapNodeVec(withTiledMapNode, calibratedVec)); + + default: + return null; + } +} + +TileCollisionManager.prototype.continuousMapNodePosToContinuousObjLayerOffset = function (withTiledMapNode, continuousMapNodePos) { + var tiledMapIns = withTiledMapNode.getComponent(cc.TiledMap); + + var mapOrientation = tiledMapIns.getMapOrientation(); + var mapTileRectilinearSize = tiledMapIns.getTileSize(); + + switch (mapOrientation) { + case cc.TiledMap.Orientation.ORTHO: + // TODO + return null; + + case cc.TiledMap.Orientation.ISO: + // The immediately following statement takes a magic assumption that the anchor of `withTiledMapNode` is (0.5, 0.5) which is NOT NECESSARILY true. + var layerOffset = cc.v2(0, +(withTiledMapNode.getContentSize().height * 0.5)); + var calibratedVec = continuousMapNodePos.sub(layerOffset); // TODO: Respect the real offsets! + return this.continuousMapNodeVecToContinuousObjLayerVec(withTiledMapNode, calibratedVec); + + default: + return null; + } +} + +/** + * Note that `TileCollisionManager.extractBoundaryObjects` returns everything with coordinates local to `withTiledMapNode`! + */ +window.battleEntityTypeNameToGlobalGid = {}; +TileCollisionManager.prototype.extractBoundaryObjects = function (withTiledMapNode) { + let toRet = { + barriers: [], + shelters: [], + shelterChainTails: [], + shelterChainHeads: [], + sheltersZReducer: [], + frameAnimations: [], + grandBoundaries: [], + }; + const tiledMapIns = withTiledMapNode.getComponent(cc.TiledMap); // This is a magic name. + const mapTileSize = tiledMapIns.getTileSize(); + const mapOrientation = tiledMapIns.getMapOrientation(); + + /* + * Copies from https://github.com/cocos-creator/engine/blob/master/cocos2d/tilemap/CCTiledMap.js as a hack to parse advanced info + * of a TSX file. [BEGINS] + */ + const file = tiledMapIns._tmxFile; + const texValues = file.textures; + const texKeys = file.textureNames; + const textures = {}; + for (let texIdx = 0; texIdx < texValues.length; ++texIdx) { + textures[texKeys[texIdx]] = texValues[texIdx]; + } + + const tsxFileNames = file.tsxFileNames; + const tsxFiles = file.tsxFiles; + let tsxMap = {}; + for (let tsxFilenameIdx = 0; tsxFilenameIdx < tsxFileNames.length; ++tsxFilenameIdx) { + if (0 >= tsxFileNames[tsxFilenameIdx].length) continue; + tsxMap[tsxFileNames[tsxFilenameIdx]] = tsxFiles[tsxFilenameIdx].text; + } + + const mapInfo = new cc.TMXMapInfo(file.tmxXmlStr, tsxMap, textures); + const tileSets = mapInfo.getTilesets(); + /* + * Copies from https://github.com/cocos-creator/engine/blob/master/cocos2d/tilemap/CCTiledMap.js as a hack to parse advanced info + * of a TSX file. [ENDS] + */ + let gidBoundariesMap = {}; + const tilesElListUnderTilesets = {}; + for (let tsxFilenameIdx = 0; tsxFilenameIdx < tsxFileNames.length; ++tsxFilenameIdx) { + const tsxOrientation = tileSets[tsxFilenameIdx].orientation; + if (cc.TiledMap.Orientation.ORTHO == tsxOrientation) { + cc.error("Error at tileset %s: We proceed with ONLY tilesets in ORTHO orientation for all map orientations by now.", tsxFileNames[tsxFilenameIdx]); + continue; + }; + + const tsxXMLStr = tsxMap[tsxFileNames[tsxFilenameIdx]]; + const selTileset = mapInfo._parser._parseXML(tsxXMLStr).documentElement; + const firstGid = (parseInt(selTileset.getAttribute('firstgid')) || tileSets[tsxFilenameIdx].firstGid || 0); + const currentTiles = selTileset.getElementsByTagName('tile'); + if (!currentTiles) continue; + tilesElListUnderTilesets[tsxFileNames[tsxFilenameIdx]] = currentTiles; + + for (let tileIdx = 0; tileIdx < currentTiles.length; ++tileIdx) { + const currentTile = currentTiles[tileIdx]; + const parentGid = parseInt(firstGid) + parseInt(currentTile.getAttribute('id') || 0); + let childrenOfCurrentTile = null; + if (cc.sys.isNative) { + childrenOfCurrentTile = currentTile.getElementsByTagName("objectgroup"); + } else if (cc.sys.platform == cc.sys.WECHAT_GAME) { + childrenOfCurrentTile = currentTile.childNodes; + } else { + childrenOfCurrentTile = currentTile.children; + } + for (let childIdx = 0; childIdx < childrenOfCurrentTile.length; ++childIdx) { + const ch = childrenOfCurrentTile[childIdx]; + if ('objectgroup' != ch.nodeName) continue; + var currentObjectGroupUnderTile = mapInfo._parseObjectGroup(ch); + gidBoundariesMap[parentGid] = { + barriers: [], + shelters: [], + sheltersZReducer: [], + }; + for (let oidx = 0; oidx < currentObjectGroupUnderTile._objects.length; ++oidx) { + const oo = currentObjectGroupUnderTile._objects[oidx]; + const polylinePoints = oo.polylinePoints; + if (null == polylinePoints) continue; + const boundaryType = oo.boundary_type; + switch (boundaryType) { + case "LowScoreTreasure": + case "HighScoreTreasure": + case "GuardTower": + const spriteFrameInfoForGid = getOrCreateSpriteFrameForGid(parentGid, mapInfo, tilesElListUnderTilesets); + if (null != spriteFrameInfoForGid) { + window.battleEntityTypeNameToGlobalGid[boundaryType] = parentGid; + } + break; + case "barrier": + let brToPushTmp = []; + for (let bidx = 0; bidx < polylinePoints.length; ++bidx) { + brToPushTmp.push(cc.v2(oo.x, oo.y).add(polylinePoints[bidx])); + } + brToPushTmp.boundaryType = boundaryType; + gidBoundariesMap[parentGid].barriers.push(brToPushTmp); + break; + case "shelter": + let shToPushTmp = []; + for (let shidx = 0; shidx < polylinePoints.length; ++shidx) { + shToPushTmp.push(cc.v2(oo.x, oo.y).add(polylinePoints[shidx])); + } + shToPushTmp.boundaryType = boundaryType; + gidBoundariesMap[parentGid].shelters.push(shToPushTmp); + break; + case "shelter_z_reducer": + let shzrToPushTmp = []; + for (let shzridx = 0; shzridx < polylinePoints.length; ++shzridx) { + shzrToPushTmp.push(cc.v2(oo.x, oo.y).add(polylinePoints[shzridx])); + } + shzrToPushTmp.boundaryType = boundaryType; + gidBoundariesMap[parentGid].sheltersZReducer.push(shzrToPushTmp); + break; + default: + break; + } + } + } + } + } + + // Reference http://docs.cocos.com/creator/api/en/classes/TiledMap.html. + let allObjectGroups = tiledMapIns.getObjectGroups(); + + for (var i = 0; i < allObjectGroups.length; ++i) { + // Reference http://docs.cocos.com/creator/api/en/classes/TiledObjectGroup.html. + var objectGroup = allObjectGroups[i]; + if ("frame_anim" != objectGroup.getProperty("type")) continue; + var allObjects = objectGroup.getObjects(); + for (var j = 0; j < allObjects.length; ++j) { + var object = allObjects[j]; + var gid = object.gid; + if (!gid || gid <= 0) { + continue; + } + var animationClipInfoForGid = getOrCreateAnimationClipForGid(gid, mapInfo, tilesElListUnderTilesets); + if (!animationClipInfoForGid) continue; + toRet.frameAnimations.push({ + posInMapNode: this.continuousObjLayerOffsetToContinuousMapNodePos(withTiledMapNode, object.offset), + origSize: animationClipInfoForGid.origSize, + sizeInMapNode: cc.size(object.width, object.height), + animationClip: animationClipInfoForGid.animationClip + }); + } + } + + for (let i = 0; i < allObjectGroups.length; ++i) { + var objectGroup = allObjectGroups[i]; + if ("barrier_and_shelter" != objectGroup.getProperty("type")) continue; + var allObjects = objectGroup.getObjects(); + for (let j = 0; j < allObjects.length; ++j) { + let object = allObjects[j]; + let gid = object.gid; + if (0 < gid) { + continue; + } + const polylinePoints = object.polylinePoints; + if (null == polylinePoints) { + continue + } + for (let k = 0; k < polylinePoints.length; ++k) { + /* Since CocosCreatorv2.1.3, the Y-coord of object polylines DIRECTLY DRAWN ON tmx with ISOMETRIC ORIENTATION is inverted. -- YFLu, 2019-11-01. */ + polylinePoints[k].y = -polylinePoints[k].y; + } + const boundaryType = object.boundary_type; + switch (boundaryType) { + case "barrier": + let toPushBarriers = []; + for (let k = 0; k < polylinePoints.length; ++k) { + const tmp = object.offset.add(polylinePoints[k]); + toPushBarriers.push(this.continuousObjLayerOffsetToContinuousMapNodePos(withTiledMapNode, tmp)); + } + if (null != object.debug_mark) { + console.log("Transformed ", polylinePoints, ", to ", toPushBarriers); + } + toPushBarriers.boundaryType = boundaryType; + toRet.barriers.push(toPushBarriers); + break; + case "shelter": + let toPushShelters = []; + for (let kk = 0; kk < polylinePoints.length; ++kk) { + toPushShelters.push(this.continuousObjLayerOffsetToContinuousMapNodePos(withTiledMapNode, object.offset.add(polylinePoints[kk]))); + } + toPushShelters.boundaryType = boundaryType; + toRet.shelters.push(toPushShelters); + break; + case "shelter_z_reducer": + let toPushSheltersZReducer = []; + for (let kkk = 0; kkk < polylinePoints.length; ++kkk) { + toPushSheltersZReducer.push(this.continuousObjLayerOffsetToContinuousMapNodePos(withTiledMapNode, object.offset.add(polylinePoints[kkk]))); + } + toPushSheltersZReducer.boundaryType = boundaryType; + toRet.sheltersZReducer.push(toPushSheltersZReducer); + break; + default: + break; + } + } + } + + const allLayers = tiledMapIns.getLayers(); + + let layerDOMTrees = []; + const mapDomTree = mapInfo._parser._parseXML(tiledMapIns.tmxAsset.tmxXmlStr).documentElement; + const mapDOMAllChildren = (cc.sys.platform == cc.sys.WECHAT_GAME ? mapDomTree.childNodes : mapDomTree.children); + for (let mdtIdx = 0; mdtIdx < mapDOMAllChildren.length; ++mdtIdx) { + const tmpCh = mapDOMAllChildren[mdtIdx]; + if (mapInfo._shouldIgnoreNode(tmpCh)) { + continue; + } + + if (tmpCh.nodeName != 'layer') { + continue; + } + layerDOMTrees.push(tmpCh); + } + + for (let j = 0; j < allLayers.length; ++j) { + // TODO: Respect layer offset! + const currentTileLayer = allLayers[j]; + const currentTileset = currentTileLayer.getTileSet(); + + if (!currentTileset) { + continue; + } + + const currentLayerSize = currentTileLayer.getLayerSize(); + + const currentLayerTileSize = currentTileset._tileSize; + const firstGidInCurrentTileset = currentTileset.firstGid; + + for (let discreteXInLayer = 0; discreteXInLayer < currentLayerSize.width; ++discreteXInLayer) { + for (let discreteYInLayer = 0; discreteYInLayer < currentLayerSize.height; ++discreteYInLayer) { + const currentGid = currentTileLayer.getTileGIDAt(discreteXInLayer, discreteYInLayer); + if (0 >= currentGid) continue; + const gidBoundaries = gidBoundariesMap[currentGid]; + if (!gidBoundaries) continue; + switch (mapOrientation) { + case cc.TiledMap.Orientation.ORTHO: + // TODO + return toRet; + + case cc.TiledMap.Orientation.ISO: + const centreOfAnchorTileInMapNode = this._continuousFromCentreOfDiscreteTile(withTiledMapNode, tiledMapIns, currentTileLayer, discreteXInLayer, discreteYInLayer); + const topLeftOfWholeTsxTileInMapNode = centreOfAnchorTileInMapNode.add(cc.v2(-0.5 * mapTileSize.width, currentLayerTileSize.height - 0.5 * mapTileSize.height)); + for (let bidx = 0; bidx < gidBoundaries.barriers.length; ++bidx) { + const theBarrier = gidBoundaries.barriers[bidx]; // An array of cc.v2 points. + let brToPushTmp = []; + for (let tbidx = 0; tbidx < theBarrier.length; ++tbidx) { + brToPushTmp.push(topLeftOfWholeTsxTileInMapNode.add(cc.v2(theBarrier[tbidx].x, -theBarrier[tbidx].y /* Mind the reverse y-axis here. */))); + } + toRet.barriers.push(brToPushTmp); + } + for (let shidx = 0; shidx < gidBoundaries.shelters.length; ++shzridx) { + const theShelter = gidBoundaries.shelters[shidx]; // An array of cc.v2 points. + let shToPushTmp = []; + for (let tshidx = 0; tshidx < theShelter.length; ++tshidx) { + shToPushTmp.push(topLeftOfWholeTsxTileInMapNode.add(cc.v2(theShelter[tshidx].x, -theShelter[tshidx].y))); + } + toRet.shelters.push(shToPushTmp); + } + for (let shzridx = 0; shzridx < gidBoundaries.sheltersZReducer.length; ++shzridx) { + const theShelter = gidBoundaries.sheltersZReducer[shzridx]; // An array of cc.v2 points. + let shzrToPushTmp = []; + for (let tshzridx = 0; tshzridx < theShelter.length; ++tshzridx) { + shzrToPushTmp.push(topLeftOfWholeTsxTileInMapNode.add(cc.v2(theShelter[tshzridx].x, -theShelter[tshzridx].y))); + } + toRet.sheltersZReducer.push(shzrToPushTmp); + } + + continue; + + default: + return toRet; + } + } + } + } + return toRet; +} + +TileCollisionManager.prototype.isOutOfMapNode = function (tiledMapNode, continuousPosLocalToMap) { + var tiledMapIns = tiledMapNode.getComponent(cc.TiledMap); // This is a magic name. + + var mapOrientation = tiledMapIns.getMapOrientation(); + var mapTileRectilinearSize = tiledMapIns.getTileSize(); + + var mapContentSize = cc.size(tiledMapIns.getTileSize().width * tiledMapIns.getMapSize().width, tiledMapIns.getTileSize().height * tiledMapIns.getMapSize().height); + + switch (mapOrientation) { + case cc.TiledMap.Orientation.ORTHO: + // TODO + return true; + + case cc.TiledMap.Orientation.ISO: + var continuousObjLayerOffset = this.continuousMapNodePosToContinuousObjLayerOffset(tiledMapNode, continuousPosLocalToMap); + return 0 > continuousObjLayerOffset.x || 0 > continuousObjLayerOffset.y || mapContentSize.width < continuousObjLayerOffset.x || mapContentSize.height < continuousObjLayerOffset.y; + + default: + return true; + } + return true; +}; + +TileCollisionManager.prototype.initMapNodeByTiledBoundaries = function(mapScriptIns, mapNode, extractedBoundaryObjs) { + const tiledMapIns = mapNode.getComponent(cc.TiledMap); + if (extractedBoundaryObjs.grandBoundaries) { + window.grandBoundary = []; + for (let boundaryObj of extractedBoundaryObjs.grandBoundaries) { + for (let p of boundaryObj) { + if (CC_DEBUG) { + const labelNode = new cc.Node(); + labelNode.setPosition(p); + const label = labelNode.addComponent(cc.Label); + label.string = "GB_(" + p.x.toFixed(2) + ", " + p.y.toFixed(2) + ")"; + safelyAddChild(mapNode, labelNode); + setLocalZOrder(labelNode, 999); + } + window.grandBoundary.push(p); + } + break; + } + } + + mapScriptIns.dictOfTiledFrameAnimationList = {}; + for (let frameAnim of extractedBoundaryObjs.frameAnimations) { + if (!frameAnim.type) { + cc.warn("should bind a type to the frameAnim object layer"); + continue + } + const tiledMapIns = mapScriptIns.node.getComponent(cc.TiledMap); + let frameAnimInType = mapScriptIns.dictOfTiledFrameAnimationList[frameAnim.type]; + if (!frameAnimInType) { + mapScriptIns.dictOfTiledFrameAnimationList[frameAnim.type] = []; + frameAnimInType = mapScriptIns.dictOfTiledFrameAnimationList[frameAnim.type]; + } + const animNode = cc.instantiate(mapScriptIns.tiledAnimPrefab); + const anim = animNode.getComponent(cc.Animation); + animNode.setPosition(frameAnim.posInMapNode); + animNode.width = frameAnim.sizeInMapNode.width; + animNode.height = frameAnim.sizeInMapNode.height; + animNode.setScale(frameAnim.sizeInMapNode.width / frameAnim.origSize.width, frameAnim.sizeInMapNode.height / frameAnim.origSize.height); + animNode.opacity = 0; + animNode.setAnchorPoint(cc.v2(0.5, 0)); // A special requirement for "image-type Tiled object" by "CocosCreator v2.0.1". + safelyAddChild(mapScriptIns.node, animNode); + setLocalZOrder(animNode, 5); + anim.addClip(frameAnim.animationClip, "default"); + anim.play("default"); + frameAnimInType.push(animNode); + } + + for (let boundaryObj of extractedBoundaryObjs.shelterChainTails) { + const newShelter = cc.instantiate(mapScriptIns.polygonBoundaryShelterPrefab); + const newBoundaryOffsetInMapNode = cc.v2(boundaryObj[0].x, boundaryObj[0].y); + newShelter.setPosition(newBoundaryOffsetInMapNode); + newShelter.setAnchorPoint(cc.v2(0, 0)); + const newShelterColliderIns = newShelter.getComponent(cc.PolygonCollider); + newShelterColliderIns.points = []; + for (let p of boundaryObj) { + newShelterColliderIns.points.push(p.sub(newBoundaryOffsetInMapNode)); + } + newShelter.pTiledLayer = boundaryObj.pTiledLayer; + newShelter.tileDiscretePos = boundaryObj.tileDiscretePos; + if (null != boundaryObj.imageObject) { + newShelter.imageObject = boundaryObj.imageObject; + newShelter.tailOrHead = "tail"; + window.addToGlobalShelterChainVerticeMap(newShelter.imageObject.imageObjectNode); // Deliberately NOT adding at the "traversal of shelterChainHeads". + } + newShelter.boundaryObj = boundaryObj; + mapScriptIns.node.addChild(newShelter); + } + + for (let boundaryObj of extractedBoundaryObjs.shelterChainHeads) { + const newShelter = cc.instantiate(mapScriptIns.polygonBoundaryShelterPrefab); + const newBoundaryOffsetInMapNode = cc.v2(boundaryObj[0].x, boundaryObj[0].y); + newShelter.setPosition(newBoundaryOffsetInMapNode); + newShelter.setAnchorPoint(cc.v2(0, 0)); + const newShelterColliderIns = newShelter.getComponent(cc.PolygonCollider); + newShelterColliderIns.points = []; + for (let p of boundaryObj) { + newShelterColliderIns.points.push(p.sub(newBoundaryOffsetInMapNode)); + } + newShelter.pTiledLayer = boundaryObj.pTiledLayer; + newShelter.tileDiscretePos = boundaryObj.tileDiscretePos; + if (null != boundaryObj.imageObject) { + newShelter.imageObject = boundaryObj.imageObject; + newShelter.tailOrHead = "head"; + } + newShelter.boundaryObj = boundaryObj; + mapScriptIns.node.addChild(newShelter); + } + + mapScriptIns.barrierColliders = []; + for (let boundaryObj of extractedBoundaryObjs.barriers) { + const newBarrier = cc.instantiate(mapScriptIns.polygonBoundaryBarrierPrefab); + const newBoundaryOffsetInMapNode = cc.v2(boundaryObj[0].x, boundaryObj[0].y); + newBarrier.setPosition(newBoundaryOffsetInMapNode); + newBarrier.setAnchorPoint(cc.v2(0, 0)); + const newBarrierColliderIns = newBarrier.getComponent(cc.PolygonCollider); + newBarrierColliderIns.points = []; + for (let p of boundaryObj) { + newBarrierColliderIns.points.push(p.sub(newBoundaryOffsetInMapNode)); + } + mapScriptIns.barrierColliders.push(newBarrierColliderIns); + mapScriptIns.node.addChild(newBarrier); + } + + for (let boundaryObj of extractedBoundaryObjs.sheltersZReducer) { + const newShelter = cc.instantiate(mapScriptIns.polygonBoundaryShelterZReducerPrefab); + const newBoundaryOffsetInMapNode = cc.v2(boundaryObj[0].x, boundaryObj[0].y); + newShelter.setPosition(newBoundaryOffsetInMapNode); + newShelter.setAnchorPoint(cc.v2(0, 0)); + const newShelterColliderIns = newShelter.getComponent(cc.PolygonCollider); + newShelterColliderIns.points = []; + for (let p of boundaryObj) { + newShelterColliderIns.points.push(p.sub(newBoundaryOffsetInMapNode)); + } + mapScriptIns.node.addChild(newShelter); + } + + const allLayers = tiledMapIns.getLayers(); + for (let layer of allLayers) { + const layerType = layer.getProperty("type"); + switch (layerType) { + case "barrier_and_shelter": + setLocalZOrder(layer.node, 3); + break; + case "shelter_preview": + layer.node.opacity = 100; + setLocalZOrder(layer.node, 500); + break; + default: + break; + } + } + + const allObjectGroups = tiledMapIns.getObjectGroups(); + for (let objectGroup of allObjectGroups) { + const objectGroupType = objectGroup.getProperty("type"); + switch (objectGroupType) { + case "barrier_and_shelter": + setLocalZOrder(objectGroup.node, 3); + break; + default: + break; + } + } +} + +window.tileCollisionManager = new TileCollisionManager(); diff --git a/frontend/assets/scripts/TileCollisionManagerSingleton.js.meta b/frontend/assets/scripts/TileCollisionManagerSingleton.js.meta new file mode 100644 index 0000000..f1708bb --- /dev/null +++ b/frontend/assets/scripts/TileCollisionManagerSingleton.js.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.5", + "uuid": "91a92fb7-f06a-4b7e-8438-eb743ee49e4e", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/scripts/TouchEventsManager.js b/frontend/assets/scripts/TouchEventsManager.js new file mode 100644 index 0000000..22c1554 --- /dev/null +++ b/frontend/assets/scripts/TouchEventsManager.js @@ -0,0 +1,387 @@ +window.DIRECTION_DECODER = [ + [0, 0], + [0, +1], + [0, -1], + [+2, 0], + [-2, 0], + [+2, +1], + [-2, -1], + [+2, -1], + [-2, +1], + [+2, 0], + [-2, 0], + [0, +1], + [0, -1], +]; + +cc.Class({ + extends: cc.Component, + properties: { + // For joystick begins. + translationListenerNode: { + default: null, + type: cc.Node + }, + zoomingListenerNode: { + default: null, + type: cc.Node + }, + stickhead: { + default: null, + type: cc.Node + }, + base: { + default: null, + type: cc.Node + }, + joyStickEps: { + default: 0.10, + type: cc.Float + }, + magicLeanLowerBound: { + default: 0.414, // Tangent of (PI/8). + type: cc.Float + }, + magicLeanUpperBound: { + default: 2.414, // Tangent of (3*PI/8). + type: cc.Float + }, + // For joystick ends. + linearScaleFacBase: { + default: 1.00, + type: cc.Float + }, + minScale: { + default: 1.00, + type: cc.Float + }, + maxScale: { + default: 2.50, + type: cc.Float + }, + maxMovingBufferLength: { + default: 1, + type: cc.Integer + }, + zoomingScaleFacBase: { + default: 0.10, + type: cc.Float + }, + zoomingSpeedBase: { + default: 4.0, + type: cc.Float + }, + linearSpeedBase: { + default: 320.0, + type: cc.Float + }, + canvasNode: { + default: null, + type: cc.Node + }, + mapNode: { + default: null, + type: cc.Node + }, + linearMovingEps: { + default: 0.10, + type: cc.Float + }, + scaleByEps: { + default: 0.0375, + type: cc.Float + }, + }, + + start() {}, + + onLoad() { + this.cachedStickHeadPosition = cc.v2(0.0, 0.0); + this.canvasNode = this.mapNode.parent; + this.mainCameraNode = this.canvasNode.getChildByName("Main Camera"); // Cannot drag and assign the `mainCameraNode` from CocosCreator EDITOR directly, otherwise it'll cause an infinite loading time, till v2.1.0. + this.mainCamera = this.mainCameraNode.getComponent(cc.Camera); + this.activeDirection = { + dx: 0.0, + dy: 0.0 + }; + this.maxHeadDistance = (0.5 * this.base.width); + + this._initTouchEvent(); + this._cachedMapNodePosTarget = []; + this._cachedZoomRawTarget = null; + + this.mapScriptIns = this.mapNode.getComponent("Map"); + this.initialized = true; + }, + + justifyMapNodePosAndScale(linearSpeedBase, zoomingSpeedBase) { + const self = this; + if (false == self.mapScriptIns._inputControlEnabled) return; + if (null != self._cachedMapNodePosTarget) { + while (self.maxMovingBufferLength < self._cachedMapNodePosTarget.length) { + self._cachedMapNodePosTarget.shift(); + } + if (0 < self._cachedMapNodePosTarget.length && 0 == self.mapNode.getNumberOfRunningActions()) { + const nextMapNodePosTarget = self._cachedMapNodePosTarget.shift(); + const linearSpeed = linearSpeedBase; + const finalDiffVec = nextMapNodePosTarget.pos.sub(self.mapNode.position); + const finalDiffVecMag = finalDiffVec.mag(); + if (self.linearMovingEps > finalDiffVecMag) { + // Jittering. + // cc.log("Map node moving by finalDiffVecMag == %s is just jittering.", finalDiffVecMag); + return; + } + const durationSeconds = finalDiffVecMag / linearSpeed; + cc.log("Map node moving to %o in %s/%s == %s seconds.", nextMapNodePosTarget.pos, finalDiffVecMag, linearSpeed, durationSeconds); + const bufferedTargetPos = cc.v2(nextMapNodePosTarget.pos.x, nextMapNodePosTarget.pos.y); + self.mapNode.runAction(cc.sequence( + cc.moveTo(durationSeconds, bufferedTargetPos), + cc.callFunc(() => { + if (self._isMapOverMoved(self.mapNode.position)) { + self.mapNode.setPosition(bufferedTargetPos); + } + }, self) + )); + } + } + if (null != self._cachedZoomRawTarget && false == self._cachedZoomRawTarget.processed) { + cc.log(`Processing self._cachedZoomRawTarget == ${self._cachedZoomRawTarget}`); + self._cachedZoomRawTarget.processed = true; + self.mapNode.setScale(self._cachedZoomRawTarget.scale); + } + }, + + _initTouchEvent() { + const self = this; + const translationListenerNode = (self.translationListenerNode ? self.translationListenerNode : self.mapNode); + const zoomingListenerNode = (self.zoomingListenerNode ? self.zoomingListenerNode : self.mapNode); + + translationListenerNode.on(cc.Node.EventType.TOUCH_START, function(event) { + self._touchStartEvent(event); + }); + translationListenerNode.on(cc.Node.EventType.TOUCH_MOVE, function(event) { + self._translationEvent(event); + }); + translationListenerNode.on(cc.Node.EventType.TOUCH_END, function(event) { + self._touchEndEvent(event); + }); + translationListenerNode.on(cc.Node.EventType.TOUCH_CANCEL, function(event) { + self._touchEndEvent(event); + }); + translationListenerNode.inTouchPoints = new Map(); + + zoomingListenerNode.on(cc.Node.EventType.TOUCH_START, function(event) { + self._touchStartEvent(event); + }); + zoomingListenerNode.on(cc.Node.EventType.TOUCH_MOVE, function(event) { + self._zoomingEvent(event); + }); + zoomingListenerNode.on(cc.Node.EventType.TOUCH_END, function(event) { + self._touchEndEvent(event); + }); + zoomingListenerNode.on(cc.Node.EventType.TOUCH_CANCEL, function(event) { + self._touchEndEvent(event); + }); + zoomingListenerNode.inTouchPoints = new Map(); + }, + + _isMapOverMoved(mapTargetPos) { + const virtualPlayerPos = cc.v2(-mapTargetPos.x, -mapTargetPos.y); + return tileCollisionManager.isOutOfMapNode(this.mapNode, virtualPlayerPos); + }, + + _touchStartEvent(event) { + const theListenerNode = event.target; + for (let touch of event._touches) { + theListenerNode.inTouchPoints.set(touch._id, touch); + } + }, + + _translationEvent(event) { + if (ALL_MAP_STATES.VISUAL != this.mapScriptIns.state) { + return; + } + const theListenerNode = event.target; + const linearScaleFacBase = this.linearScaleFacBase; // Not used yet. + if (1 != theListenerNode.inTouchPoints.size) { + return; + } + if (!theListenerNode.inTouchPoints.has(event.currentTouch._id)) { + return; + } + const diffVec = event.currentTouch._point.sub(event.currentTouch._startPoint); + const distance = diffVec.mag(); + const overMoved = (distance > this.maxHeadDistance); + if (overMoved) { + const ratio = (this.maxHeadDistance / distance); + this.cachedStickHeadPosition = diffVec.mul(ratio); + } else { + const ratio = (distance / this.maxHeadDistance); + this.cachedStickHeadPosition = diffVec.mul(ratio); + } + }, + + _zoomingEvent(event) { + if (ALL_MAP_STATES.VISUAL != this.mapScriptIns.state) { + return; + } + const theListenerNode = event.target; + if (2 != theListenerNode.inTouchPoints.size) { + return; + } + if (2 == event._touches.length) { + const firstTouch = event._touches[0]; + const secondTouch = event._touches[1]; + + const startMagnitude = firstTouch._startPoint.sub(secondTouch._startPoint).mag(); + const currentMagnitude = firstTouch._point.sub(secondTouch._point).mag(); + + let scaleBy = (currentMagnitude / startMagnitude); + scaleBy = 1 + (scaleBy - 1) * this.zoomingScaleFacBase; + if (1 < scaleBy && Math.abs(scaleBy - 1) < this.scaleByEps) { + // Jitterring. + cc.log(`ScaleBy == ${scaleBy} is just jittering.`); + return; + } + if (1 > scaleBy && Math.abs(scaleBy - 1) < 0.5 * this.scaleByEps) { + // Jitterring. + cc.log(`ScaleBy == ${scaleBy} is just jittering.`); + return; + } + if (!this.mainCamera) return; + const targetScale = this.mainCamera.zoomRatio * scaleBy; + if (this.minScale > targetScale || targetScale > this.maxScale) { + return; + } + this.mainCamera.zoomRatio = targetScale; + for (let child of this.mainCameraNode.children) { + child.setScale(1/targetScale); + } + } + }, + + _touchEndEvent(event) { + const theListenerNode = event.target; + do { + if (!theListenerNode.inTouchPoints.has(event.currentTouch._id)) { + break; + } + const diffVec = event.currentTouch._point.sub(event.currentTouch._startPoint); + const diffVecMag = diffVec.mag(); + if (this.linearMovingEps <= diffVecMag) { + break; + } + // Only triggers map-state-switch when `diffVecMag` is sufficiently small. + + if (ALL_MAP_STATES.VISUAL != this.mapScriptIns.state) { + break; + } + + // TODO: Handle single-finger-click event. + } while (false); + this.cachedStickHeadPosition = cc.v2(0.0, 0.0); + for (let touch of event._touches) { + if (touch) { + theListenerNode.inTouchPoints.delete(touch._id); + } + } + }, + + _touchCancelEvent(event) {}, + + update(dt) { + if (this.inMultiTouch) return; + if (true != this.initialized) return; + this.stickhead.setPosition(this.cachedStickHeadPosition); + }, + + discretizeDirection(continuousDx, continuousDy, eps) { + let ret = { + dx: 0, + dy: 0, + encodedIdx: 0 + }; + if (Math.abs(continuousDx) < eps && Math.abs(continuousDy) < eps) { + return ret; + } + + if (Math.abs(continuousDx) < eps) { + ret.dx = 0; + if (0 < continuousDy) { + ret.dy = +1; // up + ret.encodedIdx = 1; + } else { + ret.dy = -1; // down + ret.encodedIdx = 2; + } + } else if (Math.abs(continuousDy) < eps) { + ret.dy = 0; + if (0 < continuousDx) { + ret.dx = +2; // right + ret.encodedIdx = 3; + } else { + ret.dx = -2; // left + ret.encodedIdx = 4; + } + } else { + const criticalRatio = continuousDy / continuousDx; + if (criticalRatio > this.magicLeanLowerBound && criticalRatio < this.magicLeanUpperBound) { + if (0 < continuousDx) { + ret.dx = +2; + ret.dy = +1; + ret.encodedIdx = 5; + } else { + ret.dx = -2; + ret.dy = -1; + ret.encodedIdx = 6; + } + } else if (criticalRatio > -this.magicLeanUpperBound && criticalRatio < -this.magicLeanLowerBound) { + if (0 < continuousDx) { + ret.dx = +2; + ret.dy = -1; + ret.encodedIdx = 7; + } else { + ret.dx = -2; + ret.dy = +1; + ret.encodedIdx = 8; + } + } else { + if (Math.abs(criticalRatio) < 1) { + ret.dy = 0; + if (0 < continuousDx) { + ret.dx = +2; + ret.encodedIdx = 9; + } else { + ret.dx = -2; + ret.encodedIdx = 10; + } + } else { + ret.dx = 0; + if (0 < continuousDy) { + ret.dy = +1; + ret.encodedIdx = 11; + } else { + ret.dy = -1; + ret.encodedIdx = 12; + } + } + } + } + return ret; + }, + + decodeDirection(encodedDirection) { + const mapped = window.DIRECTION_DECODER[encodedDirection]; + if (null == mapped) { + console.error("Unexpected encodedDirection = ", encodedDirection); + } + return { + dx: mapped[0], + dy: mapped[1] + } + }, + + getDiscretizedDirection() { + return this.discretizeDirection(this.cachedStickHeadPosition.x, this.cachedStickHeadPosition.y, this.joyStickEps); + } +}); diff --git a/frontend/assets/scripts/TouchEventsManager.js.meta b/frontend/assets/scripts/TouchEventsManager.js.meta new file mode 100644 index 0000000..8531106 --- /dev/null +++ b/frontend/assets/scripts/TouchEventsManager.js.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.5", + "uuid": "d34e3738-8dde-4da9-8b60-f25b4bf50493", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/scripts/Treasure.js b/frontend/assets/scripts/Treasure.js new file mode 100644 index 0000000..cc032cb --- /dev/null +++ b/frontend/assets/scripts/Treasure.js @@ -0,0 +1,26 @@ +window.LOW_SCORE_TREASURE_TYPE = 1; +window.HIGH_SCORE_TREASURE_TYPE = 2; + +window.LOW_SCORE_TREASURE_SCORE = 100; +window.HIGH_SCORE_TREASURE_SCORE = 200; + +cc.Class({ + extends: cc.Component, + + properties: { + }, + + setData (treasureInfo) { + const self = this; + this.score = treasureInfo.score; + this.type = treasureInfo.type; + + this.treasureInfo = treasureInfo; + + const spriteComponent = this.node.getComponent(cc.Sprite); + const targetGid = (window.LOW_SCORE_TREASURE_TYPE == treasureInfo.type ? window.battleEntityTypeNameToGlobalGid["LowScoreTreasure"] : window.battleEntityTypeNameToGlobalGid["HighScoreTreasure"]) + spriteComponent.spriteFrame = window.getOrCreateSpriteFrameForGid(targetGid).spriteFrame; + }, + + start() {}, +}) diff --git a/frontend/assets/scripts/Treasure.js.meta b/frontend/assets/scripts/Treasure.js.meta new file mode 100644 index 0000000..059e451 --- /dev/null +++ b/frontend/assets/scripts/Treasure.js.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.5", + "uuid": "5eea6ce5-0343-4776-80a4-fccd69bd099b", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/scripts/TreasurePickedUpAnim.js b/frontend/assets/scripts/TreasurePickedUpAnim.js new file mode 100644 index 0000000..21fd04c --- /dev/null +++ b/frontend/assets/scripts/TreasurePickedUpAnim.js @@ -0,0 +1,84 @@ +cc.Class({ + extends: cc.Component, + + properties: { + pickedUpAnimNode: { + type: cc.Node, + default: null + }, + durationMillis: { + default: 0 + }, + binglingAnimNode: { + type: cc.Node, + default: null + }, + binglingAnimDurationMillis: { + default: 0 + }, + scoreLabelNode: { + type: cc.Node, + default: null + } + + }, + + + setData (treasureInfo) { + const self = this; + this.score = treasureInfo.score ? treasureInfo.score : 100 ; + this.type = treasureInfo.type ? treasureInfo.type : 1; + this.scoreLabelNode.getComponent(cc.Label).string = this.score; + const spriteComponent = this.pickedUpAnimNode.getComponent(cc.Sprite); + //hardcode treasurePNG's path. + cc.loader.loadRes("textures/treasures/"+ this.type, cc.SpriteFrame, function (err, frame) { + if(err){ + cc.warn(err); + return; + } + spriteComponent.spriteFrame = frame; + }) + }, + + // LIFE-CYCLE CALLBACKS: + update (dt) { + const changingNode = this.pickedUpAnimNode; + const elapsedMillis = Date.now() - this.startedAtMillis; + if(elapsedMillis >= this.binglingAnimDurationMillis && null != this.binglingAnimNode && true == this.binglingAnimNode.active) { + this.binglingAnimNode.active = false; + this.startedAtMillis = Date.now(); + } + if(this.binglingAnimNode.active) + return; + if (elapsedMillis > this.durationMillis) { + this.node.destroy(); + return; + } + if (elapsedMillis <= this.firstDurationMillis) { + let posDiff = cc.v2(0, dt * this.yIncreaseSpeed); + changingNode.setPosition(changingNode.position.add(posDiff)); + this.scoreLabelNode.setPosition(this.scoreLabelNode.position.add(posDiff)); + changingNode.scale += (this.scaleIncreaseSpeed*dt); + } else { + let posDiff = cc.v2(dt * this.xIncreaseSpeed , ( -1 *dt * this.yDecreaseSpeed)); + changingNode.setPosition(changingNode.position.add(posDiff)); + this.scoreLabelNode.setPosition(this.scoreLabelNode.position.add(posDiff)); + changingNode.opacity -= dt * this.opacityDegradeSpeed; + this.scoreLabelNode.opacity -= dt * this.opacityDegradeSpeed; + } + }, + + onLoad() { + this.pickedUpAnimNode.scale = 0; + this.startedAtMillis = Date.now(); + + this.firstDurationMillis = (0.8*this.durationMillis); + this.yIncreaseSpeed = (200 *1000/this.firstDurationMillis); + this.scaleIncreaseSpeed = (2 * 1000/this.firstDurationMillis); + + this.scondDurationMillis = (0.2 * this.durationMillis ); + this.opacityDegradeSpeed = (255*1000/this.scondDurationMillis); + this.yDecreaseSpeed = (30*1000/this.scondDurationMillis); + this.xIncreaseSpeed = (20*1000/this.scondDurationMillis); + } +}); diff --git a/frontend/assets/scripts/TreasurePickedUpAnim.js.meta b/frontend/assets/scripts/TreasurePickedUpAnim.js.meta new file mode 100644 index 0000000..4dc5cd9 --- /dev/null +++ b/frontend/assets/scripts/TreasurePickedUpAnim.js.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.5", + "uuid": "697ef72c-27ee-4184-9ae3-885808d58153", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/scripts/Type2NPCPlayer.js b/frontend/assets/scripts/Type2NPCPlayer.js new file mode 100644 index 0000000..f2414fd --- /dev/null +++ b/frontend/assets/scripts/Type2NPCPlayer.js @@ -0,0 +1,28 @@ +const BasePlayer = require("./BasePlayer"); + +cc.Class({ + extends: BasePlayer, + + // LIFE-CYCLE CALLBACKS: + start() { + BasePlayer.prototype.start.call(this); + }, + + onLoad() { + BasePlayer.prototype.onLoad.call(this); + this.clips = { + '01': 'FlatHeadSisterRunTop', + '0-1': 'FlatHeadSisterRunBottom', + '-20': 'FlatHeadSisterRunLeft', + '20': 'FlatHeadSisterRunRight', + '-21': 'FlatHeadSisterRunTopLeft', + '21': 'FlatHeadSisterRunTopRight', + '-2-1': 'FlatHeadSisterRunBottomLeft', + '2-1': 'FlatHeadSisterRunBottomRight' + }; + }, + + update(dt) { + }, + +}); diff --git a/frontend/assets/scripts/Type2NPCPlayer.js.meta b/frontend/assets/scripts/Type2NPCPlayer.js.meta new file mode 100644 index 0000000..0c1d04e --- /dev/null +++ b/frontend/assets/scripts/Type2NPCPlayer.js.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.5", + "uuid": "233a1795-0de3-4d7c-9ce6-c5736ade723f", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/scripts/WechatGameLogin.js b/frontend/assets/scripts/WechatGameLogin.js new file mode 100644 index 0000000..8e5f849 --- /dev/null +++ b/frontend/assets/scripts/WechatGameLogin.js @@ -0,0 +1,628 @@ +const i18n = require('LanguageData'); +i18n.init(window.language); // languageID should be equal to the one we input in New Language ID input field + +const WECHAT_ON_HIDE_TARGET_ACTION = { + SHARE_CHAT_MESSAGE: 8, + CLOSE: 3, +}; + +const pbStructRoot = require('./modules/room_downsync_frame_proto_bundle.forcemsg.js'); +window.RoomDownsyncFrame = pbStructRoot.treasurehunterx.RoomDownsyncFrame; +window.BattleColliderInfo = pbStructRoot.treasurehunterx.BattleColliderInfo; + +cc.Class({ + extends: cc.Component, + + properties: { + cavasNode: { + default: null, + type: cc.Node + }, + backgroundNode: { + default: null, + type: cc.Node + }, + loadingPrefab: { + default: null, + type: cc.Prefab + }, + tipsLabel: { + default: null, + type: cc.Label, + }, + + downloadProgress: { + default: null, + type: cc.ProgressBar, + }, + writtenBytes: { + default: null, + type: cc.Label, + }, + expectedToWriteBytes: { + default: null, + type: cc.Label, + }, + + handlerProgress: { + default: null, + type: cc.ProgressBar, + }, + handledUrlsCount: { + default: null, + type: cc.Label, + }, + toHandledUrlsCount: { + default: null, + type: cc.Label, + }, + }, + + + // LIFE-CYCLE CALLBACKS: + onLoad() { + wx.onShow((res) => { + console.log("+++++ wx onShow(), onShow.res ", res); + window.expectedRoomId = res.query.expectedRoomId; + }); + wx.onHide((res) => { + // Reference https://developers.weixin.qq.com/minigame/dev/api/wx.exitMiniProgram.html. + console.log("+++++ wx onHide(), onHide.res: ", res); + if ( + WECHAT_ON_HIDE_TARGET_ACTION == res.targetAction + || + "back" == res.mode // After "WeChat v7.0.4 on iOS" + || + "close" == res.mode + ) { + window.clearLocalStorageAndBackToLoginScene(); + } else { + // Deliberately left blank. + } + }); + + const self = this; + self.getRetCodeList(); + self.getRegexList(); + + self.showTips(i18n.t("login.tips.AUTO_LOGIN_1")); + self.checkIntAuthTokenExpire().then( + () => { + self.showTips(i18n.t("login.tips.AUTO_LOGIN_2")); + const intAuthToken = JSON.parse(cc.sys.localStorage.getItem('selfPlayer')).intAuthToken; + self.useTokenLogin(intAuthToken); + }, + () => { + // 调用wx.login然后请求登录。 + wx.authorize({ + scope: "scope.userInfo", + success() { + self.showTips(i18n.t("login.tips.WECHAT_AUTHORIZED_AND_INT_AUTH_TOKEN_LOGGING_IN")); + wx.login({ + success(res) { + console.log("wx login success, res: ", res); + const code = res.code; + + wx.getUserInfo({ + success(res) { + const userInfo = res.userInfo; + console.log("Get user info ok: ", userInfo); + self.useWxCodeMiniGameLogin(code, userInfo); + }, + fail(err) { + console.error(i18n.t("login.tips.AUTO_LOGIN_FAILED_WILL_USE_MANUAL_LOGIN"), err); + self.showTips(i18n.t("login.tips.AUTO_LOGIN_FAILED_WILL_USE_MANUAL_LOGIN")); + self.createAuthorizeThenLoginButton(); + }, + }) + }, + fail(err) { + if (err) { + console.error(i18n.t("login.tips.AUTO_LOGIN_FAILED_WILL_USE_MANUAL_LOGIN"), err); + self.showTips(i18n.t("login.tips.AUTO_LOGIN_FAILED_WILL_USE_MANUAL_LOGIN")); + self.createAuthorizeThenLoginButton(); + } + }, + }); + }, + fail(err) { + console.error(i18n.t("login.tips.AUTO_LOGIN_FAILED_WILL_USE_MANUAL_LOGIN"), err); + self.showTips(i18n.t("login.tips.AUTO_LOGIN_FAILED_WILL_USE_MANUAL_LOGIN")); + self.createAuthorizeThenLoginButton(); + } + }) + } + ); + }, + + createAuthorizeThenLoginButton(tips) { + const self = this; + + let sysInfo = wx.getSystemInfoSync(); + //获取微信界面大小 + let width = sysInfo.screenWidth; + let height = sysInfo.screenHeight; + + let button = wx.createUserInfoButton({ + type: 'text', + text: '', + style: { + left: 0, + top: 0, + width: width, + height: height, + backgroundColor: '#00000000', //最后两位为透明度 + color: '#ffffff', + fontSize: 20, + textAlign: "center", + lineHeight: height, + }, + }); + button.onTap((res) => { + console.log(res); + if (null != res.userInfo) { + const userInfo = res.userInfo; + self.showTips(i18n.t("login.tips.WECHAT_AUTHORIZED_AND_INT_AUTH_TOKEN_LOGGING_IN")); + + wx.login({ + success(res) { + console.log('wx.login success, res:', res); + const code = res.code; + self.useWxCodeMiniGameLogin(code, userInfo); + button.destroy(); + }, + fail(err) { + console.err(i18n.t("login.tips.AUTO_LOGIN_FAILED_WILL_USE_MANUAL_LOGIN"), err); + self.showTips(i18n.t("login.tips.AUTO_LOGIN_FAILED_WILL_USE_MANUAL_LOGIN")); + }, + }); + } else { + self.showTips(i18n.t("login.tips.PLEASE_AUTHORIZE_WECHAT_LOGIN_FIRST")); + } + }) + + }, + + onDestroy() { + console.log("+++++++ WechatGameLogin onDestroy()"); + }, + + showTips(text) { + if (this.tipsLabel != null) { + this.tipsLabel.string = text; + } else { + console.log('Login scene showTips failed') + } + }, + + getRetCodeList() { + const self = this; + self.retCodeDict = constants.RET_CODE; + }, + + getRegexList() { + const self = this; + self.regexList = { + EMAIL: /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/, + PHONE: /^\+?[0-9]{8,14}$/, + STREET_META: /^.{5,100}$/, + LNG_LAT_TEXT: /^[0-9]+(\.[0-9]{4,6})$/, + SEO_KEYWORD: /^.{2,50}$/, + PASSWORD: /^.{6,50}$/, + SMS_CAPTCHA_CODE: /^[0-9]{4}$/, + ADMIN_HANDLE: /^.{4,50}$/, + }; + }, + + onSMSCaptchaGetButtonClicked(evt) { + var timerEnable = true; + const self = this; + if (!self.checkPhoneNumber('getCaptcha')) { + return; + } + NetworkUtils.ajax({ + url: backendAddress.PROTOCOL + '://' + backendAddress.HOST + ':' + backendAddress.PORT + constants.ROUTE_PATH.API + constants.ROUTE_PATH.PLAYER + + constants.ROUTE_PATH.VERSION + constants.ROUTE_PATH.SMS_CAPTCHA + constants.ROUTE_PATH.GET, + type: 'GET', + data: { + phoneCountryCode: self.phoneCountryCodeInput.getComponent(cc.EditBox).string, + phoneNum: self.phoneNumberInput.getComponent(cc.EditBox).string + }, + success: function(res) { + switch (res.ret) { + case constants.RET_CODE.OK: + self.phoneNumberTips.getComponent(cc.Label).string = ''; + self.captchaTips.getComponent(cc.Label).string = ''; + break; + case constants.RET_CODE.DUPLICATED: + self.captchaTips.getComponent(cc.Label).string = i18n.t("login.tips.DUPLICATED"); + break; + case constants.RET_CODE.INCORRECT_PHONE_COUNTRY_CODE: + case constants.RET_CODE.INCORRECT_PHONE_NUMBER: + self.captchaTips.getComponent(cc.Label).string = i18n.t("login.tips.PHONE_ERR"); + break; + case constants.RET_CODE.IS_TEST_ACC: + self.smsLoginCaptchaInput.getComponent(cc.EditBox).string = res.smsLoginCaptcha; + self.captchaTips.getComponent(cc.Label).string = i18n.t("login.tips.TEST_USER"); + timerEnable = false; + // clearInterval(self.countdownTimer); + break; + case constants.RET_CODE.SMS_CAPTCHA_REQUESTED_TOO_FREQUENTLY: + self.captchaTips.getComponent(cc.Label).string = i18n.t("login.tips.SMS_CAPTCHA_FREEQUENT_REQUIRE"); + default: + break; + } + if (timerEnable) + self.countdownTime(self); + } + }); + }, + + countdownTime(self) { + self.smsLoginCaptchaButton.off('click', self.onSMSCaptchaGetButtonClicked); + self.smsLoginCaptchaButton.removeChild(self.smsGetCaptchaNode); + self.smsWaitCountdownNode.parent = self.smsLoginCaptchaButton; + var total = 20; // Magic number + self.countdownTimer = setInterval(function() { + if (total === 0) { + self.smsWaitCountdownNode.parent.removeChild(self.smsWaitCountdownNode); + self.smsGetCaptchaNode.parent = self.smsLoginCaptchaButton; + self.smsWaitCountdownNode.getChildByName('WaitTimeLabel').getComponent(cc.Label).string = 20; + self.smsLoginCaptchaButton.on('click', self.onSMSCaptchaGetButtonClicked); + clearInterval(self.countdownTimer); + } else { + total--; + self.smsWaitCountdownNode.getChildByName('WaitTimeLabel').getComponent(cc.Label).string = total; + } + }, 1000) + + }, + + checkIntAuthTokenExpire() { + return new Promise((resolve, reject) => { + if (!cc.sys.localStorage.getItem("selfPlayer")) { + reject(); + return; + } + const selfPlayer = JSON.parse(cc.sys.localStorage.getItem('selfPlayer')); + (selfPlayer.intAuthToken && new Date().getTime() < selfPlayer.expiresAt) ? resolve() : reject(); + }) + }, + + checkPhoneNumber(type) { + const self = this; + const phoneNumberRegexp = self.regexList.PHONE; + var phoneNumberString = self.phoneNumberInput.getComponent(cc.EditBox).string; + if (phoneNumberString) { + return true; + if (!phoneNumberRegexp.test(phoneNumberString)) { + self.captchaTips.getComponent(cc.Label).string = i18n.t("login.tips.PHONE_ERR"); + return false; + } else { + return true; + } + } else { + if (type === 'getCaptcha' || type === 'login') { + self.captchaTips.getComponent(cc.Label).string = i18n.t("login.tips.PHONE_ERR"); + } + return false; + } + }, + + checkCaptcha(type) { + const self = this; + const captchaRegexp = self.regexList.SMS_CAPTCHA_CODE; + var captchaString = self.smsLoginCaptchaInput.getComponent(cc.EditBox).string; + + if (captchaString) { + if (self.smsLoginCaptchaInput.getComponent(cc.EditBox).string.length !== 4 || (!captchaRegexp.test(captchaString))) { + self.captchaTips.getComponent(cc.Label).string = i18n.t("login.tips.CAPTCHA_ERR"); + return false; + } else { + return true; + } + } else { + if (type === 'login') { + self.captchaTips.getComponent(cc.Label).string = i18n.t("login.tips.CAPTCHA_ERR"); + } + return false; + } + }, + + useTokenLogin(_intAuthToken) { + var self = this; + NetworkUtils.ajax({ + url: backendAddress.PROTOCOL + '://' + backendAddress.HOST + ':' + backendAddress.PORT + constants.ROUTE_PATH.API + constants.ROUTE_PATH.PLAYER + constants.ROUTE_PATH.VERSION + constants.ROUTE_PATH.INT_AUTH_TOKEN + constants.ROUTE_PATH.LOGIN, + type: "POST", + data: { + intAuthToken: _intAuthToken + }, + success: function(resp) { + self.onLoggedIn(resp); + }, + error: function(xhr, status, errMsg) { + console.log("Login attempt `useTokenLogin` failed, about to execute `clearBoundRoomIdInBothVolatileAndPersistentStorage`."); + window.clearBoundRoomIdInBothVolatileAndPersistentStorage() + + self.showTips(i18n.t("login.tips.AUTO_LOGIN_FAILED_WILL_USE_MANUAL_LOGIN")); + self.createAuthorizeThenLoginButton(); + }, + timeout: function() { + self.enableInteractiveControls(true); + }, + }); + }, + + enableInteractiveControls(enabled) {}, + + onLoginButtonClicked(evt) { + const self = this; + if (!self.checkPhoneNumber('login') || !self.checkCaptcha('login')) { + return; + } + self.loginParams = { + phoneCountryCode: self.phoneCountryCodeInput.getComponent(cc.EditBox).string, + phoneNum: self.phoneNumberInput.getComponent(cc.EditBox).string, + smsLoginCaptcha: self.smsLoginCaptchaInput.getComponent(cc.EditBox).string + }; + self.enableInteractiveControls(false); + + NetworkUtils.ajax({ + url: backendAddress.PROTOCOL + '://' + backendAddress.HOST + ':' + backendAddress.PORT + constants.ROUTE_PATH.API + constants.ROUTE_PATH.PLAYER + + constants.ROUTE_PATH.VERSION + constants.ROUTE_PATH.SMS_CAPTCHA + constants.ROUTE_PATH.LOGIN, + type: "POST", + data: self.loginParams, + success: function(resp) { + self.onLoggedIn(resp); + }, + error: function(xhr, status, errMsg) { + console.log("Login attempt `onLoginButtonClicked` failed, about to execute `clearBoundRoomIdInBothVolatileAndPersistentStorage`."); + window.clearBoundRoomIdInBothVolatileAndPersistentStorage() + }, + timeout: function() { + self.enableInteractiveControls(true); + } + }); + }, + onWechatLoggedIn(res) { + const self = this; + if (constants.RET_CODE.OK == res.ret) { + //根据服务器返回信息设置selfPlayer + self.enableInteractiveControls(false); + const date = Number(res.expiresAt); + const selfPlayer = { + expiresAt: date, + playerId: res.playerId, + intAuthToken: res.intAuthToken, + displayName: res.displayName, + avatar: res.avatar, + } + cc.sys.localStorage.setItem('selfPlayer', JSON.stringify(selfPlayer)); + + self.useTokenLogin(res.intAuthToken); + } else { + cc.sys.localStorage.removeItem("selfPlayer"); + window.clearBoundRoomIdInBothVolatileAndPersistentStorage(); + + self.showTips(i18n.t("login.tips.WECHAT_LOGIN_FAILED_TAP_SCREEN_TO_RETRY") + ", errorCode = " + res.ret); + self.createAuthorizeThenLoginButton(); + } + }, + + onLoggedIn(res) { + const self = this; + console.log("OnLoggedIn: ", res); + if (constants.RET_CODE.OK == res.ret) { + if (window.isUsingX5BlinkKernelOrWebkitWeChatKernel()) { + window.initWxSdk = self.initWxSdk.bind(self); + window.initWxSdk(); + } + self.enableInteractiveControls(false); + const date = Number(res.expiresAt); + const selfPlayer = { + expiresAt: date, + playerId: res.playerId, + intAuthToken: res.intAuthToken, + avatar: res.avatar, + displayName: res.displayName, + name: res.name, + } + cc.sys.localStorage.setItem("selfPlayer", JSON.stringify(selfPlayer)); + console.log("cc.sys.localStorage.selfPlayer = ", cc.sys.localStorage.getItem("selfPlayer")); + if (self.countdownTimer) { + clearInterval(self.countdownTimer); + } + + cc.director.loadScene('default_map'); + } else { + console.warn('onLoggedIn failed!') + cc.sys.localStorage.removeItem("selfPlayer"); + window.clearBoundRoomIdInBothVolatileAndPersistentStorage(); + self.enableInteractiveControls(true); + switch (res.ret) { + case constants.RET_CODE.DUPLICATED: + this.captchaTips.getComponent(cc.Label).string = i18n.t("login.tips.DUPLICATED"); + break; + case constants.RET_CODE.TOKEN_EXPIRED: + this.captchaTips.getComponent(cc.Label).string = i18n.t("login.tips.LOGIN_TOKEN_EXPIRED"); + break; + case constants.RET_CODE.SMS_CAPTCHA_NOT_MATCH: + self.captchaTips.getComponent(cc.Label).string = i18n.t("login.tips.SMS_CAPTCHA_NOT_MATCH"); + break; + case constants.RET_CODE.INCORRECT_CAPTCHA: + self.captchaTips.getComponent(cc.Label).string = i18n.t("login.tips.SMS_CAPTCHA_NOT_MATCH"); + break; + case constants.RET_CODE.SMS_CAPTCHA_CODE_NOT_EXISTING: + self.captchaTips.getComponent(cc.Label).string = i18n.t("login.tips.SMS_CAPTCHA_NOT_MATCH"); + break; + case constants.RET_CODE.INCORRECT_PHONE_NUMBER: + self.captchaTips.getComponent(cc.Label).string = i18n.t("login.tips.INCORRECT_PHONE_NUMBER"); + break; + case constants.RET_CODE.INVALID_REQUEST_PARAM: + self.captchaTips.getComponent(cc.Label).string = i18n.t("login.tips.INCORRECT_PHONE_NUMBER"); + break; + case constants.RET_CODE.INCORRECT_PHONE_COUNTRY_CODE: + case constants.RET_CODE.INCORRECT_PHONE_NUMBER: + this.captchaTips.getComponent(cc.Label).string = i18n.t("login.tips.INCORRECT_PHONE_NUMBER"); + break; + default: + break; + } + + self.showTips(i18n.t("login.tips.AUTO_LOGIN_FAILED_WILL_USE_MANUAL_LOGIN")); + self.createAuthorizeThenLoginButton(); + } + }, + + useWXCodeLogin(_code) { + const self = this; + NetworkUtils.ajax({ + url: backendAddress.PROTOCOL + '://' + backendAddress.HOST + ':' + backendAddress.PORT + constants.ROUTE_PATH.API + constants.ROUTE_PATH.PLAYER + constants.ROUTE_PATH.VERSION + constants.ROUTE_PATH.WECHAT + constants.ROUTE_PATH.LOGIN, + type: "POST", + data: { + code: _code + }, + success: function(res) { + self.onWechatLoggedIn(res); + }, + error: function(xhr, status, errMsg) { + console.log("Login attempt `onLoginButtonClicked` failed, about to execute `clearBoundRoomIdInBothVolatileAndPersistentStorage`."); + cc.sys.localStorage.removeItem("selfPlayer"); + window.clearBoundRoomIdInBothVolatileAndPersistentStorage(); + self.showTips(i18n.t("login.tips.WECHAT_LOGIN_FAILED_TAP_SCREEN_TO_RETRY") + ", errorMsg =" + errMsg); + }, + timeout: function() { + console.log("Login attempt `onLoginButtonClicked` timed out, about to execute `clearBoundRoomIdInBothVolatileAndPersistentStorage`."); + cc.sys.localStorage.removeItem("selfPlayer"); + window.clearBoundRoomIdInBothVolatileAndPersistentStorage(); + self.showTips(i18n.t("login.tips.WECHAT_LOGIN_FAILED_TAP_SCREEN_TO_RETRY") + ", errorMsg =" + errMsg); + }, + }); + }, + + // 对比useWxCodeLogin函数只是请求了不同url + useWxCodeMiniGameLogin(_code, _userInfo) { + const self = this; + NetworkUtils.ajax({ + url: backendAddress.PROTOCOL + '://' + backendAddress.HOST + ':' + backendAddress.PORT + constants.ROUTE_PATH.API + constants.ROUTE_PATH.PLAYER + constants.ROUTE_PATH.VERSION + constants.ROUTE_PATH.WECHATGAME + constants.ROUTE_PATH.LOGIN, + type: "POST", + data: { + code: _code, + avatarUrl: _userInfo.avatarUrl, + nickName: _userInfo.nickName, + }, + success: function(res) { + self.onWechatLoggedIn(res); + }, + error: function(xhr, status, errMsg) { + console.log("Login attempt `onLoginButtonClicked` failed, about to execute `clearBoundRoomIdInBothVolatileAndPersistentStorage`."); + cc.sys.localStorage.removeItem("selfPlayer"); + window.clearBoundRoomIdInBothVolatileAndPersistentStorage(); + self.showTips(i18n.t("login.tips.WECHAT_LOGIN_FAILED_TAP_SCREEN_TO_RETRY") + ", errorMsg =" + errMsg); + self.createAuthorizeThenLoginButton(); + }, + timeout: function() { + console.log("Login attempt `onLoginButtonClicked` failed, about to execute `clearBoundRoomIdInBothVolatileAndPersistentStorage`."); + cc.sys.localStorage.removeItem("selfPlayer"); + window.clearBoundRoomIdInBothVolatileAndPersistentStorage(); + self.showTips(i18n.t("login.tips.WECHAT_LOGIN_FAILED_TAP_SCREEN_TO_RETRY")); + self.createAuthorizeThenLoginButton(); + }, + }); + }, + + getWechatCode(evt) { + let self = this; + self.showTips(""); + const wechatServerEndpoint = wechatAddress.PROTOCOL + "://" + wechatAddress.HOST + ((null != wechatAddress.PORT && "" != wechatAddress.PORT.trim()) ? (":" + wechatAddress.PORT) : ""); + const url = wechatServerEndpoint + constants.WECHAT.AUTHORIZE_PATH + "?" + wechatAddress.APPID_LITERAL + "&" + constants.WECHAT.REDIRECT_RUI_KEY + NetworkUtils.encode(window.location.href) + "&" + constants.WECHAT.RESPONSE_TYPE + "&" + constants.WECHAT.SCOPE + constants.WECHAT.FIN; + console.log("To visit wechat auth addr: ", url); + window.location.href = url; + }, + + initWxSdk() { + const selfPlayer = JSON.parse(cc.sys.localStorage.getItem('selfPlayer')); + const origUrl = window.location.protocol + "//" + window.location.host + window.location.pathname; + /* + * The `shareLink` must + * - have its 2nd-order-domain registered as trusted 2nd-order under the targetd `res.jsConfig.app_id`, and + * - extracted from current window.location.href. + */ + const shareLink = origUrl; + const updateAppMsgShareDataObj = { + type: 'link', // 分享类型,music、video或link,不填默认为link + dataUrl: '', // 如果type是music或video,则要提供数据链接,默认为空 + title: document.title, // 分享标题 + desc: 'Let\'s play together!', // 分享描述 + link: shareLink + (cc.sys.localStorage.getItem('boundRoomId') ? "" : ("?expectedRoomId=" + cc.sys.localStorage.getItem('boundRoomId'))), + imgUrl: origUrl + "/favicon.ico", // 分享图标 + success: function() { + // 设置成功 + } + }; + const menuShareTimelineObj = { + title: document.title, // 分享标题 + link: shareLink + (cc.sys.localStorage.getItem('boundRoomId') ? "" : ("?expectedRoomId=" + cc.sys.localStorage.getItem('boundRoomId'))), + imgUrl: origUrl + "/favicon.ico", // 分享图标 + success: function() {} + }; + + const wxConfigUrl = (window.isUsingWebkitWechatKernel() ? window.atFirstLocationHref : window.location.href); + + //接入微信登录接口 + NetworkUtils.ajax({ + "url": backendAddress.PROTOCOL + '://' + backendAddress.HOST + ':' + backendAddress.PORT + constants.ROUTE_PATH.API + constants.ROUTE_PATH.PLAYER + constants.ROUTE_PATH.VERSION + constants.ROUTE_PATH.WECHAT + constants.ROUTE_PATH.JSCONFIG, + type: "POST", + data: { + "url": wxConfigUrl, + "intAuthToken": selfPlayer.intAuthToken, + }, + success: function(res) { + if (constants.RET_CODE.OK != res.ret) { + console.warn("Failed to get `wsConfig`: ", res); + return; + } + const jsConfig = res.jsConfig; + const configData = { + debug: CC_DEBUG, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。 + appId: jsConfig.app_id, // 必填,公众号的唯一标识 + timestamp: jsConfig.timestamp.toString(), // 必填,生成签名的时间戳 + nonceStr: jsConfig.nonce_str, // 必填,生成签名的随机串 + jsApiList: ['onMenuShareAppMessage', 'onMenuShareTimeline'], + signature: jsConfig.signature, // 必填,签名 + }; + console.log("config url: ", wxConfigUrl); + console.log("wx.config: ", configData); + wx.config(configData); + console.log("Current window.location.href: ", window.location.href); + wx.ready(function() { + console.log("Here is wx.ready.") + wx.onMenuShareAppMessage(updateAppMsgShareDataObj); + wx.onMenuShareTimeline(menuShareTimelineObj); + }); + wx.error(function(res) { + console.error("wx config fails and error is ", JSON.stringify(res)); + }); + }, + error: function(xhr, status, errMsg) { + console.error("Failed to get `wsConfig`: ", errMsg); + }, + }); + }, + + update(dt) { + const self = this; + if (null != wxDownloader && 0 < wxDownloader.totalBytesExpectedToWriteForAllTasks) { + self.writtenBytes.string = wxDownloader.totalBytesWrittenForAllTasks; + self.expectedToWriteBytes.string = wxDownloader.totalBytesExpectedToWriteForAllTasks; + self.downloadProgress.progress = 1.0*wxDownloader.totalBytesWrittenForAllTasks/wxDownloader.totalBytesExpectedToWriteForAllTasks; + } + const totalUrlsToHandle = (wxDownloader.immediateHandleItemCount + wxDownloader.immediateReadFromLocalCount + wxDownloader.immediatePackDownloaderCount); + const totalUrlsHandled = (wxDownloader.immediateHandleItemCompleteCount + wxDownloader.immediateReadFromLocalCompleteCount + wxDownloader.immediatePackDownloaderCompleteCount); + if (null != wxDownloader && 0 < totalUrlsToHandle) { + self.handledUrlsCount.string = totalUrlsHandled; + self.toHandledUrlsCount.string = totalUrlsToHandle; + self.handlerProgress.progress = 1.0*totalUrlsHandled/totalUrlsToHandle; + } + } +}); diff --git a/frontend/assets/scripts/WechatGameLogin.js.meta b/frontend/assets/scripts/WechatGameLogin.js.meta new file mode 100644 index 0000000..bf132d7 --- /dev/null +++ b/frontend/assets/scripts/WechatGameLogin.js.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.5", + "uuid": "8264fb72-e348-45e4-9ab3-5bffb9a561ee", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/scripts/WsSessionMgr.js b/frontend/assets/scripts/WsSessionMgr.js new file mode 100644 index 0000000..baa36ee --- /dev/null +++ b/frontend/assets/scripts/WsSessionMgr.js @@ -0,0 +1,263 @@ +window.UPSYNC_MSG_ACT_HB_PING = 1; +window.UPSYNC_MSG_ACT_PLAYER_CMD = 2; +window.UPSYNC_MSG_ACT_PLAYER_COLLIDER_ACK = 3; + +window.DOWNSYNC_MSG_ACT_HB_REQ = 1; +window.DOWNSYNC_MSG_ACT_INPUT_BATCH = 2; +window.DOWNSYNC_MSG_ACT_ROOM_FRAME = 3; + +window.sendSafely = function(msgStr) { + /** + * - "If the data can't be sent (for example, because it needs to be buffered but the buffer is full), the socket is closed automatically." + * + * from https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/send. + */ + if (null == window.clientSession || window.clientSession.readyState != WebSocket.OPEN) return false; + window.clientSession.send(msgStr); +} + +window.sendUint8AsBase64Safely = function(msgUint8Arr) { + if (null == window.clientSession || window.clientSession.readyState != WebSocket.OPEN) return false; + window.clientSession.send(_uint8ToBase64(msgUint8Arr)); +} + +window.closeWSConnection = function() { + if (null == window.clientSession || window.clientSession.readyState != WebSocket.OPEN) return; + console.log(`Closing "window.clientSession" from the client-side.`); + window.clientSession.close(); +} + +window.getBoundRoomIdFromPersistentStorage = function() { + const boundRoomIdExpiresAt = parseInt(cc.sys.localStorage.getItem("boundRoomIdExpiresAt")); + if (!boundRoomIdExpiresAt || Date.now() >= boundRoomIdExpiresAt) { + window.clearBoundRoomIdInBothVolatileAndPersistentStorage(); + return null; + } + return cc.sys.localStorage.getItem("boundRoomId"); +}; + +window.clearBoundRoomIdInBothVolatileAndPersistentStorage = function() { + window.boundRoomId = null; + cc.sys.localStorage.removeItem("boundRoomId"); + cc.sys.localStorage.removeItem("boundRoomIdExpiresAt"); +}; + +window.clearSelfPlayer = function() { + cc.sys.localStorage.removeItem("selfPlayer"); +}; + +window.boundRoomId = getBoundRoomIdFromPersistentStorage(); +window.handleHbRequirements = function(resp) { + if (constants.RET_CODE.OK != resp.ret) return; + if (null == window.boundRoomId) { + window.boundRoomId = resp.bciFrame.boundRoomId; + cc.sys.localStorage.setItem('boundRoomId', window.boundRoomId); + cc.sys.localStorage.setItem('boundRoomIdExpiresAt', Date.now() + 10 * 60 * 1000); // Temporarily hardcoded, for `boundRoomId` only. + } + + if (window.handleBattleColliderInfo) { + window.handleBattleColliderInfo(resp.bciFrame); + } +}; + +function _uint8ToBase64(uint8Arr) { + return window.btoa(uint8Arr); +} + +function _base64ToUint8Array(base64) { + var origBytes = null; + if (null != window.atob) { + var origBinaryStr = window.atob(base64); + var origLen = origBinaryStr.length; + origBytes = new Uint8Array(origLen); + for (var i = 0; i < origLen; i++) { + origBytes[i] = origBinaryStr.charCodeAt(i); + } + return origBytes; + } else if (cc.sys.platform == cc.sys.WECHAT_GAME) { + return Buffer.from(base64, 'base64'); + } else { + return null; + } +} + +function _base64ToArrayBuffer(base64) { + return _base64ToUint8Array(base64).buffer; +} + +window.getExpectedRoomIdSync = function() { + if (cc.sys.platform == cc.sys.WECHAT_GAME) { + return window.expectedRoomId; + } else { + const qDict = window.getQueryParamDict(); + if (qDict) { + return qDict["expectedRoomId"]; + } else { + if (window.history && window.history.state) { + return window.history.state.expectedRoomId; + } + } + } + + return null; +}; + +window.unsetClientSessionCloseOrErrorFlag = function() { + cc.sys.localStorage.removeItem("ClientSessionCloseOrErrorFlag"); + return; +} + +window.setClientSessionCloseOrErrorFlag = function() { + const oldVal = cc.sys.localStorage.getItem("ClientSessionCloseOrErrorFlag"); + if (true == oldVal) return false; + cc.sys.localStorage.setItem("ClientSessionCloseOrErrorFlag", true); + return true; +} + +window.initPersistentSessionClient = function(onopenCb, expectedRoomId) { + if (window.clientSession && window.clientSession.readyState == WebSocket.OPEN) { + if (null != onopenCb) { + onopenCb(); + } + return; + } + + const intAuthToken = cc.sys.localStorage.getItem("selfPlayer") ? JSON.parse(cc.sys.localStorage.getItem('selfPlayer')).intAuthToken : ""; + + let urlToConnect = backendAddress.PROTOCOL.replace('http', 'ws') + '://' + backendAddress.HOST + ":" + backendAddress.PORT + backendAddress.WS_PATH_PREFIX + "?intAuthToken=" + intAuthToken; + + if (null != expectedRoomId) { + console.log("initPersistentSessionClient with expectedRoomId == " + expectedRoomId); + urlToConnect = urlToConnect + "&expectedRoomId=" + expectedRoomId; + if (cc.sys.platform == cc.sys.WECHAT_GAME) { + // This is a dirty hack. -- YFLu + window.expectedRoomId = null; + } + } else { + window.boundRoomId = getBoundRoomIdFromPersistentStorage(); + if (null != window.boundRoomId) { + console.log("initPersistentSessionClient with boundRoomId == " + boundRoomId); + urlToConnect = urlToConnect + "&boundRoomId=" + window.boundRoomId; + } + } + + const currentHistoryState = window.history && window.history.state ? window.history.state : {}; + + if (cc.sys.platform != cc.sys.WECHAT_GAME) { + window.history.replaceState(currentHistoryState, document.title, window.location.pathname); + } + + const clientSession = new WebSocket(urlToConnect); + clientSession.binaryType = 'arraybuffer'; // Make 'event.data' of 'onmessage' an "ArrayBuffer" instead of a "Blob" + + clientSession.onopen = function(event) { + console.log("The WS clientSession is opened."); + window.clientSession = clientSession; + if (null == onopenCb) return; + onopenCb(); + }; + + clientSession.onmessage = function(event) { + if (null == event || null == event.data) { + return; + } + try { + const resp = window.WsResp.decode(new Uint8Array(event.data)); + switch (resp.act) { + case window.DOWNSYNC_MSG_ACT_HB_REQ: + window.handleHbRequirements(resp); // 获取boundRoomId并存储到localStorage + break; + case window.DOWNSYNC_MSG_ACT_ROOM_FRAME: + if (window.handleRoomDownsyncFrame) { + window.handleRoomDownsyncFrame(resp.rdf); + } + break; + case window.DOWNSYNC_MSG_ACT_INPUT_BATCH: + if (window.handleInputFrameDownsyncBatch) { + window.handleInputFrameDownsyncBatch(resp.inputFrameDownsyncBatch); + } + break; + default: + break; + } + } catch (e) { + console.error("Unexpected error when parsing data of:", event.data, e); + } + }; + + clientSession.onerror = function(event) { + if (!window.setClientSessionCloseOrErrorFlag()) { + return; + } + console.error("Error caught on the WS clientSession: ", event); + if (window.clientSessionPingInterval) { + clearInterval(window.clientSessionPingInterval); + } + if (window.handleClientSessionCloseOrError) { + window.handleClientSessionCloseOrError(); + } + window.unsetClientSessionCloseOrErrorFlag(); + }; + + clientSession.onclose = function(event) { + if (!window.setClientSessionCloseOrErrorFlag()) { + return; + } + console.warn("The WS clientSession is closed: ", event); + if (window.clientSessionPingInterval) { + clearInterval(window.clientSessionPingInterval); + } + if (false == event.wasClean) { + // Chrome doesn't allow the use of "CustomCloseCode"s (yet) and will callback with a "WebsocketStdCloseCode 1006" and "false == event.wasClean" here. See https://tools.ietf.org/html/rfc6455#section-7.4 for more information. + if (window.handleClientSessionCloseOrError) { + window.handleClientSessionCloseOrError(); + } + } else { + switch (event.code) { + case constants.RET_CODE.PLAYER_NOT_FOUND: + case constants.RET_CODE.PLAYER_CHEATING: + window.clearBoundRoomIdInBothVolatileAndPersistentStorage(); + break; + default: + break; + } + + if (window.handleClientSessionCloseOrError) { + window.handleClientSessionCloseOrError(); + } + } + window.unsetClientSessionCloseOrErrorFlag(); + }; +}; + +window.clearLocalStorageAndBackToLoginScene = function(shouldRetainBoundRoomIdInBothVolatileAndPersistentStorage) { + console.warn("+++++++ Calling `clearLocalStorageAndBackToLoginScene`"); + + if (window.mapIns && window.mapIns.musicEffectManagerScriptIns) { + window.mapIns.musicEffectManagerScriptIns.stopAllMusic(); + } + /** + * Here I deliberately removed the callback in the "common `handleClientSessionCloseOrError` callback" + * within which another invocation to `clearLocalStorageAndBackToLoginScene` will be made. + * + * It'll be re-assigned to the common one upon reentrance of `Map.onLoad`. + * + * -- YFLu 2019-04-06 + */ + window.handleClientSessionCloseOrError = () => { + console.warn("+++++++ Special handleClientSessionCloseOrError() assigned within `clearLocalStorageAndBackToLoginScene`"); + // TBD. + window.handleClientSessionCloseOrError = null; // To ensure that it's called at most once. + }; + window.closeWSConnection(); + window.clearSelfPlayer(); + if (true != shouldRetainBoundRoomIdInBothVolatileAndPersistentStorage) { + window.clearBoundRoomIdInBothVolatileAndPersistentStorage(); + } + if (cc.sys.platform == cc.sys.WECHAT_GAME) { + cc.director.loadScene('wechatGameLogin'); + } else { + cc.director.loadScene('login'); + } +}; + diff --git a/frontend/assets/scripts/WsSessionMgr.js.meta b/frontend/assets/scripts/WsSessionMgr.js.meta new file mode 100644 index 0000000..514c335 --- /dev/null +++ b/frontend/assets/scripts/WsSessionMgr.js.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.5", + "uuid": "07a29622-1fef-4e3a-b892-7e203315ca91", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/scripts/modules.meta b/frontend/assets/scripts/modules.meta new file mode 100644 index 0000000..e8e56ab --- /dev/null +++ b/frontend/assets/scripts/modules.meta @@ -0,0 +1,7 @@ +{ + "ver": "1.0.1", + "uuid": "40cf5957-2ccf-450f-b78e-6d65eb2fe420", + "isSubpackage": false, + "subpackageName": "", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/scripts/modules/protobuf-with-floating-num-decoding-endianess-toggle.js b/frontend/assets/scripts/modules/protobuf-with-floating-num-decoding-endianess-toggle.js new file mode 100644 index 0000000..f32fce6 --- /dev/null +++ b/frontend/assets/scripts/modules/protobuf-with-floating-num-decoding-endianess-toggle.js @@ -0,0 +1,8736 @@ +/*! + * protobuf.js v6.8.8 (c) 2016, daniel wirtz + * compiled thu, 19 jul 2018 00:33:25 utc + * licensed under the bsd-3-clause license + * see: https://github.com/dcodeio/protobuf.js for details + */ +(function(undefined){"use strict";(function prelude(modules, cache, entries) { + + // This is the prelude used to bundle protobuf.js for the browser. Wraps up the CommonJS + // sources through a conflict-free require shim and is again wrapped within an iife that + // provides a minification-friendly `undefined` var plus a global "use strict" directive + // so that minification can remove the directives of each module. + + function $require(name) { + var $module = cache[name]; + if (!$module) + modules[name][0].call($module = cache[name] = { exports: {} }, $require, $module, $module.exports); + return $module.exports; + } + + var protobuf = $require(entries[0]); + + // Expose globally + protobuf.util.global.protobuf = protobuf; + + // Be nice to AMD + if (typeof define === "function" && define.amd) + define(["long"], function(Long) { + if (Long && Long.isLong) { + protobuf.util.Long = Long; + protobuf.configure(); + } + return protobuf; + }); + + // Be nice to CommonJS + if (typeof module === "object" && module && module.exports) + module.exports = protobuf; + +})/* end of prelude */({1:[function(require,module,exports){ +"use strict"; +module.exports = asPromise; + +/** + * Callback as used by {@link util.asPromise}. + * @typedef asPromiseCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {...*} params Additional arguments + * @returns {undefined} + */ + +/** + * Returns a promise from a node-style callback function. + * @memberof util + * @param {asPromiseCallback} fn Function to call + * @param {*} ctx Function context + * @param {...*} params Function arguments + * @returns {Promise<*>} Promisified function + */ +function asPromise(fn, ctx/*, varargs */) { + var params = new Array(arguments.length - 1), + offset = 0, + index = 2, + pending = true; + while (index < arguments.length) + params[offset++] = arguments[index++]; + return new Promise(function executor(resolve, reject) { + params[offset] = function callback(err/*, varargs */) { + if (pending) { + pending = false; + if (err) + reject(err); + else { + var params = new Array(arguments.length - 1), + offset = 0; + while (offset < params.length) + params[offset++] = arguments[offset]; + resolve.apply(null, params); + } + } + }; + try { + fn.apply(ctx || null, params); + } catch (err) { + if (pending) { + pending = false; + reject(err); + } + } + }); +} + +},{}],2:[function(require,module,exports){ +"use strict"; + +/** + * A minimal base64 implementation for number arrays. + * @memberof util + * @namespace + */ +var base64 = exports; + +/** + * Calculates the byte length of a base64 encoded string. + * @param {string} string Base64 encoded string + * @returns {number} Byte length + */ +base64.length = function length(string) { + var p = string.length; + if (!p) + return 0; + var n = 0; + while (--p % 4 > 1 && string.charAt(p) === "=") + ++n; + return Math.ceil(string.length * 3) / 4 - n; +}; + +// Base64 encoding table +var b64 = new Array(64); + +// Base64 decoding table +var s64 = new Array(123); + +// 65..90, 97..122, 48..57, 43, 47 +for (var i = 0; i < 64;) + s64[b64[i] = i < 26 ? i + 65 : i < 52 ? i + 71 : i < 62 ? i - 4 : i - 59 | 43] = i++; + +/** + * Encodes a buffer to a base64 encoded string. + * @param {Uint8Array} buffer Source buffer + * @param {number} start Source start + * @param {number} end Source end + * @returns {string} Base64 encoded string + */ +base64.encode = function encode(buffer, start, end) { + var parts = null, + chunk = []; + var i = 0, // output index + j = 0, // goto index + t; // temporary + while (start < end) { + var b = buffer[start++]; + switch (j) { + case 0: + chunk[i++] = b64[b >> 2]; + t = (b & 3) << 4; + j = 1; + break; + case 1: + chunk[i++] = b64[t | b >> 4]; + t = (b & 15) << 2; + j = 2; + break; + case 2: + chunk[i++] = b64[t | b >> 6]; + chunk[i++] = b64[b & 63]; + j = 0; + break; + } + if (i > 8191) { + (parts || (parts = [])).push(String.fromCharCode.apply(String, chunk)); + i = 0; + } + } + if (j) { + chunk[i++] = b64[t]; + chunk[i++] = 61; + if (j === 1) + chunk[i++] = 61; + } + if (parts) { + if (i) + parts.push(String.fromCharCode.apply(String, chunk.slice(0, i))); + return parts.join(""); + } + return String.fromCharCode.apply(String, chunk.slice(0, i)); +}; + +var invalidEncoding = "invalid encoding"; + +/** + * Decodes a base64 encoded string to a buffer. + * @param {string} string Source string + * @param {Uint8Array} buffer Destination buffer + * @param {number} offset Destination offset + * @returns {number} Number of bytes written + * @throws {Error} If encoding is invalid + */ +base64.decode = function decode(string, buffer, offset) { + var start = offset; + var j = 0, // goto index + t; // temporary + for (var i = 0; i < string.length;) { + var c = string.charCodeAt(i++); + if (c === 61 && j > 1) + break; + if ((c = s64[c]) === undefined) + throw Error(invalidEncoding); + switch (j) { + case 0: + t = c; + j = 1; + break; + case 1: + buffer[offset++] = t << 2 | (c & 48) >> 4; + t = c; + j = 2; + break; + case 2: + buffer[offset++] = (t & 15) << 4 | (c & 60) >> 2; + t = c; + j = 3; + break; + case 3: + buffer[offset++] = (t & 3) << 6 | c; + j = 0; + break; + } + } + if (j === 1) + throw Error(invalidEncoding); + return offset - start; +}; + +/** + * Tests if the specified string appears to be base64 encoded. + * @param {string} string String to test + * @returns {boolean} `true` if probably base64 encoded, otherwise false + */ +base64.test = function test(string) { + return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(string); +}; + +},{}],3:[function(require,module,exports){ +"use strict"; +module.exports = codegen; + +/** + * Begins generating a function. + * @memberof util + * @param {string[]} functionParams Function parameter names + * @param {string} [functionName] Function name if not anonymous + * @returns {Codegen} Appender that appends code to the function's body + */ +function codegen(functionParams, functionName) { + + /* istanbul ignore if */ + if (typeof functionParams === "string") { + functionName = functionParams; + functionParams = undefined; + } + + var body = []; + + /** + * Appends code to the function's body or finishes generation. + * @typedef Codegen + * @type {function} + * @param {string|Object.} [formatStringOrScope] Format string or, to finish the function, an object of additional scope variables, if any + * @param {...*} [formatParams] Format parameters + * @returns {Codegen|Function} Itself or the generated function if finished + * @throws {Error} If format parameter counts do not match + */ + + function Codegen(formatStringOrScope) { + // note that explicit array handling below makes this ~50% faster + + // finish the function + if (typeof formatStringOrScope !== "string") { + var source = toString(); + if (codegen.verbose) + console.log("codegen: " + source); // eslint-disable-line no-console + source = "return " + source; + if (formatStringOrScope) { + var scopeKeys = Object.keys(formatStringOrScope), + scopeParams = new Array(scopeKeys.length + 1), + scopeValues = new Array(scopeKeys.length), + scopeOffset = 0; + while (scopeOffset < scopeKeys.length) { + scopeParams[scopeOffset] = scopeKeys[scopeOffset]; + scopeValues[scopeOffset] = formatStringOrScope[scopeKeys[scopeOffset++]]; + } + scopeParams[scopeOffset] = source; + return Function.apply(null, scopeParams).apply(null, scopeValues); // eslint-disable-line no-new-func + } + return Function(source)(); // eslint-disable-line no-new-func + } + + // otherwise append to body + var formatParams = new Array(arguments.length - 1), + formatOffset = 0; + while (formatOffset < formatParams.length) + formatParams[formatOffset] = arguments[++formatOffset]; + formatOffset = 0; + formatStringOrScope = formatStringOrScope.replace(/%([%dfijs])/g, function replace($0, $1) { + var value = formatParams[formatOffset++]; + switch ($1) { + case "d": case "f": return String(Number(value)); + case "i": return String(Math.floor(value)); + case "j": return JSON.stringify(value); + case "s": return String(value); + } + return "%"; + }); + if (formatOffset !== formatParams.length) + throw Error("parameter count mismatch"); + body.push(formatStringOrScope); + return Codegen; + } + + function toString(functionNameOverride) { + return "function " + (functionNameOverride || functionName || "") + "(" + (functionParams && functionParams.join(",") || "") + "){\n " + body.join("\n ") + "\n}"; + } + + Codegen.toString = toString; + return Codegen; +} + +/** + * Begins generating a function. + * @memberof util + * @function codegen + * @param {string} [functionName] Function name if not anonymous + * @returns {Codegen} Appender that appends code to the function's body + * @variation 2 + */ + +/** + * When set to `true`, codegen will log generated code to console. Useful for debugging. + * @name util.codegen.verbose + * @type {boolean} + */ +codegen.verbose = false; + +},{}],4:[function(require,module,exports){ +"use strict"; +module.exports = EventEmitter; + +/** + * Constructs a new event emitter instance. + * @classdesc A minimal event emitter. + * @memberof util + * @constructor + */ +function EventEmitter() { + + /** + * Registered listeners. + * @type {Object.} + * @private + */ + this._listeners = {}; +} + +/** + * Registers an event listener. + * @param {string} evt Event name + * @param {function} fn Listener + * @param {*} [ctx] Listener context + * @returns {util.EventEmitter} `this` + */ +EventEmitter.prototype.on = function on(evt, fn, ctx) { + (this._listeners[evt] || (this._listeners[evt] = [])).push({ + fn : fn, + ctx : ctx || this + }); + return this; +}; + +/** + * Removes an event listener or any matching listeners if arguments are omitted. + * @param {string} [evt] Event name. Removes all listeners if omitted. + * @param {function} [fn] Listener to remove. Removes all listeners of `evt` if omitted. + * @returns {util.EventEmitter} `this` + */ +EventEmitter.prototype.off = function off(evt, fn) { + if (evt === undefined) + this._listeners = {}; + else { + if (fn === undefined) + this._listeners[evt] = []; + else { + var listeners = this._listeners[evt]; + for (var i = 0; i < listeners.length;) + if (listeners[i].fn === fn) + listeners.splice(i, 1); + else + ++i; + } + } + return this; +}; + +/** + * Emits an event by calling its listeners with the specified arguments. + * @param {string} evt Event name + * @param {...*} args Arguments + * @returns {util.EventEmitter} `this` + */ +EventEmitter.prototype.emit = function emit(evt) { + var listeners = this._listeners[evt]; + if (listeners) { + var args = [], + i = 1; + for (; i < arguments.length;) + args.push(arguments[i++]); + for (i = 0; i < listeners.length;) + listeners[i].fn.apply(listeners[i++].ctx, args); + } + return this; +}; + +},{}],5:[function(require,module,exports){ +"use strict"; +module.exports = fetch; + +var asPromise = require(1), + inquire = require(7); + +var fs = inquire("fs"); + +/** + * Node-style callback as used by {@link util.fetch}. + * @typedef FetchCallback + * @type {function} + * @param {?Error} error Error, if any, otherwise `null` + * @param {string} [contents] File contents, if there hasn't been an error + * @returns {undefined} + */ + +/** + * Options as used by {@link util.fetch}. + * @typedef FetchOptions + * @type {Object} + * @property {boolean} [binary=false] Whether expecting a binary response + * @property {boolean} [xhr=false] If `true`, forces the use of XMLHttpRequest + */ + +/** + * Fetches the contents of a file. + * @memberof util + * @param {string} filename File path or url + * @param {FetchOptions} options Fetch options + * @param {FetchCallback} callback Callback function + * @returns {undefined} + */ +function fetch(filename, options, callback) { + if (typeof options === "function") { + callback = options; + options = {}; + } else if (!options) + options = {}; + + if (!callback) + return asPromise(fetch, this, filename, options); // eslint-disable-line no-invalid-this + + // if a node-like filesystem is present, try it first but fall back to XHR if nothing is found. + if (!options.xhr && fs && fs.readFile) + return fs.readFile(filename, function fetchReadFileCallback(err, contents) { + return err && typeof XMLHttpRequest !== "undefined" + ? fetch.xhr(filename, options, callback) + : err + ? callback(err) + : callback(null, options.binary ? contents : contents.toString("utf8")); + }); + + // use the XHR version otherwise. + return fetch.xhr(filename, options, callback); +} + +/** + * Fetches the contents of a file. + * @name util.fetch + * @function + * @param {string} path File path or url + * @param {FetchCallback} callback Callback function + * @returns {undefined} + * @variation 2 + */ + +/** + * Fetches the contents of a file. + * @name util.fetch + * @function + * @param {string} path File path or url + * @param {FetchOptions} [options] Fetch options + * @returns {Promise} Promise + * @variation 3 + */ + +/**/ +fetch.xhr = function fetch_xhr(filename, options, callback) { + var xhr = new XMLHttpRequest(); + xhr.onreadystatechange /* works everywhere */ = function fetchOnReadyStateChange() { + + if (xhr.readyState !== 4) + return undefined; + + // local cors security errors return status 0 / empty string, too. afaik this cannot be + // reliably distinguished from an actually empty file for security reasons. feel free + // to send a pull request if you are aware of a solution. + if (xhr.status !== 0 && xhr.status !== 200) + return callback(Error("status " + xhr.status)); + + // if binary data is expected, make sure that some sort of array is returned, even if + // ArrayBuffers are not supported. the binary string fallback, however, is unsafe. + if (options.binary) { + var buffer = xhr.response; + if (!buffer) { + buffer = []; + for (var i = 0; i < xhr.responseText.length; ++i) + buffer.push(xhr.responseText.charCodeAt(i) & 255); + } + return callback(null, typeof Uint8Array !== "undefined" ? new Uint8Array(buffer) : buffer); + } + return callback(null, xhr.responseText); + }; + + if (options.binary) { + // ref: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Sending_and_Receiving_Binary_Data#Receiving_binary_data_in_older_browsers + if ("overrideMimeType" in xhr) + xhr.overrideMimeType("text/plain; charset=x-user-defined"); + xhr.responseType = "arraybuffer"; + } + + xhr.open("GET", filename); + xhr.send(); +}; + +},{"1":1,"7":7}],6:[function(require,module,exports){ +"use strict"; + +module.exports = factory(factory); + +/** + * Reads / writes floats / doubles from / to buffers. + * @name util.float + * @namespace + */ + +/** + * Writes a 32 bit float to a buffer using little endian byte order. + * @name util.float.writeFloatLE + * @function + * @param {number} val Value to write + * @param {Uint8Array} buf Target buffer + * @param {number} pos Target buffer offset + * @returns {undefined} + */ + +/** + * Writes a 32 bit float to a buffer using big endian byte order. + * @name util.float.writeFloatBE + * @function + * @param {number} val Value to write + * @param {Uint8Array} buf Target buffer + * @param {number} pos Target buffer offset + * @returns {undefined} + */ + +/** + * Reads a 32 bit float from a buffer using little endian byte order. + * @name util.float.readFloatLE + * @function + * @param {Uint8Array} buf Source buffer + * @param {number} pos Source buffer offset + * @returns {number} Value read + */ + +/** + * Reads a 32 bit float from a buffer using big endian byte order. + * @name util.float.readFloatBE + * @function + * @param {Uint8Array} buf Source buffer + * @param {number} pos Source buffer offset + * @returns {number} Value read + */ + +/** + * Writes a 64 bit double to a buffer using little endian byte order. + * @name util.float.writeDoubleLE + * @function + * @param {number} val Value to write + * @param {Uint8Array} buf Target buffer + * @param {number} pos Target buffer offset + * @returns {undefined} + */ + +/** + * Writes a 64 bit double to a buffer using big endian byte order. + * @name util.float.writeDoubleBE + * @function + * @param {number} val Value to write + * @param {Uint8Array} buf Target buffer + * @param {number} pos Target buffer offset + * @returns {undefined} + */ + +/** + * Reads a 64 bit double from a buffer using little endian byte order. + * @name util.float.readDoubleLE + * @function + * @param {Uint8Array} buf Source buffer + * @param {number} pos Source buffer offset + * @returns {number} Value read + */ + +/** + * Reads a 64 bit double from a buffer using big endian byte order. + * @name util.float.readDoubleBE + * @function + * @param {Uint8Array} buf Source buffer + * @param {number} pos Source buffer offset + * @returns {number} Value read + */ + +// Factory function for the purpose of node-based testing in modified global environments +function factory(exports) { + + // float: typed array + if (typeof Float32Array !== "undefined") (function() { + + var f32 = new Float32Array([ -0 ]), + f8b = new Uint8Array(f32.buffer), + le = f8b[3] === 128; + + function writeFloat_f32_cpy(val, buf, pos) { + f32[0] = val; + buf[pos ] = f8b[0]; + buf[pos + 1] = f8b[1]; + buf[pos + 2] = f8b[2]; + buf[pos + 3] = f8b[3]; + } + + function writeFloat_f32_rev(val, buf, pos) { + f32[0] = val; + buf[pos ] = f8b[3]; + buf[pos + 1] = f8b[2]; + buf[pos + 2] = f8b[1]; + buf[pos + 3] = f8b[0]; + } + + /* istanbul ignore next */ + exports.writeFloatLE = le ? writeFloat_f32_cpy : writeFloat_f32_rev; + /* istanbul ignore next */ + exports.writeFloatBE = le ? writeFloat_f32_rev : writeFloat_f32_cpy; + + function readFloat_f32_cpy(buf, pos) { + f8b[0] = buf[pos ]; + f8b[1] = buf[pos + 1]; + f8b[2] = buf[pos + 2]; + f8b[3] = buf[pos + 3]; + return f32[0]; + } + + function readFloat_f32_rev(buf, pos) { + f8b[3] = buf[pos ]; + f8b[2] = buf[pos + 1]; + f8b[1] = buf[pos + 2]; + f8b[0] = buf[pos + 3]; + return f32[0]; + } + + /* istanbul ignore next */ + exports.readFloatLE = le ? readFloat_f32_cpy : readFloat_f32_rev; + /* istanbul ignore next */ + exports.readFloatBE = le ? readFloat_f32_rev : readFloat_f32_cpy; + + // float: ieee754 + })(); else (function() { + + function writeFloat_ieee754(writeUint, val, buf, pos) { + var sign = val < 0 ? 1 : 0; + if (sign) + val = -val; + if (val === 0) + writeUint(1 / val > 0 ? /* positive */ 0 : /* negative 0 */ 2147483648, buf, pos); + else if (isNaN(val)) + writeUint(2143289344, buf, pos); + else if (val > 3.4028234663852886e+38) // +-Infinity + writeUint((sign << 31 | 2139095040) >>> 0, buf, pos); + else if (val < 1.1754943508222875e-38) // denormal + writeUint((sign << 31 | Math.round(val / 1.401298464324817e-45)) >>> 0, buf, pos); + else { + var exponent = Math.floor(Math.log(val) / Math.LN2), + mantissa = Math.round(val * Math.pow(2, -exponent) * 8388608) & 8388607; + writeUint((sign << 31 | exponent + 127 << 23 | mantissa) >>> 0, buf, pos); + } + } + + exports.writeFloatLE = writeFloat_ieee754.bind(null, writeUintLE); + exports.writeFloatBE = writeFloat_ieee754.bind(null, writeUintBE); + + function readFloat_ieee754(readUint, buf, pos) { + var uint = readUint(buf, pos), + sign = (uint >> 31) * 2 + 1, + exponent = uint >>> 23 & 255, + mantissa = uint & 8388607; + return exponent === 255 + ? mantissa + ? NaN + : sign * Infinity + : exponent === 0 // denormal + ? sign * 1.401298464324817e-45 * mantissa + : sign * Math.pow(2, exponent - 150) * (mantissa + 8388608); + } + + exports.readFloatLE = readFloat_ieee754.bind(null, readUintLE); + exports.readFloatBE = readFloat_ieee754.bind(null, readUintBE); + + })(); + + // double: typed array + if (typeof Float64Array !== "undefined") (function() { + + var f64 = new Float64Array([-0]), + f8b = new Uint8Array(f64.buffer), + le = f8b[7] === 128; + + function writeDouble_f64_cpy(val, buf, pos) { + f64[0] = val; + buf[pos ] = f8b[0]; + buf[pos + 1] = f8b[1]; + buf[pos + 2] = f8b[2]; + buf[pos + 3] = f8b[3]; + buf[pos + 4] = f8b[4]; + buf[pos + 5] = f8b[5]; + buf[pos + 6] = f8b[6]; + buf[pos + 7] = f8b[7]; + } + + function writeDouble_f64_rev(val, buf, pos) { + f64[0] = val; + buf[pos ] = f8b[7]; + buf[pos + 1] = f8b[6]; + buf[pos + 2] = f8b[5]; + buf[pos + 3] = f8b[4]; + buf[pos + 4] = f8b[3]; + buf[pos + 5] = f8b[2]; + buf[pos + 6] = f8b[1]; + buf[pos + 7] = f8b[0]; + } + + /* istanbul ignore next */ + exports.writeDoubleLE = le ? writeDouble_f64_cpy : writeDouble_f64_rev; + /* istanbul ignore next */ + exports.writeDoubleBE = le ? writeDouble_f64_rev : writeDouble_f64_cpy; + + function readDouble_f64_cpy(buf, pos) { + f8b[0] = buf[pos ]; + f8b[1] = buf[pos + 1]; + f8b[2] = buf[pos + 2]; + f8b[3] = buf[pos + 3]; + f8b[4] = buf[pos + 4]; + f8b[5] = buf[pos + 5]; + f8b[6] = buf[pos + 6]; + f8b[7] = buf[pos + 7]; + return f64[0]; + } + + function readDouble_f64_rev(buf, pos) { + f8b[7] = buf[pos ]; + f8b[6] = buf[pos + 1]; + f8b[5] = buf[pos + 2]; + f8b[4] = buf[pos + 3]; + f8b[3] = buf[pos + 4]; + f8b[2] = buf[pos + 5]; + f8b[1] = buf[pos + 6]; + f8b[0] = buf[pos + 7]; + return f64[0]; + } + + /* istanbul ignore next */ + exports.readDoubleLE = le ? readDouble_f64_cpy : readDouble_f64_rev; + /* istanbul ignore next */ + exports.readDoubleBE = le ? readDouble_f64_rev : readDouble_f64_cpy; + + // double: ieee754 + })(); else (function() { + + function writeDouble_ieee754(writeUint, off0, off1, val, buf, pos) { + var sign = val < 0 ? 1 : 0; + if (sign) + val = -val; + if (val === 0) { + writeUint(0, buf, pos + off0); + writeUint(1 / val > 0 ? /* positive */ 0 : /* negative 0 */ 2147483648, buf, pos + off1); + } else if (isNaN(val)) { + writeUint(0, buf, pos + off0); + writeUint(2146959360, buf, pos + off1); + } else if (val > 1.7976931348623157e+308) { // +-Infinity + writeUint(0, buf, pos + off0); + writeUint((sign << 31 | 2146435072) >>> 0, buf, pos + off1); + } else { + var mantissa; + if (val < 2.2250738585072014e-308) { // denormal + mantissa = val / 5e-324; + writeUint(mantissa >>> 0, buf, pos + off0); + writeUint((sign << 31 | mantissa / 4294967296) >>> 0, buf, pos + off1); + } else { + var exponent = Math.floor(Math.log(val) / Math.LN2); + if (exponent === 1024) + exponent = 1023; + mantissa = val * Math.pow(2, -exponent); + writeUint(mantissa * 4503599627370496 >>> 0, buf, pos + off0); + writeUint((sign << 31 | exponent + 1023 << 20 | mantissa * 1048576 & 1048575) >>> 0, buf, pos + off1); + } + } + } + + exports.writeDoubleLE = writeDouble_ieee754.bind(null, writeUintLE, 0, 4); + exports.writeDoubleBE = writeDouble_ieee754.bind(null, writeUintBE, 4, 0); + + function readDouble_ieee754(readUint, off0, off1, buf, pos) { + var lo = readUint(buf, pos + off0), + hi = readUint(buf, pos + off1); + var sign = (hi >> 31) * 2 + 1, + exponent = hi >>> 20 & 2047, + mantissa = 4294967296 * (hi & 1048575) + lo; + return exponent === 2047 + ? mantissa + ? NaN + : sign * Infinity + : exponent === 0 // denormal + ? sign * 5e-324 * mantissa + : sign * Math.pow(2, exponent - 1075) * (mantissa + 4503599627370496); + } + + exports.readDoubleLE = readDouble_ieee754.bind(null, readUintLE, 0, 4); + exports.readDoubleBE = readDouble_ieee754.bind(null, readUintBE, 4, 0); + + })(); + + return exports; +} + +// uint helpers + +function writeUintLE(val, buf, pos) { + buf[pos ] = val & 255; + buf[pos + 1] = val >>> 8 & 255; + buf[pos + 2] = val >>> 16 & 255; + buf[pos + 3] = val >>> 24; +} + +function writeUintBE(val, buf, pos) { + buf[pos ] = val >>> 24; + buf[pos + 1] = val >>> 16 & 255; + buf[pos + 2] = val >>> 8 & 255; + buf[pos + 3] = val & 255; +} + +function readUintLE(buf, pos) { + return (buf[pos ] + | buf[pos + 1] << 8 + | buf[pos + 2] << 16 + | buf[pos + 3] << 24) >>> 0; +} + +function readUintBE(buf, pos) { + return (buf[pos ] << 24 + | buf[pos + 1] << 16 + | buf[pos + 2] << 8 + | buf[pos + 3]) >>> 0; +} + +},{}],7:[function(require,module,exports){ +"use strict"; +module.exports = inquire; + +/** + * Requires a module only if available. + * @memberof util + * @param {string} moduleName Module to require + * @returns {?Object} Required module if available and not empty, otherwise `null` + */ +function inquire(moduleName) { + try { + var mod = eval("quire".replace(/^/,"re"))(moduleName); // eslint-disable-line no-eval + if (mod && (mod.length || Object.keys(mod).length)) + return mod; + } catch (e) {} // eslint-disable-line no-empty + return null; +} + +},{}],8:[function(require,module,exports){ +"use strict"; + +/** + * A minimal path module to resolve Unix, Windows and URL paths alike. + * @memberof util + * @namespace + */ +var path = exports; + +var isAbsolute = +/** + * Tests if the specified path is absolute. + * @param {string} path Path to test + * @returns {boolean} `true` if path is absolute + */ +path.isAbsolute = function isAbsolute(path) { + return /^(?:\/|\w+:)/.test(path); +}; + +var normalize = +/** + * Normalizes the specified path. + * @param {string} path Path to normalize + * @returns {string} Normalized path + */ +path.normalize = function normalize(path) { + path = path.replace(/\\/g, "/") + .replace(/\/{2,}/g, "/"); + var parts = path.split("/"), + absolute = isAbsolute(path), + prefix = ""; + if (absolute) + prefix = parts.shift() + "/"; + for (var i = 0; i < parts.length;) { + if (parts[i] === "..") { + if (i > 0 && parts[i - 1] !== "..") + parts.splice(--i, 2); + else if (absolute) + parts.splice(i, 1); + else + ++i; + } else if (parts[i] === ".") + parts.splice(i, 1); + else + ++i; + } + return prefix + parts.join("/"); +}; + +/** + * Resolves the specified include path against the specified origin path. + * @param {string} originPath Path to the origin file + * @param {string} includePath Include path relative to origin path + * @param {boolean} [alreadyNormalized=false] `true` if both paths are already known to be normalized + * @returns {string} Path to the include file + */ +path.resolve = function resolve(originPath, includePath, alreadyNormalized) { + if (!alreadyNormalized) + includePath = normalize(includePath); + if (isAbsolute(includePath)) + return includePath; + if (!alreadyNormalized) + originPath = normalize(originPath); + return (originPath = originPath.replace(/(?:\/|^)[^/]+$/, "")).length ? normalize(originPath + "/" + includePath) : includePath; +}; + +},{}],9:[function(require,module,exports){ +"use strict"; +module.exports = pool; + +/** + * An allocator as used by {@link util.pool}. + * @typedef PoolAllocator + * @type {function} + * @param {number} size Buffer size + * @returns {Uint8Array} Buffer + */ + +/** + * A slicer as used by {@link util.pool}. + * @typedef PoolSlicer + * @type {function} + * @param {number} start Start offset + * @param {number} end End offset + * @returns {Uint8Array} Buffer slice + * @this {Uint8Array} + */ + +/** + * A general purpose buffer pool. + * @memberof util + * @function + * @param {PoolAllocator} alloc Allocator + * @param {PoolSlicer} slice Slicer + * @param {number} [size=8192] Slab size + * @returns {PoolAllocator} Pooled allocator + */ +function pool(alloc, slice, size) { + var SIZE = size || 8192; + var MAX = SIZE >>> 1; + var slab = null; + var offset = SIZE; + return function pool_alloc(size) { + if (size < 1 || size > MAX) + return alloc(size); + if (offset + size > SIZE) { + slab = alloc(SIZE); + offset = 0; + } + var buf = slice.call(slab, offset, offset += size); + if (offset & 7) // align to 32 bit + offset = (offset | 7) + 1; + return buf; + }; +} + +},{}],10:[function(require,module,exports){ +"use strict"; + +/** + * A minimal UTF8 implementation for number arrays. + * @memberof util + * @namespace + */ +var utf8 = exports; + +/** + * Calculates the UTF8 byte length of a string. + * @param {string} string String + * @returns {number} Byte length + */ +utf8.length = function utf8_length(string) { + var len = 0, + c = 0; + for (var i = 0; i < string.length; ++i) { + c = string.charCodeAt(i); + if (c < 128) + len += 1; + else if (c < 2048) + len += 2; + else if ((c & 0xFC00) === 0xD800 && (string.charCodeAt(i + 1) & 0xFC00) === 0xDC00) { + ++i; + len += 4; + } else + len += 3; + } + return len; +}; + +/** + * Reads UTF8 bytes as a string. + * @param {Uint8Array} buffer Source buffer + * @param {number} start Source start + * @param {number} end Source end + * @returns {string} String read + */ +utf8.read = function utf8_read(buffer, start, end) { + var len = end - start; + if (len < 1) + return ""; + var parts = null, + chunk = [], + i = 0, // char offset + t; // temporary + while (start < end) { + t = buffer[start++]; + if (t < 128) + chunk[i++] = t; + else if (t > 191 && t < 224) + chunk[i++] = (t & 31) << 6 | buffer[start++] & 63; + else if (t > 239 && t < 365) { + t = ((t & 7) << 18 | (buffer[start++] & 63) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63) - 0x10000; + chunk[i++] = 0xD800 + (t >> 10); + chunk[i++] = 0xDC00 + (t & 1023); + } else + chunk[i++] = (t & 15) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63; + if (i > 8191) { + (parts || (parts = [])).push(String.fromCharCode.apply(String, chunk)); + i = 0; + } + } + if (parts) { + if (i) + parts.push(String.fromCharCode.apply(String, chunk.slice(0, i))); + return parts.join(""); + } + return String.fromCharCode.apply(String, chunk.slice(0, i)); +}; + +/** + * Writes a string as UTF8 bytes. + * @param {string} string Source string + * @param {Uint8Array} buffer Destination buffer + * @param {number} offset Destination offset + * @returns {number} Bytes written + */ +utf8.write = function utf8_write(string, buffer, offset) { + var start = offset, + c1, // character 1 + c2; // character 2 + for (var i = 0; i < string.length; ++i) { + c1 = string.charCodeAt(i); + if (c1 < 128) { + buffer[offset++] = c1; + } else if (c1 < 2048) { + buffer[offset++] = c1 >> 6 | 192; + buffer[offset++] = c1 & 63 | 128; + } else if ((c1 & 0xFC00) === 0xD800 && ((c2 = string.charCodeAt(i + 1)) & 0xFC00) === 0xDC00) { + c1 = 0x10000 + ((c1 & 0x03FF) << 10) + (c2 & 0x03FF); + ++i; + buffer[offset++] = c1 >> 18 | 240; + buffer[offset++] = c1 >> 12 & 63 | 128; + buffer[offset++] = c1 >> 6 & 63 | 128; + buffer[offset++] = c1 & 63 | 128; + } else { + buffer[offset++] = c1 >> 12 | 224; + buffer[offset++] = c1 >> 6 & 63 | 128; + buffer[offset++] = c1 & 63 | 128; + } + } + return offset - start; +}; + +},{}],11:[function(require,module,exports){ +"use strict"; +module.exports = common; + +var commonRe = /\/|\./; + +/** + * Provides common type definitions. + * Can also be used to provide additional google types or your own custom types. + * @param {string} name Short name as in `google/protobuf/[name].proto` or full file name + * @param {Object.} json JSON definition within `google.protobuf` if a short name, otherwise the file's root definition + * @returns {undefined} + * @property {INamespace} google/protobuf/any.proto Any + * @property {INamespace} google/protobuf/duration.proto Duration + * @property {INamespace} google/protobuf/empty.proto Empty + * @property {INamespace} google/protobuf/field_mask.proto FieldMask + * @property {INamespace} google/protobuf/struct.proto Struct, Value, NullValue and ListValue + * @property {INamespace} google/protobuf/timestamp.proto Timestamp + * @property {INamespace} google/protobuf/wrappers.proto Wrappers + * @example + * // manually provides descriptor.proto (assumes google/protobuf/ namespace and .proto extension) + * protobuf.common("descriptor", descriptorJson); + * + * // manually provides a custom definition (uses my.foo namespace) + * protobuf.common("my/foo/bar.proto", myFooBarJson); + */ +function common(name, json) { + if (!commonRe.test(name)) { + name = "google/protobuf/" + name + ".proto"; + json = { nested: { google: { nested: { protobuf: { nested: json } } } } }; + } + common[name] = json; +} + +// Not provided because of limited use (feel free to discuss or to provide yourself): +// +// google/protobuf/descriptor.proto +// google/protobuf/source_context.proto +// google/protobuf/type.proto +// +// Stripped and pre-parsed versions of these non-bundled files are instead available as part of +// the repository or package within the google/protobuf directory. + +common("any", { + + /** + * Properties of a google.protobuf.Any message. + * @interface IAny + * @type {Object} + * @property {string} [typeUrl] + * @property {Uint8Array} [bytes] + * @memberof common + */ + Any: { + fields: { + type_url: { + type: "string", + id: 1 + }, + value: { + type: "bytes", + id: 2 + } + } + } +}); + +var timeType; + +common("duration", { + + /** + * Properties of a google.protobuf.Duration message. + * @interface IDuration + * @type {Object} + * @property {number|Long} [seconds] + * @property {number} [nanos] + * @memberof common + */ + Duration: timeType = { + fields: { + seconds: { + type: "int64", + id: 1 + }, + nanos: { + type: "int32", + id: 2 + } + } + } +}); + +common("timestamp", { + + /** + * Properties of a google.protobuf.Timestamp message. + * @interface ITimestamp + * @type {Object} + * @property {number|Long} [seconds] + * @property {number} [nanos] + * @memberof common + */ + Timestamp: timeType +}); + +common("empty", { + + /** + * Properties of a google.protobuf.Empty message. + * @interface IEmpty + * @memberof common + */ + Empty: { + fields: {} + } +}); + +common("struct", { + + /** + * Properties of a google.protobuf.Struct message. + * @interface IStruct + * @type {Object} + * @property {Object.} [fields] + * @memberof common + */ + Struct: { + fields: { + fields: { + keyType: "string", + type: "Value", + id: 1 + } + } + }, + + /** + * Properties of a google.protobuf.Value message. + * @interface IValue + * @type {Object} + * @property {string} [kind] + * @property {0} [nullValue] + * @property {number} [numberValue] + * @property {string} [stringValue] + * @property {boolean} [boolValue] + * @property {IStruct} [structValue] + * @property {IListValue} [listValue] + * @memberof common + */ + Value: { + oneofs: { + kind: { + oneof: [ + "nullValue", + "numberValue", + "stringValue", + "boolValue", + "structValue", + "listValue" + ] + } + }, + fields: { + nullValue: { + type: "NullValue", + id: 1 + }, + numberValue: { + type: "double", + id: 2 + }, + stringValue: { + type: "string", + id: 3 + }, + boolValue: { + type: "bool", + id: 4 + }, + structValue: { + type: "Struct", + id: 5 + }, + listValue: { + type: "ListValue", + id: 6 + } + } + }, + + NullValue: { + values: { + NULL_VALUE: 0 + } + }, + + /** + * Properties of a google.protobuf.ListValue message. + * @interface IListValue + * @type {Object} + * @property {Array.} [values] + * @memberof common + */ + ListValue: { + fields: { + values: { + rule: "repeated", + type: "Value", + id: 1 + } + } + } +}); + +common("wrappers", { + + /** + * Properties of a google.protobuf.DoubleValue message. + * @interface IDoubleValue + * @type {Object} + * @property {number} [value] + * @memberof common + */ + DoubleValue: { + fields: { + value: { + type: "double", + id: 1 + } + } + }, + + /** + * Properties of a google.protobuf.FloatValue message. + * @interface IFloatValue + * @type {Object} + * @property {number} [value] + * @memberof common + */ + FloatValue: { + fields: { + value: { + type: "float", + id: 1 + } + } + }, + + /** + * Properties of a google.protobuf.Int64Value message. + * @interface IInt64Value + * @type {Object} + * @property {number|Long} [value] + * @memberof common + */ + Int64Value: { + fields: { + value: { + type: "int64", + id: 1 + } + } + }, + + /** + * Properties of a google.protobuf.UInt64Value message. + * @interface IUInt64Value + * @type {Object} + * @property {number|Long} [value] + * @memberof common + */ + UInt64Value: { + fields: { + value: { + type: "uint64", + id: 1 + } + } + }, + + /** + * Properties of a google.protobuf.Int32Value message. + * @interface IInt32Value + * @type {Object} + * @property {number} [value] + * @memberof common + */ + Int32Value: { + fields: { + value: { + type: "int32", + id: 1 + } + } + }, + + /** + * Properties of a google.protobuf.UInt32Value message. + * @interface IUInt32Value + * @type {Object} + * @property {number} [value] + * @memberof common + */ + UInt32Value: { + fields: { + value: { + type: "uint32", + id: 1 + } + } + }, + + /** + * Properties of a google.protobuf.BoolValue message. + * @interface IBoolValue + * @type {Object} + * @property {boolean} [value] + * @memberof common + */ + BoolValue: { + fields: { + value: { + type: "bool", + id: 1 + } + } + }, + + /** + * Properties of a google.protobuf.StringValue message. + * @interface IStringValue + * @type {Object} + * @property {string} [value] + * @memberof common + */ + StringValue: { + fields: { + value: { + type: "string", + id: 1 + } + } + }, + + /** + * Properties of a google.protobuf.BytesValue message. + * @interface IBytesValue + * @type {Object} + * @property {Uint8Array} [value] + * @memberof common + */ + BytesValue: { + fields: { + value: { + type: "bytes", + id: 1 + } + } + } +}); + +common("field_mask", { + + /** + * Properties of a google.protobuf.FieldMask message. + * @interface IDoubleValue + * @type {Object} + * @property {number} [value] + * @memberof common + */ + FieldMask: { + fields: { + paths: { + rule: "repeated", + type: "string", + id: 1 + } + } + } +}); + +/** + * Gets the root definition of the specified common proto file. + * + * Bundled definitions are: + * - google/protobuf/any.proto + * - google/protobuf/duration.proto + * - google/protobuf/empty.proto + * - google/protobuf/field_mask.proto + * - google/protobuf/struct.proto + * - google/protobuf/timestamp.proto + * - google/protobuf/wrappers.proto + * + * @param {string} file Proto file name + * @returns {INamespace|null} Root definition or `null` if not defined + */ +common.get = function get(file) { + return common[file] || null; +}; + +},{}],12:[function(require,module,exports){ +"use strict"; +/** + * Runtime message from/to plain object converters. + * @namespace + */ +var converter = exports; + +var Enum = require(15), + util = require(37); + +/** + * Generates a partial value fromObject conveter. + * @param {Codegen} gen Codegen instance + * @param {Field} field Reflected field + * @param {number} fieldIndex Field index + * @param {string} prop Property reference + * @returns {Codegen} Codegen instance + * @ignore + */ +function genValuePartial_fromObject(gen, field, fieldIndex, prop) { + /* eslint-disable no-unexpected-multiline, block-scoped-var, no-redeclare */ + if (field.resolvedType) { + if (field.resolvedType instanceof Enum) { gen + ("switch(d%s){", prop); + for (var values = field.resolvedType.values, keys = Object.keys(values), i = 0; i < keys.length; ++i) { + if (field.repeated && values[keys[i]] === field.typeDefault) gen + ("default:"); + gen + ("case%j:", keys[i]) + ("case %i:", values[keys[i]]) + ("m%s=%j", prop, values[keys[i]]) + ("break"); + } gen + ("}"); + } else gen + ("if(typeof d%s!==\"object\")", prop) + ("throw TypeError(%j)", field.fullName + ": object expected") + ("m%s=types[%i].fromObject(d%s)", prop, fieldIndex, prop); + } else { + var isUnsigned = false; + switch (field.type) { + case "double": + case "float": gen + ("m%s=Number(d%s)", prop, prop); // also catches "NaN", "Infinity" + break; + case "uint32": + case "fixed32": gen + ("m%s=d%s>>>0", prop, prop); + break; + case "int32": + case "sint32": + case "sfixed32": gen + ("m%s=d%s|0", prop, prop); + break; + case "uint64": + isUnsigned = true; + // eslint-disable-line no-fallthrough + case "int64": + case "sint64": + case "fixed64": + case "sfixed64": gen + ("if(util.Long)") + ("(m%s=util.Long.fromValue(d%s)).unsigned=%j", prop, prop, isUnsigned) + ("else if(typeof d%s===\"string\")", prop) + ("m%s=parseInt(d%s,10)", prop, prop) + ("else if(typeof d%s===\"number\")", prop) + ("m%s=d%s", prop, prop) + ("else if(typeof d%s===\"object\")", prop) + ("m%s=new util.LongBits(d%s.low>>>0,d%s.high>>>0).toNumber(%s)", prop, prop, prop, isUnsigned ? "true" : ""); + break; + case "bytes": gen + ("if(typeof d%s===\"string\")", prop) + ("util.base64.decode(d%s,m%s=util.newBuffer(util.base64.length(d%s)),0)", prop, prop, prop) + ("else if(d%s.length)", prop) + ("m%s=d%s", prop, prop); + break; + case "string": gen + ("m%s=String(d%s)", prop, prop); + break; + case "bool": gen + ("m%s=Boolean(d%s)", prop, prop); + break; + /* default: gen + ("m%s=d%s", prop, prop); + break; */ + } + } + return gen; + /* eslint-enable no-unexpected-multiline, block-scoped-var, no-redeclare */ +} + +/** + * Generates a plain object to runtime message converter specific to the specified message type. + * @param {Type} mtype Message type + * @returns {Codegen} Codegen instance + */ +converter.fromObject = function fromObject(mtype) { + /* eslint-disable no-unexpected-multiline, block-scoped-var, no-redeclare */ + var fields = mtype.fieldsArray; + var gen = util.codegen(["d"], mtype.name + "$fromObject") + ("if(d instanceof this.ctor)") + ("return d"); + if (!fields.length) return gen + ("return new this.ctor"); + gen + ("var m=new this.ctor"); + for (var i = 0; i < fields.length; ++i) { + var field = fields[i].resolve(), + prop = util.safeProp(field.name); + + // Map fields + if (field.map) { gen + ("if(d%s){", prop) + ("if(typeof d%s!==\"object\")", prop) + ("throw TypeError(%j)", field.fullName + ": object expected") + ("m%s={}", prop) + ("for(var ks=Object.keys(d%s),i=0;i>>0,m%s.high>>>0).toNumber(%s):m%s", prop, prop, prop, prop, isUnsigned ? "true": "", prop); + break; + case "bytes": gen + ("d%s=o.bytes===String?util.base64.encode(m%s,0,m%s.length):o.bytes===Array?Array.prototype.slice.call(m%s):m%s", prop, prop, prop, prop, prop); + break; + default: gen + ("d%s=m%s", prop, prop); + break; + } + } + return gen; + /* eslint-enable no-unexpected-multiline, block-scoped-var, no-redeclare */ +} + +/** + * Generates a runtime message to plain object converter specific to the specified message type. + * @param {Type} mtype Message type + * @returns {Codegen} Codegen instance + */ +converter.toObject = function toObject(mtype) { + /* eslint-disable no-unexpected-multiline, block-scoped-var, no-redeclare */ + var fields = mtype.fieldsArray.slice().sort(util.compareFieldsById); + if (!fields.length) + return util.codegen()("return {}"); + var gen = util.codegen(["m", "o"], mtype.name + "$toObject") + ("if(!o)") + ("o={}") + ("var d={}"); + + var repeatedFields = [], + mapFields = [], + normalFields = [], + i = 0; + for (; i < fields.length; ++i) + if (!fields[i].partOf) + ( fields[i].resolve().repeated ? repeatedFields + : fields[i].map ? mapFields + : normalFields).push(fields[i]); + + if (repeatedFields.length) { gen + ("if(o.arrays||o.defaults){"); + for (i = 0; i < repeatedFields.length; ++i) gen + ("d%s=[]", util.safeProp(repeatedFields[i].name)); + gen + ("}"); + } + + if (mapFields.length) { gen + ("if(o.objects||o.defaults){"); + for (i = 0; i < mapFields.length; ++i) gen + ("d%s={}", util.safeProp(mapFields[i].name)); + gen + ("}"); + } + + if (normalFields.length) { gen + ("if(o.defaults){"); + for (i = 0; i < normalFields.length; ++i) { + var field = normalFields[i], + prop = util.safeProp(field.name); + if (field.resolvedType instanceof Enum) gen + ("d%s=o.enums===String?%j:%j", prop, field.resolvedType.valuesById[field.typeDefault], field.typeDefault); + else if (field.long) gen + ("if(util.Long){") + ("var n=new util.Long(%i,%i,%j)", field.typeDefault.low, field.typeDefault.high, field.typeDefault.unsigned) + ("d%s=o.longs===String?n.toString():o.longs===Number?n.toNumber():n", prop) + ("}else") + ("d%s=o.longs===String?%j:%i", prop, field.typeDefault.toString(), field.typeDefault.toNumber()); + else if (field.bytes) { + var arrayDefault = "[" + Array.prototype.slice.call(field.typeDefault).join(",") + "]"; + gen + ("if(o.bytes===String)d%s=%j", prop, String.fromCharCode.apply(String, field.typeDefault)) + ("else{") + ("d%s=%s", prop, arrayDefault) + ("if(o.bytes!==Array)d%s=util.newBuffer(d%s)", prop, prop) + ("}"); + } else gen + ("d%s=%j", prop, field.typeDefault); // also messages (=null) + } gen + ("}"); + } + var hasKs2 = false; + for (i = 0; i < fields.length; ++i) { + var field = fields[i], + index = mtype._fieldsArray.indexOf(field), + prop = util.safeProp(field.name); + if (field.map) { + if (!hasKs2) { hasKs2 = true; gen + ("var ks2"); + } gen + ("if(m%s&&(ks2=Object.keys(m%s)).length){", prop, prop) + ("d%s={}", prop) + ("for(var j=0;j>>3){"); + + var i = 0; + for (; i < /* initializes */ mtype.fieldsArray.length; ++i) { + var field = mtype._fieldsArray[i].resolve(), + type = field.resolvedType instanceof Enum ? "int32" : field.type, + ref = "m" + util.safeProp(field.name); gen + ("case %i:", field.id); + + // Map fields + if (field.map) { gen + ("r.skip().pos++") // assumes id 1 + key wireType + ("if(%s===util.emptyObject)", ref) + ("%s={}", ref) + ("k=r.%s()", field.keyType) + ("r.pos++"); // assumes id 2 + value wireType + if (types.long[field.keyType] !== undefined) { + if (types.basic[type] === undefined) gen + ("%s[typeof k===\"object\"?util.longToHash(k):k]=types[%i].decode(r,r.uint32())", ref, i); // can't be groups + else gen + ("%s[typeof k===\"object\"?util.longToHash(k):k]=r.%s()", ref, type); + } else { + if (types.basic[type] === undefined) gen + ("%s[k]=types[%i].decode(r,r.uint32())", ref, i); // can't be groups + else gen + ("%s[k]=r.%s()", ref, type); + } + + // Repeated fields + } else if (field.repeated) { gen + + ("if(!(%s&&%s.length))", ref, ref) + ("%s=[]", ref); + + // Packable (always check for forward and backward compatiblity) + if (types.packed[type] !== undefined) gen + ("if((t&7)===2){") + ("var c2=r.uint32()+r.pos") + ("while(r.pos>> 0, (field.id << 3 | 4) >>> 0) + : gen("types[%i].encode(%s,w.uint32(%i).fork()).ldelim()", fieldIndex, ref, (field.id << 3 | 2) >>> 0); +} + +/** + * Generates an encoder specific to the specified message type. + * @param {Type} mtype Message type + * @returns {Codegen} Codegen instance + */ +function encoder(mtype) { + /* eslint-disable no-unexpected-multiline, block-scoped-var, no-redeclare */ + var gen = util.codegen(["m", "w"], mtype.name + "$encode") + ("if(!w)") + ("w=Writer.create()"); + + var i, ref; + + // "when a message is serialized its known fields should be written sequentially by field number" + var fields = /* initializes */ mtype.fieldsArray.slice().sort(util.compareFieldsById); + + for (var i = 0; i < fields.length; ++i) { + var field = fields[i].resolve(), + index = mtype._fieldsArray.indexOf(field), + type = field.resolvedType instanceof Enum ? "int32" : field.type, + wireType = types.basic[type]; + ref = "m" + util.safeProp(field.name); + + // Map fields + if (field.map) { + gen + ("if(%s!=null&&m.hasOwnProperty(%j)){", ref, field.name) // !== undefined && !== null + ("for(var ks=Object.keys(%s),i=0;i>> 0, 8 | types.mapKey[field.keyType], field.keyType); + if (wireType === undefined) gen + ("types[%i].encode(%s[ks[i]],w.uint32(18).fork()).ldelim().ldelim()", index, ref); // can't be groups + else gen + (".uint32(%i).%s(%s[ks[i]]).ldelim()", 16 | wireType, type, ref); + gen + ("}") + ("}"); + + // Repeated fields + } else if (field.repeated) { gen + ("if(%s!=null&&%s.length){", ref, ref); // !== undefined && !== null + + // Packed repeated + if (field.packed && types.packed[type] !== undefined) { gen + + ("w.uint32(%i).fork()", (field.id << 3 | 2) >>> 0) + ("for(var i=0;i<%s.length;++i)", ref) + ("w.%s(%s[i])", type, ref) + ("w.ldelim()"); + + // Non-packed + } else { gen + + ("for(var i=0;i<%s.length;++i)", ref); + if (wireType === undefined) + genTypePartial(gen, field, index, ref + "[i]"); + else gen + ("w.uint32(%i).%s(%s[i])", (field.id << 3 | wireType) >>> 0, type, ref); + + } gen + ("}"); + + // Non-repeated + } else { + if (field.optional) gen + ("if(%s!=null&&m.hasOwnProperty(%j))", ref, field.name); // !== undefined && !== null + + if (wireType === undefined) + genTypePartial(gen, field, index, ref); + else gen + ("w.uint32(%i).%s(%s)", (field.id << 3 | wireType) >>> 0, type, ref); + + } + } + + return gen + ("return w"); + /* eslint-enable no-unexpected-multiline, block-scoped-var, no-redeclare */ +} +},{"15":15,"36":36,"37":37}],15:[function(require,module,exports){ +"use strict"; +module.exports = Enum; + +// extends ReflectionObject +var ReflectionObject = require(24); +((Enum.prototype = Object.create(ReflectionObject.prototype)).constructor = Enum).className = "Enum"; + +var Namespace = require(23), + util = require(37); + +/** + * Constructs a new enum instance. + * @classdesc Reflected enum. + * @extends ReflectionObject + * @constructor + * @param {string} name Unique name within its namespace + * @param {Object.} [values] Enum values as an object, by name + * @param {Object.} [options] Declared options + * @param {string} [comment] The comment for this enum + * @param {Object.} [comments] The value comments for this enum + */ +function Enum(name, values, options, comment, comments) { + ReflectionObject.call(this, name, options); + + if (values && typeof values !== "object") + throw TypeError("values must be an object"); + + /** + * Enum values by id. + * @type {Object.} + */ + this.valuesById = {}; + + /** + * Enum values by name. + * @type {Object.} + */ + this.values = Object.create(this.valuesById); // toJSON, marker + + /** + * Enum comment text. + * @type {string|null} + */ + this.comment = comment; + + /** + * Value comment texts, if any. + * @type {Object.} + */ + this.comments = comments || {}; + + /** + * Reserved ranges, if any. + * @type {Array.} + */ + this.reserved = undefined; // toJSON + + // Note that values inherit valuesById on their prototype which makes them a TypeScript- + // compatible enum. This is used by pbts to write actual enum definitions that work for + // static and reflection code alike instead of emitting generic object definitions. + + if (values) + for (var keys = Object.keys(values), i = 0; i < keys.length; ++i) + if (typeof values[keys[i]] === "number") // use forward entries only + this.valuesById[ this.values[keys[i]] = values[keys[i]] ] = keys[i]; +} + +/** + * Enum descriptor. + * @interface IEnum + * @property {Object.} values Enum values + * @property {Object.} [options] Enum options + */ + +/** + * Constructs an enum from an enum descriptor. + * @param {string} name Enum name + * @param {IEnum} json Enum descriptor + * @returns {Enum} Created enum + * @throws {TypeError} If arguments are invalid + */ +Enum.fromJSON = function fromJSON(name, json) { + var enm = new Enum(name, json.values, json.options, json.comment, json.comments); + enm.reserved = json.reserved; + return enm; +}; + +/** + * Converts this enum to an enum descriptor. + * @param {IToJSONOptions} [toJSONOptions] JSON conversion options + * @returns {IEnum} Enum descriptor + */ +Enum.prototype.toJSON = function toJSON(toJSONOptions) { + var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false; + return util.toObject([ + "options" , this.options, + "values" , this.values, + "reserved" , this.reserved && this.reserved.length ? this.reserved : undefined, + "comment" , keepComments ? this.comment : undefined, + "comments" , keepComments ? this.comments : undefined + ]); +}; + +/** + * Adds a value to this enum. + * @param {string} name Value name + * @param {number} id Value id + * @param {string} [comment] Comment, if any + * @returns {Enum} `this` + * @throws {TypeError} If arguments are invalid + * @throws {Error} If there is already a value with this name or id + */ +Enum.prototype.add = function add(name, id, comment) { + // utilized by the parser but not by .fromJSON + + if (!util.isString(name)) + throw TypeError("name must be a string"); + + if (!util.isInteger(id)) + throw TypeError("id must be an integer"); + + if (this.values[name] !== undefined) + throw Error("duplicate name '" + name + "' in " + this); + + if (this.isReservedId(id)) + throw Error("id " + id + " is reserved in " + this); + + if (this.isReservedName(name)) + throw Error("name '" + name + "' is reserved in " + this); + + if (this.valuesById[id] !== undefined) { + if (!(this.options && this.options.allow_alias)) + throw Error("duplicate id " + id + " in " + this); + this.values[name] = id; + } else + this.valuesById[this.values[name] = id] = name; + + this.comments[name] = comment || null; + return this; +}; + +/** + * Removes a value from this enum + * @param {string} name Value name + * @returns {Enum} `this` + * @throws {TypeError} If arguments are invalid + * @throws {Error} If `name` is not a name of this enum + */ +Enum.prototype.remove = function remove(name) { + + if (!util.isString(name)) + throw TypeError("name must be a string"); + + var val = this.values[name]; + if (val == null) + throw Error("name '" + name + "' does not exist in " + this); + + delete this.valuesById[val]; + delete this.values[name]; + delete this.comments[name]; + + return this; +}; + +/** + * Tests if the specified id is reserved. + * @param {number} id Id to test + * @returns {boolean} `true` if reserved, otherwise `false` + */ +Enum.prototype.isReservedId = function isReservedId(id) { + return Namespace.isReservedId(this.reserved, id); +}; + +/** + * Tests if the specified name is reserved. + * @param {string} name Name to test + * @returns {boolean} `true` if reserved, otherwise `false` + */ +Enum.prototype.isReservedName = function isReservedName(name) { + return Namespace.isReservedName(this.reserved, name); +}; + +},{"23":23,"24":24,"37":37}],16:[function(require,module,exports){ +"use strict"; +module.exports = Field; + +// extends ReflectionObject +var ReflectionObject = require(24); +((Field.prototype = Object.create(ReflectionObject.prototype)).constructor = Field).className = "Field"; + +var Enum = require(15), + types = require(36), + util = require(37); + +var Type; // cyclic + +var ruleRe = /^required|optional|repeated$/; + +/** + * Constructs a new message field instance. Note that {@link MapField|map fields} have their own class. + * @name Field + * @classdesc Reflected message field. + * @extends FieldBase + * @constructor + * @param {string} name Unique name within its namespace + * @param {number} id Unique id within its namespace + * @param {string} type Value type + * @param {string|Object.} [rule="optional"] Field rule + * @param {string|Object.} [extend] Extended type if different from parent + * @param {Object.} [options] Declared options + */ + +/** + * Constructs a field from a field descriptor. + * @param {string} name Field name + * @param {IField} json Field descriptor + * @returns {Field} Created field + * @throws {TypeError} If arguments are invalid + */ +Field.fromJSON = function fromJSON(name, json) { + return new Field(name, json.id, json.type, json.rule, json.extend, json.options, json.comment); +}; + +/** + * Not an actual constructor. Use {@link Field} instead. + * @classdesc Base class of all reflected message fields. This is not an actual class but here for the sake of having consistent type definitions. + * @exports FieldBase + * @extends ReflectionObject + * @constructor + * @param {string} name Unique name within its namespace + * @param {number} id Unique id within its namespace + * @param {string} type Value type + * @param {string|Object.} [rule="optional"] Field rule + * @param {string|Object.} [extend] Extended type if different from parent + * @param {Object.} [options] Declared options + * @param {string} [comment] Comment associated with this field + */ +function Field(name, id, type, rule, extend, options, comment) { + + if (util.isObject(rule)) { + comment = extend; + options = rule; + rule = extend = undefined; + } else if (util.isObject(extend)) { + comment = options; + options = extend; + extend = undefined; + } + + ReflectionObject.call(this, name, options); + + if (!util.isInteger(id) || id < 0) + throw TypeError("id must be a non-negative integer"); + + if (!util.isString(type)) + throw TypeError("type must be a string"); + + if (rule !== undefined && !ruleRe.test(rule = rule.toString().toLowerCase())) + throw TypeError("rule must be a string rule"); + + if (extend !== undefined && !util.isString(extend)) + throw TypeError("extend must be a string"); + + /** + * Field rule, if any. + * @type {string|undefined} + */ + this.rule = rule && rule !== "optional" ? rule : undefined; // toJSON + + /** + * Field type. + * @type {string} + */ + this.type = type; // toJSON + + /** + * Unique field id. + * @type {number} + */ + this.id = id; // toJSON, marker + + /** + * Extended type if different from parent. + * @type {string|undefined} + */ + this.extend = extend || undefined; // toJSON + + /** + * Whether this field is required. + * @type {boolean} + */ + this.required = rule === "required"; + + /** + * Whether this field is optional. + * @type {boolean} + */ + this.optional = !this.required; + + /** + * Whether this field is repeated. + * @type {boolean} + */ + this.repeated = rule === "repeated"; + + /** + * Whether this field is a map or not. + * @type {boolean} + */ + this.map = false; + + /** + * Message this field belongs to. + * @type {Type|null} + */ + this.message = null; + + /** + * OneOf this field belongs to, if any, + * @type {OneOf|null} + */ + this.partOf = null; + + /** + * The field type's default value. + * @type {*} + */ + this.typeDefault = null; + + /** + * The field's default value on prototypes. + * @type {*} + */ + this.defaultValue = null; + + /** + * Whether this field's value should be treated as a long. + * @type {boolean} + */ + this.long = util.Long ? types.long[type] !== undefined : /* istanbul ignore next */ false; + + /** + * Whether this field's value is a buffer. + * @type {boolean} + */ + this.bytes = type === "bytes"; + + /** + * Resolved type if not a basic type. + * @type {Type|Enum|null} + */ + this.resolvedType = null; + + /** + * Sister-field within the extended type if a declaring extension field. + * @type {Field|null} + */ + this.extensionField = null; + + /** + * Sister-field within the declaring namespace if an extended field. + * @type {Field|null} + */ + this.declaringField = null; + + /** + * Internally remembers whether this field is packed. + * @type {boolean|null} + * @private + */ + this._packed = null; + + /** + * Comment for this field. + * @type {string|null} + */ + this.comment = comment; +} + +/** + * Determines whether this field is packed. Only relevant when repeated and working with proto2. + * @name Field#packed + * @type {boolean} + * @readonly + */ +Object.defineProperty(Field.prototype, "packed", { + get: function() { + // defaults to packed=true if not explicity set to false + if (this._packed === null) + this._packed = this.getOption("packed") !== false; + return this._packed; + } +}); + +/** + * @override + */ +Field.prototype.setOption = function setOption(name, value, ifNotSet) { + if (name === "packed") // clear cached before setting + this._packed = null; + return ReflectionObject.prototype.setOption.call(this, name, value, ifNotSet); +}; + +/** + * Field descriptor. + * @interface IField + * @property {string} [rule="optional"] Field rule + * @property {string} type Field type + * @property {number} id Field id + * @property {Object.} [options] Field options + */ + +/** + * Extension field descriptor. + * @interface IExtensionField + * @extends IField + * @property {string} extend Extended type + */ + +/** + * Converts this field to a field descriptor. + * @param {IToJSONOptions} [toJSONOptions] JSON conversion options + * @returns {IField} Field descriptor + */ +Field.prototype.toJSON = function toJSON(toJSONOptions) { + var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false; + return util.toObject([ + "rule" , this.rule !== "optional" && this.rule || undefined, + "type" , this.type, + "id" , this.id, + "extend" , this.extend, + "options" , this.options, + "comment" , keepComments ? this.comment : undefined + ]); +}; + +/** + * Resolves this field's type references. + * @returns {Field} `this` + * @throws {Error} If any reference cannot be resolved + */ +Field.prototype.resolve = function resolve() { + + if (this.resolved) + return this; + + if ((this.typeDefault = types.defaults[this.type]) === undefined) { // if not a basic type, resolve it + this.resolvedType = (this.declaringField ? this.declaringField.parent : this.parent).lookupTypeOrEnum(this.type); + if (this.resolvedType instanceof Type) + this.typeDefault = null; + else // instanceof Enum + this.typeDefault = this.resolvedType.values[Object.keys(this.resolvedType.values)[0]]; // first defined + } + + // use explicitly set default value if present + if (this.options && this.options["default"] != null) { + this.typeDefault = this.options["default"]; + if (this.resolvedType instanceof Enum && typeof this.typeDefault === "string") + this.typeDefault = this.resolvedType.values[this.typeDefault]; + } + + // remove unnecessary options + if (this.options) { + if (this.options.packed === true || this.options.packed !== undefined && this.resolvedType && !(this.resolvedType instanceof Enum)) + delete this.options.packed; + if (!Object.keys(this.options).length) + this.options = undefined; + } + + // convert to internal data type if necesssary + if (this.long) { + this.typeDefault = util.Long.fromNumber(this.typeDefault, this.type.charAt(0) === "u"); + + /* istanbul ignore else */ + if (Object.freeze) + Object.freeze(this.typeDefault); // long instances are meant to be immutable anyway (i.e. use small int cache that even requires it) + + } else if (this.bytes && typeof this.typeDefault === "string") { + var buf; + if (util.base64.test(this.typeDefault)) + util.base64.decode(this.typeDefault, buf = util.newBuffer(util.base64.length(this.typeDefault)), 0); + else + util.utf8.write(this.typeDefault, buf = util.newBuffer(util.utf8.length(this.typeDefault)), 0); + this.typeDefault = buf; + } + + // take special care of maps and repeated fields + if (this.map) + this.defaultValue = util.emptyObject; + else if (this.repeated) + this.defaultValue = util.emptyArray; + else + this.defaultValue = this.typeDefault; + + // ensure proper value on prototype + if (this.parent instanceof Type) + this.parent.ctor.prototype[this.name] = this.defaultValue; + + return ReflectionObject.prototype.resolve.call(this); +}; + +/** + * Decorator function as returned by {@link Field.d} and {@link MapField.d} (TypeScript). + * @typedef FieldDecorator + * @type {function} + * @param {Object} prototype Target prototype + * @param {string} fieldName Field name + * @returns {undefined} + */ + +/** + * Field decorator (TypeScript). + * @name Field.d + * @function + * @param {number} fieldId Field id + * @param {"double"|"float"|"int32"|"uint32"|"sint32"|"fixed32"|"sfixed32"|"int64"|"uint64"|"sint64"|"fixed64"|"sfixed64"|"string"|"bool"|"bytes"|Object} fieldType Field type + * @param {"optional"|"required"|"repeated"} [fieldRule="optional"] Field rule + * @param {T} [defaultValue] Default value + * @returns {FieldDecorator} Decorator function + * @template T extends number | number[] | Long | Long[] | string | string[] | boolean | boolean[] | Uint8Array | Uint8Array[] | Buffer | Buffer[] + */ +Field.d = function decorateField(fieldId, fieldType, fieldRule, defaultValue) { + + // submessage: decorate the submessage and use its name as the type + if (typeof fieldType === "function") + fieldType = util.decorateType(fieldType).name; + + // enum reference: create a reflected copy of the enum and keep reuseing it + else if (fieldType && typeof fieldType === "object") + fieldType = util.decorateEnum(fieldType).name; + + return function fieldDecorator(prototype, fieldName) { + util.decorateType(prototype.constructor) + .add(new Field(fieldName, fieldId, fieldType, fieldRule, { "default": defaultValue })); + }; +}; + +/** + * Field decorator (TypeScript). + * @name Field.d + * @function + * @param {number} fieldId Field id + * @param {Constructor|string} fieldType Field type + * @param {"optional"|"required"|"repeated"} [fieldRule="optional"] Field rule + * @returns {FieldDecorator} Decorator function + * @template T extends Message + * @variation 2 + */ +// like Field.d but without a default value + +// Sets up cyclic dependencies (called in index-light) +Field._configure = function configure(Type_) { + Type = Type_; +}; + +},{"15":15,"24":24,"36":36,"37":37}],17:[function(require,module,exports){ +"use strict"; +var protobuf = module.exports = require(18); + +protobuf.build = "light"; + +/** + * A node-style callback as used by {@link load} and {@link Root#load}. + * @typedef LoadCallback + * @type {function} + * @param {Error|null} error Error, if any, otherwise `null` + * @param {Root} [root] Root, if there hasn't been an error + * @returns {undefined} + */ + +/** + * Loads one or multiple .proto or preprocessed .json files into a common root namespace and calls the callback. + * @param {string|string[]} filename One or multiple files to load + * @param {Root} root Root namespace, defaults to create a new one if omitted. + * @param {LoadCallback} callback Callback function + * @returns {undefined} + * @see {@link Root#load} + */ +function load(filename, root, callback) { + if (typeof root === "function") { + callback = root; + root = new protobuf.Root(); + } else if (!root) + root = new protobuf.Root(); + return root.load(filename, callback); +} + +/** + * Loads one or multiple .proto or preprocessed .json files into a common root namespace and calls the callback. + * @name load + * @function + * @param {string|string[]} filename One or multiple files to load + * @param {LoadCallback} callback Callback function + * @returns {undefined} + * @see {@link Root#load} + * @variation 2 + */ +// function load(filename:string, callback:LoadCallback):undefined + +/** + * Loads one or multiple .proto or preprocessed .json files into a common root namespace and returns a promise. + * @name load + * @function + * @param {string|string[]} filename One or multiple files to load + * @param {Root} [root] Root namespace, defaults to create a new one if omitted. + * @returns {Promise} Promise + * @see {@link Root#load} + * @variation 3 + */ +// function load(filename:string, [root:Root]):Promise + +protobuf.load = load; + +/** + * Synchronously loads one or multiple .proto or preprocessed .json files into a common root namespace (node only). + * @param {string|string[]} filename One or multiple files to load + * @param {Root} [root] Root namespace, defaults to create a new one if omitted. + * @returns {Root} Root namespace + * @throws {Error} If synchronous fetching is not supported (i.e. in browsers) or if a file's syntax is invalid + * @see {@link Root#loadSync} + */ +function loadSync(filename, root) { + if (!root) + root = new protobuf.Root(); + return root.loadSync(filename); +} + +protobuf.loadSync = loadSync; + +// Serialization +protobuf.encoder = require(14); +protobuf.decoder = require(13); +protobuf.verifier = require(40); +protobuf.converter = require(12); + +// Reflection +protobuf.ReflectionObject = require(24); +protobuf.Namespace = require(23); +protobuf.Root = require(29); +protobuf.Enum = require(15); +protobuf.Type = require(35); +protobuf.Field = require(16); +protobuf.OneOf = require(25); +protobuf.MapField = require(20); +protobuf.Service = require(33); +protobuf.Method = require(22); + +// Runtime +protobuf.Message = require(21); +protobuf.wrappers = require(41); + +// Utility +protobuf.types = require(36); +protobuf.util = require(37); + +// Set up possibly cyclic reflection dependencies +protobuf.ReflectionObject._configure(protobuf.Root); +protobuf.Namespace._configure(protobuf.Type, protobuf.Service, protobuf.Enum); +protobuf.Root._configure(protobuf.Type); +protobuf.Field._configure(protobuf.Type); + +},{"12":12,"13":13,"14":14,"15":15,"16":16,"18":18,"20":20,"21":21,"22":22,"23":23,"24":24,"25":25,"29":29,"33":33,"35":35,"36":36,"37":37,"40":40,"41":41}],18:[function(require,module,exports){ +"use strict"; +var protobuf = exports; + +/** + * Build type, one of `"full"`, `"light"` or `"minimal"`. + * @name build + * @type {string} + * @const + */ +protobuf.build = "minimal"; + +// Serialization +protobuf.Writer = require(42); +protobuf.BufferWriter = require(43); +protobuf.Reader = require(27); +protobuf.BufferReader = require(28); + +// Utility +protobuf.util = require(39); +protobuf.rpc = require(31); +protobuf.roots = require(30); +protobuf.configure = configure; + +/* istanbul ignore next */ +/** + * Reconfigures the library according to the environment. + * @returns {undefined} + */ +function configure() { + protobuf.Reader._configure(protobuf.BufferReader); + protobuf.util._configure(); +} + +// Set up buffer utility according to the environment +protobuf.Writer._configure(protobuf.BufferWriter); +configure(); + +},{"27":27,"28":28,"30":30,"31":31,"39":39,"42":42,"43":43}],19:[function(require,module,exports){ +"use strict"; +var protobuf = module.exports = require(17); + +protobuf.build = "full"; + +// Parser +protobuf.tokenize = require(34); +protobuf.parse = require(26); +protobuf.common = require(11); + +// Configure parser +protobuf.Root._configure(protobuf.Type, protobuf.parse, protobuf.common); + +},{"11":11,"17":17,"26":26,"34":34}],20:[function(require,module,exports){ +"use strict"; +module.exports = MapField; + +// extends Field +var Field = require(16); +((MapField.prototype = Object.create(Field.prototype)).constructor = MapField).className = "MapField"; + +var types = require(36), + util = require(37); + +/** + * Constructs a new map field instance. + * @classdesc Reflected map field. + * @extends FieldBase + * @constructor + * @param {string} name Unique name within its namespace + * @param {number} id Unique id within its namespace + * @param {string} keyType Key type + * @param {string} type Value type + * @param {Object.} [options] Declared options + * @param {string} [comment] Comment associated with this field + */ +function MapField(name, id, keyType, type, options, comment) { + Field.call(this, name, id, type, undefined, undefined, options, comment); + + /* istanbul ignore if */ + if (!util.isString(keyType)) + throw TypeError("keyType must be a string"); + + /** + * Key type. + * @type {string} + */ + this.keyType = keyType; // toJSON, marker + + /** + * Resolved key type if not a basic type. + * @type {ReflectionObject|null} + */ + this.resolvedKeyType = null; + + // Overrides Field#map + this.map = true; +} + +/** + * Map field descriptor. + * @interface IMapField + * @extends {IField} + * @property {string} keyType Key type + */ + +/** + * Extension map field descriptor. + * @interface IExtensionMapField + * @extends IMapField + * @property {string} extend Extended type + */ + +/** + * Constructs a map field from a map field descriptor. + * @param {string} name Field name + * @param {IMapField} json Map field descriptor + * @returns {MapField} Created map field + * @throws {TypeError} If arguments are invalid + */ +MapField.fromJSON = function fromJSON(name, json) { + return new MapField(name, json.id, json.keyType, json.type, json.options, json.comment); +}; + +/** + * Converts this map field to a map field descriptor. + * @param {IToJSONOptions} [toJSONOptions] JSON conversion options + * @returns {IMapField} Map field descriptor + */ +MapField.prototype.toJSON = function toJSON(toJSONOptions) { + var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false; + return util.toObject([ + "keyType" , this.keyType, + "type" , this.type, + "id" , this.id, + "extend" , this.extend, + "options" , this.options, + "comment" , keepComments ? this.comment : undefined + ]); +}; + +/** + * @override + */ +MapField.prototype.resolve = function resolve() { + if (this.resolved) + return this; + + // Besides a value type, map fields have a key type that may be "any scalar type except for floating point types and bytes" + if (types.mapKey[this.keyType] === undefined) + throw Error("invalid key type: " + this.keyType); + + return Field.prototype.resolve.call(this); +}; + +/** + * Map field decorator (TypeScript). + * @name MapField.d + * @function + * @param {number} fieldId Field id + * @param {"int32"|"uint32"|"sint32"|"fixed32"|"sfixed32"|"int64"|"uint64"|"sint64"|"fixed64"|"sfixed64"|"bool"|"string"} fieldKeyType Field key type + * @param {"double"|"float"|"int32"|"uint32"|"sint32"|"fixed32"|"sfixed32"|"int64"|"uint64"|"sint64"|"fixed64"|"sfixed64"|"bool"|"string"|"bytes"|Object|Constructor<{}>} fieldValueType Field value type + * @returns {FieldDecorator} Decorator function + * @template T extends { [key: string]: number | Long | string | boolean | Uint8Array | Buffer | number[] | Message<{}> } + */ +MapField.d = function decorateMapField(fieldId, fieldKeyType, fieldValueType) { + + // submessage value: decorate the submessage and use its name as the type + if (typeof fieldValueType === "function") + fieldValueType = util.decorateType(fieldValueType).name; + + // enum reference value: create a reflected copy of the enum and keep reuseing it + else if (fieldValueType && typeof fieldValueType === "object") + fieldValueType = util.decorateEnum(fieldValueType).name; + + return function mapFieldDecorator(prototype, fieldName) { + util.decorateType(prototype.constructor) + .add(new MapField(fieldName, fieldId, fieldKeyType, fieldValueType)); + }; +}; + +},{"16":16,"36":36,"37":37}],21:[function(require,module,exports){ +"use strict"; +module.exports = Message; + +var util = require(39); + +/** + * Constructs a new message instance. + * @classdesc Abstract runtime message. + * @constructor + * @param {Properties} [properties] Properties to set + * @template T extends object = object + */ +function Message(properties) { + // not used internally + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + this[keys[i]] = properties[keys[i]]; +} + +/** + * Reference to the reflected type. + * @name Message.$type + * @type {Type} + * @readonly + */ + +/** + * Reference to the reflected type. + * @name Message#$type + * @type {Type} + * @readonly + */ + +/*eslint-disable valid-jsdoc*/ + +/** + * Creates a new message of this type using the specified properties. + * @param {Object.} [properties] Properties to set + * @returns {Message} Message instance + * @template T extends Message + * @this Constructor + */ +Message.create = function create(properties) { + return this.$type.create(properties); +}; + +/** + * Encodes a message of this type. + * @param {T|Object.} message Message to encode + * @param {Writer} [writer] Writer to use + * @returns {Writer} Writer + * @template T extends Message + * @this Constructor + */ +Message.encode = function encode(message, writer) { + return this.$type.encode(message, writer); +}; + +/** + * Encodes a message of this type preceeded by its length as a varint. + * @param {T|Object.} message Message to encode + * @param {Writer} [writer] Writer to use + * @returns {Writer} Writer + * @template T extends Message + * @this Constructor + */ +Message.encodeDelimited = function encodeDelimited(message, writer) { + return this.$type.encodeDelimited(message, writer); +}; + +/** + * Decodes a message of this type. + * @name Message.decode + * @function + * @param {Reader|Uint8Array} reader Reader or buffer to decode + * @returns {T} Decoded message + * @template T extends Message + * @this Constructor + */ +Message.decode = function decode(reader) { + return this.$type.decode(reader); +}; + +/** + * Decodes a message of this type preceeded by its length as a varint. + * @name Message.decodeDelimited + * @function + * @param {Reader|Uint8Array} reader Reader or buffer to decode + * @returns {T} Decoded message + * @template T extends Message + * @this Constructor + */ +Message.decodeDelimited = function decodeDelimited(reader) { + return this.$type.decodeDelimited(reader); +}; + +/** + * Verifies a message of this type. + * @name Message.verify + * @function + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ +Message.verify = function verify(message) { + return this.$type.verify(message); +}; + +/** + * Creates a new message of this type from a plain object. Also converts values to their respective internal types. + * @param {Object.} object Plain object + * @returns {T} Message instance + * @template T extends Message + * @this Constructor + */ +Message.fromObject = function fromObject(object) { + return this.$type.fromObject(object); +}; + +/** + * Creates a plain object from a message of this type. Also converts values to other types if specified. + * @param {T} message Message instance + * @param {IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + * @template T extends Message + * @this Constructor + */ +Message.toObject = function toObject(message, options) { + return this.$type.toObject(message, options); +}; + +/** + * Converts this message to JSON. + * @returns {Object.} JSON object + */ +Message.prototype.toJSON = function toJSON() { + return this.$type.toObject(this, util.toJSONOptions); +}; + +/*eslint-enable valid-jsdoc*/ +},{"39":39}],22:[function(require,module,exports){ +"use strict"; +module.exports = Method; + +// extends ReflectionObject +var ReflectionObject = require(24); +((Method.prototype = Object.create(ReflectionObject.prototype)).constructor = Method).className = "Method"; + +var util = require(37); + +/** + * Constructs a new service method instance. + * @classdesc Reflected service method. + * @extends ReflectionObject + * @constructor + * @param {string} name Method name + * @param {string|undefined} type Method type, usually `"rpc"` + * @param {string} requestType Request message type + * @param {string} responseType Response message type + * @param {boolean|Object.} [requestStream] Whether the request is streamed + * @param {boolean|Object.} [responseStream] Whether the response is streamed + * @param {Object.} [options] Declared options + * @param {string} [comment] The comment for this method + */ +function Method(name, type, requestType, responseType, requestStream, responseStream, options, comment) { + + /* istanbul ignore next */ + if (util.isObject(requestStream)) { + options = requestStream; + requestStream = responseStream = undefined; + } else if (util.isObject(responseStream)) { + options = responseStream; + responseStream = undefined; + } + + /* istanbul ignore if */ + if (!(type === undefined || util.isString(type))) + throw TypeError("type must be a string"); + + /* istanbul ignore if */ + if (!util.isString(requestType)) + throw TypeError("requestType must be a string"); + + /* istanbul ignore if */ + if (!util.isString(responseType)) + throw TypeError("responseType must be a string"); + + ReflectionObject.call(this, name, options); + + /** + * Method type. + * @type {string} + */ + this.type = type || "rpc"; // toJSON + + /** + * Request type. + * @type {string} + */ + this.requestType = requestType; // toJSON, marker + + /** + * Whether requests are streamed or not. + * @type {boolean|undefined} + */ + this.requestStream = requestStream ? true : undefined; // toJSON + + /** + * Response type. + * @type {string} + */ + this.responseType = responseType; // toJSON + + /** + * Whether responses are streamed or not. + * @type {boolean|undefined} + */ + this.responseStream = responseStream ? true : undefined; // toJSON + + /** + * Resolved request type. + * @type {Type|null} + */ + this.resolvedRequestType = null; + + /** + * Resolved response type. + * @type {Type|null} + */ + this.resolvedResponseType = null; + + /** + * Comment for this method + * @type {string|null} + */ + this.comment = comment; +} + +/** + * Method descriptor. + * @interface IMethod + * @property {string} [type="rpc"] Method type + * @property {string} requestType Request type + * @property {string} responseType Response type + * @property {boolean} [requestStream=false] Whether requests are streamed + * @property {boolean} [responseStream=false] Whether responses are streamed + * @property {Object.} [options] Method options + */ + +/** + * Constructs a method from a method descriptor. + * @param {string} name Method name + * @param {IMethod} json Method descriptor + * @returns {Method} Created method + * @throws {TypeError} If arguments are invalid + */ +Method.fromJSON = function fromJSON(name, json) { + return new Method(name, json.type, json.requestType, json.responseType, json.requestStream, json.responseStream, json.options, json.comment); +}; + +/** + * Converts this method to a method descriptor. + * @param {IToJSONOptions} [toJSONOptions] JSON conversion options + * @returns {IMethod} Method descriptor + */ +Method.prototype.toJSON = function toJSON(toJSONOptions) { + var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false; + return util.toObject([ + "type" , this.type !== "rpc" && /* istanbul ignore next */ this.type || undefined, + "requestType" , this.requestType, + "requestStream" , this.requestStream, + "responseType" , this.responseType, + "responseStream" , this.responseStream, + "options" , this.options, + "comment" , keepComments ? this.comment : undefined + ]); +}; + +/** + * @override + */ +Method.prototype.resolve = function resolve() { + + /* istanbul ignore if */ + if (this.resolved) + return this; + + this.resolvedRequestType = this.parent.lookupType(this.requestType); + this.resolvedResponseType = this.parent.lookupType(this.responseType); + + return ReflectionObject.prototype.resolve.call(this); +}; + +},{"24":24,"37":37}],23:[function(require,module,exports){ +"use strict"; +module.exports = Namespace; + +// extends ReflectionObject +var ReflectionObject = require(24); +((Namespace.prototype = Object.create(ReflectionObject.prototype)).constructor = Namespace).className = "Namespace"; + +var Field = require(16), + util = require(37); + +var Type, // cyclic + Service, + Enum; + +/** + * Constructs a new namespace instance. + * @name Namespace + * @classdesc Reflected namespace. + * @extends NamespaceBase + * @constructor + * @param {string} name Namespace name + * @param {Object.} [options] Declared options + */ + +/** + * Constructs a namespace from JSON. + * @memberof Namespace + * @function + * @param {string} name Namespace name + * @param {Object.} json JSON object + * @returns {Namespace} Created namespace + * @throws {TypeError} If arguments are invalid + */ +Namespace.fromJSON = function fromJSON(name, json) { + return new Namespace(name, json.options).addJSON(json.nested); +}; + +/** + * Converts an array of reflection objects to JSON. + * @memberof Namespace + * @param {ReflectionObject[]} array Object array + * @param {IToJSONOptions} [toJSONOptions] JSON conversion options + * @returns {Object.|undefined} JSON object or `undefined` when array is empty + */ +function arrayToJSON(array, toJSONOptions) { + if (!(array && array.length)) + return undefined; + var obj = {}; + for (var i = 0; i < array.length; ++i) + obj[array[i].name] = array[i].toJSON(toJSONOptions); + return obj; +} + +Namespace.arrayToJSON = arrayToJSON; + +/** + * Tests if the specified id is reserved. + * @param {Array.|undefined} reserved Array of reserved ranges and names + * @param {number} id Id to test + * @returns {boolean} `true` if reserved, otherwise `false` + */ +Namespace.isReservedId = function isReservedId(reserved, id) { + if (reserved) + for (var i = 0; i < reserved.length; ++i) + if (typeof reserved[i] !== "string" && reserved[i][0] <= id && reserved[i][1] >= id) + return true; + return false; +}; + +/** + * Tests if the specified name is reserved. + * @param {Array.|undefined} reserved Array of reserved ranges and names + * @param {string} name Name to test + * @returns {boolean} `true` if reserved, otherwise `false` + */ +Namespace.isReservedName = function isReservedName(reserved, name) { + if (reserved) + for (var i = 0; i < reserved.length; ++i) + if (reserved[i] === name) + return true; + return false; +}; + +/** + * Not an actual constructor. Use {@link Namespace} instead. + * @classdesc Base class of all reflection objects containing nested objects. This is not an actual class but here for the sake of having consistent type definitions. + * @exports NamespaceBase + * @extends ReflectionObject + * @abstract + * @constructor + * @param {string} name Namespace name + * @param {Object.} [options] Declared options + * @see {@link Namespace} + */ +function Namespace(name, options) { + ReflectionObject.call(this, name, options); + + /** + * Nested objects by name. + * @type {Object.|undefined} + */ + this.nested = undefined; // toJSON + + /** + * Cached nested objects as an array. + * @type {ReflectionObject[]|null} + * @private + */ + this._nestedArray = null; +} + +function clearCache(namespace) { + namespace._nestedArray = null; + return namespace; +} + +/** + * Nested objects of this namespace as an array for iteration. + * @name NamespaceBase#nestedArray + * @type {ReflectionObject[]} + * @readonly + */ +Object.defineProperty(Namespace.prototype, "nestedArray", { + get: function() { + return this._nestedArray || (this._nestedArray = util.toArray(this.nested)); + } +}); + +/** + * Namespace descriptor. + * @interface INamespace + * @property {Object.} [options] Namespace options + * @property {Object.} [nested] Nested object descriptors + */ + +/** + * Any extension field descriptor. + * @typedef AnyExtensionField + * @type {IExtensionField|IExtensionMapField} + */ + +/** + * Any nested object descriptor. + * @typedef AnyNestedObject + * @type {IEnum|IType|IService|AnyExtensionField|INamespace} + */ +// ^ BEWARE: VSCode hangs forever when using more than 5 types (that's why AnyExtensionField exists in the first place) + +/** + * Converts this namespace to a namespace descriptor. + * @param {IToJSONOptions} [toJSONOptions] JSON conversion options + * @returns {INamespace} Namespace descriptor + */ +Namespace.prototype.toJSON = function toJSON(toJSONOptions) { + return util.toObject([ + "options" , this.options, + "nested" , arrayToJSON(this.nestedArray, toJSONOptions) + ]); +}; + +/** + * Adds nested objects to this namespace from nested object descriptors. + * @param {Object.} nestedJson Any nested object descriptors + * @returns {Namespace} `this` + */ +Namespace.prototype.addJSON = function addJSON(nestedJson) { + var ns = this; + /* istanbul ignore else */ + if (nestedJson) { + for (var names = Object.keys(nestedJson), i = 0, nested; i < names.length; ++i) { + nested = nestedJson[names[i]]; + ns.add( // most to least likely + ( nested.fields !== undefined + ? Type.fromJSON + : nested.values !== undefined + ? Enum.fromJSON + : nested.methods !== undefined + ? Service.fromJSON + : nested.id !== undefined + ? Field.fromJSON + : Namespace.fromJSON )(names[i], nested) + ); + } + } + return this; +}; + +/** + * Gets the nested object of the specified name. + * @param {string} name Nested object name + * @returns {ReflectionObject|null} The reflection object or `null` if it doesn't exist + */ +Namespace.prototype.get = function get(name) { + return this.nested && this.nested[name] + || null; +}; + +/** + * Gets the values of the nested {@link Enum|enum} of the specified name. + * This methods differs from {@link Namespace#get|get} in that it returns an enum's values directly and throws instead of returning `null`. + * @param {string} name Nested enum name + * @returns {Object.} Enum values + * @throws {Error} If there is no such enum + */ +Namespace.prototype.getEnum = function getEnum(name) { + if (this.nested && this.nested[name] instanceof Enum) + return this.nested[name].values; + throw Error("no such enum: " + name); +}; + +/** + * Adds a nested object to this namespace. + * @param {ReflectionObject} object Nested object to add + * @returns {Namespace} `this` + * @throws {TypeError} If arguments are invalid + * @throws {Error} If there is already a nested object with this name + */ +Namespace.prototype.add = function add(object) { + + if (!(object instanceof Field && object.extend !== undefined || object instanceof Type || object instanceof Enum || object instanceof Service || object instanceof Namespace)) + throw TypeError("object must be a valid nested object"); + + if (!this.nested) + this.nested = {}; + else { + var prev = this.get(object.name); + if (prev) { + if (prev instanceof Namespace && object instanceof Namespace && !(prev instanceof Type || prev instanceof Service)) { + // replace plain namespace but keep existing nested elements and options + var nested = prev.nestedArray; + for (var i = 0; i < nested.length; ++i) + object.add(nested[i]); + this.remove(prev); + if (!this.nested) + this.nested = {}; + object.setOptions(prev.options, true); + + } else + throw Error("duplicate name '" + object.name + "' in " + this); + } + } + this.nested[object.name] = object; + object.onAdd(this); + return clearCache(this); +}; + +/** + * Removes a nested object from this namespace. + * @param {ReflectionObject} object Nested object to remove + * @returns {Namespace} `this` + * @throws {TypeError} If arguments are invalid + * @throws {Error} If `object` is not a member of this namespace + */ +Namespace.prototype.remove = function remove(object) { + + if (!(object instanceof ReflectionObject)) + throw TypeError("object must be a ReflectionObject"); + if (object.parent !== this) + throw Error(object + " is not a member of " + this); + + delete this.nested[object.name]; + if (!Object.keys(this.nested).length) + this.nested = undefined; + + object.onRemove(this); + return clearCache(this); +}; + +/** + * Defines additial namespaces within this one if not yet existing. + * @param {string|string[]} path Path to create + * @param {*} [json] Nested types to create from JSON + * @returns {Namespace} Pointer to the last namespace created or `this` if path is empty + */ +Namespace.prototype.define = function define(path, json) { + + if (util.isString(path)) + path = path.split("."); + else if (!Array.isArray(path)) + throw TypeError("illegal path"); + if (path && path.length && path[0] === "") + throw Error("path must be relative"); + + var ptr = this; + while (path.length > 0) { + var part = path.shift(); + if (ptr.nested && ptr.nested[part]) { + ptr = ptr.nested[part]; + if (!(ptr instanceof Namespace)) + throw Error("path conflicts with non-namespace objects"); + } else + ptr.add(ptr = new Namespace(part)); + } + if (json) + ptr.addJSON(json); + return ptr; +}; + +/** + * Resolves this namespace's and all its nested objects' type references. Useful to validate a reflection tree, but comes at a cost. + * @returns {Namespace} `this` + */ +Namespace.prototype.resolveAll = function resolveAll() { + var nested = this.nestedArray, i = 0; + while (i < nested.length) + if (nested[i] instanceof Namespace) + nested[i++].resolveAll(); + else + nested[i++].resolve(); + return this.resolve(); +}; + +/** + * Recursively looks up the reflection object matching the specified path in the scope of this namespace. + * @param {string|string[]} path Path to look up + * @param {*|Array.<*>} filterTypes Filter types, any combination of the constructors of `protobuf.Type`, `protobuf.Enum`, `protobuf.Service` etc. + * @param {boolean} [parentAlreadyChecked=false] If known, whether the parent has already been checked + * @returns {ReflectionObject|null} Looked up object or `null` if none could be found + */ +Namespace.prototype.lookup = function lookup(path, filterTypes, parentAlreadyChecked) { + + /* istanbul ignore next */ + if (typeof filterTypes === "boolean") { + parentAlreadyChecked = filterTypes; + filterTypes = undefined; + } else if (filterTypes && !Array.isArray(filterTypes)) + filterTypes = [ filterTypes ]; + + if (util.isString(path) && path.length) { + if (path === ".") + return this.root; + path = path.split("."); + } else if (!path.length) + return this; + + // Start at root if path is absolute + if (path[0] === "") + return this.root.lookup(path.slice(1), filterTypes); + + // Test if the first part matches any nested object, and if so, traverse if path contains more + var found = this.get(path[0]); + if (found) { + if (path.length === 1) { + if (!filterTypes || filterTypes.indexOf(found.constructor) > -1) + return found; + } else if (found instanceof Namespace && (found = found.lookup(path.slice(1), filterTypes, true))) + return found; + + // Otherwise try each nested namespace + } else + for (var i = 0; i < this.nestedArray.length; ++i) + if (this._nestedArray[i] instanceof Namespace && (found = this._nestedArray[i].lookup(path, filterTypes, true))) + return found; + + // If there hasn't been a match, try again at the parent + if (this.parent === null || parentAlreadyChecked) + return null; + return this.parent.lookup(path, filterTypes); +}; + +/** + * Looks up the reflection object at the specified path, relative to this namespace. + * @name NamespaceBase#lookup + * @function + * @param {string|string[]} path Path to look up + * @param {boolean} [parentAlreadyChecked=false] Whether the parent has already been checked + * @returns {ReflectionObject|null} Looked up object or `null` if none could be found + * @variation 2 + */ +// lookup(path: string, [parentAlreadyChecked: boolean]) + +/** + * Looks up the {@link Type|type} at the specified path, relative to this namespace. + * Besides its signature, this methods differs from {@link Namespace#lookup|lookup} in that it throws instead of returning `null`. + * @param {string|string[]} path Path to look up + * @returns {Type} Looked up type + * @throws {Error} If `path` does not point to a type + */ +Namespace.prototype.lookupType = function lookupType(path) { + var found = this.lookup(path, [ Type ]); + if (!found) + throw Error("no such type: " + path); + return found; +}; + +/** + * Looks up the values of the {@link Enum|enum} at the specified path, relative to this namespace. + * Besides its signature, this methods differs from {@link Namespace#lookup|lookup} in that it throws instead of returning `null`. + * @param {string|string[]} path Path to look up + * @returns {Enum} Looked up enum + * @throws {Error} If `path` does not point to an enum + */ +Namespace.prototype.lookupEnum = function lookupEnum(path) { + var found = this.lookup(path, [ Enum ]); + if (!found) + throw Error("no such Enum '" + path + "' in " + this); + return found; +}; + +/** + * Looks up the {@link Type|type} or {@link Enum|enum} at the specified path, relative to this namespace. + * Besides its signature, this methods differs from {@link Namespace#lookup|lookup} in that it throws instead of returning `null`. + * @param {string|string[]} path Path to look up + * @returns {Type} Looked up type or enum + * @throws {Error} If `path` does not point to a type or enum + */ +Namespace.prototype.lookupTypeOrEnum = function lookupTypeOrEnum(path) { + var found = this.lookup(path, [ Type, Enum ]); + if (!found) + throw Error("no such Type or Enum '" + path + "' in " + this); + return found; +}; + +/** + * Looks up the {@link Service|service} at the specified path, relative to this namespace. + * Besides its signature, this methods differs from {@link Namespace#lookup|lookup} in that it throws instead of returning `null`. + * @param {string|string[]} path Path to look up + * @returns {Service} Looked up service + * @throws {Error} If `path` does not point to a service + */ +Namespace.prototype.lookupService = function lookupService(path) { + var found = this.lookup(path, [ Service ]); + if (!found) + throw Error("no such Service '" + path + "' in " + this); + return found; +}; + +// Sets up cyclic dependencies (called in index-light) +Namespace._configure = function(Type_, Service_, Enum_) { + Type = Type_; + Service = Service_; + Enum = Enum_; +}; + +},{"16":16,"24":24,"37":37}],24:[function(require,module,exports){ +"use strict"; +module.exports = ReflectionObject; + +ReflectionObject.className = "ReflectionObject"; + +var util = require(37); + +var Root; // cyclic + +/** + * Constructs a new reflection object instance. + * @classdesc Base class of all reflection objects. + * @constructor + * @param {string} name Object name + * @param {Object.} [options] Declared options + * @abstract + */ +function ReflectionObject(name, options) { + + if (!util.isString(name)) + throw TypeError("name must be a string"); + + if (options && !util.isObject(options)) + throw TypeError("options must be an object"); + + /** + * Options. + * @type {Object.|undefined} + */ + this.options = options; // toJSON + + /** + * Unique name within its namespace. + * @type {string} + */ + this.name = name; + + /** + * Parent namespace. + * @type {Namespace|null} + */ + this.parent = null; + + /** + * Whether already resolved or not. + * @type {boolean} + */ + this.resolved = false; + + /** + * Comment text, if any. + * @type {string|null} + */ + this.comment = null; + + /** + * Defining file name. + * @type {string|null} + */ + this.filename = null; +} + +Object.defineProperties(ReflectionObject.prototype, { + + /** + * Reference to the root namespace. + * @name ReflectionObject#root + * @type {Root} + * @readonly + */ + root: { + get: function() { + var ptr = this; + while (ptr.parent !== null) + ptr = ptr.parent; + return ptr; + } + }, + + /** + * Full name including leading dot. + * @name ReflectionObject#fullName + * @type {string} + * @readonly + */ + fullName: { + get: function() { + var path = [ this.name ], + ptr = this.parent; + while (ptr) { + path.unshift(ptr.name); + ptr = ptr.parent; + } + return path.join("."); + } + } +}); + +/** + * Converts this reflection object to its descriptor representation. + * @returns {Object.} Descriptor + * @abstract + */ +ReflectionObject.prototype.toJSON = /* istanbul ignore next */ function toJSON() { + throw Error(); // not implemented, shouldn't happen +}; + +/** + * Called when this object is added to a parent. + * @param {ReflectionObject} parent Parent added to + * @returns {undefined} + */ +ReflectionObject.prototype.onAdd = function onAdd(parent) { + if (this.parent && this.parent !== parent) + this.parent.remove(this); + this.parent = parent; + this.resolved = false; + var root = parent.root; + if (root instanceof Root) + root._handleAdd(this); +}; + +/** + * Called when this object is removed from a parent. + * @param {ReflectionObject} parent Parent removed from + * @returns {undefined} + */ +ReflectionObject.prototype.onRemove = function onRemove(parent) { + var root = parent.root; + if (root instanceof Root) + root._handleRemove(this); + this.parent = null; + this.resolved = false; +}; + +/** + * Resolves this objects type references. + * @returns {ReflectionObject} `this` + */ +ReflectionObject.prototype.resolve = function resolve() { + if (this.resolved) + return this; + if (this.root instanceof Root) + this.resolved = true; // only if part of a root + return this; +}; + +/** + * Gets an option value. + * @param {string} name Option name + * @returns {*} Option value or `undefined` if not set + */ +ReflectionObject.prototype.getOption = function getOption(name) { + if (this.options) + return this.options[name]; + return undefined; +}; + +/** + * Sets an option. + * @param {string} name Option name + * @param {*} value Option value + * @param {boolean} [ifNotSet] Sets the option only if it isn't currently set + * @returns {ReflectionObject} `this` + */ +ReflectionObject.prototype.setOption = function setOption(name, value, ifNotSet) { + if (!ifNotSet || !this.options || this.options[name] === undefined) + (this.options || (this.options = {}))[name] = value; + return this; +}; + +/** + * Sets multiple options. + * @param {Object.} options Options to set + * @param {boolean} [ifNotSet] Sets an option only if it isn't currently set + * @returns {ReflectionObject} `this` + */ +ReflectionObject.prototype.setOptions = function setOptions(options, ifNotSet) { + if (options) + for (var keys = Object.keys(options), i = 0; i < keys.length; ++i) + this.setOption(keys[i], options[keys[i]], ifNotSet); + return this; +}; + +/** + * Converts this instance to its string representation. + * @returns {string} Class name[, space, full name] + */ +ReflectionObject.prototype.toString = function toString() { + var className = this.constructor.className, + fullName = this.fullName; + if (fullName.length) + return className + " " + fullName; + return className; +}; + +// Sets up cyclic dependencies (called in index-light) +ReflectionObject._configure = function(Root_) { + Root = Root_; +}; + +},{"37":37}],25:[function(require,module,exports){ +"use strict"; +module.exports = OneOf; + +// extends ReflectionObject +var ReflectionObject = require(24); +((OneOf.prototype = Object.create(ReflectionObject.prototype)).constructor = OneOf).className = "OneOf"; + +var Field = require(16), + util = require(37); + +/** + * Constructs a new oneof instance. + * @classdesc Reflected oneof. + * @extends ReflectionObject + * @constructor + * @param {string} name Oneof name + * @param {string[]|Object.} [fieldNames] Field names + * @param {Object.} [options] Declared options + * @param {string} [comment] Comment associated with this field + */ +function OneOf(name, fieldNames, options, comment) { + if (!Array.isArray(fieldNames)) { + options = fieldNames; + fieldNames = undefined; + } + ReflectionObject.call(this, name, options); + + /* istanbul ignore if */ + if (!(fieldNames === undefined || Array.isArray(fieldNames))) + throw TypeError("fieldNames must be an Array"); + + /** + * Field names that belong to this oneof. + * @type {string[]} + */ + this.oneof = fieldNames || []; // toJSON, marker + + /** + * Fields that belong to this oneof as an array for iteration. + * @type {Field[]} + * @readonly + */ + this.fieldsArray = []; // declared readonly for conformance, possibly not yet added to parent + + /** + * Comment for this field. + * @type {string|null} + */ + this.comment = comment; +} + +/** + * Oneof descriptor. + * @interface IOneOf + * @property {Array.} oneof Oneof field names + * @property {Object.} [options] Oneof options + */ + +/** + * Constructs a oneof from a oneof descriptor. + * @param {string} name Oneof name + * @param {IOneOf} json Oneof descriptor + * @returns {OneOf} Created oneof + * @throws {TypeError} If arguments are invalid + */ +OneOf.fromJSON = function fromJSON(name, json) { + return new OneOf(name, json.oneof, json.options, json.comment); +}; + +/** + * Converts this oneof to a oneof descriptor. + * @param {IToJSONOptions} [toJSONOptions] JSON conversion options + * @returns {IOneOf} Oneof descriptor + */ +OneOf.prototype.toJSON = function toJSON(toJSONOptions) { + var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false; + return util.toObject([ + "options" , this.options, + "oneof" , this.oneof, + "comment" , keepComments ? this.comment : undefined + ]); +}; + +/** + * Adds the fields of the specified oneof to the parent if not already done so. + * @param {OneOf} oneof The oneof + * @returns {undefined} + * @inner + * @ignore + */ +function addFieldsToParent(oneof) { + if (oneof.parent) + for (var i = 0; i < oneof.fieldsArray.length; ++i) + if (!oneof.fieldsArray[i].parent) + oneof.parent.add(oneof.fieldsArray[i]); +} + +/** + * Adds a field to this oneof and removes it from its current parent, if any. + * @param {Field} field Field to add + * @returns {OneOf} `this` + */ +OneOf.prototype.add = function add(field) { + + /* istanbul ignore if */ + if (!(field instanceof Field)) + throw TypeError("field must be a Field"); + + if (field.parent && field.parent !== this.parent) + field.parent.remove(field); + this.oneof.push(field.name); + this.fieldsArray.push(field); + field.partOf = this; // field.parent remains null + addFieldsToParent(this); + return this; +}; + +/** + * Removes a field from this oneof and puts it back to the oneof's parent. + * @param {Field} field Field to remove + * @returns {OneOf} `this` + */ +OneOf.prototype.remove = function remove(field) { + + /* istanbul ignore if */ + if (!(field instanceof Field)) + throw TypeError("field must be a Field"); + + var index = this.fieldsArray.indexOf(field); + + /* istanbul ignore if */ + if (index < 0) + throw Error(field + " is not a member of " + this); + + this.fieldsArray.splice(index, 1); + index = this.oneof.indexOf(field.name); + + /* istanbul ignore else */ + if (index > -1) // theoretical + this.oneof.splice(index, 1); + + field.partOf = null; + return this; +}; + +/** + * @override + */ +OneOf.prototype.onAdd = function onAdd(parent) { + ReflectionObject.prototype.onAdd.call(this, parent); + var self = this; + // Collect present fields + for (var i = 0; i < this.oneof.length; ++i) { + var field = parent.get(this.oneof[i]); + if (field && !field.partOf) { + field.partOf = self; + self.fieldsArray.push(field); + } + } + // Add not yet present fields + addFieldsToParent(this); +}; + +/** + * @override + */ +OneOf.prototype.onRemove = function onRemove(parent) { + for (var i = 0, field; i < this.fieldsArray.length; ++i) + if ((field = this.fieldsArray[i]).parent) + field.parent.remove(field); + ReflectionObject.prototype.onRemove.call(this, parent); +}; + +/** + * Decorator function as returned by {@link OneOf.d} (TypeScript). + * @typedef OneOfDecorator + * @type {function} + * @param {Object} prototype Target prototype + * @param {string} oneofName OneOf name + * @returns {undefined} + */ + +/** + * OneOf decorator (TypeScript). + * @function + * @param {...string} fieldNames Field names + * @returns {OneOfDecorator} Decorator function + * @template T extends string + */ +OneOf.d = function decorateOneOf() { + var fieldNames = new Array(arguments.length), + index = 0; + while (index < arguments.length) + fieldNames[index] = arguments[index++]; + return function oneOfDecorator(prototype, oneofName) { + util.decorateType(prototype.constructor) + .add(new OneOf(oneofName, fieldNames)); + Object.defineProperty(prototype, oneofName, { + get: util.oneOfGetter(fieldNames), + set: util.oneOfSetter(fieldNames) + }); + }; +}; + +},{"16":16,"24":24,"37":37}],26:[function(require,module,exports){ +"use strict"; +module.exports = parse; + +parse.filename = null; +parse.defaults = { keepCase: false }; + +var tokenize = require(34), + Root = require(29), + Type = require(35), + Field = require(16), + MapField = require(20), + OneOf = require(25), + Enum = require(15), + Service = require(33), + Method = require(22), + types = require(36), + util = require(37); + +var base10Re = /^[1-9][0-9]*$/, + base10NegRe = /^-?[1-9][0-9]*$/, + base16Re = /^0[x][0-9a-fA-F]+$/, + base16NegRe = /^-?0[x][0-9a-fA-F]+$/, + base8Re = /^0[0-7]+$/, + base8NegRe = /^-?0[0-7]+$/, + numberRe = /^(?![eE])[0-9]*(?:\.[0-9]*)?(?:[eE][+-]?[0-9]+)?$/, + nameRe = /^[a-zA-Z_][a-zA-Z_0-9]*$/, + typeRefRe = /^(?:\.?[a-zA-Z_][a-zA-Z_0-9]*)(?:\.[a-zA-Z_][a-zA-Z_0-9]*)*$/, + fqTypeRefRe = /^(?:\.[a-zA-Z_][a-zA-Z_0-9]*)+$/; + +/** + * Result object returned from {@link parse}. + * @interface IParserResult + * @property {string|undefined} package Package name, if declared + * @property {string[]|undefined} imports Imports, if any + * @property {string[]|undefined} weakImports Weak imports, if any + * @property {string|undefined} syntax Syntax, if specified (either `"proto2"` or `"proto3"`) + * @property {Root} root Populated root instance + */ + +/** + * Options modifying the behavior of {@link parse}. + * @interface IParseOptions + * @property {boolean} [keepCase=false] Keeps field casing instead of converting to camel case + * @property {boolean} [alternateCommentMode=false] Recognize double-slash comments in addition to doc-block comments. + */ + +/** + * Options modifying the behavior of JSON serialization. + * @interface IToJSONOptions + * @property {boolean} [keepComments=false] Serializes comments. + */ + +/** + * Parses the given .proto source and returns an object with the parsed contents. + * @param {string} source Source contents + * @param {Root} root Root to populate + * @param {IParseOptions} [options] Parse options. Defaults to {@link parse.defaults} when omitted. + * @returns {IParserResult} Parser result + * @property {string} filename=null Currently processing file name for error reporting, if known + * @property {IParseOptions} defaults Default {@link IParseOptions} + */ +function parse(source, root, options) { + /* eslint-disable callback-return */ + if (!(root instanceof Root)) { + options = root; + root = new Root(); + } + if (!options) + options = parse.defaults; + + var tn = tokenize(source, options.alternateCommentMode || false), + next = tn.next, + push = tn.push, + peek = tn.peek, + skip = tn.skip, + cmnt = tn.cmnt; + + var head = true, + pkg, + imports, + weakImports, + syntax, + isProto3 = false; + + var ptr = root; + + var applyCase = options.keepCase ? function(name) { return name; } : util.camelCase; + + /* istanbul ignore next */ + function illegal(token, name, insideTryCatch) { + var filename = parse.filename; + if (!insideTryCatch) + parse.filename = null; + return Error("illegal " + (name || "token") + " '" + token + "' (" + (filename ? filename + ", " : "") + "line " + tn.line + ")"); + } + + function readString() { + var values = [], + token; + do { + /* istanbul ignore if */ + if ((token = next()) !== "\"" && token !== "'") + throw illegal(token); + + values.push(next()); + skip(token); + token = peek(); + } while (token === "\"" || token === "'"); + return values.join(""); + } + + function readValue(acceptTypeRef) { + var token = next(); + switch (token) { + case "'": + case "\"": + push(token); + return readString(); + case "true": case "TRUE": + return true; + case "false": case "FALSE": + return false; + } + try { + return parseNumber(token, /* insideTryCatch */ true); + } catch (e) { + + /* istanbul ignore else */ + if (acceptTypeRef && typeRefRe.test(token)) + return token; + + /* istanbul ignore next */ + throw illegal(token, "value"); + } + } + + function readRanges(target, acceptStrings) { + var token, start; + do { + if (acceptStrings && ((token = peek()) === "\"" || token === "'")) + target.push(readString()); + else + target.push([ start = parseId(next()), skip("to", true) ? parseId(next()) : start ]); + } while (skip(",", true)); + skip(";"); + } + + function parseNumber(token, insideTryCatch) { + var sign = 1; + if (token.charAt(0) === "-") { + sign = -1; + token = token.substring(1); + } + switch (token) { + case "inf": case "INF": case "Inf": + return sign * Infinity; + case "nan": case "NAN": case "Nan": case "NaN": + return NaN; + case "0": + return 0; + } + if (base10Re.test(token)) + return sign * parseInt(token, 10); + if (base16Re.test(token)) + return sign * parseInt(token, 16); + if (base8Re.test(token)) + return sign * parseInt(token, 8); + + /* istanbul ignore else */ + if (numberRe.test(token)) + return sign * parseFloat(token); + + /* istanbul ignore next */ + throw illegal(token, "number", insideTryCatch); + } + + function parseId(token, acceptNegative) { + switch (token) { + case "max": case "MAX": case "Max": + return 536870911; + case "0": + return 0; + } + + /* istanbul ignore if */ + if (!acceptNegative && token.charAt(0) === "-") + throw illegal(token, "id"); + + if (base10NegRe.test(token)) + return parseInt(token, 10); + if (base16NegRe.test(token)) + return parseInt(token, 16); + + /* istanbul ignore else */ + if (base8NegRe.test(token)) + return parseInt(token, 8); + + /* istanbul ignore next */ + throw illegal(token, "id"); + } + + function parsePackage() { + + /* istanbul ignore if */ + if (pkg !== undefined) + throw illegal("package"); + + pkg = next(); + + /* istanbul ignore if */ + if (!typeRefRe.test(pkg)) + throw illegal(pkg, "name"); + + ptr = ptr.define(pkg); + skip(";"); + } + + function parseImport() { + var token = peek(); + var whichImports; + switch (token) { + case "weak": + whichImports = weakImports || (weakImports = []); + next(); + break; + case "public": + next(); + // eslint-disable-line no-fallthrough + default: + whichImports = imports || (imports = []); + break; + } + token = readString(); + skip(";"); + whichImports.push(token); + } + + function parseSyntax() { + skip("="); + syntax = readString(); + isProto3 = syntax === "proto3"; + + /* istanbul ignore if */ + if (!isProto3 && syntax !== "proto2") + throw illegal(syntax, "syntax"); + + skip(";"); + } + + function parseCommon(parent, token) { + switch (token) { + + case "option": + parseOption(parent, token); + skip(";"); + return true; + + case "message": + parseType(parent, token); + return true; + + case "enum": + parseEnum(parent, token); + return true; + + case "service": + parseService(parent, token); + return true; + + case "extend": + parseExtension(parent, token); + return true; + } + return false; + } + + function ifBlock(obj, fnIf, fnElse) { + var trailingLine = tn.line; + if (obj) { + obj.comment = cmnt(); // try block-type comment + obj.filename = parse.filename; + } + if (skip("{", true)) { + var token; + while ((token = next()) !== "}") + fnIf(token); + skip(";", true); + } else { + if (fnElse) + fnElse(); + skip(";"); + if (obj && typeof obj.comment !== "string") + obj.comment = cmnt(trailingLine); // try line-type comment if no block + } + } + + function parseType(parent, token) { + + /* istanbul ignore if */ + if (!nameRe.test(token = next())) + throw illegal(token, "type name"); + + var type = new Type(token); + ifBlock(type, function parseType_block(token) { + if (parseCommon(type, token)) + return; + + switch (token) { + + case "map": + parseMapField(type, token); + break; + + case "required": + case "optional": + case "repeated": + parseField(type, token); + break; + + case "oneof": + parseOneOf(type, token); + break; + + case "extensions": + readRanges(type.extensions || (type.extensions = [])); + break; + + case "reserved": + readRanges(type.reserved || (type.reserved = []), true); + break; + + default: + /* istanbul ignore if */ + if (!isProto3 || !typeRefRe.test(token)) + throw illegal(token); + + push(token); + parseField(type, "optional"); + break; + } + }); + parent.add(type); + } + + function parseField(parent, rule, extend) { + var type = next(); + if (type === "group") { + parseGroup(parent, rule); + return; + } + + /* istanbul ignore if */ + if (!typeRefRe.test(type)) + throw illegal(type, "type"); + + var name = next(); + + /* istanbul ignore if */ + if (!nameRe.test(name)) + throw illegal(name, "name"); + + name = applyCase(name); + skip("="); + + var field = new Field(name, parseId(next()), type, rule, extend); + ifBlock(field, function parseField_block(token) { + + /* istanbul ignore else */ + if (token === "option") { + parseOption(field, token); + skip(";"); + } else + throw illegal(token); + + }, function parseField_line() { + parseInlineOptions(field); + }); + parent.add(field); + + // JSON defaults to packed=true if not set so we have to set packed=false explicity when + // parsing proto2 descriptors without the option, where applicable. This must be done for + // all known packable types and anything that could be an enum (= is not a basic type). + if (!isProto3 && field.repeated && (types.packed[type] !== undefined || types.basic[type] === undefined)) + field.setOption("packed", false, /* ifNotSet */ true); + } + + function parseGroup(parent, rule) { + var name = next(); + + /* istanbul ignore if */ + if (!nameRe.test(name)) + throw illegal(name, "name"); + + var fieldName = util.lcFirst(name); + if (name === fieldName) + name = util.ucFirst(name); + skip("="); + var id = parseId(next()); + var type = new Type(name); + type.group = true; + var field = new Field(fieldName, id, name, rule); + field.filename = parse.filename; + ifBlock(type, function parseGroup_block(token) { + switch (token) { + + case "option": + parseOption(type, token); + skip(";"); + break; + + case "required": + case "optional": + case "repeated": + parseField(type, token); + break; + + /* istanbul ignore next */ + default: + throw illegal(token); // there are no groups with proto3 semantics + } + }); + parent.add(type) + .add(field); + } + + function parseMapField(parent) { + skip("<"); + var keyType = next(); + + /* istanbul ignore if */ + if (types.mapKey[keyType] === undefined) + throw illegal(keyType, "type"); + + skip(","); + var valueType = next(); + + /* istanbul ignore if */ + if (!typeRefRe.test(valueType)) + throw illegal(valueType, "type"); + + skip(">"); + var name = next(); + + /* istanbul ignore if */ + if (!nameRe.test(name)) + throw illegal(name, "name"); + + skip("="); + var field = new MapField(applyCase(name), parseId(next()), keyType, valueType); + ifBlock(field, function parseMapField_block(token) { + + /* istanbul ignore else */ + if (token === "option") { + parseOption(field, token); + skip(";"); + } else + throw illegal(token); + + }, function parseMapField_line() { + parseInlineOptions(field); + }); + parent.add(field); + } + + function parseOneOf(parent, token) { + + /* istanbul ignore if */ + if (!nameRe.test(token = next())) + throw illegal(token, "name"); + + var oneof = new OneOf(applyCase(token)); + ifBlock(oneof, function parseOneOf_block(token) { + if (token === "option") { + parseOption(oneof, token); + skip(";"); + } else { + push(token); + parseField(oneof, "optional"); + } + }); + parent.add(oneof); + } + + function parseEnum(parent, token) { + + /* istanbul ignore if */ + if (!nameRe.test(token = next())) + throw illegal(token, "name"); + + var enm = new Enum(token); + ifBlock(enm, function parseEnum_block(token) { + switch(token) { + case "option": + parseOption(enm, token); + skip(";"); + break; + + case "reserved": + readRanges(enm.reserved || (enm.reserved = []), true); + break; + + default: + parseEnumValue(enm, token); + } + }); + parent.add(enm); + } + + function parseEnumValue(parent, token) { + + /* istanbul ignore if */ + if (!nameRe.test(token)) + throw illegal(token, "name"); + + skip("="); + var value = parseId(next(), true), + dummy = {}; + ifBlock(dummy, function parseEnumValue_block(token) { + + /* istanbul ignore else */ + if (token === "option") { + parseOption(dummy, token); // skip + skip(";"); + } else + throw illegal(token); + + }, function parseEnumValue_line() { + parseInlineOptions(dummy); // skip + }); + parent.add(token, value, dummy.comment); + } + + function parseOption(parent, token) { + var isCustom = skip("(", true); + + /* istanbul ignore if */ + if (!typeRefRe.test(token = next())) + throw illegal(token, "name"); + + var name = token; + if (isCustom) { + skip(")"); + name = "(" + name + ")"; + token = peek(); + if (fqTypeRefRe.test(token)) { + name += token; + next(); + } + } + skip("="); + parseOptionValue(parent, name); + } + + function parseOptionValue(parent, name) { + if (skip("{", true)) { // { a: "foo" b { c: "bar" } } + do { + /* istanbul ignore if */ + if (!nameRe.test(token = next())) + throw illegal(token, "name"); + + if (peek() === "{") + parseOptionValue(parent, name + "." + token); + else { + skip(":"); + if (peek() === "{") + parseOptionValue(parent, name + "." + token); + else + setOption(parent, name + "." + token, readValue(true)); + } + skip(",", true); + } while (!skip("}", true)); + } else + setOption(parent, name, readValue(true)); + // Does not enforce a delimiter to be universal + } + + function setOption(parent, name, value) { + if (parent.setOption) + parent.setOption(name, value); + } + + function parseInlineOptions(parent) { + if (skip("[", true)) { + do { + parseOption(parent, "option"); + } while (skip(",", true)); + skip("]"); + } + return parent; + } + + function parseService(parent, token) { + + /* istanbul ignore if */ + if (!nameRe.test(token = next())) + throw illegal(token, "service name"); + + var service = new Service(token); + ifBlock(service, function parseService_block(token) { + if (parseCommon(service, token)) + return; + + /* istanbul ignore else */ + if (token === "rpc") + parseMethod(service, token); + else + throw illegal(token); + }); + parent.add(service); + } + + function parseMethod(parent, token) { + var type = token; + + /* istanbul ignore if */ + if (!nameRe.test(token = next())) + throw illegal(token, "name"); + + var name = token, + requestType, requestStream, + responseType, responseStream; + + skip("("); + if (skip("stream", true)) + requestStream = true; + + /* istanbul ignore if */ + if (!typeRefRe.test(token = next())) + throw illegal(token); + + requestType = token; + skip(")"); skip("returns"); skip("("); + if (skip("stream", true)) + responseStream = true; + + /* istanbul ignore if */ + if (!typeRefRe.test(token = next())) + throw illegal(token); + + responseType = token; + skip(")"); + + var method = new Method(name, type, requestType, responseType, requestStream, responseStream); + ifBlock(method, function parseMethod_block(token) { + + /* istanbul ignore else */ + if (token === "option") { + parseOption(method, token); + skip(";"); + } else + throw illegal(token); + + }); + parent.add(method); + } + + function parseExtension(parent, token) { + + /* istanbul ignore if */ + if (!typeRefRe.test(token = next())) + throw illegal(token, "reference"); + + var reference = token; + ifBlock(null, function parseExtension_block(token) { + switch (token) { + + case "required": + case "repeated": + case "optional": + parseField(parent, token, reference); + break; + + default: + /* istanbul ignore if */ + if (!isProto3 || !typeRefRe.test(token)) + throw illegal(token); + push(token); + parseField(parent, "optional", reference); + break; + } + }); + } + + var token; + while ((token = next()) !== null) { + switch (token) { + + case "package": + + /* istanbul ignore if */ + if (!head) + throw illegal(token); + + parsePackage(); + break; + + case "import": + + /* istanbul ignore if */ + if (!head) + throw illegal(token); + + parseImport(); + break; + + case "syntax": + + /* istanbul ignore if */ + if (!head) + throw illegal(token); + + parseSyntax(); + break; + + case "option": + + /* istanbul ignore if */ + if (!head) + throw illegal(token); + + parseOption(ptr, token); + skip(";"); + break; + + default: + + /* istanbul ignore else */ + if (parseCommon(ptr, token)) { + head = false; + continue; + } + + /* istanbul ignore next */ + throw illegal(token); + } + } + + parse.filename = null; + return { + "package" : pkg, + "imports" : imports, + weakImports : weakImports, + syntax : syntax, + root : root + }; +} + +/** + * Parses the given .proto source and returns an object with the parsed contents. + * @name parse + * @function + * @param {string} source Source contents + * @param {IParseOptions} [options] Parse options. Defaults to {@link parse.defaults} when omitted. + * @returns {IParserResult} Parser result + * @property {string} filename=null Currently processing file name for error reporting, if known + * @property {IParseOptions} defaults Default {@link IParseOptions} + * @variation 2 + */ + +},{"15":15,"16":16,"20":20,"22":22,"25":25,"29":29,"33":33,"34":34,"35":35,"36":36,"37":37}],27:[function(require,module,exports){ +"use strict"; +module.exports = Reader; + +var util = require(39); + +var BufferReader; // cyclic + +var LongBits = util.LongBits, + utf8 = util.utf8; + +/* istanbul ignore next */ +function indexOutOfRange(reader, writeLength) { + return RangeError("index out of range: " + reader.pos + " + " + (writeLength || 1) + " > " + reader.len); +} + +/** + * Constructs a new reader instance using the specified buffer. + * @classdesc Wire format reader using `Uint8Array` if available, otherwise `Array`. + * @constructor + * @param {Uint8Array} buffer Buffer to read from + */ +function Reader(buffer) { + + /** + * Read buffer. + * @type {Uint8Array} + */ + this.buf = buffer; + + /** + * Read buffer position. + * @type {number} + */ + this.pos = 0; + + /** + * Read buffer length. + * @type {number} + */ + this.len = buffer.length; +} + +var create_array = typeof Uint8Array !== "undefined" + ? function create_typed_array(buffer) { + if (buffer instanceof Uint8Array || Array.isArray(buffer)) + return new Reader(buffer); + throw Error("illegal buffer"); + } + /* istanbul ignore next */ + : function create_array(buffer) { + if (Array.isArray(buffer)) + return new Reader(buffer); + throw Error("illegal buffer"); + }; + +/** + * Creates a new reader using the specified buffer. + * @function + * @param {Uint8Array|Buffer} buffer Buffer to read from + * @returns {Reader|BufferReader} A {@link BufferReader} if `buffer` is a Buffer, otherwise a {@link Reader} + * @throws {Error} If `buffer` is not a valid buffer + */ +Reader.create = util.Buffer + ? function create_buffer_setup(buffer) { + return (Reader.create = function create_buffer(buffer) { + return util.Buffer.isBuffer(buffer) + ? new BufferReader(buffer) + /* istanbul ignore next */ + : create_array(buffer); + })(buffer); + } + /* istanbul ignore next */ + : create_array; + +Reader.prototype._slice = util.Array.prototype.subarray || /* istanbul ignore next */ util.Array.prototype.slice; + +/** + * Reads a varint as an unsigned 32 bit value. + * @function + * @returns {number} Value read + */ +Reader.prototype.uint32 = (function read_uint32_setup() { + var value = 4294967295; // optimizer type-hint, tends to deopt otherwise (?!) + return function read_uint32() { + value = ( this.buf[this.pos] & 127 ) >>> 0; if (this.buf[this.pos++] < 128) return value; + value = (value | (this.buf[this.pos] & 127) << 7) >>> 0; if (this.buf[this.pos++] < 128) return value; + value = (value | (this.buf[this.pos] & 127) << 14) >>> 0; if (this.buf[this.pos++] < 128) return value; + value = (value | (this.buf[this.pos] & 127) << 21) >>> 0; if (this.buf[this.pos++] < 128) return value; + value = (value | (this.buf[this.pos] & 15) << 28) >>> 0; if (this.buf[this.pos++] < 128) return value; + + /* istanbul ignore if */ + if ((this.pos += 5) > this.len) { + this.pos = this.len; + throw indexOutOfRange(this, 10); + } + return value; + }; +})(); + +/** + * Reads a varint as a signed 32 bit value. + * @returns {number} Value read + */ +Reader.prototype.int32 = function read_int32() { + return this.uint32() | 0; +}; + +/** + * Reads a zig-zag encoded varint as a signed 32 bit value. + * @returns {number} Value read + */ +Reader.prototype.sint32 = function read_sint32() { + var value = this.uint32(); + return value >>> 1 ^ -(value & 1) | 0; +}; + +/* eslint-disable no-invalid-this */ + +function readLongVarint() { + // tends to deopt with local vars for octet etc. + var bits = new LongBits(0, 0); + var i = 0; + if (this.len - this.pos > 4) { // fast route (lo) + for (; i < 4; ++i) { + // 1st..4th + bits.lo = (bits.lo | (this.buf[this.pos] & 127) << i * 7) >>> 0; + if (this.buf[this.pos++] < 128) + return bits; + } + // 5th + bits.lo = (bits.lo | (this.buf[this.pos] & 127) << 28) >>> 0; + bits.hi = (bits.hi | (this.buf[this.pos] & 127) >> 4) >>> 0; + if (this.buf[this.pos++] < 128) + return bits; + i = 0; + } else { + for (; i < 3; ++i) { + /* istanbul ignore if */ + if (this.pos >= this.len) + throw indexOutOfRange(this); + // 1st..3th + bits.lo = (bits.lo | (this.buf[this.pos] & 127) << i * 7) >>> 0; + if (this.buf[this.pos++] < 128) + return bits; + } + // 4th + bits.lo = (bits.lo | (this.buf[this.pos++] & 127) << i * 7) >>> 0; + return bits; + } + if (this.len - this.pos > 4) { // fast route (hi) + for (; i < 5; ++i) { + // 6th..10th + bits.hi = (bits.hi | (this.buf[this.pos] & 127) << i * 7 + 3) >>> 0; + if (this.buf[this.pos++] < 128) + return bits; + } + } else { + for (; i < 5; ++i) { + /* istanbul ignore if */ + if (this.pos >= this.len) + throw indexOutOfRange(this); + // 6th..10th + bits.hi = (bits.hi | (this.buf[this.pos] & 127) << i * 7 + 3) >>> 0; + if (this.buf[this.pos++] < 128) + return bits; + } + } + /* istanbul ignore next */ + throw Error("invalid varint encoding"); +} + +/* eslint-enable no-invalid-this */ + +/** + * Reads a varint as a signed 64 bit value. + * @name Reader#int64 + * @function + * @returns {Long} Value read + */ + +/** + * Reads a varint as an unsigned 64 bit value. + * @name Reader#uint64 + * @function + * @returns {Long} Value read + */ + +/** + * Reads a zig-zag encoded varint as a signed 64 bit value. + * @name Reader#sint64 + * @function + * @returns {Long} Value read + */ + +/** + * Reads a varint as a boolean. + * @returns {boolean} Value read + */ +Reader.prototype.bool = function read_bool() { + return this.uint32() !== 0; +}; + +function readFixed32_end(buf, end) { // note that this uses `end`, not `pos` + return (buf[end - 4] + | buf[end - 3] << 8 + | buf[end - 2] << 16 + | buf[end - 1] << 24) >>> 0; +} + +/** + * Reads fixed 32 bits as an unsigned 32 bit integer. + * @returns {number} Value read + */ +Reader.prototype.fixed32 = function read_fixed32() { + + /* istanbul ignore if */ + if (this.pos + 4 > this.len) + throw indexOutOfRange(this, 4); + + return readFixed32_end(this.buf, this.pos += 4); +}; + +/** + * Reads fixed 32 bits as a signed 32 bit integer. + * @returns {number} Value read + */ +Reader.prototype.sfixed32 = function read_sfixed32() { + + /* istanbul ignore if */ + if (this.pos + 4 > this.len) + throw indexOutOfRange(this, 4); + + return readFixed32_end(this.buf, this.pos += 4) | 0; +}; + +/* eslint-disable no-invalid-this */ + +function readFixed64(/* this: Reader */) { + + /* istanbul ignore if */ + if (this.pos + 8 > this.len) + throw indexOutOfRange(this, 8); + + return new LongBits(readFixed32_end(this.buf, this.pos += 4), readFixed32_end(this.buf, this.pos += 4)); +} + +/* eslint-enable no-invalid-this */ + +/** + * Reads fixed 64 bits. + * @name Reader#fixed64 + * @function + * @returns {Long} Value read + */ + +/** + * Reads zig-zag encoded fixed 64 bits. + * @name Reader#sfixed64 + * @function + * @returns {Long} Value read + */ + +/** + * Reads a float (32 bit) as a number. + * @function + * @returns {number} Value read + */ +Reader.prototype.float = function read_float() { + + /* istanbul ignore if */ + if (this.pos + 4 > this.len) + throw indexOutOfRange(this, 4); + + var value = null; + if (window && true == window.forceBigEndianFloatingNumDecoding) { + value = util.float.readFloatBE(this.buf, this.pos); + } else { + value = util.float.readFloatLE(this.buf, this.pos); + } + this.pos += 4; + return value; +}; + +/** + * Reads a double (64 bit float) as a number. + * @function + * @returns {number} Value read + */ +Reader.prototype.double = function read_double() { + + /* istanbul ignore if */ + if (this.pos + 8 > this.len) + throw indexOutOfRange(this, 4); + + var value = null; + if (window && true == window.forceBigEndianFloatingNumDecoding) { + value = util.float.readDoubleBE(this.buf, this.pos); + } else { + value = util.float.readDoubleLE(this.buf, this.pos); + } + this.pos += 8; + return value; +}; + +/** + * Reads a sequence of bytes preceeded by its length as a varint. + * @returns {Uint8Array} Value read + */ +Reader.prototype.bytes = function read_bytes() { + var length = this.uint32(), + start = this.pos, + end = this.pos + length; + + /* istanbul ignore if */ + if (end > this.len) + throw indexOutOfRange(this, length); + + this.pos += length; + if (Array.isArray(this.buf)) // plain array + return this.buf.slice(start, end); + return start === end // fix for IE 10/Win8 and others' subarray returning array of size 1 + ? new this.buf.constructor(0) + : this._slice.call(this.buf, start, end); +}; + +/** + * Reads a string preceeded by its byte length as a varint. + * @returns {string} Value read + */ +Reader.prototype.string = function read_string() { + var bytes = this.bytes(); + return utf8.read(bytes, 0, bytes.length); +}; + +/** + * Skips the specified number of bytes if specified, otherwise skips a varint. + * @param {number} [length] Length if known, otherwise a varint is assumed + * @returns {Reader} `this` + */ +Reader.prototype.skip = function skip(length) { + if (typeof length === "number") { + /* istanbul ignore if */ + if (this.pos + length > this.len) + throw indexOutOfRange(this, length); + this.pos += length; + } else { + do { + /* istanbul ignore if */ + if (this.pos >= this.len) + throw indexOutOfRange(this); + } while (this.buf[this.pos++] & 128); + } + return this; +}; + +/** + * Skips the next element of the specified wire type. + * @param {number} wireType Wire type received + * @returns {Reader} `this` + */ +Reader.prototype.skipType = function(wireType) { + switch (wireType) { + case 0: + this.skip(); + break; + case 1: + this.skip(8); + break; + case 2: + this.skip(this.uint32()); + break; + case 3: + while ((wireType = this.uint32() & 7) !== 4) { + this.skipType(wireType); + } + break; + case 5: + this.skip(4); + break; + + /* istanbul ignore next */ + default: + throw Error("invalid wire type " + wireType + " at offset " + this.pos); + } + return this; +}; + +Reader._configure = function(BufferReader_) { + BufferReader = BufferReader_; + + var fn = util.Long ? "toLong" : /* istanbul ignore next */ "toNumber"; + util.merge(Reader.prototype, { + + int64: function read_int64() { + return readLongVarint.call(this)[fn](false); + }, + + uint64: function read_uint64() { + return readLongVarint.call(this)[fn](true); + }, + + sint64: function read_sint64() { + return readLongVarint.call(this).zzDecode()[fn](false); + }, + + fixed64: function read_fixed64() { + return readFixed64.call(this)[fn](true); + }, + + sfixed64: function read_sfixed64() { + return readFixed64.call(this)[fn](false); + } + + }); +}; + +},{"39":39}],28:[function(require,module,exports){ +"use strict"; +module.exports = BufferReader; + +// extends Reader +var Reader = require(27); +(BufferReader.prototype = Object.create(Reader.prototype)).constructor = BufferReader; + +var util = require(39); + +/** + * Constructs a new buffer reader instance. + * @classdesc Wire format reader using node buffers. + * @extends Reader + * @constructor + * @param {Buffer} buffer Buffer to read from + */ +function BufferReader(buffer) { + Reader.call(this, buffer); + + /** + * Read buffer. + * @name BufferReader#buf + * @type {Buffer} + */ +} + +/* istanbul ignore else */ +if (util.Buffer) + BufferReader.prototype._slice = util.Buffer.prototype.slice; + +/** + * @override + */ +BufferReader.prototype.string = function read_string_buffer() { + var len = this.uint32(); // modifies pos + return this.buf.utf8Slice(this.pos, this.pos = Math.min(this.pos + len, this.len)); +}; + +/** + * Reads a sequence of bytes preceeded by its length as a varint. + * @name BufferReader#bytes + * @function + * @returns {Buffer} Value read + */ + +},{"27":27,"39":39}],29:[function(require,module,exports){ +"use strict"; +module.exports = Root; + +// extends Namespace +var Namespace = require(23); +((Root.prototype = Object.create(Namespace.prototype)).constructor = Root).className = "Root"; + +var Field = require(16), + Enum = require(15), + OneOf = require(25), + util = require(37); + +var Type, // cyclic + parse, // might be excluded + common; // " + +/** + * Constructs a new root namespace instance. + * @classdesc Root namespace wrapping all types, enums, services, sub-namespaces etc. that belong together. + * @extends NamespaceBase + * @constructor + * @param {Object.} [options] Top level options + */ +function Root(options) { + Namespace.call(this, "", options); + + /** + * Deferred extension fields. + * @type {Field[]} + */ + this.deferred = []; + + /** + * Resolved file names of loaded files. + * @type {string[]} + */ + this.files = []; +} + +/** + * Loads a namespace descriptor into a root namespace. + * @param {INamespace} json Nameespace descriptor + * @param {Root} [root] Root namespace, defaults to create a new one if omitted + * @returns {Root} Root namespace + */ +Root.fromJSON = function fromJSON(json, root) { + if (!root) + root = new Root(); + if (json.options) + root.setOptions(json.options); + return root.addJSON(json.nested); +}; + +/** + * Resolves the path of an imported file, relative to the importing origin. + * This method exists so you can override it with your own logic in case your imports are scattered over multiple directories. + * @function + * @param {string} origin The file name of the importing file + * @param {string} target The file name being imported + * @returns {string|null} Resolved path to `target` or `null` to skip the file + */ +Root.prototype.resolvePath = util.path.resolve; + +// A symbol-like function to safely signal synchronous loading +/* istanbul ignore next */ +function SYNC() {} // eslint-disable-line no-empty-function + +/** + * Loads one or multiple .proto or preprocessed .json files into this root namespace and calls the callback. + * @param {string|string[]} filename Names of one or multiple files to load + * @param {IParseOptions} options Parse options + * @param {LoadCallback} callback Callback function + * @returns {undefined} + */ +Root.prototype.load = function load(filename, options, callback) { + if (typeof options === "function") { + callback = options; + options = undefined; + } + var self = this; + if (!callback) + return util.asPromise(load, self, filename, options); + + var sync = callback === SYNC; // undocumented + + // Finishes loading by calling the callback (exactly once) + function finish(err, root) { + /* istanbul ignore if */ + if (!callback) + return; + var cb = callback; + callback = null; + if (sync) + throw err; + cb(err, root); + } + + // Processes a single file + function process(filename, source) { + try { + if (util.isString(source) && source.charAt(0) === "{") + source = JSON.parse(source); + if (!util.isString(source)) + self.setOptions(source.options).addJSON(source.nested); + else { + parse.filename = filename; + var parsed = parse(source, self, options), + resolved, + i = 0; + if (parsed.imports) + for (; i < parsed.imports.length; ++i) + if (resolved = self.resolvePath(filename, parsed.imports[i])) + fetch(resolved); + if (parsed.weakImports) + for (i = 0; i < parsed.weakImports.length; ++i) + if (resolved = self.resolvePath(filename, parsed.weakImports[i])) + fetch(resolved, true); + } + } catch (err) { + finish(err); + } + if (!sync && !queued) + finish(null, self); // only once anyway + } + + // Fetches a single file + function fetch(filename, weak) { + + // Strip path if this file references a bundled definition + var idx = filename.lastIndexOf("google/protobuf/"); + if (idx > -1) { + var altname = filename.substring(idx); + if (altname in common) + filename = altname; + } + + // Skip if already loaded / attempted + if (self.files.indexOf(filename) > -1) + return; + self.files.push(filename); + + // Shortcut bundled definitions + if (filename in common) { + if (sync) + process(filename, common[filename]); + else { + ++queued; + setTimeout(function() { + --queued; + process(filename, common[filename]); + }); + } + return; + } + + // Otherwise fetch from disk or network + if (sync) { + var source; + try { + source = util.fs.readFileSync(filename).toString("utf8"); + } catch (err) { + if (!weak) + finish(err); + return; + } + process(filename, source); + } else { + ++queued; + util.fetch(filename, function(err, source) { + --queued; + /* istanbul ignore if */ + if (!callback) + return; // terminated meanwhile + if (err) { + /* istanbul ignore else */ + if (!weak) + finish(err); + else if (!queued) // can't be covered reliably + finish(null, self); + return; + } + process(filename, source); + }); + } + } + var queued = 0; + + // Assembling the root namespace doesn't require working type + // references anymore, so we can load everything in parallel + if (util.isString(filename)) + filename = [ filename ]; + for (var i = 0, resolved; i < filename.length; ++i) + if (resolved = self.resolvePath("", filename[i])) + fetch(resolved); + + if (sync) + return self; + if (!queued) + finish(null, self); + return undefined; +}; +// function load(filename:string, options:IParseOptions, callback:LoadCallback):undefined + +/** + * Loads one or multiple .proto or preprocessed .json files into this root namespace and calls the callback. + * @function Root#load + * @param {string|string[]} filename Names of one or multiple files to load + * @param {LoadCallback} callback Callback function + * @returns {undefined} + * @variation 2 + */ +// function load(filename:string, callback:LoadCallback):undefined + +/** + * Loads one or multiple .proto or preprocessed .json files into this root namespace and returns a promise. + * @function Root#load + * @param {string|string[]} filename Names of one or multiple files to load + * @param {IParseOptions} [options] Parse options. Defaults to {@link parse.defaults} when omitted. + * @returns {Promise} Promise + * @variation 3 + */ +// function load(filename:string, [options:IParseOptions]):Promise + +/** + * Synchronously loads one or multiple .proto or preprocessed .json files into this root namespace (node only). + * @function Root#loadSync + * @param {string|string[]} filename Names of one or multiple files to load + * @param {IParseOptions} [options] Parse options. Defaults to {@link parse.defaults} when omitted. + * @returns {Root} Root namespace + * @throws {Error} If synchronous fetching is not supported (i.e. in browsers) or if a file's syntax is invalid + */ +Root.prototype.loadSync = function loadSync(filename, options) { + if (!util.isNode) + throw Error("not supported"); + return this.load(filename, options, SYNC); +}; + +/** + * @override + */ +Root.prototype.resolveAll = function resolveAll() { + if (this.deferred.length) + throw Error("unresolvable extensions: " + this.deferred.map(function(field) { + return "'extend " + field.extend + "' in " + field.parent.fullName; + }).join(", ")); + return Namespace.prototype.resolveAll.call(this); +}; + +// only uppercased (and thus conflict-free) children are exposed, see below +var exposeRe = /^[A-Z]/; + +/** + * Handles a deferred declaring extension field by creating a sister field to represent it within its extended type. + * @param {Root} root Root instance + * @param {Field} field Declaring extension field witin the declaring type + * @returns {boolean} `true` if successfully added to the extended type, `false` otherwise + * @inner + * @ignore + */ +function tryHandleExtension(root, field) { + var extendedType = field.parent.lookup(field.extend); + if (extendedType) { + var sisterField = new Field(field.fullName, field.id, field.type, field.rule, undefined, field.options); + sisterField.declaringField = field; + field.extensionField = sisterField; + extendedType.add(sisterField); + return true; + } + return false; +} + +/** + * Called when any object is added to this root or its sub-namespaces. + * @param {ReflectionObject} object Object added + * @returns {undefined} + * @private + */ +Root.prototype._handleAdd = function _handleAdd(object) { + if (object instanceof Field) { + + if (/* an extension field (implies not part of a oneof) */ object.extend !== undefined && /* not already handled */ !object.extensionField) + if (!tryHandleExtension(this, object)) + this.deferred.push(object); + + } else if (object instanceof Enum) { + + if (exposeRe.test(object.name)) + object.parent[object.name] = object.values; // expose enum values as property of its parent + + } else if (!(object instanceof OneOf)) /* everything else is a namespace */ { + + if (object instanceof Type) // Try to handle any deferred extensions + for (var i = 0; i < this.deferred.length;) + if (tryHandleExtension(this, this.deferred[i])) + this.deferred.splice(i, 1); + else + ++i; + for (var j = 0; j < /* initializes */ object.nestedArray.length; ++j) // recurse into the namespace + this._handleAdd(object._nestedArray[j]); + if (exposeRe.test(object.name)) + object.parent[object.name] = object; // expose namespace as property of its parent + } + + // The above also adds uppercased (and thus conflict-free) nested types, services and enums as + // properties of namespaces just like static code does. This allows using a .d.ts generated for + // a static module with reflection-based solutions where the condition is met. +}; + +/** + * Called when any object is removed from this root or its sub-namespaces. + * @param {ReflectionObject} object Object removed + * @returns {undefined} + * @private + */ +Root.prototype._handleRemove = function _handleRemove(object) { + if (object instanceof Field) { + + if (/* an extension field */ object.extend !== undefined) { + if (/* already handled */ object.extensionField) { // remove its sister field + object.extensionField.parent.remove(object.extensionField); + object.extensionField = null; + } else { // cancel the extension + var index = this.deferred.indexOf(object); + /* istanbul ignore else */ + if (index > -1) + this.deferred.splice(index, 1); + } + } + + } else if (object instanceof Enum) { + + if (exposeRe.test(object.name)) + delete object.parent[object.name]; // unexpose enum values + + } else if (object instanceof Namespace) { + + for (var i = 0; i < /* initializes */ object.nestedArray.length; ++i) // recurse into the namespace + this._handleRemove(object._nestedArray[i]); + + if (exposeRe.test(object.name)) + delete object.parent[object.name]; // unexpose namespaces + + } +}; + +// Sets up cyclic dependencies (called in index-light) +Root._configure = function(Type_, parse_, common_) { + Type = Type_; + parse = parse_; + common = common_; +}; + +},{"15":15,"16":16,"23":23,"25":25,"37":37}],30:[function(require,module,exports){ +"use strict"; +module.exports = {}; + +/** + * Named roots. + * This is where pbjs stores generated structures (the option `-r, --root` specifies a name). + * Can also be used manually to make roots available accross modules. + * @name roots + * @type {Object.} + * @example + * // pbjs -r myroot -o compiled.js ... + * + * // in another module: + * require("./compiled.js"); + * + * // in any subsequent module: + * var root = protobuf.roots["myroot"]; + */ + +},{}],31:[function(require,module,exports){ +"use strict"; + +/** + * Streaming RPC helpers. + * @namespace + */ +var rpc = exports; + +/** + * RPC implementation passed to {@link Service#create} performing a service request on network level, i.e. by utilizing http requests or websockets. + * @typedef RPCImpl + * @type {function} + * @param {Method|rpc.ServiceMethod,Message<{}>>} method Reflected or static method being called + * @param {Uint8Array} requestData Request data + * @param {RPCImplCallback} callback Callback function + * @returns {undefined} + * @example + * function rpcImpl(method, requestData, callback) { + * if (protobuf.util.lcFirst(method.name) !== "myMethod") // compatible with static code + * throw Error("no such method"); + * asynchronouslyObtainAResponse(requestData, function(err, responseData) { + * callback(err, responseData); + * }); + * } + */ + +/** + * Node-style callback as used by {@link RPCImpl}. + * @typedef RPCImplCallback + * @type {function} + * @param {Error|null} error Error, if any, otherwise `null` + * @param {Uint8Array|null} [response] Response data or `null` to signal end of stream, if there hasn't been an error + * @returns {undefined} + */ + +rpc.Service = require(32); + +},{"32":32}],32:[function(require,module,exports){ +"use strict"; +module.exports = Service; + +var util = require(39); + +// Extends EventEmitter +(Service.prototype = Object.create(util.EventEmitter.prototype)).constructor = Service; + +/** + * A service method callback as used by {@link rpc.ServiceMethod|ServiceMethod}. + * + * Differs from {@link RPCImplCallback} in that it is an actual callback of a service method which may not return `response = null`. + * @typedef rpc.ServiceMethodCallback + * @template TRes extends Message + * @type {function} + * @param {Error|null} error Error, if any + * @param {TRes} [response] Response message + * @returns {undefined} + */ + +/** + * A service method part of a {@link rpc.Service} as created by {@link Service.create}. + * @typedef rpc.ServiceMethod + * @template TReq extends Message + * @template TRes extends Message + * @type {function} + * @param {TReq|Properties} request Request message or plain object + * @param {rpc.ServiceMethodCallback} [callback] Node-style callback called with the error, if any, and the response message + * @returns {Promise>} Promise if `callback` has been omitted, otherwise `undefined` + */ + +/** + * Constructs a new RPC service instance. + * @classdesc An RPC service as returned by {@link Service#create}. + * @exports rpc.Service + * @extends util.EventEmitter + * @constructor + * @param {RPCImpl} rpcImpl RPC implementation + * @param {boolean} [requestDelimited=false] Whether requests are length-delimited + * @param {boolean} [responseDelimited=false] Whether responses are length-delimited + */ +function Service(rpcImpl, requestDelimited, responseDelimited) { + + if (typeof rpcImpl !== "function") + throw TypeError("rpcImpl must be a function"); + + util.EventEmitter.call(this); + + /** + * RPC implementation. Becomes `null` once the service is ended. + * @type {RPCImpl|null} + */ + this.rpcImpl = rpcImpl; + + /** + * Whether requests are length-delimited. + * @type {boolean} + */ + this.requestDelimited = Boolean(requestDelimited); + + /** + * Whether responses are length-delimited. + * @type {boolean} + */ + this.responseDelimited = Boolean(responseDelimited); +} + +/** + * Calls a service method through {@link rpc.Service#rpcImpl|rpcImpl}. + * @param {Method|rpc.ServiceMethod} method Reflected or static method + * @param {Constructor} requestCtor Request constructor + * @param {Constructor} responseCtor Response constructor + * @param {TReq|Properties} request Request message or plain object + * @param {rpc.ServiceMethodCallback} callback Service callback + * @returns {undefined} + * @template TReq extends Message + * @template TRes extends Message + */ +Service.prototype.rpcCall = function rpcCall(method, requestCtor, responseCtor, request, callback) { + + if (!request) + throw TypeError("request must be specified"); + + var self = this; + if (!callback) + return util.asPromise(rpcCall, self, method, requestCtor, responseCtor, request); + + if (!self.rpcImpl) { + setTimeout(function() { callback(Error("already ended")); }, 0); + return undefined; + } + + try { + return self.rpcImpl( + method, + requestCtor[self.requestDelimited ? "encodeDelimited" : "encode"](request).finish(), + function rpcCallback(err, response) { + + if (err) { + self.emit("error", err, method); + return callback(err); + } + + if (response === null) { + self.end(/* endedByRPC */ true); + return undefined; + } + + if (!(response instanceof responseCtor)) { + try { + response = responseCtor[self.responseDelimited ? "decodeDelimited" : "decode"](response); + } catch (err) { + self.emit("error", err, method); + return callback(err); + } + } + + self.emit("data", response, method); + return callback(null, response); + } + ); + } catch (err) { + self.emit("error", err, method); + setTimeout(function() { callback(err); }, 0); + return undefined; + } +}; + +/** + * Ends this service and emits the `end` event. + * @param {boolean} [endedByRPC=false] Whether the service has been ended by the RPC implementation. + * @returns {rpc.Service} `this` + */ +Service.prototype.end = function end(endedByRPC) { + if (this.rpcImpl) { + if (!endedByRPC) // signal end to rpcImpl + this.rpcImpl(null, null, null); + this.rpcImpl = null; + this.emit("end").off(); + } + return this; +}; + +},{"39":39}],33:[function(require,module,exports){ +"use strict"; +module.exports = Service; + +// extends Namespace +var Namespace = require(23); +((Service.prototype = Object.create(Namespace.prototype)).constructor = Service).className = "Service"; + +var Method = require(22), + util = require(37), + rpc = require(31); + +/** + * Constructs a new service instance. + * @classdesc Reflected service. + * @extends NamespaceBase + * @constructor + * @param {string} name Service name + * @param {Object.} [options] Service options + * @throws {TypeError} If arguments are invalid + */ +function Service(name, options) { + Namespace.call(this, name, options); + + /** + * Service methods. + * @type {Object.} + */ + this.methods = {}; // toJSON, marker + + /** + * Cached methods as an array. + * @type {Method[]|null} + * @private + */ + this._methodsArray = null; +} + +/** + * Service descriptor. + * @interface IService + * @extends INamespace + * @property {Object.} methods Method descriptors + */ + +/** + * Constructs a service from a service descriptor. + * @param {string} name Service name + * @param {IService} json Service descriptor + * @returns {Service} Created service + * @throws {TypeError} If arguments are invalid + */ +Service.fromJSON = function fromJSON(name, json) { + var service = new Service(name, json.options); + /* istanbul ignore else */ + if (json.methods) + for (var names = Object.keys(json.methods), i = 0; i < names.length; ++i) + service.add(Method.fromJSON(names[i], json.methods[names[i]])); + if (json.nested) + service.addJSON(json.nested); + service.comment = json.comment; + return service; +}; + +/** + * Converts this service to a service descriptor. + * @param {IToJSONOptions} [toJSONOptions] JSON conversion options + * @returns {IService} Service descriptor + */ +Service.prototype.toJSON = function toJSON(toJSONOptions) { + var inherited = Namespace.prototype.toJSON.call(this, toJSONOptions); + var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false; + return util.toObject([ + "options" , inherited && inherited.options || undefined, + "methods" , Namespace.arrayToJSON(this.methodsArray, toJSONOptions) || /* istanbul ignore next */ {}, + "nested" , inherited && inherited.nested || undefined, + "comment" , keepComments ? this.comment : undefined + ]); +}; + +/** + * Methods of this service as an array for iteration. + * @name Service#methodsArray + * @type {Method[]} + * @readonly + */ +Object.defineProperty(Service.prototype, "methodsArray", { + get: function() { + return this._methodsArray || (this._methodsArray = util.toArray(this.methods)); + } +}); + +function clearCache(service) { + service._methodsArray = null; + return service; +} + +/** + * @override + */ +Service.prototype.get = function get(name) { + return this.methods[name] + || Namespace.prototype.get.call(this, name); +}; + +/** + * @override + */ +Service.prototype.resolveAll = function resolveAll() { + var methods = this.methodsArray; + for (var i = 0; i < methods.length; ++i) + methods[i].resolve(); + return Namespace.prototype.resolve.call(this); +}; + +/** + * @override + */ +Service.prototype.add = function add(object) { + + /* istanbul ignore if */ + if (this.get(object.name)) + throw Error("duplicate name '" + object.name + "' in " + this); + + if (object instanceof Method) { + this.methods[object.name] = object; + object.parent = this; + return clearCache(this); + } + return Namespace.prototype.add.call(this, object); +}; + +/** + * @override + */ +Service.prototype.remove = function remove(object) { + if (object instanceof Method) { + + /* istanbul ignore if */ + if (this.methods[object.name] !== object) + throw Error(object + " is not a member of " + this); + + delete this.methods[object.name]; + object.parent = null; + return clearCache(this); + } + return Namespace.prototype.remove.call(this, object); +}; + +/** + * Creates a runtime service using the specified rpc implementation. + * @param {RPCImpl} rpcImpl RPC implementation + * @param {boolean} [requestDelimited=false] Whether requests are length-delimited + * @param {boolean} [responseDelimited=false] Whether responses are length-delimited + * @returns {rpc.Service} RPC service. Useful where requests and/or responses are streamed. + */ +Service.prototype.create = function create(rpcImpl, requestDelimited, responseDelimited) { + var rpcService = new rpc.Service(rpcImpl, requestDelimited, responseDelimited); + for (var i = 0, method; i < /* initializes */ this.methodsArray.length; ++i) { + var methodName = util.lcFirst((method = this._methodsArray[i]).resolve().name).replace(/[^$\w_]/g, ""); + rpcService[methodName] = util.codegen(["r","c"], util.isReserved(methodName) ? methodName + "_" : methodName)("return this.rpcCall(m,q,s,r,c)")({ + m: method, + q: method.resolvedRequestType.ctor, + s: method.resolvedResponseType.ctor + }); + } + return rpcService; +}; + +},{"22":22,"23":23,"31":31,"37":37}],34:[function(require,module,exports){ +"use strict"; +module.exports = tokenize; + +var delimRe = /[\s{}=;:[\],'"()<>]/g, + stringDoubleRe = /(?:"([^"\\]*(?:\\.[^"\\]*)*)")/g, + stringSingleRe = /(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g; + +var setCommentRe = /^ *[*/]+ */, + setCommentAltRe = /^\s*\*?\/*/, + setCommentSplitRe = /\n/g, + whitespaceRe = /\s/, + unescapeRe = /\\(.?)/g; + +var unescapeMap = { + "0": "\0", + "r": "\r", + "n": "\n", + "t": "\t" +}; + +/** + * Unescapes a string. + * @param {string} str String to unescape + * @returns {string} Unescaped string + * @property {Object.} map Special characters map + * @memberof tokenize + */ +function unescape(str) { + return str.replace(unescapeRe, function($0, $1) { + switch ($1) { + case "\\": + case "": + return $1; + default: + return unescapeMap[$1] || ""; + } + }); +} + +tokenize.unescape = unescape; + +/** + * Gets the next token and advances. + * @typedef TokenizerHandleNext + * @type {function} + * @returns {string|null} Next token or `null` on eof + */ + +/** + * Peeks for the next token. + * @typedef TokenizerHandlePeek + * @type {function} + * @returns {string|null} Next token or `null` on eof + */ + +/** + * Pushes a token back to the stack. + * @typedef TokenizerHandlePush + * @type {function} + * @param {string} token Token + * @returns {undefined} + */ + +/** + * Skips the next token. + * @typedef TokenizerHandleSkip + * @type {function} + * @param {string} expected Expected token + * @param {boolean} [optional=false] If optional + * @returns {boolean} Whether the token matched + * @throws {Error} If the token didn't match and is not optional + */ + +/** + * Gets the comment on the previous line or, alternatively, the line comment on the specified line. + * @typedef TokenizerHandleCmnt + * @type {function} + * @param {number} [line] Line number + * @returns {string|null} Comment text or `null` if none + */ + +/** + * Handle object returned from {@link tokenize}. + * @interface ITokenizerHandle + * @property {TokenizerHandleNext} next Gets the next token and advances (`null` on eof) + * @property {TokenizerHandlePeek} peek Peeks for the next token (`null` on eof) + * @property {TokenizerHandlePush} push Pushes a token back to the stack + * @property {TokenizerHandleSkip} skip Skips a token, returns its presence and advances or, if non-optional and not present, throws + * @property {TokenizerHandleCmnt} cmnt Gets the comment on the previous line or the line comment on the specified line, if any + * @property {number} line Current line number + */ + +/** + * Tokenizes the given .proto source and returns an object with useful utility functions. + * @param {string} source Source contents + * @param {boolean} alternateCommentMode Whether we should activate alternate comment parsing mode. + * @returns {ITokenizerHandle} Tokenizer handle + */ +function tokenize(source, alternateCommentMode) { + /* eslint-disable callback-return */ + source = source.toString(); + + var offset = 0, + length = source.length, + line = 1, + commentType = null, + commentText = null, + commentLine = 0, + commentLineEmpty = false; + + var stack = []; + + var stringDelim = null; + + /* istanbul ignore next */ + /** + * Creates an error for illegal syntax. + * @param {string} subject Subject + * @returns {Error} Error created + * @inner + */ + function illegal(subject) { + return Error("illegal " + subject + " (line " + line + ")"); + } + + /** + * Reads a string till its end. + * @returns {string} String read + * @inner + */ + function readString() { + var re = stringDelim === "'" ? stringSingleRe : stringDoubleRe; + re.lastIndex = offset - 1; + var match = re.exec(source); + if (!match) + throw illegal("string"); + offset = re.lastIndex; + push(stringDelim); + stringDelim = null; + return unescape(match[1]); + } + + /** + * Gets the character at `pos` within the source. + * @param {number} pos Position + * @returns {string} Character + * @inner + */ + function charAt(pos) { + return source.charAt(pos); + } + + /** + * Sets the current comment text. + * @param {number} start Start offset + * @param {number} end End offset + * @returns {undefined} + * @inner + */ + function setComment(start, end) { + commentType = source.charAt(start++); + commentLine = line; + commentLineEmpty = false; + var lookback; + if (alternateCommentMode) { + lookback = 2; // alternate comment parsing: "//" or "/*" + } else { + lookback = 3; // "///" or "/**" + } + var commentOffset = start - lookback, + c; + do { + if (--commentOffset < 0 || + (c = source.charAt(commentOffset)) === "\n") { + commentLineEmpty = true; + break; + } + } while (c === " " || c === "\t"); + var lines = source + .substring(start, end) + .split(setCommentSplitRe); + for (var i = 0; i < lines.length; ++i) + lines[i] = lines[i] + .replace(alternateCommentMode ? setCommentAltRe : setCommentRe, "") + .trim(); + commentText = lines + .join("\n") + .trim(); + } + + function isDoubleSlashCommentLine(startOffset) { + var endOffset = findEndOfLine(startOffset); + + // see if remaining line matches comment pattern + var lineText = source.substring(startOffset, endOffset); + // look for 1 or 2 slashes since startOffset would already point past + // the first slash that started the comment. + var isComment = /^\s*\/{1,2}/.test(lineText); + return isComment; + } + + function findEndOfLine(cursor) { + // find end of cursor's line + var endOffset = cursor; + while (endOffset < length && charAt(endOffset) !== "\n") { + endOffset++; + } + return endOffset; + } + + /** + * Obtains the next token. + * @returns {string|null} Next token or `null` on eof + * @inner + */ + function next() { + if (stack.length > 0) + return stack.shift(); + if (stringDelim) + return readString(); + var repeat, + prev, + curr, + start, + isDoc; + do { + if (offset === length) + return null; + repeat = false; + while (whitespaceRe.test(curr = charAt(offset))) { + if (curr === "\n") + ++line; + if (++offset === length) + return null; + } + + if (charAt(offset) === "/") { + if (++offset === length) { + throw illegal("comment"); + } + if (charAt(offset) === "/") { // Line + if (!alternateCommentMode) { + // check for triple-slash comment + isDoc = charAt(start = offset + 1) === "/"; + + while (charAt(++offset) !== "\n") { + if (offset === length) { + return null; + } + } + ++offset; + if (isDoc) { + setComment(start, offset - 1); + } + ++line; + repeat = true; + } else { + // check for double-slash comments, consolidating consecutive lines + start = offset; + isDoc = false; + if (isDoubleSlashCommentLine(offset)) { + isDoc = true; + do { + offset = findEndOfLine(offset); + if (offset === length) { + break; + } + offset++; + } while (isDoubleSlashCommentLine(offset)); + } else { + offset = Math.min(length, findEndOfLine(offset) + 1); + } + if (isDoc) { + setComment(start, offset); + } + line++; + repeat = true; + } + } else if ((curr = charAt(offset)) === "*") { /* Block */ + // check for /** (regular comment mode) or /* (alternate comment mode) + start = offset + 1; + isDoc = alternateCommentMode || charAt(start) === "*"; + do { + if (curr === "\n") { + ++line; + } + if (++offset === length) { + throw illegal("comment"); + } + prev = curr; + curr = charAt(offset); + } while (prev !== "*" || curr !== "/"); + ++offset; + if (isDoc) { + setComment(start, offset - 2); + } + repeat = true; + } else { + return "/"; + } + } + } while (repeat); + + // offset !== length if we got here + + var end = offset; + delimRe.lastIndex = 0; + var delim = delimRe.test(charAt(end++)); + if (!delim) + while (end < length && !delimRe.test(charAt(end))) + ++end; + var token = source.substring(offset, offset = end); + if (token === "\"" || token === "'") + stringDelim = token; + return token; + } + + /** + * Pushes a token back to the stack. + * @param {string} token Token + * @returns {undefined} + * @inner + */ + function push(token) { + stack.push(token); + } + + /** + * Peeks for the next token. + * @returns {string|null} Token or `null` on eof + * @inner + */ + function peek() { + if (!stack.length) { + var token = next(); + if (token === null) + return null; + push(token); + } + return stack[0]; + } + + /** + * Skips a token. + * @param {string} expected Expected token + * @param {boolean} [optional=false] Whether the token is optional + * @returns {boolean} `true` when skipped, `false` if not + * @throws {Error} When a required token is not present + * @inner + */ + function skip(expected, optional) { + var actual = peek(), + equals = actual === expected; + if (equals) { + next(); + return true; + } + if (!optional) + throw illegal("token '" + actual + "', '" + expected + "' expected"); + return false; + } + + /** + * Gets a comment. + * @param {number} [trailingLine] Line number if looking for a trailing comment + * @returns {string|null} Comment text + * @inner + */ + function cmnt(trailingLine) { + var ret = null; + if (trailingLine === undefined) { + if (commentLine === line - 1 && (alternateCommentMode || commentType === "*" || commentLineEmpty)) { + ret = commentText; + } + } else { + /* istanbul ignore else */ + if (commentLine < trailingLine) { + peek(); + } + if (commentLine === trailingLine && !commentLineEmpty && (alternateCommentMode || commentType === "/")) { + ret = commentText; + } + } + return ret; + } + + return Object.defineProperty({ + next: next, + peek: peek, + push: push, + skip: skip, + cmnt: cmnt + }, "line", { + get: function() { return line; } + }); + /* eslint-enable callback-return */ +} + +},{}],35:[function(require,module,exports){ +"use strict"; +module.exports = Type; + +// extends Namespace +var Namespace = require(23); +((Type.prototype = Object.create(Namespace.prototype)).constructor = Type).className = "Type"; + +var Enum = require(15), + OneOf = require(25), + Field = require(16), + MapField = require(20), + Service = require(33), + Message = require(21), + Reader = require(27), + Writer = require(42), + util = require(37), + encoder = require(14), + decoder = require(13), + verifier = require(40), + converter = require(12), + wrappers = require(41); + +/** + * Constructs a new reflected message type instance. + * @classdesc Reflected message type. + * @extends NamespaceBase + * @constructor + * @param {string} name Message name + * @param {Object.} [options] Declared options + */ +function Type(name, options) { + Namespace.call(this, name, options); + + /** + * Message fields. + * @type {Object.} + */ + this.fields = {}; // toJSON, marker + + /** + * Oneofs declared within this namespace, if any. + * @type {Object.} + */ + this.oneofs = undefined; // toJSON + + /** + * Extension ranges, if any. + * @type {number[][]} + */ + this.extensions = undefined; // toJSON + + /** + * Reserved ranges, if any. + * @type {Array.} + */ + this.reserved = undefined; // toJSON + + /*? + * Whether this type is a legacy group. + * @type {boolean|undefined} + */ + this.group = undefined; // toJSON + + /** + * Cached fields by id. + * @type {Object.|null} + * @private + */ + this._fieldsById = null; + + /** + * Cached fields as an array. + * @type {Field[]|null} + * @private + */ + this._fieldsArray = null; + + /** + * Cached oneofs as an array. + * @type {OneOf[]|null} + * @private + */ + this._oneofsArray = null; + + /** + * Cached constructor. + * @type {Constructor<{}>} + * @private + */ + this._ctor = null; +} + +Object.defineProperties(Type.prototype, { + + /** + * Message fields by id. + * @name Type#fieldsById + * @type {Object.} + * @readonly + */ + fieldsById: { + get: function() { + + /* istanbul ignore if */ + if (this._fieldsById) + return this._fieldsById; + + this._fieldsById = {}; + for (var names = Object.keys(this.fields), i = 0; i < names.length; ++i) { + var field = this.fields[names[i]], + id = field.id; + + /* istanbul ignore if */ + if (this._fieldsById[id]) + throw Error("duplicate id " + id + " in " + this); + + this._fieldsById[id] = field; + } + return this._fieldsById; + } + }, + + /** + * Fields of this message as an array for iteration. + * @name Type#fieldsArray + * @type {Field[]} + * @readonly + */ + fieldsArray: { + get: function() { + return this._fieldsArray || (this._fieldsArray = util.toArray(this.fields)); + } + }, + + /** + * Oneofs of this message as an array for iteration. + * @name Type#oneofsArray + * @type {OneOf[]} + * @readonly + */ + oneofsArray: { + get: function() { + return this._oneofsArray || (this._oneofsArray = util.toArray(this.oneofs)); + } + }, + + /** + * The registered constructor, if any registered, otherwise a generic constructor. + * Assigning a function replaces the internal constructor. If the function does not extend {@link Message} yet, its prototype will be setup accordingly and static methods will be populated. If it already extends {@link Message}, it will just replace the internal constructor. + * @name Type#ctor + * @type {Constructor<{}>} + */ + ctor: { + get: function() { + return this._ctor || (this.ctor = Type.generateConstructor(this)()); + }, + set: function(ctor) { + + // Ensure proper prototype + var prototype = ctor.prototype; + if (!(prototype instanceof Message)) { + (ctor.prototype = new Message()).constructor = ctor; + util.merge(ctor.prototype, prototype); + } + + // Classes and messages reference their reflected type + ctor.$type = ctor.prototype.$type = this; + + // Mix in static methods + util.merge(ctor, Message, true); + + this._ctor = ctor; + + // Messages have non-enumerable default values on their prototype + var i = 0; + for (; i < /* initializes */ this.fieldsArray.length; ++i) + this._fieldsArray[i].resolve(); // ensures a proper value + + // Messages have non-enumerable getters and setters for each virtual oneof field + var ctorProperties = {}; + for (i = 0; i < /* initializes */ this.oneofsArray.length; ++i) + ctorProperties[this._oneofsArray[i].resolve().name] = { + get: util.oneOfGetter(this._oneofsArray[i].oneof), + set: util.oneOfSetter(this._oneofsArray[i].oneof) + }; + if (i) + Object.defineProperties(ctor.prototype, ctorProperties); + } + } +}); + +/** + * Generates a constructor function for the specified type. + * @param {Type} mtype Message type + * @returns {Codegen} Codegen instance + */ +Type.generateConstructor = function generateConstructor(mtype) { + /* eslint-disable no-unexpected-multiline */ + var gen = util.codegen(["p"], mtype.name); + // explicitly initialize mutable object/array fields so that these aren't just inherited from the prototype + for (var i = 0, field; i < mtype.fieldsArray.length; ++i) + if ((field = mtype._fieldsArray[i]).map) gen + ("this%s={}", util.safeProp(field.name)); + else if (field.repeated) gen + ("this%s=[]", util.safeProp(field.name)); + return gen + ("if(p)for(var ks=Object.keys(p),i=0;i} [oneofs] Oneof descriptors + * @property {Object.} fields Field descriptors + * @property {number[][]} [extensions] Extension ranges + * @property {number[][]} [reserved] Reserved ranges + * @property {boolean} [group=false] Whether a legacy group or not + */ + +/** + * Creates a message type from a message type descriptor. + * @param {string} name Message name + * @param {IType} json Message type descriptor + * @returns {Type} Created message type + */ +Type.fromJSON = function fromJSON(name, json) { + var type = new Type(name, json.options); + type.extensions = json.extensions; + type.reserved = json.reserved; + var names = Object.keys(json.fields), + i = 0; + for (; i < names.length; ++i) + type.add( + ( typeof json.fields[names[i]].keyType !== "undefined" + ? MapField.fromJSON + : Field.fromJSON )(names[i], json.fields[names[i]]) + ); + if (json.oneofs) + for (names = Object.keys(json.oneofs), i = 0; i < names.length; ++i) + type.add(OneOf.fromJSON(names[i], json.oneofs[names[i]])); + if (json.nested) + for (names = Object.keys(json.nested), i = 0; i < names.length; ++i) { + var nested = json.nested[names[i]]; + type.add( // most to least likely + ( nested.id !== undefined + ? Field.fromJSON + : nested.fields !== undefined + ? Type.fromJSON + : nested.values !== undefined + ? Enum.fromJSON + : nested.methods !== undefined + ? Service.fromJSON + : Namespace.fromJSON )(names[i], nested) + ); + } + if (json.extensions && json.extensions.length) + type.extensions = json.extensions; + if (json.reserved && json.reserved.length) + type.reserved = json.reserved; + if (json.group) + type.group = true; + if (json.comment) + type.comment = json.comment; + return type; +}; + +/** + * Converts this message type to a message type descriptor. + * @param {IToJSONOptions} [toJSONOptions] JSON conversion options + * @returns {IType} Message type descriptor + */ +Type.prototype.toJSON = function toJSON(toJSONOptions) { + var inherited = Namespace.prototype.toJSON.call(this, toJSONOptions); + var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false; + return util.toObject([ + "options" , inherited && inherited.options || undefined, + "oneofs" , Namespace.arrayToJSON(this.oneofsArray, toJSONOptions), + "fields" , Namespace.arrayToJSON(this.fieldsArray.filter(function(obj) { return !obj.declaringField; }), toJSONOptions) || {}, + "extensions" , this.extensions && this.extensions.length ? this.extensions : undefined, + "reserved" , this.reserved && this.reserved.length ? this.reserved : undefined, + "group" , this.group || undefined, + "nested" , inherited && inherited.nested || undefined, + "comment" , keepComments ? this.comment : undefined + ]); +}; + +/** + * @override + */ +Type.prototype.resolveAll = function resolveAll() { + var fields = this.fieldsArray, i = 0; + while (i < fields.length) + fields[i++].resolve(); + var oneofs = this.oneofsArray; i = 0; + while (i < oneofs.length) + oneofs[i++].resolve(); + return Namespace.prototype.resolveAll.call(this); +}; + +/** + * @override + */ +Type.prototype.get = function get(name) { + return this.fields[name] + || this.oneofs && this.oneofs[name] + || this.nested && this.nested[name] + || null; +}; + +/** + * Adds a nested object to this type. + * @param {ReflectionObject} object Nested object to add + * @returns {Type} `this` + * @throws {TypeError} If arguments are invalid + * @throws {Error} If there is already a nested object with this name or, if a field, when there is already a field with this id + */ +Type.prototype.add = function add(object) { + + if (this.get(object.name)) + throw Error("duplicate name '" + object.name + "' in " + this); + + if (object instanceof Field && object.extend === undefined) { + // NOTE: Extension fields aren't actual fields on the declaring type, but nested objects. + // The root object takes care of adding distinct sister-fields to the respective extended + // type instead. + + // avoids calling the getter if not absolutely necessary because it's called quite frequently + if (this._fieldsById ? /* istanbul ignore next */ this._fieldsById[object.id] : this.fieldsById[object.id]) + throw Error("duplicate id " + object.id + " in " + this); + if (this.isReservedId(object.id)) + throw Error("id " + object.id + " is reserved in " + this); + if (this.isReservedName(object.name)) + throw Error("name '" + object.name + "' is reserved in " + this); + + if (object.parent) + object.parent.remove(object); + this.fields[object.name] = object; + object.message = this; + object.onAdd(this); + return clearCache(this); + } + if (object instanceof OneOf) { + if (!this.oneofs) + this.oneofs = {}; + this.oneofs[object.name] = object; + object.onAdd(this); + return clearCache(this); + } + return Namespace.prototype.add.call(this, object); +}; + +/** + * Removes a nested object from this type. + * @param {ReflectionObject} object Nested object to remove + * @returns {Type} `this` + * @throws {TypeError} If arguments are invalid + * @throws {Error} If `object` is not a member of this type + */ +Type.prototype.remove = function remove(object) { + if (object instanceof Field && object.extend === undefined) { + // See Type#add for the reason why extension fields are excluded here. + + /* istanbul ignore if */ + if (!this.fields || this.fields[object.name] !== object) + throw Error(object + " is not a member of " + this); + + delete this.fields[object.name]; + object.parent = null; + object.onRemove(this); + return clearCache(this); + } + if (object instanceof OneOf) { + + /* istanbul ignore if */ + if (!this.oneofs || this.oneofs[object.name] !== object) + throw Error(object + " is not a member of " + this); + + delete this.oneofs[object.name]; + object.parent = null; + object.onRemove(this); + return clearCache(this); + } + return Namespace.prototype.remove.call(this, object); +}; + +/** + * Tests if the specified id is reserved. + * @param {number} id Id to test + * @returns {boolean} `true` if reserved, otherwise `false` + */ +Type.prototype.isReservedId = function isReservedId(id) { + return Namespace.isReservedId(this.reserved, id); +}; + +/** + * Tests if the specified name is reserved. + * @param {string} name Name to test + * @returns {boolean} `true` if reserved, otherwise `false` + */ +Type.prototype.isReservedName = function isReservedName(name) { + return Namespace.isReservedName(this.reserved, name); +}; + +/** + * Creates a new message of this type using the specified properties. + * @param {Object.} [properties] Properties to set + * @returns {Message<{}>} Message instance + */ +Type.prototype.create = function create(properties) { + return new this.ctor(properties); +}; + +/** + * Sets up {@link Type#encode|encode}, {@link Type#decode|decode} and {@link Type#verify|verify}. + * @returns {Type} `this` + */ +Type.prototype.setup = function setup() { + // Sets up everything at once so that the prototype chain does not have to be re-evaluated + // multiple times (V8, soft-deopt prototype-check). + + var fullName = this.fullName, + types = []; + for (var i = 0; i < /* initializes */ this.fieldsArray.length; ++i) + types.push(this._fieldsArray[i].resolve().resolvedType); + + // Replace setup methods with type-specific generated functions + this.encode = encoder(this)({ + Writer : Writer, + types : types, + util : util + }); + this.decode = decoder(this)({ + Reader : Reader, + types : types, + util : util + }); + this.verify = verifier(this)({ + types : types, + util : util + }); + this.fromObject = converter.fromObject(this)({ + types : types, + util : util + }); + this.toObject = converter.toObject(this)({ + types : types, + util : util + }); + + // Inject custom wrappers for common types + var wrapper = wrappers[fullName]; + if (wrapper) { + var originalThis = Object.create(this); + // if (wrapper.fromObject) { + originalThis.fromObject = this.fromObject; + this.fromObject = wrapper.fromObject.bind(originalThis); + // } + // if (wrapper.toObject) { + originalThis.toObject = this.toObject; + this.toObject = wrapper.toObject.bind(originalThis); + // } + } + + return this; +}; + +/** + * Encodes a message of this type. Does not implicitly {@link Type#verify|verify} messages. + * @param {Message<{}>|Object.} message Message instance or plain object + * @param {Writer} [writer] Writer to encode to + * @returns {Writer} writer + */ +Type.prototype.encode = function encode_setup(message, writer) { + return this.setup().encode(message, writer); // overrides this method +}; + +/** + * Encodes a message of this type preceeded by its byte length as a varint. Does not implicitly {@link Type#verify|verify} messages. + * @param {Message<{}>|Object.} message Message instance or plain object + * @param {Writer} [writer] Writer to encode to + * @returns {Writer} writer + */ +Type.prototype.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer && writer.len ? writer.fork() : writer).ldelim(); +}; + +/** + * Decodes a message of this type. + * @param {Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Length of the message, if known beforehand + * @returns {Message<{}>} Decoded message + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {util.ProtocolError<{}>} If required fields are missing + */ +Type.prototype.decode = function decode_setup(reader, length) { + return this.setup().decode(reader, length); // overrides this method +}; + +/** + * Decodes a message of this type preceeded by its byte length as a varint. + * @param {Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {Message<{}>} Decoded message + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {util.ProtocolError} If required fields are missing + */ +Type.prototype.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof Reader)) + reader = Reader.create(reader); + return this.decode(reader, reader.uint32()); +}; + +/** + * Verifies that field values are valid and that required fields are present. + * @param {Object.} message Plain object to verify + * @returns {null|string} `null` if valid, otherwise the reason why it is not + */ +Type.prototype.verify = function verify_setup(message) { + return this.setup().verify(message); // overrides this method +}; + +/** + * Creates a new message of this type from a plain object. Also converts values to their respective internal types. + * @param {Object.} object Plain object to convert + * @returns {Message<{}>} Message instance + */ +Type.prototype.fromObject = function fromObject(object) { + return this.setup().fromObject(object); +}; + +/** + * Conversion options as used by {@link Type#toObject} and {@link Message.toObject}. + * @interface IConversionOptions + * @property {Function} [longs] Long conversion type. + * Valid values are `String` and `Number` (the global types). + * Defaults to copy the present value, which is a possibly unsafe number without and a {@link Long} with a long library. + * @property {Function} [enums] Enum value conversion type. + * Only valid value is `String` (the global type). + * Defaults to copy the present value, which is the numeric id. + * @property {Function} [bytes] Bytes value conversion type. + * Valid values are `Array` and (a base64 encoded) `String` (the global types). + * Defaults to copy the present value, which usually is a Buffer under node and an Uint8Array in the browser. + * @property {boolean} [defaults=false] Also sets default values on the resulting object + * @property {boolean} [arrays=false] Sets empty arrays for missing repeated fields even if `defaults=false` + * @property {boolean} [objects=false] Sets empty objects for missing map fields even if `defaults=false` + * @property {boolean} [oneofs=false] Includes virtual oneof properties set to the present field's name, if any + * @property {boolean} [json=false] Performs additional JSON compatibility conversions, i.e. NaN and Infinity to strings + */ + +/** + * Creates a plain object from a message of this type. Also converts values to other types if specified. + * @param {Message<{}>} message Message instance + * @param {IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ +Type.prototype.toObject = function toObject(message, options) { + return this.setup().toObject(message, options); +}; + +/** + * Decorator function as returned by {@link Type.d} (TypeScript). + * @typedef TypeDecorator + * @type {function} + * @param {Constructor} target Target constructor + * @returns {undefined} + * @template T extends Message + */ + +/** + * Type decorator (TypeScript). + * @param {string} [typeName] Type name, defaults to the constructor's name + * @returns {TypeDecorator} Decorator function + * @template T extends Message + */ +Type.d = function decorateType(typeName) { + return function typeDecorator(target) { + util.decorateType(target, typeName); + }; +}; + +},{"12":12,"13":13,"14":14,"15":15,"16":16,"20":20,"21":21,"23":23,"25":25,"27":27,"33":33,"37":37,"40":40,"41":41,"42":42}],36:[function(require,module,exports){ +"use strict"; + +/** + * Common type constants. + * @namespace + */ +var types = exports; + +var util = require(37); + +var s = [ + "double", // 0 + "float", // 1 + "int32", // 2 + "uint32", // 3 + "sint32", // 4 + "fixed32", // 5 + "sfixed32", // 6 + "int64", // 7 + "uint64", // 8 + "sint64", // 9 + "fixed64", // 10 + "sfixed64", // 11 + "bool", // 12 + "string", // 13 + "bytes" // 14 +]; + +function bake(values, offset) { + var i = 0, o = {}; + offset |= 0; + while (i < values.length) o[s[i + offset]] = values[i++]; + return o; +} + +/** + * Basic type wire types. + * @type {Object.} + * @const + * @property {number} double=1 Fixed64 wire type + * @property {number} float=5 Fixed32 wire type + * @property {number} int32=0 Varint wire type + * @property {number} uint32=0 Varint wire type + * @property {number} sint32=0 Varint wire type + * @property {number} fixed32=5 Fixed32 wire type + * @property {number} sfixed32=5 Fixed32 wire type + * @property {number} int64=0 Varint wire type + * @property {number} uint64=0 Varint wire type + * @property {number} sint64=0 Varint wire type + * @property {number} fixed64=1 Fixed64 wire type + * @property {number} sfixed64=1 Fixed64 wire type + * @property {number} bool=0 Varint wire type + * @property {number} string=2 Ldelim wire type + * @property {number} bytes=2 Ldelim wire type + */ +types.basic = bake([ + /* double */ 1, + /* float */ 5, + /* int32 */ 0, + /* uint32 */ 0, + /* sint32 */ 0, + /* fixed32 */ 5, + /* sfixed32 */ 5, + /* int64 */ 0, + /* uint64 */ 0, + /* sint64 */ 0, + /* fixed64 */ 1, + /* sfixed64 */ 1, + /* bool */ 0, + /* string */ 2, + /* bytes */ 2 +]); + +/** + * Basic type defaults. + * @type {Object.} + * @const + * @property {number} double=0 Double default + * @property {number} float=0 Float default + * @property {number} int32=0 Int32 default + * @property {number} uint32=0 Uint32 default + * @property {number} sint32=0 Sint32 default + * @property {number} fixed32=0 Fixed32 default + * @property {number} sfixed32=0 Sfixed32 default + * @property {number} int64=0 Int64 default + * @property {number} uint64=0 Uint64 default + * @property {number} sint64=0 Sint32 default + * @property {number} fixed64=0 Fixed64 default + * @property {number} sfixed64=0 Sfixed64 default + * @property {boolean} bool=false Bool default + * @property {string} string="" String default + * @property {Array.} bytes=Array(0) Bytes default + * @property {null} message=null Message default + */ +types.defaults = bake([ + /* double */ 0, + /* float */ 0, + /* int32 */ 0, + /* uint32 */ 0, + /* sint32 */ 0, + /* fixed32 */ 0, + /* sfixed32 */ 0, + /* int64 */ 0, + /* uint64 */ 0, + /* sint64 */ 0, + /* fixed64 */ 0, + /* sfixed64 */ 0, + /* bool */ false, + /* string */ "", + /* bytes */ util.emptyArray, + /* message */ null +]); + +/** + * Basic long type wire types. + * @type {Object.} + * @const + * @property {number} int64=0 Varint wire type + * @property {number} uint64=0 Varint wire type + * @property {number} sint64=0 Varint wire type + * @property {number} fixed64=1 Fixed64 wire type + * @property {number} sfixed64=1 Fixed64 wire type + */ +types.long = bake([ + /* int64 */ 0, + /* uint64 */ 0, + /* sint64 */ 0, + /* fixed64 */ 1, + /* sfixed64 */ 1 +], 7); + +/** + * Allowed types for map keys with their associated wire type. + * @type {Object.} + * @const + * @property {number} int32=0 Varint wire type + * @property {number} uint32=0 Varint wire type + * @property {number} sint32=0 Varint wire type + * @property {number} fixed32=5 Fixed32 wire type + * @property {number} sfixed32=5 Fixed32 wire type + * @property {number} int64=0 Varint wire type + * @property {number} uint64=0 Varint wire type + * @property {number} sint64=0 Varint wire type + * @property {number} fixed64=1 Fixed64 wire type + * @property {number} sfixed64=1 Fixed64 wire type + * @property {number} bool=0 Varint wire type + * @property {number} string=2 Ldelim wire type + */ +types.mapKey = bake([ + /* int32 */ 0, + /* uint32 */ 0, + /* sint32 */ 0, + /* fixed32 */ 5, + /* sfixed32 */ 5, + /* int64 */ 0, + /* uint64 */ 0, + /* sint64 */ 0, + /* fixed64 */ 1, + /* sfixed64 */ 1, + /* bool */ 0, + /* string */ 2 +], 2); + +/** + * Allowed types for packed repeated fields with their associated wire type. + * @type {Object.} + * @const + * @property {number} double=1 Fixed64 wire type + * @property {number} float=5 Fixed32 wire type + * @property {number} int32=0 Varint wire type + * @property {number} uint32=0 Varint wire type + * @property {number} sint32=0 Varint wire type + * @property {number} fixed32=5 Fixed32 wire type + * @property {number} sfixed32=5 Fixed32 wire type + * @property {number} int64=0 Varint wire type + * @property {number} uint64=0 Varint wire type + * @property {number} sint64=0 Varint wire type + * @property {number} fixed64=1 Fixed64 wire type + * @property {number} sfixed64=1 Fixed64 wire type + * @property {number} bool=0 Varint wire type + */ +types.packed = bake([ + /* double */ 1, + /* float */ 5, + /* int32 */ 0, + /* uint32 */ 0, + /* sint32 */ 0, + /* fixed32 */ 5, + /* sfixed32 */ 5, + /* int64 */ 0, + /* uint64 */ 0, + /* sint64 */ 0, + /* fixed64 */ 1, + /* sfixed64 */ 1, + /* bool */ 0 +]); + +},{"37":37}],37:[function(require,module,exports){ +"use strict"; + +/** + * Various utility functions. + * @namespace + */ +var util = module.exports = require(39); + +var roots = require(30); + +var Type, // cyclic + Enum; + +util.codegen = require(3); +util.fetch = require(5); +util.path = require(8); + +/** + * Node's fs module if available. + * @type {Object.} + */ +util.fs = util.inquire("fs"); + +/** + * Converts an object's values to an array. + * @param {Object.} object Object to convert + * @returns {Array.<*>} Converted array + */ +util.toArray = function toArray(object) { + if (object) { + var keys = Object.keys(object), + array = new Array(keys.length), + index = 0; + while (index < keys.length) + array[index] = object[keys[index++]]; + return array; + } + return []; +}; + +/** + * Converts an array of keys immediately followed by their respective value to an object, omitting undefined values. + * @param {Array.<*>} array Array to convert + * @returns {Object.} Converted object + */ +util.toObject = function toObject(array) { + var object = {}, + index = 0; + while (index < array.length) { + var key = array[index++], + val = array[index++]; + if (val !== undefined) + object[key] = val; + } + return object; +}; + +var safePropBackslashRe = /\\/g, + safePropQuoteRe = /"/g; + +/** + * Tests whether the specified name is a reserved word in JS. + * @param {string} name Name to test + * @returns {boolean} `true` if reserved, otherwise `false` + */ +util.isReserved = function isReserved(name) { + return /^(?:do|if|in|for|let|new|try|var|case|else|enum|eval|false|null|this|true|void|with|break|catch|class|const|super|throw|while|yield|delete|export|import|public|return|static|switch|typeof|default|extends|finally|package|private|continue|debugger|function|arguments|interface|protected|implements|instanceof)$/.test(name); +}; + +/** + * Returns a safe property accessor for the specified property name. + * @param {string} prop Property name + * @returns {string} Safe accessor + */ +util.safeProp = function safeProp(prop) { + if (!/^[$\w_]+$/.test(prop) || util.isReserved(prop)) + return "[\"" + prop.replace(safePropBackslashRe, "\\\\").replace(safePropQuoteRe, "\\\"") + "\"]"; + return "." + prop; +}; + +/** + * Converts the first character of a string to upper case. + * @param {string} str String to convert + * @returns {string} Converted string + */ +util.ucFirst = function ucFirst(str) { + return str.charAt(0).toUpperCase() + str.substring(1); +}; + +var camelCaseRe = /_([a-z])/g; + +/** + * Converts a string to camel case. + * @param {string} str String to convert + * @returns {string} Converted string + */ +util.camelCase = function camelCase(str) { + return str.substring(0, 1) + + str.substring(1) + .replace(camelCaseRe, function($0, $1) { return $1.toUpperCase(); }); +}; + +/** + * Compares reflected fields by id. + * @param {Field} a First field + * @param {Field} b Second field + * @returns {number} Comparison value + */ +util.compareFieldsById = function compareFieldsById(a, b) { + return a.id - b.id; +}; + +/** + * Decorator helper for types (TypeScript). + * @param {Constructor} ctor Constructor function + * @param {string} [typeName] Type name, defaults to the constructor's name + * @returns {Type} Reflected type + * @template T extends Message + * @property {Root} root Decorators root + */ +util.decorateType = function decorateType(ctor, typeName) { + + /* istanbul ignore if */ + if (ctor.$type) { + if (typeName && ctor.$type.name !== typeName) { + util.decorateRoot.remove(ctor.$type); + ctor.$type.name = typeName; + util.decorateRoot.add(ctor.$type); + } + return ctor.$type; + } + + /* istanbul ignore next */ + if (!Type) + Type = require(35); + + var type = new Type(typeName || ctor.name); + util.decorateRoot.add(type); + type.ctor = ctor; // sets up .encode, .decode etc. + Object.defineProperty(ctor, "$type", { value: type, enumerable: false }); + Object.defineProperty(ctor.prototype, "$type", { value: type, enumerable: false }); + return type; +}; + +var decorateEnumIndex = 0; + +/** + * Decorator helper for enums (TypeScript). + * @param {Object} object Enum object + * @returns {Enum} Reflected enum + */ +util.decorateEnum = function decorateEnum(object) { + + /* istanbul ignore if */ + if (object.$type) + return object.$type; + + /* istanbul ignore next */ + if (!Enum) + Enum = require(15); + + var enm = new Enum("Enum" + decorateEnumIndex++, object); + util.decorateRoot.add(enm); + Object.defineProperty(object, "$type", { value: enm, enumerable: false }); + return enm; +}; + +/** + * Decorator root (TypeScript). + * @name util.decorateRoot + * @type {Root} + * @readonly + */ +Object.defineProperty(util, "decorateRoot", { + get: function() { + return roots["decorated"] || (roots["decorated"] = new (require(29))()); + } +}); + +},{"15":15,"29":29,"3":3,"30":30,"35":35,"39":39,"5":5,"8":8}],38:[function(require,module,exports){ +"use strict"; +module.exports = LongBits; + +var util = require(39); + +/** + * Constructs new long bits. + * @classdesc Helper class for working with the low and high bits of a 64 bit value. + * @memberof util + * @constructor + * @param {number} lo Low 32 bits, unsigned + * @param {number} hi High 32 bits, unsigned + */ +function LongBits(lo, hi) { + + // note that the casts below are theoretically unnecessary as of today, but older statically + // generated converter code might still call the ctor with signed 32bits. kept for compat. + + /** + * Low bits. + * @type {number} + */ + this.lo = lo >>> 0; + + /** + * High bits. + * @type {number} + */ + this.hi = hi >>> 0; +} + +/** + * Zero bits. + * @memberof util.LongBits + * @type {util.LongBits} + */ +var zero = LongBits.zero = new LongBits(0, 0); + +zero.toNumber = function() { return 0; }; +zero.zzEncode = zero.zzDecode = function() { return this; }; +zero.length = function() { return 1; }; + +/** + * Zero hash. + * @memberof util.LongBits + * @type {string} + */ +var zeroHash = LongBits.zeroHash = "\0\0\0\0\0\0\0\0"; + +/** + * Constructs new long bits from the specified number. + * @param {number} value Value + * @returns {util.LongBits} Instance + */ +LongBits.fromNumber = function fromNumber(value) { + if (value === 0) + return zero; + var sign = value < 0; + if (sign) + value = -value; + var lo = value >>> 0, + hi = (value - lo) / 4294967296 >>> 0; + if (sign) { + hi = ~hi >>> 0; + lo = ~lo >>> 0; + if (++lo > 4294967295) { + lo = 0; + if (++hi > 4294967295) + hi = 0; + } + } + return new LongBits(lo, hi); +}; + +/** + * Constructs new long bits from a number, long or string. + * @param {Long|number|string} value Value + * @returns {util.LongBits} Instance + */ +LongBits.from = function from(value) { + if (typeof value === "number") + return LongBits.fromNumber(value); + if (util.isString(value)) { + /* istanbul ignore else */ + if (util.Long) + value = util.Long.fromString(value); + else + return LongBits.fromNumber(parseInt(value, 10)); + } + return value.low || value.high ? new LongBits(value.low >>> 0, value.high >>> 0) : zero; +}; + +/** + * Converts this long bits to a possibly unsafe JavaScript number. + * @param {boolean} [unsigned=false] Whether unsigned or not + * @returns {number} Possibly unsafe number + */ +LongBits.prototype.toNumber = function toNumber(unsigned) { + if (!unsigned && this.hi >>> 31) { + var lo = ~this.lo + 1 >>> 0, + hi = ~this.hi >>> 0; + if (!lo) + hi = hi + 1 >>> 0; + return -(lo + hi * 4294967296); + } + return this.lo + this.hi * 4294967296; +}; + +/** + * Converts this long bits to a long. + * @param {boolean} [unsigned=false] Whether unsigned or not + * @returns {Long} Long + */ +LongBits.prototype.toLong = function toLong(unsigned) { + return util.Long + ? new util.Long(this.lo | 0, this.hi | 0, Boolean(unsigned)) + /* istanbul ignore next */ + : { low: this.lo | 0, high: this.hi | 0, unsigned: Boolean(unsigned) }; +}; + +var charCodeAt = String.prototype.charCodeAt; + +/** + * Constructs new long bits from the specified 8 characters long hash. + * @param {string} hash Hash + * @returns {util.LongBits} Bits + */ +LongBits.fromHash = function fromHash(hash) { + if (hash === zeroHash) + return zero; + return new LongBits( + ( charCodeAt.call(hash, 0) + | charCodeAt.call(hash, 1) << 8 + | charCodeAt.call(hash, 2) << 16 + | charCodeAt.call(hash, 3) << 24) >>> 0 + , + ( charCodeAt.call(hash, 4) + | charCodeAt.call(hash, 5) << 8 + | charCodeAt.call(hash, 6) << 16 + | charCodeAt.call(hash, 7) << 24) >>> 0 + ); +}; + +/** + * Converts this long bits to a 8 characters long hash. + * @returns {string} Hash + */ +LongBits.prototype.toHash = function toHash() { + return String.fromCharCode( + this.lo & 255, + this.lo >>> 8 & 255, + this.lo >>> 16 & 255, + this.lo >>> 24 , + this.hi & 255, + this.hi >>> 8 & 255, + this.hi >>> 16 & 255, + this.hi >>> 24 + ); +}; + +/** + * Zig-zag encodes this long bits. + * @returns {util.LongBits} `this` + */ +LongBits.prototype.zzEncode = function zzEncode() { + var mask = this.hi >> 31; + this.hi = ((this.hi << 1 | this.lo >>> 31) ^ mask) >>> 0; + this.lo = ( this.lo << 1 ^ mask) >>> 0; + return this; +}; + +/** + * Zig-zag decodes this long bits. + * @returns {util.LongBits} `this` + */ +LongBits.prototype.zzDecode = function zzDecode() { + var mask = -(this.lo & 1); + this.lo = ((this.lo >>> 1 | this.hi << 31) ^ mask) >>> 0; + this.hi = ( this.hi >>> 1 ^ mask) >>> 0; + return this; +}; + +/** + * Calculates the length of this longbits when encoded as a varint. + * @returns {number} Length + */ +LongBits.prototype.length = function length() { + var part0 = this.lo, + part1 = (this.lo >>> 28 | this.hi << 4) >>> 0, + part2 = this.hi >>> 24; + return part2 === 0 + ? part1 === 0 + ? part0 < 16384 + ? part0 < 128 ? 1 : 2 + : part0 < 2097152 ? 3 : 4 + : part1 < 16384 + ? part1 < 128 ? 5 : 6 + : part1 < 2097152 ? 7 : 8 + : part2 < 128 ? 9 : 10; +}; + +},{"39":39}],39:[function(require,module,exports){ +"use strict"; +var util = exports; + +// used to return a Promise where callback is omitted +util.asPromise = require(1); + +// converts to / from base64 encoded strings +util.base64 = require(2); + +// base class of rpc.Service +util.EventEmitter = require(4); + +// float handling accross browsers +util.float = require(6); + +// requires modules optionally and hides the call from bundlers +util.inquire = require(7); + +// converts to / from utf8 encoded strings +util.utf8 = require(10); + +// provides a node-like buffer pool in the browser +util.pool = require(9); + +// utility to work with the low and high bits of a 64 bit value +util.LongBits = require(38); + +// global object reference +util.global = typeof window !== "undefined" && window + || typeof global !== "undefined" && global + || typeof self !== "undefined" && self + || this; // eslint-disable-line no-invalid-this + +/** + * An immuable empty array. + * @memberof util + * @type {Array.<*>} + * @const + */ +util.emptyArray = Object.freeze ? Object.freeze([]) : /* istanbul ignore next */ []; // used on prototypes + +/** + * An immutable empty object. + * @type {Object} + * @const + */ +util.emptyObject = Object.freeze ? Object.freeze({}) : /* istanbul ignore next */ {}; // used on prototypes + +/** + * Whether running within node or not. + * @memberof util + * @type {boolean} + * @const + */ +util.isNode = Boolean(util.global.process && util.global.process.versions && util.global.process.versions.node); + +/** + * Tests if the specified value is an integer. + * @function + * @param {*} value Value to test + * @returns {boolean} `true` if the value is an integer + */ +util.isInteger = Number.isInteger || /* istanbul ignore next */ function isInteger(value) { + return typeof value === "number" && isFinite(value) && Math.floor(value) === value; +}; + +/** + * Tests if the specified value is a string. + * @param {*} value Value to test + * @returns {boolean} `true` if the value is a string + */ +util.isString = function isString(value) { + return typeof value === "string" || value instanceof String; +}; + +/** + * Tests if the specified value is a non-null object. + * @param {*} value Value to test + * @returns {boolean} `true` if the value is a non-null object + */ +util.isObject = function isObject(value) { + return value && typeof value === "object"; +}; + +/** + * Checks if a property on a message is considered to be present. + * This is an alias of {@link util.isSet}. + * @function + * @param {Object} obj Plain object or message instance + * @param {string} prop Property name + * @returns {boolean} `true` if considered to be present, otherwise `false` + */ +util.isset = + +/** + * Checks if a property on a message is considered to be present. + * @param {Object} obj Plain object or message instance + * @param {string} prop Property name + * @returns {boolean} `true` if considered to be present, otherwise `false` + */ +util.isSet = function isSet(obj, prop) { + var value = obj[prop]; + if (value != null && obj.hasOwnProperty(prop)) // eslint-disable-line eqeqeq, no-prototype-builtins + return typeof value !== "object" || (Array.isArray(value) ? value.length : Object.keys(value).length) > 0; + return false; +}; + +/** + * Any compatible Buffer instance. + * This is a minimal stand-alone definition of a Buffer instance. The actual type is that exported by node's typings. + * @interface Buffer + * @extends Uint8Array + */ + +/** + * Node's Buffer class if available. + * @type {Constructor} + */ +util.Buffer = (function() { + try { + var Buffer = util.inquire("buffer").Buffer; + // refuse to use non-node buffers if not explicitly assigned (perf reasons): + return Buffer.prototype.utf8Write ? Buffer : /* istanbul ignore next */ null; + } catch (e) { + /* istanbul ignore next */ + return null; + } +})(); + +// Internal alias of or polyfull for Buffer.from. +util._Buffer_from = null; + +// Internal alias of or polyfill for Buffer.allocUnsafe. +util._Buffer_allocUnsafe = null; + +/** + * Creates a new buffer of whatever type supported by the environment. + * @param {number|number[]} [sizeOrArray=0] Buffer size or number array + * @returns {Uint8Array|Buffer} Buffer + */ +util.newBuffer = function newBuffer(sizeOrArray) { + /* istanbul ignore next */ + return typeof sizeOrArray === "number" + ? util.Buffer + ? util._Buffer_allocUnsafe(sizeOrArray) + : new util.Array(sizeOrArray) + : util.Buffer + ? util._Buffer_from(sizeOrArray) + : typeof Uint8Array === "undefined" + ? sizeOrArray + : new Uint8Array(sizeOrArray); +}; + +/** + * Array implementation used in the browser. `Uint8Array` if supported, otherwise `Array`. + * @type {Constructor} + */ +util.Array = typeof Uint8Array !== "undefined" ? Uint8Array /* istanbul ignore next */ : Array; + +/** + * Any compatible Long instance. + * This is a minimal stand-alone definition of a Long instance. The actual type is that exported by long.js. + * @interface Long + * @property {number} low Low bits + * @property {number} high High bits + * @property {boolean} unsigned Whether unsigned or not + */ + +/** + * Long.js's Long class if available. + * @type {Constructor} + */ +util.Long = /* istanbul ignore next */ util.global.dcodeIO && /* istanbul ignore next */ util.global.dcodeIO.Long + || /* istanbul ignore next */ util.global.Long + || util.inquire("long"); + +/** + * Regular expression used to verify 2 bit (`bool`) map keys. + * @type {RegExp} + * @const + */ +util.key2Re = /^true|false|0|1$/; + +/** + * Regular expression used to verify 32 bit (`int32` etc.) map keys. + * @type {RegExp} + * @const + */ +util.key32Re = /^-?(?:0|[1-9][0-9]*)$/; + +/** + * Regular expression used to verify 64 bit (`int64` etc.) map keys. + * @type {RegExp} + * @const + */ +util.key64Re = /^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/; + +/** + * Converts a number or long to an 8 characters long hash string. + * @param {Long|number} value Value to convert + * @returns {string} Hash + */ +util.longToHash = function longToHash(value) { + return value + ? util.LongBits.from(value).toHash() + : util.LongBits.zeroHash; +}; + +/** + * Converts an 8 characters long hash string to a long or number. + * @param {string} hash Hash + * @param {boolean} [unsigned=false] Whether unsigned or not + * @returns {Long|number} Original value + */ +util.longFromHash = function longFromHash(hash, unsigned) { + var bits = util.LongBits.fromHash(hash); + if (util.Long) + return util.Long.fromBits(bits.lo, bits.hi, unsigned); + return bits.toNumber(Boolean(unsigned)); +}; + +/** + * Merges the properties of the source object into the destination object. + * @memberof util + * @param {Object.} dst Destination object + * @param {Object.} src Source object + * @param {boolean} [ifNotSet=false] Merges only if the key is not already set + * @returns {Object.} Destination object + */ +function merge(dst, src, ifNotSet) { // used by converters + for (var keys = Object.keys(src), i = 0; i < keys.length; ++i) + if (dst[keys[i]] === undefined || !ifNotSet) + dst[keys[i]] = src[keys[i]]; + return dst; +} + +util.merge = merge; + +/** + * Converts the first character of a string to lower case. + * @param {string} str String to convert + * @returns {string} Converted string + */ +util.lcFirst = function lcFirst(str) { + return str.charAt(0).toLowerCase() + str.substring(1); +}; + +/** + * Creates a custom error constructor. + * @memberof util + * @param {string} name Error name + * @returns {Constructor} Custom error constructor + */ +function newError(name) { + + function CustomError(message, properties) { + + if (!(this instanceof CustomError)) + return new CustomError(message, properties); + + // Error.call(this, message); + // ^ just returns a new error instance because the ctor can be called as a function + + Object.defineProperty(this, "message", { get: function() { return message; } }); + + /* istanbul ignore next */ + if (Error.captureStackTrace) // node + Error.captureStackTrace(this, CustomError); + else + Object.defineProperty(this, "stack", { value: (new Error()).stack || "" }); + + if (properties) + merge(this, properties); + } + + (CustomError.prototype = Object.create(Error.prototype)).constructor = CustomError; + + Object.defineProperty(CustomError.prototype, "name", { get: function() { return name; } }); + + CustomError.prototype.toString = function toString() { + return this.name + ": " + this.message; + }; + + return CustomError; +} + +util.newError = newError; + +/** + * Constructs a new protocol error. + * @classdesc Error subclass indicating a protocol specifc error. + * @memberof util + * @extends Error + * @template T extends Message + * @constructor + * @param {string} message Error message + * @param {Object.} [properties] Additional properties + * @example + * try { + * MyMessage.decode(someBuffer); // throws if required fields are missing + * } catch (e) { + * if (e instanceof ProtocolError && e.instance) + * console.log("decoded so far: " + JSON.stringify(e.instance)); + * } + */ +util.ProtocolError = newError("ProtocolError"); + +/** + * So far decoded message instance. + * @name util.ProtocolError#instance + * @type {Message} + */ + +/** + * A OneOf getter as returned by {@link util.oneOfGetter}. + * @typedef OneOfGetter + * @type {function} + * @returns {string|undefined} Set field name, if any + */ + +/** + * Builds a getter for a oneof's present field name. + * @param {string[]} fieldNames Field names + * @returns {OneOfGetter} Unbound getter + */ +util.oneOfGetter = function getOneOf(fieldNames) { + var fieldMap = {}; + for (var i = 0; i < fieldNames.length; ++i) + fieldMap[fieldNames[i]] = 1; + + /** + * @returns {string|undefined} Set field name, if any + * @this Object + * @ignore + */ + return function() { // eslint-disable-line consistent-return + for (var keys = Object.keys(this), i = keys.length - 1; i > -1; --i) + if (fieldMap[keys[i]] === 1 && this[keys[i]] !== undefined && this[keys[i]] !== null) + return keys[i]; + }; +}; + +/** + * A OneOf setter as returned by {@link util.oneOfSetter}. + * @typedef OneOfSetter + * @type {function} + * @param {string|undefined} value Field name + * @returns {undefined} + */ + +/** + * Builds a setter for a oneof's present field name. + * @param {string[]} fieldNames Field names + * @returns {OneOfSetter} Unbound setter + */ +util.oneOfSetter = function setOneOf(fieldNames) { + + /** + * @param {string} name Field name + * @returns {undefined} + * @this Object + * @ignore + */ + return function(name) { + for (var i = 0; i < fieldNames.length; ++i) + if (fieldNames[i] !== name) + delete this[fieldNames[i]]; + }; +}; + +/** + * Default conversion options used for {@link Message#toJSON} implementations. + * + * These options are close to proto3's JSON mapping with the exception that internal types like Any are handled just like messages. More precisely: + * + * - Longs become strings + * - Enums become string keys + * - Bytes become base64 encoded strings + * - (Sub-)Messages become plain objects + * - Maps become plain objects with all string keys + * - Repeated fields become arrays + * - NaN and Infinity for float and double fields become strings + * + * @type {IConversionOptions} + * @see https://developers.google.com/protocol-buffers/docs/proto3?hl=en#json + */ +util.toJSONOptions = { + longs: String, + enums: String, + bytes: String, + json: true +}; + +// Sets up buffer utility according to the environment (called in index-minimal) +util._configure = function() { + var Buffer = util.Buffer; + /* istanbul ignore if */ + if (!Buffer) { + util._Buffer_from = util._Buffer_allocUnsafe = null; + return; + } + // because node 4.x buffers are incompatible & immutable + // see: https://github.com/dcodeIO/protobuf.js/pull/665 + util._Buffer_from = Buffer.from !== Uint8Array.from && Buffer.from || + /* istanbul ignore next */ + function Buffer_from(value, encoding) { + return new Buffer(value, encoding); + }; + util._Buffer_allocUnsafe = Buffer.allocUnsafe || + /* istanbul ignore next */ + function Buffer_allocUnsafe(size) { + return new Buffer(size); + }; +}; + +},{"1":1,"10":10,"2":2,"38":38,"4":4,"6":6,"7":7,"9":9}],40:[function(require,module,exports){ +"use strict"; +module.exports = verifier; + +var Enum = require(15), + util = require(37); + +function invalid(field, expected) { + return field.name + ": " + expected + (field.repeated && expected !== "array" ? "[]" : field.map && expected !== "object" ? "{k:"+field.keyType+"}" : "") + " expected"; +} + +/** + * Generates a partial value verifier. + * @param {Codegen} gen Codegen instance + * @param {Field} field Reflected field + * @param {number} fieldIndex Field index + * @param {string} ref Variable reference + * @returns {Codegen} Codegen instance + * @ignore + */ +function genVerifyValue(gen, field, fieldIndex, ref) { + /* eslint-disable no-unexpected-multiline */ + if (field.resolvedType) { + if (field.resolvedType instanceof Enum) { gen + ("switch(%s){", ref) + ("default:") + ("return%j", invalid(field, "enum value")); + for (var keys = Object.keys(field.resolvedType.values), j = 0; j < keys.length; ++j) gen + ("case %i:", field.resolvedType.values[keys[j]]); + gen + ("break") + ("}"); + } else { + gen + ("{") + ("var e=types[%i].verify(%s);", fieldIndex, ref) + ("if(e)") + ("return%j+e", field.name + ".") + ("}"); + } + } else { + switch (field.type) { + case "int32": + case "uint32": + case "sint32": + case "fixed32": + case "sfixed32": gen + ("if(!util.isInteger(%s))", ref) + ("return%j", invalid(field, "integer")); + break; + case "int64": + case "uint64": + case "sint64": + case "fixed64": + case "sfixed64": gen + ("if(!util.isInteger(%s)&&!(%s&&util.isInteger(%s.low)&&util.isInteger(%s.high)))", ref, ref, ref, ref) + ("return%j", invalid(field, "integer|Long")); + break; + case "float": + case "double": gen + ("if(typeof %s!==\"number\")", ref) + ("return%j", invalid(field, "number")); + break; + case "bool": gen + ("if(typeof %s!==\"boolean\")", ref) + ("return%j", invalid(field, "boolean")); + break; + case "string": gen + ("if(!util.isString(%s))", ref) + ("return%j", invalid(field, "string")); + break; + case "bytes": gen + ("if(!(%s&&typeof %s.length===\"number\"||util.isString(%s)))", ref, ref, ref) + ("return%j", invalid(field, "buffer")); + break; + } + } + return gen; + /* eslint-enable no-unexpected-multiline */ +} + +/** + * Generates a partial key verifier. + * @param {Codegen} gen Codegen instance + * @param {Field} field Reflected field + * @param {string} ref Variable reference + * @returns {Codegen} Codegen instance + * @ignore + */ +function genVerifyKey(gen, field, ref) { + /* eslint-disable no-unexpected-multiline */ + switch (field.keyType) { + case "int32": + case "uint32": + case "sint32": + case "fixed32": + case "sfixed32": gen + ("if(!util.key32Re.test(%s))", ref) + ("return%j", invalid(field, "integer key")); + break; + case "int64": + case "uint64": + case "sint64": + case "fixed64": + case "sfixed64": gen + ("if(!util.key64Re.test(%s))", ref) // see comment above: x is ok, d is not + ("return%j", invalid(field, "integer|Long key")); + break; + case "bool": gen + ("if(!util.key2Re.test(%s))", ref) + ("return%j", invalid(field, "boolean key")); + break; + } + return gen; + /* eslint-enable no-unexpected-multiline */ +} + +/** + * Generates a verifier specific to the specified message type. + * @param {Type} mtype Message type + * @returns {Codegen} Codegen instance + */ +function verifier(mtype) { + /* eslint-disable no-unexpected-multiline */ + + var gen = util.codegen(["m"], mtype.name + "$verify") + ("if(typeof m!==\"object\"||m===null)") + ("return%j", "object expected"); + var oneofs = mtype.oneofsArray, + seenFirstField = {}; + if (oneofs.length) gen + ("var p={}"); + + for (var i = 0; i < /* initializes */ mtype.fieldsArray.length; ++i) { + var field = mtype._fieldsArray[i].resolve(), + ref = "m" + util.safeProp(field.name); + + if (field.optional) gen + ("if(%s!=null&&m.hasOwnProperty(%j)){", ref, field.name); // !== undefined && !== null + + // map fields + if (field.map) { gen + ("if(!util.isObject(%s))", ref) + ("return%j", invalid(field, "object")) + ("var k=Object.keys(%s)", ref) + ("for(var i=0;i} + * @const + */ +var wrappers = exports; + +var Message = require(21); + +/** + * From object converter part of an {@link IWrapper}. + * @typedef WrapperFromObjectConverter + * @type {function} + * @param {Object.} object Plain object + * @returns {Message<{}>} Message instance + * @this Type + */ + +/** + * To object converter part of an {@link IWrapper}. + * @typedef WrapperToObjectConverter + * @type {function} + * @param {Message<{}>} message Message instance + * @param {IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + * @this Type + */ + +/** + * Common type wrapper part of {@link wrappers}. + * @interface IWrapper + * @property {WrapperFromObjectConverter} [fromObject] From object converter + * @property {WrapperToObjectConverter} [toObject] To object converter + */ + +// Custom wrapper for Any +wrappers[".google.protobuf.Any"] = { + + fromObject: function(object) { + + // unwrap value type if mapped + if (object && object["@type"]) { + var type = this.lookup(object["@type"]); + /* istanbul ignore else */ + if (type) { + // type_url does not accept leading "." + var type_url = object["@type"].charAt(0) === "." ? + object["@type"].substr(1) : object["@type"]; + // type_url prefix is optional, but path seperator is required + return this.create({ + type_url: "/" + type_url, + value: type.encode(type.fromObject(object)).finish() + }); + } + } + + return this.fromObject(object); + }, + + toObject: function(message, options) { + + // decode value if requested and unmapped + if (options && options.json && message.type_url && message.value) { + // Only use fully qualified type name after the last '/' + var name = message.type_url.substring(message.type_url.lastIndexOf("/") + 1); + var type = this.lookup(name); + /* istanbul ignore else */ + if (type) + message = type.decode(message.value); + } + + // wrap value if unmapped + if (!(message instanceof this.ctor) && message instanceof Message) { + var object = message.$type.toObject(message, options); + object["@type"] = message.$type.fullName; + return object; + } + + return this.toObject(message, options); + } +}; + +},{"21":21}],42:[function(require,module,exports){ +"use strict"; +module.exports = Writer; + +var util = require(39); + +var BufferWriter; // cyclic + +var LongBits = util.LongBits, + base64 = util.base64, + utf8 = util.utf8; + +/** + * Constructs a new writer operation instance. + * @classdesc Scheduled writer operation. + * @constructor + * @param {function(*, Uint8Array, number)} fn Function to call + * @param {number} len Value byte length + * @param {*} val Value to write + * @ignore + */ +function Op(fn, len, val) { + + /** + * Function to call. + * @type {function(Uint8Array, number, *)} + */ + this.fn = fn; + + /** + * Value byte length. + * @type {number} + */ + this.len = len; + + /** + * Next operation. + * @type {Writer.Op|undefined} + */ + this.next = undefined; + + /** + * Value to write. + * @type {*} + */ + this.val = val; // type varies +} + +/* istanbul ignore next */ +function noop() {} // eslint-disable-line no-empty-function + +/** + * Constructs a new writer state instance. + * @classdesc Copied writer state. + * @memberof Writer + * @constructor + * @param {Writer} writer Writer to copy state from + * @ignore + */ +function State(writer) { + + /** + * Current head. + * @type {Writer.Op} + */ + this.head = writer.head; + + /** + * Current tail. + * @type {Writer.Op} + */ + this.tail = writer.tail; + + /** + * Current buffer length. + * @type {number} + */ + this.len = writer.len; + + /** + * Next state. + * @type {State|null} + */ + this.next = writer.states; +} + +/** + * Constructs a new writer instance. + * @classdesc Wire format writer using `Uint8Array` if available, otherwise `Array`. + * @constructor + */ +function Writer() { + + /** + * Current length. + * @type {number} + */ + this.len = 0; + + /** + * Operations head. + * @type {Object} + */ + this.head = new Op(noop, 0, 0); + + /** + * Operations tail + * @type {Object} + */ + this.tail = this.head; + + /** + * Linked forked states. + * @type {Object|null} + */ + this.states = null; + + // When a value is written, the writer calculates its byte length and puts it into a linked + // list of operations to perform when finish() is called. This both allows us to allocate + // buffers of the exact required size and reduces the amount of work we have to do compared + // to first calculating over objects and then encoding over objects. In our case, the encoding + // part is just a linked list walk calling operations with already prepared values. +} + +/** + * Creates a new writer. + * @function + * @returns {BufferWriter|Writer} A {@link BufferWriter} when Buffers are supported, otherwise a {@link Writer} + */ +Writer.create = util.Buffer + ? function create_buffer_setup() { + return (Writer.create = function create_buffer() { + return new BufferWriter(); + })(); + } + /* istanbul ignore next */ + : function create_array() { + return new Writer(); + }; + +/** + * Allocates a buffer of the specified size. + * @param {number} size Buffer size + * @returns {Uint8Array} Buffer + */ +Writer.alloc = function alloc(size) { + return new util.Array(size); +}; + +// Use Uint8Array buffer pool in the browser, just like node does with buffers +/* istanbul ignore else */ +if (util.Array !== Array) + Writer.alloc = util.pool(Writer.alloc, util.Array.prototype.subarray); + +/** + * Pushes a new operation to the queue. + * @param {function(Uint8Array, number, *)} fn Function to call + * @param {number} len Value byte length + * @param {number} val Value to write + * @returns {Writer} `this` + * @private + */ +Writer.prototype._push = function push(fn, len, val) { + this.tail = this.tail.next = new Op(fn, len, val); + this.len += len; + return this; +}; + +function writeByte(val, buf, pos) { + buf[pos] = val & 255; +} + +function writeVarint32(val, buf, pos) { + while (val > 127) { + buf[pos++] = val & 127 | 128; + val >>>= 7; + } + buf[pos] = val; +} + +/** + * Constructs a new varint writer operation instance. + * @classdesc Scheduled varint writer operation. + * @extends Op + * @constructor + * @param {number} len Value byte length + * @param {number} val Value to write + * @ignore + */ +function VarintOp(len, val) { + this.len = len; + this.next = undefined; + this.val = val; +} + +VarintOp.prototype = Object.create(Op.prototype); +VarintOp.prototype.fn = writeVarint32; + +/** + * Writes an unsigned 32 bit value as a varint. + * @param {number} value Value to write + * @returns {Writer} `this` + */ +Writer.prototype.uint32 = function write_uint32(value) { + // here, the call to this.push has been inlined and a varint specific Op subclass is used. + // uint32 is by far the most frequently used operation and benefits significantly from this. + this.len += (this.tail = this.tail.next = new VarintOp( + (value = value >>> 0) + < 128 ? 1 + : value < 16384 ? 2 + : value < 2097152 ? 3 + : value < 268435456 ? 4 + : 5, + value)).len; + return this; +}; + +/** + * Writes a signed 32 bit value as a varint. + * @function + * @param {number} value Value to write + * @returns {Writer} `this` + */ +Writer.prototype.int32 = function write_int32(value) { + return value < 0 + ? this._push(writeVarint64, 10, LongBits.fromNumber(value)) // 10 bytes per spec + : this.uint32(value); +}; + +/** + * Writes a 32 bit value as a varint, zig-zag encoded. + * @param {number} value Value to write + * @returns {Writer} `this` + */ +Writer.prototype.sint32 = function write_sint32(value) { + return this.uint32((value << 1 ^ value >> 31) >>> 0); +}; + +function writeVarint64(val, buf, pos) { + while (val.hi) { + buf[pos++] = val.lo & 127 | 128; + val.lo = (val.lo >>> 7 | val.hi << 25) >>> 0; + val.hi >>>= 7; + } + while (val.lo > 127) { + buf[pos++] = val.lo & 127 | 128; + val.lo = val.lo >>> 7; + } + buf[pos++] = val.lo; +} + +/** + * Writes an unsigned 64 bit value as a varint. + * @param {Long|number|string} value Value to write + * @returns {Writer} `this` + * @throws {TypeError} If `value` is a string and no long library is present. + */ +Writer.prototype.uint64 = function write_uint64(value) { + var bits = LongBits.from(value); + return this._push(writeVarint64, bits.length(), bits); +}; + +/** + * Writes a signed 64 bit value as a varint. + * @function + * @param {Long|number|string} value Value to write + * @returns {Writer} `this` + * @throws {TypeError} If `value` is a string and no long library is present. + */ +Writer.prototype.int64 = Writer.prototype.uint64; + +/** + * Writes a signed 64 bit value as a varint, zig-zag encoded. + * @param {Long|number|string} value Value to write + * @returns {Writer} `this` + * @throws {TypeError} If `value` is a string and no long library is present. + */ +Writer.prototype.sint64 = function write_sint64(value) { + var bits = LongBits.from(value).zzEncode(); + return this._push(writeVarint64, bits.length(), bits); +}; + +/** + * Writes a boolish value as a varint. + * @param {boolean} value Value to write + * @returns {Writer} `this` + */ +Writer.prototype.bool = function write_bool(value) { + return this._push(writeByte, 1, value ? 1 : 0); +}; + +function writeFixed32(val, buf, pos) { + buf[pos ] = val & 255; + buf[pos + 1] = val >>> 8 & 255; + buf[pos + 2] = val >>> 16 & 255; + buf[pos + 3] = val >>> 24; +} + +/** + * Writes an unsigned 32 bit value as fixed 32 bits. + * @param {number} value Value to write + * @returns {Writer} `this` + */ +Writer.prototype.fixed32 = function write_fixed32(value) { + return this._push(writeFixed32, 4, value >>> 0); +}; + +/** + * Writes a signed 32 bit value as fixed 32 bits. + * @function + * @param {number} value Value to write + * @returns {Writer} `this` + */ +Writer.prototype.sfixed32 = Writer.prototype.fixed32; + +/** + * Writes an unsigned 64 bit value as fixed 64 bits. + * @param {Long|number|string} value Value to write + * @returns {Writer} `this` + * @throws {TypeError} If `value` is a string and no long library is present. + */ +Writer.prototype.fixed64 = function write_fixed64(value) { + var bits = LongBits.from(value); + return this._push(writeFixed32, 4, bits.lo)._push(writeFixed32, 4, bits.hi); +}; + +/** + * Writes a signed 64 bit value as fixed 64 bits. + * @function + * @param {Long|number|string} value Value to write + * @returns {Writer} `this` + * @throws {TypeError} If `value` is a string and no long library is present. + */ +Writer.prototype.sfixed64 = Writer.prototype.fixed64; + +/** + * Writes a float (32 bit). + * @function + * @param {number} value Value to write + * @returns {Writer} `this` + */ +Writer.prototype.float = function write_float(value) { + return this._push(util.float.writeFloatLE, 4, value); +}; + +/** + * Writes a double (64 bit float). + * @function + * @param {number} value Value to write + * @returns {Writer} `this` + */ +Writer.prototype.double = function write_double(value) { + return this._push(util.float.writeDoubleLE, 8, value); +}; + +var writeBytes = util.Array.prototype.set + ? function writeBytes_set(val, buf, pos) { + buf.set(val, pos); // also works for plain array values + } + /* istanbul ignore next */ + : function writeBytes_for(val, buf, pos) { + for (var i = 0; i < val.length; ++i) + buf[pos + i] = val[i]; + }; + +/** + * Writes a sequence of bytes. + * @param {Uint8Array|string} value Buffer or base64 encoded string to write + * @returns {Writer} `this` + */ +Writer.prototype.bytes = function write_bytes(value) { + var len = value.length >>> 0; + if (!len) + return this._push(writeByte, 1, 0); + if (util.isString(value)) { + var buf = Writer.alloc(len = base64.length(value)); + base64.decode(value, buf, 0); + value = buf; + } + return this.uint32(len)._push(writeBytes, len, value); +}; + +/** + * Writes a string. + * @param {string} value Value to write + * @returns {Writer} `this` + */ +Writer.prototype.string = function write_string(value) { + var len = utf8.length(value); + return len + ? this.uint32(len)._push(utf8.write, len, value) + : this._push(writeByte, 1, 0); +}; + +/** + * Forks this writer's state by pushing it to a stack. + * Calling {@link Writer#reset|reset} or {@link Writer#ldelim|ldelim} resets the writer to the previous state. + * @returns {Writer} `this` + */ +Writer.prototype.fork = function fork() { + this.states = new State(this); + this.head = this.tail = new Op(noop, 0, 0); + this.len = 0; + return this; +}; + +/** + * Resets this instance to the last state. + * @returns {Writer} `this` + */ +Writer.prototype.reset = function reset() { + if (this.states) { + this.head = this.states.head; + this.tail = this.states.tail; + this.len = this.states.len; + this.states = this.states.next; + } else { + this.head = this.tail = new Op(noop, 0, 0); + this.len = 0; + } + return this; +}; + +/** + * Resets to the last state and appends the fork state's current write length as a varint followed by its operations. + * @returns {Writer} `this` + */ +Writer.prototype.ldelim = function ldelim() { + var head = this.head, + tail = this.tail, + len = this.len; + this.reset().uint32(len); + if (len) { + this.tail.next = head.next; // skip noop + this.tail = tail; + this.len += len; + } + return this; +}; + +/** + * Finishes the write operation. + * @returns {Uint8Array} Finished buffer + */ +Writer.prototype.finish = function finish() { + var head = this.head.next, // skip noop + buf = this.constructor.alloc(this.len), + pos = 0; + while (head) { + head.fn(head.val, buf, pos); + pos += head.len; + head = head.next; + } + // this.head = this.tail = null; + return buf; +}; + +Writer._configure = function(BufferWriter_) { + BufferWriter = BufferWriter_; +}; + +},{"39":39}],43:[function(require,module,exports){ +"use strict"; +module.exports = BufferWriter; + +// extends Writer +var Writer = require(42); +(BufferWriter.prototype = Object.create(Writer.prototype)).constructor = BufferWriter; + +var util = require(39); + +var Buffer = util.Buffer; + +/** + * Constructs a new buffer writer instance. + * @classdesc Wire format writer using node buffers. + * @extends Writer + * @constructor + */ +function BufferWriter() { + Writer.call(this); +} + +/** + * Allocates a buffer of the specified size. + * @param {number} size Buffer size + * @returns {Buffer} Buffer + */ +BufferWriter.alloc = function alloc_buffer(size) { + return (BufferWriter.alloc = util._Buffer_allocUnsafe)(size); +}; + +var writeBytesBuffer = Buffer && Buffer.prototype instanceof Uint8Array && Buffer.prototype.set.name === "set" + ? function writeBytesBuffer_set(val, buf, pos) { + buf.set(val, pos); // faster than copy (requires node >= 4 where Buffers extend Uint8Array and set is properly inherited) + // also works for plain array values + } + /* istanbul ignore next */ + : function writeBytesBuffer_copy(val, buf, pos) { + if (val.copy) // Buffer values + val.copy(buf, pos, 0, val.length); + else for (var i = 0; i < val.length;) // plain array values + buf[pos++] = val[i++]; + }; + +/** + * @override + */ +BufferWriter.prototype.bytes = function write_bytes_buffer(value) { + if (util.isString(value)) + value = util._Buffer_from(value, "base64"); + var len = value.length >>> 0; + this.uint32(len); + if (len) + this._push(writeBytesBuffer, len, value); + return this; +}; + +function writeStringBuffer(val, buf, pos) { + if (val.length < 40) // plain js is faster for short strings (probably due to redundant assertions) + util.utf8.write(val, buf, pos); + else + buf.utf8Write(val, pos); +} + +/** + * @override + */ +BufferWriter.prototype.string = function write_string_buffer(value) { + var len = Buffer.byteLength(value); + this.uint32(len); + if (len) + this._push(writeStringBuffer, len, value); + return this; +}; + + +/** + * Finishes the write operation. + * @name BufferWriter#finish + * @function + * @returns {Buffer} Finished buffer + */ + +},{"39":39,"42":42}]},{},[19]) + +})(); +//# sourceMappingURL=protobuf.js.map diff --git a/frontend/assets/scripts/modules/protobuf-with-floating-num-decoding-endianess-toggle.js.meta b/frontend/assets/scripts/modules/protobuf-with-floating-num-decoding-endianess-toggle.js.meta new file mode 100644 index 0000000..1f79d7b --- /dev/null +++ b/frontend/assets/scripts/modules/protobuf-with-floating-num-decoding-endianess-toggle.js.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.5", + "uuid": "f9cd97f6-3533-4a27-afc8-cf302da003b2", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/scripts/modules/protobuf.js.map b/frontend/assets/scripts/modules/protobuf.js.map new file mode 100644 index 0000000..d00d017 --- /dev/null +++ b/frontend/assets/scripts/modules/protobuf.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["lib/prelude.js","../node_modules/@protobufjs/aspromise/index.js","../node_modules/@protobufjs/base64/index.js","../node_modules/@protobufjs/codegen/index.js","../node_modules/@protobufjs/eventemitter/index.js","../node_modules/@protobufjs/fetch/index.js","../node_modules/@protobufjs/float/index.js","../node_modules/@protobufjs/inquire/index.js","../node_modules/@protobufjs/path/index.js","../node_modules/@protobufjs/pool/index.js","../node_modules/@protobufjs/utf8/index.js","../src/common.js","../src/converter.js","../src/decoder.js","../src/encoder.js","../src/enum.js","../src/field.js","../src/index-light.js","../src/index-minimal.js","../src/index","../src/mapfield.js","../src/message.js","../src/method.js","../src/namespace.js","../src/object.js","../src/oneof.js","../src/parse.js","../src/reader.js","../src/reader_buffer.js","../src/root.js","../src/roots.js","../src/rpc.js","../src/rpc/service.js","../src/service.js","../src/tokenize.js","../src/type.js","../src/types.js","../src/util.js","../src/util/longbits.js","../src/util/minimal.js","../src/verifier.js","../src/wrappers.js","../src/writer.js","../src/writer_buffer.js"],"names":[],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;ACjCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACpDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC3IA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACnGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC5EA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACnHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC/UA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACjBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACjEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AChDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACzGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC/YA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACrSA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC1GA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACnGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACrLA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACnXA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACxGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACpCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACZA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC9HA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC1IA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACvJA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACjbA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACxMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC3MA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACtvBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACrZA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC5CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC/VA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AClBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACpCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC9IA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACvKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC7YA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC7kBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACpMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AClLA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACxMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC9ZA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AChLA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACnFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC3cA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"protobuf.js","sourcesContent":["(function prelude(modules, cache, entries) {\r\n\r\n // This is the prelude used to bundle protobuf.js for the browser. Wraps up the CommonJS\r\n // sources through a conflict-free require shim and is again wrapped within an iife that\r\n // provides a minification-friendly `undefined` var plus a global \"use strict\" directive\r\n // so that minification can remove the directives of each module.\r\n\r\n function $require(name) {\r\n var $module = cache[name];\r\n if (!$module)\r\n modules[name][0].call($module = cache[name] = { exports: {} }, $require, $module, $module.exports);\r\n return $module.exports;\r\n }\r\n\r\n var protobuf = $require(entries[0]);\r\n\r\n // Expose globally\r\n protobuf.util.global.protobuf = protobuf;\r\n\r\n // Be nice to AMD\r\n if (typeof define === \"function\" && define.amd)\r\n define([\"long\"], function(Long) {\r\n if (Long && Long.isLong) {\r\n protobuf.util.Long = Long;\r\n protobuf.configure();\r\n }\r\n return protobuf;\r\n });\r\n\r\n // Be nice to CommonJS\r\n if (typeof module === \"object\" && module && module.exports)\r\n module.exports = protobuf;\r\n\r\n})/* end of prelude */","\"use strict\";\r\nmodule.exports = asPromise;\r\n\r\n/**\r\n * Callback as used by {@link util.asPromise}.\r\n * @typedef asPromiseCallback\r\n * @type {function}\r\n * @param {Error|null} error Error, if any\r\n * @param {...*} params Additional arguments\r\n * @returns {undefined}\r\n */\r\n\r\n/**\r\n * Returns a promise from a node-style callback function.\r\n * @memberof util\r\n * @param {asPromiseCallback} fn Function to call\r\n * @param {*} ctx Function context\r\n * @param {...*} params Function arguments\r\n * @returns {Promise<*>} Promisified function\r\n */\r\nfunction asPromise(fn, ctx/*, varargs */) {\r\n var params = new Array(arguments.length - 1),\r\n offset = 0,\r\n index = 2,\r\n pending = true;\r\n while (index < arguments.length)\r\n params[offset++] = arguments[index++];\r\n return new Promise(function executor(resolve, reject) {\r\n params[offset] = function callback(err/*, varargs */) {\r\n if (pending) {\r\n pending = false;\r\n if (err)\r\n reject(err);\r\n else {\r\n var params = new Array(arguments.length - 1),\r\n offset = 0;\r\n while (offset < params.length)\r\n params[offset++] = arguments[offset];\r\n resolve.apply(null, params);\r\n }\r\n }\r\n };\r\n try {\r\n fn.apply(ctx || null, params);\r\n } catch (err) {\r\n if (pending) {\r\n pending = false;\r\n reject(err);\r\n }\r\n }\r\n });\r\n}\r\n","\"use strict\";\r\n\r\n/**\r\n * A minimal base64 implementation for number arrays.\r\n * @memberof util\r\n * @namespace\r\n */\r\nvar base64 = exports;\r\n\r\n/**\r\n * Calculates the byte length of a base64 encoded string.\r\n * @param {string} string Base64 encoded string\r\n * @returns {number} Byte length\r\n */\r\nbase64.length = function length(string) {\r\n var p = string.length;\r\n if (!p)\r\n return 0;\r\n var n = 0;\r\n while (--p % 4 > 1 && string.charAt(p) === \"=\")\r\n ++n;\r\n return Math.ceil(string.length * 3) / 4 - n;\r\n};\r\n\r\n// Base64 encoding table\r\nvar b64 = new Array(64);\r\n\r\n// Base64 decoding table\r\nvar s64 = new Array(123);\r\n\r\n// 65..90, 97..122, 48..57, 43, 47\r\nfor (var i = 0; i < 64;)\r\n s64[b64[i] = i < 26 ? i + 65 : i < 52 ? i + 71 : i < 62 ? i - 4 : i - 59 | 43] = i++;\r\n\r\n/**\r\n * Encodes a buffer to a base64 encoded string.\r\n * @param {Uint8Array} buffer Source buffer\r\n * @param {number} start Source start\r\n * @param {number} end Source end\r\n * @returns {string} Base64 encoded string\r\n */\r\nbase64.encode = function encode(buffer, start, end) {\r\n var parts = null,\r\n chunk = [];\r\n var i = 0, // output index\r\n j = 0, // goto index\r\n t; // temporary\r\n while (start < end) {\r\n var b = buffer[start++];\r\n switch (j) {\r\n case 0:\r\n chunk[i++] = b64[b >> 2];\r\n t = (b & 3) << 4;\r\n j = 1;\r\n break;\r\n case 1:\r\n chunk[i++] = b64[t | b >> 4];\r\n t = (b & 15) << 2;\r\n j = 2;\r\n break;\r\n case 2:\r\n chunk[i++] = b64[t | b >> 6];\r\n chunk[i++] = b64[b & 63];\r\n j = 0;\r\n break;\r\n }\r\n if (i > 8191) {\r\n (parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));\r\n i = 0;\r\n }\r\n }\r\n if (j) {\r\n chunk[i++] = b64[t];\r\n chunk[i++] = 61;\r\n if (j === 1)\r\n chunk[i++] = 61;\r\n }\r\n if (parts) {\r\n if (i)\r\n parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));\r\n return parts.join(\"\");\r\n }\r\n return String.fromCharCode.apply(String, chunk.slice(0, i));\r\n};\r\n\r\nvar invalidEncoding = \"invalid encoding\";\r\n\r\n/**\r\n * Decodes a base64 encoded string to a buffer.\r\n * @param {string} string Source string\r\n * @param {Uint8Array} buffer Destination buffer\r\n * @param {number} offset Destination offset\r\n * @returns {number} Number of bytes written\r\n * @throws {Error} If encoding is invalid\r\n */\r\nbase64.decode = function decode(string, buffer, offset) {\r\n var start = offset;\r\n var j = 0, // goto index\r\n t; // temporary\r\n for (var i = 0; i < string.length;) {\r\n var c = string.charCodeAt(i++);\r\n if (c === 61 && j > 1)\r\n break;\r\n if ((c = s64[c]) === undefined)\r\n throw Error(invalidEncoding);\r\n switch (j) {\r\n case 0:\r\n t = c;\r\n j = 1;\r\n break;\r\n case 1:\r\n buffer[offset++] = t << 2 | (c & 48) >> 4;\r\n t = c;\r\n j = 2;\r\n break;\r\n case 2:\r\n buffer[offset++] = (t & 15) << 4 | (c & 60) >> 2;\r\n t = c;\r\n j = 3;\r\n break;\r\n case 3:\r\n buffer[offset++] = (t & 3) << 6 | c;\r\n j = 0;\r\n break;\r\n }\r\n }\r\n if (j === 1)\r\n throw Error(invalidEncoding);\r\n return offset - start;\r\n};\r\n\r\n/**\r\n * Tests if the specified string appears to be base64 encoded.\r\n * @param {string} string String to test\r\n * @returns {boolean} `true` if probably base64 encoded, otherwise false\r\n */\r\nbase64.test = function test(string) {\r\n return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(string);\r\n};\r\n","\"use strict\";\r\nmodule.exports = codegen;\r\n\r\n/**\r\n * Begins generating a function.\r\n * @memberof util\r\n * @param {string[]} functionParams Function parameter names\r\n * @param {string} [functionName] Function name if not anonymous\r\n * @returns {Codegen} Appender that appends code to the function's body\r\n */\r\nfunction codegen(functionParams, functionName) {\r\n\r\n /* istanbul ignore if */\r\n if (typeof functionParams === \"string\") {\r\n functionName = functionParams;\r\n functionParams = undefined;\r\n }\r\n\r\n var body = [];\r\n\r\n /**\r\n * Appends code to the function's body or finishes generation.\r\n * @typedef Codegen\r\n * @type {function}\r\n * @param {string|Object.} [formatStringOrScope] Format string or, to finish the function, an object of additional scope variables, if any\r\n * @param {...*} [formatParams] Format parameters\r\n * @returns {Codegen|Function} Itself or the generated function if finished\r\n * @throws {Error} If format parameter counts do not match\r\n */\r\n\r\n function Codegen(formatStringOrScope) {\r\n // note that explicit array handling below makes this ~50% faster\r\n\r\n // finish the function\r\n if (typeof formatStringOrScope !== \"string\") {\r\n var source = toString();\r\n if (codegen.verbose)\r\n console.log(\"codegen: \" + source); // eslint-disable-line no-console\r\n source = \"return \" + source;\r\n if (formatStringOrScope) {\r\n var scopeKeys = Object.keys(formatStringOrScope),\r\n scopeParams = new Array(scopeKeys.length + 1),\r\n scopeValues = new Array(scopeKeys.length),\r\n scopeOffset = 0;\r\n while (scopeOffset < scopeKeys.length) {\r\n scopeParams[scopeOffset] = scopeKeys[scopeOffset];\r\n scopeValues[scopeOffset] = formatStringOrScope[scopeKeys[scopeOffset++]];\r\n }\r\n scopeParams[scopeOffset] = source;\r\n return Function.apply(null, scopeParams).apply(null, scopeValues); // eslint-disable-line no-new-func\r\n }\r\n return Function(source)(); // eslint-disable-line no-new-func\r\n }\r\n\r\n // otherwise append to body\r\n var formatParams = new Array(arguments.length - 1),\r\n formatOffset = 0;\r\n while (formatOffset < formatParams.length)\r\n formatParams[formatOffset] = arguments[++formatOffset];\r\n formatOffset = 0;\r\n formatStringOrScope = formatStringOrScope.replace(/%([%dfijs])/g, function replace($0, $1) {\r\n var value = formatParams[formatOffset++];\r\n switch ($1) {\r\n case \"d\": case \"f\": return String(Number(value));\r\n case \"i\": return String(Math.floor(value));\r\n case \"j\": return JSON.stringify(value);\r\n case \"s\": return String(value);\r\n }\r\n return \"%\";\r\n });\r\n if (formatOffset !== formatParams.length)\r\n throw Error(\"parameter count mismatch\");\r\n body.push(formatStringOrScope);\r\n return Codegen;\r\n }\r\n\r\n function toString(functionNameOverride) {\r\n return \"function \" + (functionNameOverride || functionName || \"\") + \"(\" + (functionParams && functionParams.join(\",\") || \"\") + \"){\\n \" + body.join(\"\\n \") + \"\\n}\";\r\n }\r\n\r\n Codegen.toString = toString;\r\n return Codegen;\r\n}\r\n\r\n/**\r\n * Begins generating a function.\r\n * @memberof util\r\n * @function codegen\r\n * @param {string} [functionName] Function name if not anonymous\r\n * @returns {Codegen} Appender that appends code to the function's body\r\n * @variation 2\r\n */\r\n\r\n/**\r\n * When set to `true`, codegen will log generated code to console. Useful for debugging.\r\n * @name util.codegen.verbose\r\n * @type {boolean}\r\n */\r\ncodegen.verbose = false;\r\n","\"use strict\";\r\nmodule.exports = EventEmitter;\r\n\r\n/**\r\n * Constructs a new event emitter instance.\r\n * @classdesc A minimal event emitter.\r\n * @memberof util\r\n * @constructor\r\n */\r\nfunction EventEmitter() {\r\n\r\n /**\r\n * Registered listeners.\r\n * @type {Object.}\r\n * @private\r\n */\r\n this._listeners = {};\r\n}\r\n\r\n/**\r\n * Registers an event listener.\r\n * @param {string} evt Event name\r\n * @param {function} fn Listener\r\n * @param {*} [ctx] Listener context\r\n * @returns {util.EventEmitter} `this`\r\n */\r\nEventEmitter.prototype.on = function on(evt, fn, ctx) {\r\n (this._listeners[evt] || (this._listeners[evt] = [])).push({\r\n fn : fn,\r\n ctx : ctx || this\r\n });\r\n return this;\r\n};\r\n\r\n/**\r\n * Removes an event listener or any matching listeners if arguments are omitted.\r\n * @param {string} [evt] Event name. Removes all listeners if omitted.\r\n * @param {function} [fn] Listener to remove. Removes all listeners of `evt` if omitted.\r\n * @returns {util.EventEmitter} `this`\r\n */\r\nEventEmitter.prototype.off = function off(evt, fn) {\r\n if (evt === undefined)\r\n this._listeners = {};\r\n else {\r\n if (fn === undefined)\r\n this._listeners[evt] = [];\r\n else {\r\n var listeners = this._listeners[evt];\r\n for (var i = 0; i < listeners.length;)\r\n if (listeners[i].fn === fn)\r\n listeners.splice(i, 1);\r\n else\r\n ++i;\r\n }\r\n }\r\n return this;\r\n};\r\n\r\n/**\r\n * Emits an event by calling its listeners with the specified arguments.\r\n * @param {string} evt Event name\r\n * @param {...*} args Arguments\r\n * @returns {util.EventEmitter} `this`\r\n */\r\nEventEmitter.prototype.emit = function emit(evt) {\r\n var listeners = this._listeners[evt];\r\n if (listeners) {\r\n var args = [],\r\n i = 1;\r\n for (; i < arguments.length;)\r\n args.push(arguments[i++]);\r\n for (i = 0; i < listeners.length;)\r\n listeners[i].fn.apply(listeners[i++].ctx, args);\r\n }\r\n return this;\r\n};\r\n","\"use strict\";\r\nmodule.exports = fetch;\r\n\r\nvar asPromise = require(1),\r\n inquire = require(7);\r\n\r\nvar fs = inquire(\"fs\");\r\n\r\n/**\r\n * Node-style callback as used by {@link util.fetch}.\r\n * @typedef FetchCallback\r\n * @type {function}\r\n * @param {?Error} error Error, if any, otherwise `null`\r\n * @param {string} [contents] File contents, if there hasn't been an error\r\n * @returns {undefined}\r\n */\r\n\r\n/**\r\n * Options as used by {@link util.fetch}.\r\n * @typedef FetchOptions\r\n * @type {Object}\r\n * @property {boolean} [binary=false] Whether expecting a binary response\r\n * @property {boolean} [xhr=false] If `true`, forces the use of XMLHttpRequest\r\n */\r\n\r\n/**\r\n * Fetches the contents of a file.\r\n * @memberof util\r\n * @param {string} filename File path or url\r\n * @param {FetchOptions} options Fetch options\r\n * @param {FetchCallback} callback Callback function\r\n * @returns {undefined}\r\n */\r\nfunction fetch(filename, options, callback) {\r\n if (typeof options === \"function\") {\r\n callback = options;\r\n options = {};\r\n } else if (!options)\r\n options = {};\r\n\r\n if (!callback)\r\n return asPromise(fetch, this, filename, options); // eslint-disable-line no-invalid-this\r\n\r\n // if a node-like filesystem is present, try it first but fall back to XHR if nothing is found.\r\n if (!options.xhr && fs && fs.readFile)\r\n return fs.readFile(filename, function fetchReadFileCallback(err, contents) {\r\n return err && typeof XMLHttpRequest !== \"undefined\"\r\n ? fetch.xhr(filename, options, callback)\r\n : err\r\n ? callback(err)\r\n : callback(null, options.binary ? contents : contents.toString(\"utf8\"));\r\n });\r\n\r\n // use the XHR version otherwise.\r\n return fetch.xhr(filename, options, callback);\r\n}\r\n\r\n/**\r\n * Fetches the contents of a file.\r\n * @name util.fetch\r\n * @function\r\n * @param {string} path File path or url\r\n * @param {FetchCallback} callback Callback function\r\n * @returns {undefined}\r\n * @variation 2\r\n */\r\n\r\n/**\r\n * Fetches the contents of a file.\r\n * @name util.fetch\r\n * @function\r\n * @param {string} path File path or url\r\n * @param {FetchOptions} [options] Fetch options\r\n * @returns {Promise} Promise\r\n * @variation 3\r\n */\r\n\r\n/**/\r\nfetch.xhr = function fetch_xhr(filename, options, callback) {\r\n var xhr = new XMLHttpRequest();\r\n xhr.onreadystatechange /* works everywhere */ = function fetchOnReadyStateChange() {\r\n\r\n if (xhr.readyState !== 4)\r\n return undefined;\r\n\r\n // local cors security errors return status 0 / empty string, too. afaik this cannot be\r\n // reliably distinguished from an actually empty file for security reasons. feel free\r\n // to send a pull request if you are aware of a solution.\r\n if (xhr.status !== 0 && xhr.status !== 200)\r\n return callback(Error(\"status \" + xhr.status));\r\n\r\n // if binary data is expected, make sure that some sort of array is returned, even if\r\n // ArrayBuffers are not supported. the binary string fallback, however, is unsafe.\r\n if (options.binary) {\r\n var buffer = xhr.response;\r\n if (!buffer) {\r\n buffer = [];\r\n for (var i = 0; i < xhr.responseText.length; ++i)\r\n buffer.push(xhr.responseText.charCodeAt(i) & 255);\r\n }\r\n return callback(null, typeof Uint8Array !== \"undefined\" ? new Uint8Array(buffer) : buffer);\r\n }\r\n return callback(null, xhr.responseText);\r\n };\r\n\r\n if (options.binary) {\r\n // ref: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Sending_and_Receiving_Binary_Data#Receiving_binary_data_in_older_browsers\r\n if (\"overrideMimeType\" in xhr)\r\n xhr.overrideMimeType(\"text/plain; charset=x-user-defined\");\r\n xhr.responseType = \"arraybuffer\";\r\n }\r\n\r\n xhr.open(\"GET\", filename);\r\n xhr.send();\r\n};\r\n","\"use strict\";\r\n\r\nmodule.exports = factory(factory);\r\n\r\n/**\r\n * Reads / writes floats / doubles from / to buffers.\r\n * @name util.float\r\n * @namespace\r\n */\r\n\r\n/**\r\n * Writes a 32 bit float to a buffer using little endian byte order.\r\n * @name util.float.writeFloatLE\r\n * @function\r\n * @param {number} val Value to write\r\n * @param {Uint8Array} buf Target buffer\r\n * @param {number} pos Target buffer offset\r\n * @returns {undefined}\r\n */\r\n\r\n/**\r\n * Writes a 32 bit float to a buffer using big endian byte order.\r\n * @name util.float.writeFloatBE\r\n * @function\r\n * @param {number} val Value to write\r\n * @param {Uint8Array} buf Target buffer\r\n * @param {number} pos Target buffer offset\r\n * @returns {undefined}\r\n */\r\n\r\n/**\r\n * Reads a 32 bit float from a buffer using little endian byte order.\r\n * @name util.float.readFloatLE\r\n * @function\r\n * @param {Uint8Array} buf Source buffer\r\n * @param {number} pos Source buffer offset\r\n * @returns {number} Value read\r\n */\r\n\r\n/**\r\n * Reads a 32 bit float from a buffer using big endian byte order.\r\n * @name util.float.readFloatBE\r\n * @function\r\n * @param {Uint8Array} buf Source buffer\r\n * @param {number} pos Source buffer offset\r\n * @returns {number} Value read\r\n */\r\n\r\n/**\r\n * Writes a 64 bit double to a buffer using little endian byte order.\r\n * @name util.float.writeDoubleLE\r\n * @function\r\n * @param {number} val Value to write\r\n * @param {Uint8Array} buf Target buffer\r\n * @param {number} pos Target buffer offset\r\n * @returns {undefined}\r\n */\r\n\r\n/**\r\n * Writes a 64 bit double to a buffer using big endian byte order.\r\n * @name util.float.writeDoubleBE\r\n * @function\r\n * @param {number} val Value to write\r\n * @param {Uint8Array} buf Target buffer\r\n * @param {number} pos Target buffer offset\r\n * @returns {undefined}\r\n */\r\n\r\n/**\r\n * Reads a 64 bit double from a buffer using little endian byte order.\r\n * @name util.float.readDoubleLE\r\n * @function\r\n * @param {Uint8Array} buf Source buffer\r\n * @param {number} pos Source buffer offset\r\n * @returns {number} Value read\r\n */\r\n\r\n/**\r\n * Reads a 64 bit double from a buffer using big endian byte order.\r\n * @name util.float.readDoubleBE\r\n * @function\r\n * @param {Uint8Array} buf Source buffer\r\n * @param {number} pos Source buffer offset\r\n * @returns {number} Value read\r\n */\r\n\r\n// Factory function for the purpose of node-based testing in modified global environments\r\nfunction factory(exports) {\r\n\r\n // float: typed array\r\n if (typeof Float32Array !== \"undefined\") (function() {\r\n\r\n var f32 = new Float32Array([ -0 ]),\r\n f8b = new Uint8Array(f32.buffer),\r\n le = f8b[3] === 128;\r\n\r\n function writeFloat_f32_cpy(val, buf, pos) {\r\n f32[0] = val;\r\n buf[pos ] = f8b[0];\r\n buf[pos + 1] = f8b[1];\r\n buf[pos + 2] = f8b[2];\r\n buf[pos + 3] = f8b[3];\r\n }\r\n\r\n function writeFloat_f32_rev(val, buf, pos) {\r\n f32[0] = val;\r\n buf[pos ] = f8b[3];\r\n buf[pos + 1] = f8b[2];\r\n buf[pos + 2] = f8b[1];\r\n buf[pos + 3] = f8b[0];\r\n }\r\n\r\n /* istanbul ignore next */\r\n exports.writeFloatLE = le ? writeFloat_f32_cpy : writeFloat_f32_rev;\r\n /* istanbul ignore next */\r\n exports.writeFloatBE = le ? writeFloat_f32_rev : writeFloat_f32_cpy;\r\n\r\n function readFloat_f32_cpy(buf, pos) {\r\n f8b[0] = buf[pos ];\r\n f8b[1] = buf[pos + 1];\r\n f8b[2] = buf[pos + 2];\r\n f8b[3] = buf[pos + 3];\r\n return f32[0];\r\n }\r\n\r\n function readFloat_f32_rev(buf, pos) {\r\n f8b[3] = buf[pos ];\r\n f8b[2] = buf[pos + 1];\r\n f8b[1] = buf[pos + 2];\r\n f8b[0] = buf[pos + 3];\r\n return f32[0];\r\n }\r\n\r\n /* istanbul ignore next */\r\n exports.readFloatLE = le ? readFloat_f32_cpy : readFloat_f32_rev;\r\n /* istanbul ignore next */\r\n exports.readFloatBE = le ? readFloat_f32_rev : readFloat_f32_cpy;\r\n\r\n // float: ieee754\r\n })(); else (function() {\r\n\r\n function writeFloat_ieee754(writeUint, val, buf, pos) {\r\n var sign = val < 0 ? 1 : 0;\r\n if (sign)\r\n val = -val;\r\n if (val === 0)\r\n writeUint(1 / val > 0 ? /* positive */ 0 : /* negative 0 */ 2147483648, buf, pos);\r\n else if (isNaN(val))\r\n writeUint(2143289344, buf, pos);\r\n else if (val > 3.4028234663852886e+38) // +-Infinity\r\n writeUint((sign << 31 | 2139095040) >>> 0, buf, pos);\r\n else if (val < 1.1754943508222875e-38) // denormal\r\n writeUint((sign << 31 | Math.round(val / 1.401298464324817e-45)) >>> 0, buf, pos);\r\n else {\r\n var exponent = Math.floor(Math.log(val) / Math.LN2),\r\n mantissa = Math.round(val * Math.pow(2, -exponent) * 8388608) & 8388607;\r\n writeUint((sign << 31 | exponent + 127 << 23 | mantissa) >>> 0, buf, pos);\r\n }\r\n }\r\n\r\n exports.writeFloatLE = writeFloat_ieee754.bind(null, writeUintLE);\r\n exports.writeFloatBE = writeFloat_ieee754.bind(null, writeUintBE);\r\n\r\n function readFloat_ieee754(readUint, buf, pos) {\r\n var uint = readUint(buf, pos),\r\n sign = (uint >> 31) * 2 + 1,\r\n exponent = uint >>> 23 & 255,\r\n mantissa = uint & 8388607;\r\n return exponent === 255\r\n ? mantissa\r\n ? NaN\r\n : sign * Infinity\r\n : exponent === 0 // denormal\r\n ? sign * 1.401298464324817e-45 * mantissa\r\n : sign * Math.pow(2, exponent - 150) * (mantissa + 8388608);\r\n }\r\n\r\n exports.readFloatLE = readFloat_ieee754.bind(null, readUintLE);\r\n exports.readFloatBE = readFloat_ieee754.bind(null, readUintBE);\r\n\r\n })();\r\n\r\n // double: typed array\r\n if (typeof Float64Array !== \"undefined\") (function() {\r\n\r\n var f64 = new Float64Array([-0]),\r\n f8b = new Uint8Array(f64.buffer),\r\n le = f8b[7] === 128;\r\n\r\n function writeDouble_f64_cpy(val, buf, pos) {\r\n f64[0] = val;\r\n buf[pos ] = f8b[0];\r\n buf[pos + 1] = f8b[1];\r\n buf[pos + 2] = f8b[2];\r\n buf[pos + 3] = f8b[3];\r\n buf[pos + 4] = f8b[4];\r\n buf[pos + 5] = f8b[5];\r\n buf[pos + 6] = f8b[6];\r\n buf[pos + 7] = f8b[7];\r\n }\r\n\r\n function writeDouble_f64_rev(val, buf, pos) {\r\n f64[0] = val;\r\n buf[pos ] = f8b[7];\r\n buf[pos + 1] = f8b[6];\r\n buf[pos + 2] = f8b[5];\r\n buf[pos + 3] = f8b[4];\r\n buf[pos + 4] = f8b[3];\r\n buf[pos + 5] = f8b[2];\r\n buf[pos + 6] = f8b[1];\r\n buf[pos + 7] = f8b[0];\r\n }\r\n\r\n /* istanbul ignore next */\r\n exports.writeDoubleLE = le ? writeDouble_f64_cpy : writeDouble_f64_rev;\r\n /* istanbul ignore next */\r\n exports.writeDoubleBE = le ? writeDouble_f64_rev : writeDouble_f64_cpy;\r\n\r\n function readDouble_f64_cpy(buf, pos) {\r\n f8b[0] = buf[pos ];\r\n f8b[1] = buf[pos + 1];\r\n f8b[2] = buf[pos + 2];\r\n f8b[3] = buf[pos + 3];\r\n f8b[4] = buf[pos + 4];\r\n f8b[5] = buf[pos + 5];\r\n f8b[6] = buf[pos + 6];\r\n f8b[7] = buf[pos + 7];\r\n return f64[0];\r\n }\r\n\r\n function readDouble_f64_rev(buf, pos) {\r\n f8b[7] = buf[pos ];\r\n f8b[6] = buf[pos + 1];\r\n f8b[5] = buf[pos + 2];\r\n f8b[4] = buf[pos + 3];\r\n f8b[3] = buf[pos + 4];\r\n f8b[2] = buf[pos + 5];\r\n f8b[1] = buf[pos + 6];\r\n f8b[0] = buf[pos + 7];\r\n return f64[0];\r\n }\r\n\r\n /* istanbul ignore next */\r\n exports.readDoubleLE = le ? readDouble_f64_cpy : readDouble_f64_rev;\r\n /* istanbul ignore next */\r\n exports.readDoubleBE = le ? readDouble_f64_rev : readDouble_f64_cpy;\r\n\r\n // double: ieee754\r\n })(); else (function() {\r\n\r\n function writeDouble_ieee754(writeUint, off0, off1, val, buf, pos) {\r\n var sign = val < 0 ? 1 : 0;\r\n if (sign)\r\n val = -val;\r\n if (val === 0) {\r\n writeUint(0, buf, pos + off0);\r\n writeUint(1 / val > 0 ? /* positive */ 0 : /* negative 0 */ 2147483648, buf, pos + off1);\r\n } else if (isNaN(val)) {\r\n writeUint(0, buf, pos + off0);\r\n writeUint(2146959360, buf, pos + off1);\r\n } else if (val > 1.7976931348623157e+308) { // +-Infinity\r\n writeUint(0, buf, pos + off0);\r\n writeUint((sign << 31 | 2146435072) >>> 0, buf, pos + off1);\r\n } else {\r\n var mantissa;\r\n if (val < 2.2250738585072014e-308) { // denormal\r\n mantissa = val / 5e-324;\r\n writeUint(mantissa >>> 0, buf, pos + off0);\r\n writeUint((sign << 31 | mantissa / 4294967296) >>> 0, buf, pos + off1);\r\n } else {\r\n var exponent = Math.floor(Math.log(val) / Math.LN2);\r\n if (exponent === 1024)\r\n exponent = 1023;\r\n mantissa = val * Math.pow(2, -exponent);\r\n writeUint(mantissa * 4503599627370496 >>> 0, buf, pos + off0);\r\n writeUint((sign << 31 | exponent + 1023 << 20 | mantissa * 1048576 & 1048575) >>> 0, buf, pos + off1);\r\n }\r\n }\r\n }\r\n\r\n exports.writeDoubleLE = writeDouble_ieee754.bind(null, writeUintLE, 0, 4);\r\n exports.writeDoubleBE = writeDouble_ieee754.bind(null, writeUintBE, 4, 0);\r\n\r\n function readDouble_ieee754(readUint, off0, off1, buf, pos) {\r\n var lo = readUint(buf, pos + off0),\r\n hi = readUint(buf, pos + off1);\r\n var sign = (hi >> 31) * 2 + 1,\r\n exponent = hi >>> 20 & 2047,\r\n mantissa = 4294967296 * (hi & 1048575) + lo;\r\n return exponent === 2047\r\n ? mantissa\r\n ? NaN\r\n : sign * Infinity\r\n : exponent === 0 // denormal\r\n ? sign * 5e-324 * mantissa\r\n : sign * Math.pow(2, exponent - 1075) * (mantissa + 4503599627370496);\r\n }\r\n\r\n exports.readDoubleLE = readDouble_ieee754.bind(null, readUintLE, 0, 4);\r\n exports.readDoubleBE = readDouble_ieee754.bind(null, readUintBE, 4, 0);\r\n\r\n })();\r\n\r\n return exports;\r\n}\r\n\r\n// uint helpers\r\n\r\nfunction writeUintLE(val, buf, pos) {\r\n buf[pos ] = val & 255;\r\n buf[pos + 1] = val >>> 8 & 255;\r\n buf[pos + 2] = val >>> 16 & 255;\r\n buf[pos + 3] = val >>> 24;\r\n}\r\n\r\nfunction writeUintBE(val, buf, pos) {\r\n buf[pos ] = val >>> 24;\r\n buf[pos + 1] = val >>> 16 & 255;\r\n buf[pos + 2] = val >>> 8 & 255;\r\n buf[pos + 3] = val & 255;\r\n}\r\n\r\nfunction readUintLE(buf, pos) {\r\n return (buf[pos ]\r\n | buf[pos + 1] << 8\r\n | buf[pos + 2] << 16\r\n | buf[pos + 3] << 24) >>> 0;\r\n}\r\n\r\nfunction readUintBE(buf, pos) {\r\n return (buf[pos ] << 24\r\n | buf[pos + 1] << 16\r\n | buf[pos + 2] << 8\r\n | buf[pos + 3]) >>> 0;\r\n}\r\n","\"use strict\";\r\nmodule.exports = inquire;\r\n\r\n/**\r\n * Requires a module only if available.\r\n * @memberof util\r\n * @param {string} moduleName Module to require\r\n * @returns {?Object} Required module if available and not empty, otherwise `null`\r\n */\r\nfunction inquire(moduleName) {\r\n try {\r\n var mod = eval(\"quire\".replace(/^/,\"re\"))(moduleName); // eslint-disable-line no-eval\r\n if (mod && (mod.length || Object.keys(mod).length))\r\n return mod;\r\n } catch (e) {} // eslint-disable-line no-empty\r\n return null;\r\n}\r\n","\"use strict\";\r\n\r\n/**\r\n * A minimal path module to resolve Unix, Windows and URL paths alike.\r\n * @memberof util\r\n * @namespace\r\n */\r\nvar path = exports;\r\n\r\nvar isAbsolute =\r\n/**\r\n * Tests if the specified path is absolute.\r\n * @param {string} path Path to test\r\n * @returns {boolean} `true` if path is absolute\r\n */\r\npath.isAbsolute = function isAbsolute(path) {\r\n return /^(?:\\/|\\w+:)/.test(path);\r\n};\r\n\r\nvar normalize =\r\n/**\r\n * Normalizes the specified path.\r\n * @param {string} path Path to normalize\r\n * @returns {string} Normalized path\r\n */\r\npath.normalize = function normalize(path) {\r\n path = path.replace(/\\\\/g, \"/\")\r\n .replace(/\\/{2,}/g, \"/\");\r\n var parts = path.split(\"/\"),\r\n absolute = isAbsolute(path),\r\n prefix = \"\";\r\n if (absolute)\r\n prefix = parts.shift() + \"/\";\r\n for (var i = 0; i < parts.length;) {\r\n if (parts[i] === \"..\") {\r\n if (i > 0 && parts[i - 1] !== \"..\")\r\n parts.splice(--i, 2);\r\n else if (absolute)\r\n parts.splice(i, 1);\r\n else\r\n ++i;\r\n } else if (parts[i] === \".\")\r\n parts.splice(i, 1);\r\n else\r\n ++i;\r\n }\r\n return prefix + parts.join(\"/\");\r\n};\r\n\r\n/**\r\n * Resolves the specified include path against the specified origin path.\r\n * @param {string} originPath Path to the origin file\r\n * @param {string} includePath Include path relative to origin path\r\n * @param {boolean} [alreadyNormalized=false] `true` if both paths are already known to be normalized\r\n * @returns {string} Path to the include file\r\n */\r\npath.resolve = function resolve(originPath, includePath, alreadyNormalized) {\r\n if (!alreadyNormalized)\r\n includePath = normalize(includePath);\r\n if (isAbsolute(includePath))\r\n return includePath;\r\n if (!alreadyNormalized)\r\n originPath = normalize(originPath);\r\n return (originPath = originPath.replace(/(?:\\/|^)[^/]+$/, \"\")).length ? normalize(originPath + \"/\" + includePath) : includePath;\r\n};\r\n","\"use strict\";\r\nmodule.exports = pool;\r\n\r\n/**\r\n * An allocator as used by {@link util.pool}.\r\n * @typedef PoolAllocator\r\n * @type {function}\r\n * @param {number} size Buffer size\r\n * @returns {Uint8Array} Buffer\r\n */\r\n\r\n/**\r\n * A slicer as used by {@link util.pool}.\r\n * @typedef PoolSlicer\r\n * @type {function}\r\n * @param {number} start Start offset\r\n * @param {number} end End offset\r\n * @returns {Uint8Array} Buffer slice\r\n * @this {Uint8Array}\r\n */\r\n\r\n/**\r\n * A general purpose buffer pool.\r\n * @memberof util\r\n * @function\r\n * @param {PoolAllocator} alloc Allocator\r\n * @param {PoolSlicer} slice Slicer\r\n * @param {number} [size=8192] Slab size\r\n * @returns {PoolAllocator} Pooled allocator\r\n */\r\nfunction pool(alloc, slice, size) {\r\n var SIZE = size || 8192;\r\n var MAX = SIZE >>> 1;\r\n var slab = null;\r\n var offset = SIZE;\r\n return function pool_alloc(size) {\r\n if (size < 1 || size > MAX)\r\n return alloc(size);\r\n if (offset + size > SIZE) {\r\n slab = alloc(SIZE);\r\n offset = 0;\r\n }\r\n var buf = slice.call(slab, offset, offset += size);\r\n if (offset & 7) // align to 32 bit\r\n offset = (offset | 7) + 1;\r\n return buf;\r\n };\r\n}\r\n","\"use strict\";\r\n\r\n/**\r\n * A minimal UTF8 implementation for number arrays.\r\n * @memberof util\r\n * @namespace\r\n */\r\nvar utf8 = exports;\r\n\r\n/**\r\n * Calculates the UTF8 byte length of a string.\r\n * @param {string} string String\r\n * @returns {number} Byte length\r\n */\r\nutf8.length = function utf8_length(string) {\r\n var len = 0,\r\n c = 0;\r\n for (var i = 0; i < string.length; ++i) {\r\n c = string.charCodeAt(i);\r\n if (c < 128)\r\n len += 1;\r\n else if (c < 2048)\r\n len += 2;\r\n else if ((c & 0xFC00) === 0xD800 && (string.charCodeAt(i + 1) & 0xFC00) === 0xDC00) {\r\n ++i;\r\n len += 4;\r\n } else\r\n len += 3;\r\n }\r\n return len;\r\n};\r\n\r\n/**\r\n * Reads UTF8 bytes as a string.\r\n * @param {Uint8Array} buffer Source buffer\r\n * @param {number} start Source start\r\n * @param {number} end Source end\r\n * @returns {string} String read\r\n */\r\nutf8.read = function utf8_read(buffer, start, end) {\r\n var len = end - start;\r\n if (len < 1)\r\n return \"\";\r\n var parts = null,\r\n chunk = [],\r\n i = 0, // char offset\r\n t; // temporary\r\n while (start < end) {\r\n t = buffer[start++];\r\n if (t < 128)\r\n chunk[i++] = t;\r\n else if (t > 191 && t < 224)\r\n chunk[i++] = (t & 31) << 6 | buffer[start++] & 63;\r\n else if (t > 239 && t < 365) {\r\n t = ((t & 7) << 18 | (buffer[start++] & 63) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63) - 0x10000;\r\n chunk[i++] = 0xD800 + (t >> 10);\r\n chunk[i++] = 0xDC00 + (t & 1023);\r\n } else\r\n chunk[i++] = (t & 15) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63;\r\n if (i > 8191) {\r\n (parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));\r\n i = 0;\r\n }\r\n }\r\n if (parts) {\r\n if (i)\r\n parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));\r\n return parts.join(\"\");\r\n }\r\n return String.fromCharCode.apply(String, chunk.slice(0, i));\r\n};\r\n\r\n/**\r\n * Writes a string as UTF8 bytes.\r\n * @param {string} string Source string\r\n * @param {Uint8Array} buffer Destination buffer\r\n * @param {number} offset Destination offset\r\n * @returns {number} Bytes written\r\n */\r\nutf8.write = function utf8_write(string, buffer, offset) {\r\n var start = offset,\r\n c1, // character 1\r\n c2; // character 2\r\n for (var i = 0; i < string.length; ++i) {\r\n c1 = string.charCodeAt(i);\r\n if (c1 < 128) {\r\n buffer[offset++] = c1;\r\n } else if (c1 < 2048) {\r\n buffer[offset++] = c1 >> 6 | 192;\r\n buffer[offset++] = c1 & 63 | 128;\r\n } else if ((c1 & 0xFC00) === 0xD800 && ((c2 = string.charCodeAt(i + 1)) & 0xFC00) === 0xDC00) {\r\n c1 = 0x10000 + ((c1 & 0x03FF) << 10) + (c2 & 0x03FF);\r\n ++i;\r\n buffer[offset++] = c1 >> 18 | 240;\r\n buffer[offset++] = c1 >> 12 & 63 | 128;\r\n buffer[offset++] = c1 >> 6 & 63 | 128;\r\n buffer[offset++] = c1 & 63 | 128;\r\n } else {\r\n buffer[offset++] = c1 >> 12 | 224;\r\n buffer[offset++] = c1 >> 6 & 63 | 128;\r\n buffer[offset++] = c1 & 63 | 128;\r\n }\r\n }\r\n return offset - start;\r\n};\r\n","\"use strict\";\r\nmodule.exports = common;\r\n\r\nvar commonRe = /\\/|\\./;\r\n\r\n/**\r\n * Provides common type definitions.\r\n * Can also be used to provide additional google types or your own custom types.\r\n * @param {string} name Short name as in `google/protobuf/[name].proto` or full file name\r\n * @param {Object.} json JSON definition within `google.protobuf` if a short name, otherwise the file's root definition\r\n * @returns {undefined}\r\n * @property {INamespace} google/protobuf/any.proto Any\r\n * @property {INamespace} google/protobuf/duration.proto Duration\r\n * @property {INamespace} google/protobuf/empty.proto Empty\r\n * @property {INamespace} google/protobuf/field_mask.proto FieldMask\r\n * @property {INamespace} google/protobuf/struct.proto Struct, Value, NullValue and ListValue\r\n * @property {INamespace} google/protobuf/timestamp.proto Timestamp\r\n * @property {INamespace} google/protobuf/wrappers.proto Wrappers\r\n * @example\r\n * // manually provides descriptor.proto (assumes google/protobuf/ namespace and .proto extension)\r\n * protobuf.common(\"descriptor\", descriptorJson);\r\n *\r\n * // manually provides a custom definition (uses my.foo namespace)\r\n * protobuf.common(\"my/foo/bar.proto\", myFooBarJson);\r\n */\r\nfunction common(name, json) {\r\n if (!commonRe.test(name)) {\r\n name = \"google/protobuf/\" + name + \".proto\";\r\n json = { nested: { google: { nested: { protobuf: { nested: json } } } } };\r\n }\r\n common[name] = json;\r\n}\r\n\r\n// Not provided because of limited use (feel free to discuss or to provide yourself):\r\n//\r\n// google/protobuf/descriptor.proto\r\n// google/protobuf/source_context.proto\r\n// google/protobuf/type.proto\r\n//\r\n// Stripped and pre-parsed versions of these non-bundled files are instead available as part of\r\n// the repository or package within the google/protobuf directory.\r\n\r\ncommon(\"any\", {\r\n\r\n /**\r\n * Properties of a google.protobuf.Any message.\r\n * @interface IAny\r\n * @type {Object}\r\n * @property {string} [typeUrl]\r\n * @property {Uint8Array} [bytes]\r\n * @memberof common\r\n */\r\n Any: {\r\n fields: {\r\n type_url: {\r\n type: \"string\",\r\n id: 1\r\n },\r\n value: {\r\n type: \"bytes\",\r\n id: 2\r\n }\r\n }\r\n }\r\n});\r\n\r\nvar timeType;\r\n\r\ncommon(\"duration\", {\r\n\r\n /**\r\n * Properties of a google.protobuf.Duration message.\r\n * @interface IDuration\r\n * @type {Object}\r\n * @property {number|Long} [seconds]\r\n * @property {number} [nanos]\r\n * @memberof common\r\n */\r\n Duration: timeType = {\r\n fields: {\r\n seconds: {\r\n type: \"int64\",\r\n id: 1\r\n },\r\n nanos: {\r\n type: \"int32\",\r\n id: 2\r\n }\r\n }\r\n }\r\n});\r\n\r\ncommon(\"timestamp\", {\r\n\r\n /**\r\n * Properties of a google.protobuf.Timestamp message.\r\n * @interface ITimestamp\r\n * @type {Object}\r\n * @property {number|Long} [seconds]\r\n * @property {number} [nanos]\r\n * @memberof common\r\n */\r\n Timestamp: timeType\r\n});\r\n\r\ncommon(\"empty\", {\r\n\r\n /**\r\n * Properties of a google.protobuf.Empty message.\r\n * @interface IEmpty\r\n * @memberof common\r\n */\r\n Empty: {\r\n fields: {}\r\n }\r\n});\r\n\r\ncommon(\"struct\", {\r\n\r\n /**\r\n * Properties of a google.protobuf.Struct message.\r\n * @interface IStruct\r\n * @type {Object}\r\n * @property {Object.} [fields]\r\n * @memberof common\r\n */\r\n Struct: {\r\n fields: {\r\n fields: {\r\n keyType: \"string\",\r\n type: \"Value\",\r\n id: 1\r\n }\r\n }\r\n },\r\n\r\n /**\r\n * Properties of a google.protobuf.Value message.\r\n * @interface IValue\r\n * @type {Object}\r\n * @property {string} [kind]\r\n * @property {0} [nullValue]\r\n * @property {number} [numberValue]\r\n * @property {string} [stringValue]\r\n * @property {boolean} [boolValue]\r\n * @property {IStruct} [structValue]\r\n * @property {IListValue} [listValue]\r\n * @memberof common\r\n */\r\n Value: {\r\n oneofs: {\r\n kind: {\r\n oneof: [\r\n \"nullValue\",\r\n \"numberValue\",\r\n \"stringValue\",\r\n \"boolValue\",\r\n \"structValue\",\r\n \"listValue\"\r\n ]\r\n }\r\n },\r\n fields: {\r\n nullValue: {\r\n type: \"NullValue\",\r\n id: 1\r\n },\r\n numberValue: {\r\n type: \"double\",\r\n id: 2\r\n },\r\n stringValue: {\r\n type: \"string\",\r\n id: 3\r\n },\r\n boolValue: {\r\n type: \"bool\",\r\n id: 4\r\n },\r\n structValue: {\r\n type: \"Struct\",\r\n id: 5\r\n },\r\n listValue: {\r\n type: \"ListValue\",\r\n id: 6\r\n }\r\n }\r\n },\r\n\r\n NullValue: {\r\n values: {\r\n NULL_VALUE: 0\r\n }\r\n },\r\n\r\n /**\r\n * Properties of a google.protobuf.ListValue message.\r\n * @interface IListValue\r\n * @type {Object}\r\n * @property {Array.} [values]\r\n * @memberof common\r\n */\r\n ListValue: {\r\n fields: {\r\n values: {\r\n rule: \"repeated\",\r\n type: \"Value\",\r\n id: 1\r\n }\r\n }\r\n }\r\n});\r\n\r\ncommon(\"wrappers\", {\r\n\r\n /**\r\n * Properties of a google.protobuf.DoubleValue message.\r\n * @interface IDoubleValue\r\n * @type {Object}\r\n * @property {number} [value]\r\n * @memberof common\r\n */\r\n DoubleValue: {\r\n fields: {\r\n value: {\r\n type: \"double\",\r\n id: 1\r\n }\r\n }\r\n },\r\n\r\n /**\r\n * Properties of a google.protobuf.FloatValue message.\r\n * @interface IFloatValue\r\n * @type {Object}\r\n * @property {number} [value]\r\n * @memberof common\r\n */\r\n FloatValue: {\r\n fields: {\r\n value: {\r\n type: \"float\",\r\n id: 1\r\n }\r\n }\r\n },\r\n\r\n /**\r\n * Properties of a google.protobuf.Int64Value message.\r\n * @interface IInt64Value\r\n * @type {Object}\r\n * @property {number|Long} [value]\r\n * @memberof common\r\n */\r\n Int64Value: {\r\n fields: {\r\n value: {\r\n type: \"int64\",\r\n id: 1\r\n }\r\n }\r\n },\r\n\r\n /**\r\n * Properties of a google.protobuf.UInt64Value message.\r\n * @interface IUInt64Value\r\n * @type {Object}\r\n * @property {number|Long} [value]\r\n * @memberof common\r\n */\r\n UInt64Value: {\r\n fields: {\r\n value: {\r\n type: \"uint64\",\r\n id: 1\r\n }\r\n }\r\n },\r\n\r\n /**\r\n * Properties of a google.protobuf.Int32Value message.\r\n * @interface IInt32Value\r\n * @type {Object}\r\n * @property {number} [value]\r\n * @memberof common\r\n */\r\n Int32Value: {\r\n fields: {\r\n value: {\r\n type: \"int32\",\r\n id: 1\r\n }\r\n }\r\n },\r\n\r\n /**\r\n * Properties of a google.protobuf.UInt32Value message.\r\n * @interface IUInt32Value\r\n * @type {Object}\r\n * @property {number} [value]\r\n * @memberof common\r\n */\r\n UInt32Value: {\r\n fields: {\r\n value: {\r\n type: \"uint32\",\r\n id: 1\r\n }\r\n }\r\n },\r\n\r\n /**\r\n * Properties of a google.protobuf.BoolValue message.\r\n * @interface IBoolValue\r\n * @type {Object}\r\n * @property {boolean} [value]\r\n * @memberof common\r\n */\r\n BoolValue: {\r\n fields: {\r\n value: {\r\n type: \"bool\",\r\n id: 1\r\n }\r\n }\r\n },\r\n\r\n /**\r\n * Properties of a google.protobuf.StringValue message.\r\n * @interface IStringValue\r\n * @type {Object}\r\n * @property {string} [value]\r\n * @memberof common\r\n */\r\n StringValue: {\r\n fields: {\r\n value: {\r\n type: \"string\",\r\n id: 1\r\n }\r\n }\r\n },\r\n\r\n /**\r\n * Properties of a google.protobuf.BytesValue message.\r\n * @interface IBytesValue\r\n * @type {Object}\r\n * @property {Uint8Array} [value]\r\n * @memberof common\r\n */\r\n BytesValue: {\r\n fields: {\r\n value: {\r\n type: \"bytes\",\r\n id: 1\r\n }\r\n }\r\n }\r\n});\r\n\r\ncommon(\"field_mask\", {\r\n\r\n /**\r\n * Properties of a google.protobuf.FieldMask message.\r\n * @interface IDoubleValue\r\n * @type {Object}\r\n * @property {number} [value]\r\n * @memberof common\r\n */\r\n FieldMask: {\r\n fields: {\r\n paths: {\r\n rule: \"repeated\",\r\n type: \"string\",\r\n id: 1\r\n }\r\n }\r\n }\r\n});\r\n\r\n/**\r\n * Gets the root definition of the specified common proto file.\r\n *\r\n * Bundled definitions are:\r\n * - google/protobuf/any.proto\r\n * - google/protobuf/duration.proto\r\n * - google/protobuf/empty.proto\r\n * - google/protobuf/field_mask.proto\r\n * - google/protobuf/struct.proto\r\n * - google/protobuf/timestamp.proto\r\n * - google/protobuf/wrappers.proto\r\n *\r\n * @param {string} file Proto file name\r\n * @returns {INamespace|null} Root definition or `null` if not defined\r\n */\r\ncommon.get = function get(file) {\r\n return common[file] || null;\r\n};\r\n","\"use strict\";\r\n/**\r\n * Runtime message from/to plain object converters.\r\n * @namespace\r\n */\r\nvar converter = exports;\r\n\r\nvar Enum = require(15),\r\n util = require(37);\r\n\r\n/**\r\n * Generates a partial value fromObject conveter.\r\n * @param {Codegen} gen Codegen instance\r\n * @param {Field} field Reflected field\r\n * @param {number} fieldIndex Field index\r\n * @param {string} prop Property reference\r\n * @returns {Codegen} Codegen instance\r\n * @ignore\r\n */\r\nfunction genValuePartial_fromObject(gen, field, fieldIndex, prop) {\r\n /* eslint-disable no-unexpected-multiline, block-scoped-var, no-redeclare */\r\n if (field.resolvedType) {\r\n if (field.resolvedType instanceof Enum) { gen\r\n (\"switch(d%s){\", prop);\r\n for (var values = field.resolvedType.values, keys = Object.keys(values), i = 0; i < keys.length; ++i) {\r\n if (field.repeated && values[keys[i]] === field.typeDefault) gen\r\n (\"default:\");\r\n gen\r\n (\"case%j:\", keys[i])\r\n (\"case %i:\", values[keys[i]])\r\n (\"m%s=%j\", prop, values[keys[i]])\r\n (\"break\");\r\n } gen\r\n (\"}\");\r\n } else gen\r\n (\"if(typeof d%s!==\\\"object\\\")\", prop)\r\n (\"throw TypeError(%j)\", field.fullName + \": object expected\")\r\n (\"m%s=types[%i].fromObject(d%s)\", prop, fieldIndex, prop);\r\n } else {\r\n var isUnsigned = false;\r\n switch (field.type) {\r\n case \"double\":\r\n case \"float\": gen\r\n (\"m%s=Number(d%s)\", prop, prop); // also catches \"NaN\", \"Infinity\"\r\n break;\r\n case \"uint32\":\r\n case \"fixed32\": gen\r\n (\"m%s=d%s>>>0\", prop, prop);\r\n break;\r\n case \"int32\":\r\n case \"sint32\":\r\n case \"sfixed32\": gen\r\n (\"m%s=d%s|0\", prop, prop);\r\n break;\r\n case \"uint64\":\r\n isUnsigned = true;\r\n // eslint-disable-line no-fallthrough\r\n case \"int64\":\r\n case \"sint64\":\r\n case \"fixed64\":\r\n case \"sfixed64\": gen\r\n (\"if(util.Long)\")\r\n (\"(m%s=util.Long.fromValue(d%s)).unsigned=%j\", prop, prop, isUnsigned)\r\n (\"else if(typeof d%s===\\\"string\\\")\", prop)\r\n (\"m%s=parseInt(d%s,10)\", prop, prop)\r\n (\"else if(typeof d%s===\\\"number\\\")\", prop)\r\n (\"m%s=d%s\", prop, prop)\r\n (\"else if(typeof d%s===\\\"object\\\")\", prop)\r\n (\"m%s=new util.LongBits(d%s.low>>>0,d%s.high>>>0).toNumber(%s)\", prop, prop, prop, isUnsigned ? \"true\" : \"\");\r\n break;\r\n case \"bytes\": gen\r\n (\"if(typeof d%s===\\\"string\\\")\", prop)\r\n (\"util.base64.decode(d%s,m%s=util.newBuffer(util.base64.length(d%s)),0)\", prop, prop, prop)\r\n (\"else if(d%s.length)\", prop)\r\n (\"m%s=d%s\", prop, prop);\r\n break;\r\n case \"string\": gen\r\n (\"m%s=String(d%s)\", prop, prop);\r\n break;\r\n case \"bool\": gen\r\n (\"m%s=Boolean(d%s)\", prop, prop);\r\n break;\r\n /* default: gen\r\n (\"m%s=d%s\", prop, prop);\r\n break; */\r\n }\r\n }\r\n return gen;\r\n /* eslint-enable no-unexpected-multiline, block-scoped-var, no-redeclare */\r\n}\r\n\r\n/**\r\n * Generates a plain object to runtime message converter specific to the specified message type.\r\n * @param {Type} mtype Message type\r\n * @returns {Codegen} Codegen instance\r\n */\r\nconverter.fromObject = function fromObject(mtype) {\r\n /* eslint-disable no-unexpected-multiline, block-scoped-var, no-redeclare */\r\n var fields = mtype.fieldsArray;\r\n var gen = util.codegen([\"d\"], mtype.name + \"$fromObject\")\r\n (\"if(d instanceof this.ctor)\")\r\n (\"return d\");\r\n if (!fields.length) return gen\r\n (\"return new this.ctor\");\r\n gen\r\n (\"var m=new this.ctor\");\r\n for (var i = 0; i < fields.length; ++i) {\r\n var field = fields[i].resolve(),\r\n prop = util.safeProp(field.name);\r\n\r\n // Map fields\r\n if (field.map) { gen\r\n (\"if(d%s){\", prop)\r\n (\"if(typeof d%s!==\\\"object\\\")\", prop)\r\n (\"throw TypeError(%j)\", field.fullName + \": object expected\")\r\n (\"m%s={}\", prop)\r\n (\"for(var ks=Object.keys(d%s),i=0;i>>0,m%s.high>>>0).toNumber(%s):m%s\", prop, prop, prop, prop, isUnsigned ? \"true\": \"\", prop);\r\n break;\r\n case \"bytes\": gen\r\n (\"d%s=o.bytes===String?util.base64.encode(m%s,0,m%s.length):o.bytes===Array?Array.prototype.slice.call(m%s):m%s\", prop, prop, prop, prop, prop);\r\n break;\r\n default: gen\r\n (\"d%s=m%s\", prop, prop);\r\n break;\r\n }\r\n }\r\n return gen;\r\n /* eslint-enable no-unexpected-multiline, block-scoped-var, no-redeclare */\r\n}\r\n\r\n/**\r\n * Generates a runtime message to plain object converter specific to the specified message type.\r\n * @param {Type} mtype Message type\r\n * @returns {Codegen} Codegen instance\r\n */\r\nconverter.toObject = function toObject(mtype) {\r\n /* eslint-disable no-unexpected-multiline, block-scoped-var, no-redeclare */\r\n var fields = mtype.fieldsArray.slice().sort(util.compareFieldsById);\r\n if (!fields.length)\r\n return util.codegen()(\"return {}\");\r\n var gen = util.codegen([\"m\", \"o\"], mtype.name + \"$toObject\")\r\n (\"if(!o)\")\r\n (\"o={}\")\r\n (\"var d={}\");\r\n\r\n var repeatedFields = [],\r\n mapFields = [],\r\n normalFields = [],\r\n i = 0;\r\n for (; i < fields.length; ++i)\r\n if (!fields[i].partOf)\r\n ( fields[i].resolve().repeated ? repeatedFields\r\n : fields[i].map ? mapFields\r\n : normalFields).push(fields[i]);\r\n\r\n if (repeatedFields.length) { gen\r\n (\"if(o.arrays||o.defaults){\");\r\n for (i = 0; i < repeatedFields.length; ++i) gen\r\n (\"d%s=[]\", util.safeProp(repeatedFields[i].name));\r\n gen\r\n (\"}\");\r\n }\r\n\r\n if (mapFields.length) { gen\r\n (\"if(o.objects||o.defaults){\");\r\n for (i = 0; i < mapFields.length; ++i) gen\r\n (\"d%s={}\", util.safeProp(mapFields[i].name));\r\n gen\r\n (\"}\");\r\n }\r\n\r\n if (normalFields.length) { gen\r\n (\"if(o.defaults){\");\r\n for (i = 0; i < normalFields.length; ++i) {\r\n var field = normalFields[i],\r\n prop = util.safeProp(field.name);\r\n if (field.resolvedType instanceof Enum) gen\r\n (\"d%s=o.enums===String?%j:%j\", prop, field.resolvedType.valuesById[field.typeDefault], field.typeDefault);\r\n else if (field.long) gen\r\n (\"if(util.Long){\")\r\n (\"var n=new util.Long(%i,%i,%j)\", field.typeDefault.low, field.typeDefault.high, field.typeDefault.unsigned)\r\n (\"d%s=o.longs===String?n.toString():o.longs===Number?n.toNumber():n\", prop)\r\n (\"}else\")\r\n (\"d%s=o.longs===String?%j:%i\", prop, field.typeDefault.toString(), field.typeDefault.toNumber());\r\n else if (field.bytes) {\r\n var arrayDefault = \"[\" + Array.prototype.slice.call(field.typeDefault).join(\",\") + \"]\";\r\n gen\r\n (\"if(o.bytes===String)d%s=%j\", prop, String.fromCharCode.apply(String, field.typeDefault))\r\n (\"else{\")\r\n (\"d%s=%s\", prop, arrayDefault)\r\n (\"if(o.bytes!==Array)d%s=util.newBuffer(d%s)\", prop, prop)\r\n (\"}\");\r\n } else gen\r\n (\"d%s=%j\", prop, field.typeDefault); // also messages (=null)\r\n } gen\r\n (\"}\");\r\n }\r\n var hasKs2 = false;\r\n for (i = 0; i < fields.length; ++i) {\r\n var field = fields[i],\r\n index = mtype._fieldsArray.indexOf(field),\r\n prop = util.safeProp(field.name);\r\n if (field.map) {\r\n if (!hasKs2) { hasKs2 = true; gen\r\n (\"var ks2\");\r\n } gen\r\n (\"if(m%s&&(ks2=Object.keys(m%s)).length){\", prop, prop)\r\n (\"d%s={}\", prop)\r\n (\"for(var j=0;j>>3){\");\r\n\r\n var i = 0;\r\n for (; i < /* initializes */ mtype.fieldsArray.length; ++i) {\r\n var field = mtype._fieldsArray[i].resolve(),\r\n type = field.resolvedType instanceof Enum ? \"int32\" : field.type,\r\n ref = \"m\" + util.safeProp(field.name); gen\r\n (\"case %i:\", field.id);\r\n\r\n // Map fields\r\n if (field.map) { gen\r\n (\"r.skip().pos++\") // assumes id 1 + key wireType\r\n (\"if(%s===util.emptyObject)\", ref)\r\n (\"%s={}\", ref)\r\n (\"k=r.%s()\", field.keyType)\r\n (\"r.pos++\"); // assumes id 2 + value wireType\r\n if (types.long[field.keyType] !== undefined) {\r\n if (types.basic[type] === undefined) gen\r\n (\"%s[typeof k===\\\"object\\\"?util.longToHash(k):k]=types[%i].decode(r,r.uint32())\", ref, i); // can't be groups\r\n else gen\r\n (\"%s[typeof k===\\\"object\\\"?util.longToHash(k):k]=r.%s()\", ref, type);\r\n } else {\r\n if (types.basic[type] === undefined) gen\r\n (\"%s[k]=types[%i].decode(r,r.uint32())\", ref, i); // can't be groups\r\n else gen\r\n (\"%s[k]=r.%s()\", ref, type);\r\n }\r\n\r\n // Repeated fields\r\n } else if (field.repeated) { gen\r\n\r\n (\"if(!(%s&&%s.length))\", ref, ref)\r\n (\"%s=[]\", ref);\r\n\r\n // Packable (always check for forward and backward compatiblity)\r\n if (types.packed[type] !== undefined) gen\r\n (\"if((t&7)===2){\")\r\n (\"var c2=r.uint32()+r.pos\")\r\n (\"while(r.pos>> 0, (field.id << 3 | 4) >>> 0)\r\n : gen(\"types[%i].encode(%s,w.uint32(%i).fork()).ldelim()\", fieldIndex, ref, (field.id << 3 | 2) >>> 0);\r\n}\r\n\r\n/**\r\n * Generates an encoder specific to the specified message type.\r\n * @param {Type} mtype Message type\r\n * @returns {Codegen} Codegen instance\r\n */\r\nfunction encoder(mtype) {\r\n /* eslint-disable no-unexpected-multiline, block-scoped-var, no-redeclare */\r\n var gen = util.codegen([\"m\", \"w\"], mtype.name + \"$encode\")\r\n (\"if(!w)\")\r\n (\"w=Writer.create()\");\r\n\r\n var i, ref;\r\n\r\n // \"when a message is serialized its known fields should be written sequentially by field number\"\r\n var fields = /* initializes */ mtype.fieldsArray.slice().sort(util.compareFieldsById);\r\n\r\n for (var i = 0; i < fields.length; ++i) {\r\n var field = fields[i].resolve(),\r\n index = mtype._fieldsArray.indexOf(field),\r\n type = field.resolvedType instanceof Enum ? \"int32\" : field.type,\r\n wireType = types.basic[type];\r\n ref = \"m\" + util.safeProp(field.name);\r\n\r\n // Map fields\r\n if (field.map) {\r\n gen\r\n (\"if(%s!=null&&m.hasOwnProperty(%j)){\", ref, field.name) // !== undefined && !== null\r\n (\"for(var ks=Object.keys(%s),i=0;i>> 0, 8 | types.mapKey[field.keyType], field.keyType);\r\n if (wireType === undefined) gen\r\n (\"types[%i].encode(%s[ks[i]],w.uint32(18).fork()).ldelim().ldelim()\", index, ref); // can't be groups\r\n else gen\r\n (\".uint32(%i).%s(%s[ks[i]]).ldelim()\", 16 | wireType, type, ref);\r\n gen\r\n (\"}\")\r\n (\"}\");\r\n\r\n // Repeated fields\r\n } else if (field.repeated) { gen\r\n (\"if(%s!=null&&%s.length){\", ref, ref); // !== undefined && !== null\r\n\r\n // Packed repeated\r\n if (field.packed && types.packed[type] !== undefined) { gen\r\n\r\n (\"w.uint32(%i).fork()\", (field.id << 3 | 2) >>> 0)\r\n (\"for(var i=0;i<%s.length;++i)\", ref)\r\n (\"w.%s(%s[i])\", type, ref)\r\n (\"w.ldelim()\");\r\n\r\n // Non-packed\r\n } else { gen\r\n\r\n (\"for(var i=0;i<%s.length;++i)\", ref);\r\n if (wireType === undefined)\r\n genTypePartial(gen, field, index, ref + \"[i]\");\r\n else gen\r\n (\"w.uint32(%i).%s(%s[i])\", (field.id << 3 | wireType) >>> 0, type, ref);\r\n\r\n } gen\r\n (\"}\");\r\n\r\n // Non-repeated\r\n } else {\r\n if (field.optional) gen\r\n (\"if(%s!=null&&m.hasOwnProperty(%j))\", ref, field.name); // !== undefined && !== null\r\n\r\n if (wireType === undefined)\r\n genTypePartial(gen, field, index, ref);\r\n else gen\r\n (\"w.uint32(%i).%s(%s)\", (field.id << 3 | wireType) >>> 0, type, ref);\r\n\r\n }\r\n }\r\n\r\n return gen\r\n (\"return w\");\r\n /* eslint-enable no-unexpected-multiline, block-scoped-var, no-redeclare */\r\n}","\"use strict\";\r\nmodule.exports = Enum;\r\n\r\n// extends ReflectionObject\r\nvar ReflectionObject = require(24);\r\n((Enum.prototype = Object.create(ReflectionObject.prototype)).constructor = Enum).className = \"Enum\";\r\n\r\nvar Namespace = require(23),\r\n util = require(37);\r\n\r\n/**\r\n * Constructs a new enum instance.\r\n * @classdesc Reflected enum.\r\n * @extends ReflectionObject\r\n * @constructor\r\n * @param {string} name Unique name within its namespace\r\n * @param {Object.} [values] Enum values as an object, by name\r\n * @param {Object.} [options] Declared options\r\n * @param {string} [comment] The comment for this enum\r\n * @param {Object.} [comments] The value comments for this enum\r\n */\r\nfunction Enum(name, values, options, comment, comments) {\r\n ReflectionObject.call(this, name, options);\r\n\r\n if (values && typeof values !== \"object\")\r\n throw TypeError(\"values must be an object\");\r\n\r\n /**\r\n * Enum values by id.\r\n * @type {Object.}\r\n */\r\n this.valuesById = {};\r\n\r\n /**\r\n * Enum values by name.\r\n * @type {Object.}\r\n */\r\n this.values = Object.create(this.valuesById); // toJSON, marker\r\n\r\n /**\r\n * Enum comment text.\r\n * @type {string|null}\r\n */\r\n this.comment = comment;\r\n\r\n /**\r\n * Value comment texts, if any.\r\n * @type {Object.}\r\n */\r\n this.comments = comments || {};\r\n\r\n /**\r\n * Reserved ranges, if any.\r\n * @type {Array.}\r\n */\r\n this.reserved = undefined; // toJSON\r\n\r\n // Note that values inherit valuesById on their prototype which makes them a TypeScript-\r\n // compatible enum. This is used by pbts to write actual enum definitions that work for\r\n // static and reflection code alike instead of emitting generic object definitions.\r\n\r\n if (values)\r\n for (var keys = Object.keys(values), i = 0; i < keys.length; ++i)\r\n if (typeof values[keys[i]] === \"number\") // use forward entries only\r\n this.valuesById[ this.values[keys[i]] = values[keys[i]] ] = keys[i];\r\n}\r\n\r\n/**\r\n * Enum descriptor.\r\n * @interface IEnum\r\n * @property {Object.} values Enum values\r\n * @property {Object.} [options] Enum options\r\n */\r\n\r\n/**\r\n * Constructs an enum from an enum descriptor.\r\n * @param {string} name Enum name\r\n * @param {IEnum} json Enum descriptor\r\n * @returns {Enum} Created enum\r\n * @throws {TypeError} If arguments are invalid\r\n */\r\nEnum.fromJSON = function fromJSON(name, json) {\r\n var enm = new Enum(name, json.values, json.options, json.comment, json.comments);\r\n enm.reserved = json.reserved;\r\n return enm;\r\n};\r\n\r\n/**\r\n * Converts this enum to an enum descriptor.\r\n * @param {IToJSONOptions} [toJSONOptions] JSON conversion options\r\n * @returns {IEnum} Enum descriptor\r\n */\r\nEnum.prototype.toJSON = function toJSON(toJSONOptions) {\r\n var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false;\r\n return util.toObject([\r\n \"options\" , this.options,\r\n \"values\" , this.values,\r\n \"reserved\" , this.reserved && this.reserved.length ? this.reserved : undefined,\r\n \"comment\" , keepComments ? this.comment : undefined,\r\n \"comments\" , keepComments ? this.comments : undefined\r\n ]);\r\n};\r\n\r\n/**\r\n * Adds a value to this enum.\r\n * @param {string} name Value name\r\n * @param {number} id Value id\r\n * @param {string} [comment] Comment, if any\r\n * @returns {Enum} `this`\r\n * @throws {TypeError} If arguments are invalid\r\n * @throws {Error} If there is already a value with this name or id\r\n */\r\nEnum.prototype.add = function add(name, id, comment) {\r\n // utilized by the parser but not by .fromJSON\r\n\r\n if (!util.isString(name))\r\n throw TypeError(\"name must be a string\");\r\n\r\n if (!util.isInteger(id))\r\n throw TypeError(\"id must be an integer\");\r\n\r\n if (this.values[name] !== undefined)\r\n throw Error(\"duplicate name '\" + name + \"' in \" + this);\r\n\r\n if (this.isReservedId(id))\r\n throw Error(\"id \" + id + \" is reserved in \" + this);\r\n\r\n if (this.isReservedName(name))\r\n throw Error(\"name '\" + name + \"' is reserved in \" + this);\r\n\r\n if (this.valuesById[id] !== undefined) {\r\n if (!(this.options && this.options.allow_alias))\r\n throw Error(\"duplicate id \" + id + \" in \" + this);\r\n this.values[name] = id;\r\n } else\r\n this.valuesById[this.values[name] = id] = name;\r\n\r\n this.comments[name] = comment || null;\r\n return this;\r\n};\r\n\r\n/**\r\n * Removes a value from this enum\r\n * @param {string} name Value name\r\n * @returns {Enum} `this`\r\n * @throws {TypeError} If arguments are invalid\r\n * @throws {Error} If `name` is not a name of this enum\r\n */\r\nEnum.prototype.remove = function remove(name) {\r\n\r\n if (!util.isString(name))\r\n throw TypeError(\"name must be a string\");\r\n\r\n var val = this.values[name];\r\n if (val == null)\r\n throw Error(\"name '\" + name + \"' does not exist in \" + this);\r\n\r\n delete this.valuesById[val];\r\n delete this.values[name];\r\n delete this.comments[name];\r\n\r\n return this;\r\n};\r\n\r\n/**\r\n * Tests if the specified id is reserved.\r\n * @param {number} id Id to test\r\n * @returns {boolean} `true` if reserved, otherwise `false`\r\n */\r\nEnum.prototype.isReservedId = function isReservedId(id) {\r\n return Namespace.isReservedId(this.reserved, id);\r\n};\r\n\r\n/**\r\n * Tests if the specified name is reserved.\r\n * @param {string} name Name to test\r\n * @returns {boolean} `true` if reserved, otherwise `false`\r\n */\r\nEnum.prototype.isReservedName = function isReservedName(name) {\r\n return Namespace.isReservedName(this.reserved, name);\r\n};\r\n","\"use strict\";\r\nmodule.exports = Field;\r\n\r\n// extends ReflectionObject\r\nvar ReflectionObject = require(24);\r\n((Field.prototype = Object.create(ReflectionObject.prototype)).constructor = Field).className = \"Field\";\r\n\r\nvar Enum = require(15),\r\n types = require(36),\r\n util = require(37);\r\n\r\nvar Type; // cyclic\r\n\r\nvar ruleRe = /^required|optional|repeated$/;\r\n\r\n/**\r\n * Constructs a new message field instance. Note that {@link MapField|map fields} have their own class.\r\n * @name Field\r\n * @classdesc Reflected message field.\r\n * @extends FieldBase\r\n * @constructor\r\n * @param {string} name Unique name within its namespace\r\n * @param {number} id Unique id within its namespace\r\n * @param {string} type Value type\r\n * @param {string|Object.} [rule=\"optional\"] Field rule\r\n * @param {string|Object.} [extend] Extended type if different from parent\r\n * @param {Object.} [options] Declared options\r\n */\r\n\r\n/**\r\n * Constructs a field from a field descriptor.\r\n * @param {string} name Field name\r\n * @param {IField} json Field descriptor\r\n * @returns {Field} Created field\r\n * @throws {TypeError} If arguments are invalid\r\n */\r\nField.fromJSON = function fromJSON(name, json) {\r\n return new Field(name, json.id, json.type, json.rule, json.extend, json.options, json.comment);\r\n};\r\n\r\n/**\r\n * Not an actual constructor. Use {@link Field} instead.\r\n * @classdesc Base class of all reflected message fields. This is not an actual class but here for the sake of having consistent type definitions.\r\n * @exports FieldBase\r\n * @extends ReflectionObject\r\n * @constructor\r\n * @param {string} name Unique name within its namespace\r\n * @param {number} id Unique id within its namespace\r\n * @param {string} type Value type\r\n * @param {string|Object.} [rule=\"optional\"] Field rule\r\n * @param {string|Object.} [extend] Extended type if different from parent\r\n * @param {Object.} [options] Declared options\r\n * @param {string} [comment] Comment associated with this field\r\n */\r\nfunction Field(name, id, type, rule, extend, options, comment) {\r\n\r\n if (util.isObject(rule)) {\r\n comment = extend;\r\n options = rule;\r\n rule = extend = undefined;\r\n } else if (util.isObject(extend)) {\r\n comment = options;\r\n options = extend;\r\n extend = undefined;\r\n }\r\n\r\n ReflectionObject.call(this, name, options);\r\n\r\n if (!util.isInteger(id) || id < 0)\r\n throw TypeError(\"id must be a non-negative integer\");\r\n\r\n if (!util.isString(type))\r\n throw TypeError(\"type must be a string\");\r\n\r\n if (rule !== undefined && !ruleRe.test(rule = rule.toString().toLowerCase()))\r\n throw TypeError(\"rule must be a string rule\");\r\n\r\n if (extend !== undefined && !util.isString(extend))\r\n throw TypeError(\"extend must be a string\");\r\n\r\n /**\r\n * Field rule, if any.\r\n * @type {string|undefined}\r\n */\r\n this.rule = rule && rule !== \"optional\" ? rule : undefined; // toJSON\r\n\r\n /**\r\n * Field type.\r\n * @type {string}\r\n */\r\n this.type = type; // toJSON\r\n\r\n /**\r\n * Unique field id.\r\n * @type {number}\r\n */\r\n this.id = id; // toJSON, marker\r\n\r\n /**\r\n * Extended type if different from parent.\r\n * @type {string|undefined}\r\n */\r\n this.extend = extend || undefined; // toJSON\r\n\r\n /**\r\n * Whether this field is required.\r\n * @type {boolean}\r\n */\r\n this.required = rule === \"required\";\r\n\r\n /**\r\n * Whether this field is optional.\r\n * @type {boolean}\r\n */\r\n this.optional = !this.required;\r\n\r\n /**\r\n * Whether this field is repeated.\r\n * @type {boolean}\r\n */\r\n this.repeated = rule === \"repeated\";\r\n\r\n /**\r\n * Whether this field is a map or not.\r\n * @type {boolean}\r\n */\r\n this.map = false;\r\n\r\n /**\r\n * Message this field belongs to.\r\n * @type {Type|null}\r\n */\r\n this.message = null;\r\n\r\n /**\r\n * OneOf this field belongs to, if any,\r\n * @type {OneOf|null}\r\n */\r\n this.partOf = null;\r\n\r\n /**\r\n * The field type's default value.\r\n * @type {*}\r\n */\r\n this.typeDefault = null;\r\n\r\n /**\r\n * The field's default value on prototypes.\r\n * @type {*}\r\n */\r\n this.defaultValue = null;\r\n\r\n /**\r\n * Whether this field's value should be treated as a long.\r\n * @type {boolean}\r\n */\r\n this.long = util.Long ? types.long[type] !== undefined : /* istanbul ignore next */ false;\r\n\r\n /**\r\n * Whether this field's value is a buffer.\r\n * @type {boolean}\r\n */\r\n this.bytes = type === \"bytes\";\r\n\r\n /**\r\n * Resolved type if not a basic type.\r\n * @type {Type|Enum|null}\r\n */\r\n this.resolvedType = null;\r\n\r\n /**\r\n * Sister-field within the extended type if a declaring extension field.\r\n * @type {Field|null}\r\n */\r\n this.extensionField = null;\r\n\r\n /**\r\n * Sister-field within the declaring namespace if an extended field.\r\n * @type {Field|null}\r\n */\r\n this.declaringField = null;\r\n\r\n /**\r\n * Internally remembers whether this field is packed.\r\n * @type {boolean|null}\r\n * @private\r\n */\r\n this._packed = null;\r\n\r\n /**\r\n * Comment for this field.\r\n * @type {string|null}\r\n */\r\n this.comment = comment;\r\n}\r\n\r\n/**\r\n * Determines whether this field is packed. Only relevant when repeated and working with proto2.\r\n * @name Field#packed\r\n * @type {boolean}\r\n * @readonly\r\n */\r\nObject.defineProperty(Field.prototype, \"packed\", {\r\n get: function() {\r\n // defaults to packed=true if not explicity set to false\r\n if (this._packed === null)\r\n this._packed = this.getOption(\"packed\") !== false;\r\n return this._packed;\r\n }\r\n});\r\n\r\n/**\r\n * @override\r\n */\r\nField.prototype.setOption = function setOption(name, value, ifNotSet) {\r\n if (name === \"packed\") // clear cached before setting\r\n this._packed = null;\r\n return ReflectionObject.prototype.setOption.call(this, name, value, ifNotSet);\r\n};\r\n\r\n/**\r\n * Field descriptor.\r\n * @interface IField\r\n * @property {string} [rule=\"optional\"] Field rule\r\n * @property {string} type Field type\r\n * @property {number} id Field id\r\n * @property {Object.} [options] Field options\r\n */\r\n\r\n/**\r\n * Extension field descriptor.\r\n * @interface IExtensionField\r\n * @extends IField\r\n * @property {string} extend Extended type\r\n */\r\n\r\n/**\r\n * Converts this field to a field descriptor.\r\n * @param {IToJSONOptions} [toJSONOptions] JSON conversion options\r\n * @returns {IField} Field descriptor\r\n */\r\nField.prototype.toJSON = function toJSON(toJSONOptions) {\r\n var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false;\r\n return util.toObject([\r\n \"rule\" , this.rule !== \"optional\" && this.rule || undefined,\r\n \"type\" , this.type,\r\n \"id\" , this.id,\r\n \"extend\" , this.extend,\r\n \"options\" , this.options,\r\n \"comment\" , keepComments ? this.comment : undefined\r\n ]);\r\n};\r\n\r\n/**\r\n * Resolves this field's type references.\r\n * @returns {Field} `this`\r\n * @throws {Error} If any reference cannot be resolved\r\n */\r\nField.prototype.resolve = function resolve() {\r\n\r\n if (this.resolved)\r\n return this;\r\n\r\n if ((this.typeDefault = types.defaults[this.type]) === undefined) { // if not a basic type, resolve it\r\n this.resolvedType = (this.declaringField ? this.declaringField.parent : this.parent).lookupTypeOrEnum(this.type);\r\n if (this.resolvedType instanceof Type)\r\n this.typeDefault = null;\r\n else // instanceof Enum\r\n this.typeDefault = this.resolvedType.values[Object.keys(this.resolvedType.values)[0]]; // first defined\r\n }\r\n\r\n // use explicitly set default value if present\r\n if (this.options && this.options[\"default\"] != null) {\r\n this.typeDefault = this.options[\"default\"];\r\n if (this.resolvedType instanceof Enum && typeof this.typeDefault === \"string\")\r\n this.typeDefault = this.resolvedType.values[this.typeDefault];\r\n }\r\n\r\n // remove unnecessary options\r\n if (this.options) {\r\n if (this.options.packed === true || this.options.packed !== undefined && this.resolvedType && !(this.resolvedType instanceof Enum))\r\n delete this.options.packed;\r\n if (!Object.keys(this.options).length)\r\n this.options = undefined;\r\n }\r\n\r\n // convert to internal data type if necesssary\r\n if (this.long) {\r\n this.typeDefault = util.Long.fromNumber(this.typeDefault, this.type.charAt(0) === \"u\");\r\n\r\n /* istanbul ignore else */\r\n if (Object.freeze)\r\n Object.freeze(this.typeDefault); // long instances are meant to be immutable anyway (i.e. use small int cache that even requires it)\r\n\r\n } else if (this.bytes && typeof this.typeDefault === \"string\") {\r\n var buf;\r\n if (util.base64.test(this.typeDefault))\r\n util.base64.decode(this.typeDefault, buf = util.newBuffer(util.base64.length(this.typeDefault)), 0);\r\n else\r\n util.utf8.write(this.typeDefault, buf = util.newBuffer(util.utf8.length(this.typeDefault)), 0);\r\n this.typeDefault = buf;\r\n }\r\n\r\n // take special care of maps and repeated fields\r\n if (this.map)\r\n this.defaultValue = util.emptyObject;\r\n else if (this.repeated)\r\n this.defaultValue = util.emptyArray;\r\n else\r\n this.defaultValue = this.typeDefault;\r\n\r\n // ensure proper value on prototype\r\n if (this.parent instanceof Type)\r\n this.parent.ctor.prototype[this.name] = this.defaultValue;\r\n\r\n return ReflectionObject.prototype.resolve.call(this);\r\n};\r\n\r\n/**\r\n * Decorator function as returned by {@link Field.d} and {@link MapField.d} (TypeScript).\r\n * @typedef FieldDecorator\r\n * @type {function}\r\n * @param {Object} prototype Target prototype\r\n * @param {string} fieldName Field name\r\n * @returns {undefined}\r\n */\r\n\r\n/**\r\n * Field decorator (TypeScript).\r\n * @name Field.d\r\n * @function\r\n * @param {number} fieldId Field id\r\n * @param {\"double\"|\"float\"|\"int32\"|\"uint32\"|\"sint32\"|\"fixed32\"|\"sfixed32\"|\"int64\"|\"uint64\"|\"sint64\"|\"fixed64\"|\"sfixed64\"|\"string\"|\"bool\"|\"bytes\"|Object} fieldType Field type\r\n * @param {\"optional\"|\"required\"|\"repeated\"} [fieldRule=\"optional\"] Field rule\r\n * @param {T} [defaultValue] Default value\r\n * @returns {FieldDecorator} Decorator function\r\n * @template T extends number | number[] | Long | Long[] | string | string[] | boolean | boolean[] | Uint8Array | Uint8Array[] | Buffer | Buffer[]\r\n */\r\nField.d = function decorateField(fieldId, fieldType, fieldRule, defaultValue) {\r\n\r\n // submessage: decorate the submessage and use its name as the type\r\n if (typeof fieldType === \"function\")\r\n fieldType = util.decorateType(fieldType).name;\r\n\r\n // enum reference: create a reflected copy of the enum and keep reuseing it\r\n else if (fieldType && typeof fieldType === \"object\")\r\n fieldType = util.decorateEnum(fieldType).name;\r\n\r\n return function fieldDecorator(prototype, fieldName) {\r\n util.decorateType(prototype.constructor)\r\n .add(new Field(fieldName, fieldId, fieldType, fieldRule, { \"default\": defaultValue }));\r\n };\r\n};\r\n\r\n/**\r\n * Field decorator (TypeScript).\r\n * @name Field.d\r\n * @function\r\n * @param {number} fieldId Field id\r\n * @param {Constructor|string} fieldType Field type\r\n * @param {\"optional\"|\"required\"|\"repeated\"} [fieldRule=\"optional\"] Field rule\r\n * @returns {FieldDecorator} Decorator function\r\n * @template T extends Message\r\n * @variation 2\r\n */\r\n// like Field.d but without a default value\r\n\r\n// Sets up cyclic dependencies (called in index-light)\r\nField._configure = function configure(Type_) {\r\n Type = Type_;\r\n};\r\n","\"use strict\";\r\nvar protobuf = module.exports = require(18);\r\n\r\nprotobuf.build = \"light\";\r\n\r\n/**\r\n * A node-style callback as used by {@link load} and {@link Root#load}.\r\n * @typedef LoadCallback\r\n * @type {function}\r\n * @param {Error|null} error Error, if any, otherwise `null`\r\n * @param {Root} [root] Root, if there hasn't been an error\r\n * @returns {undefined}\r\n */\r\n\r\n/**\r\n * Loads one or multiple .proto or preprocessed .json files into a common root namespace and calls the callback.\r\n * @param {string|string[]} filename One or multiple files to load\r\n * @param {Root} root Root namespace, defaults to create a new one if omitted.\r\n * @param {LoadCallback} callback Callback function\r\n * @returns {undefined}\r\n * @see {@link Root#load}\r\n */\r\nfunction load(filename, root, callback) {\r\n if (typeof root === \"function\") {\r\n callback = root;\r\n root = new protobuf.Root();\r\n } else if (!root)\r\n root = new protobuf.Root();\r\n return root.load(filename, callback);\r\n}\r\n\r\n/**\r\n * Loads one or multiple .proto or preprocessed .json files into a common root namespace and calls the callback.\r\n * @name load\r\n * @function\r\n * @param {string|string[]} filename One or multiple files to load\r\n * @param {LoadCallback} callback Callback function\r\n * @returns {undefined}\r\n * @see {@link Root#load}\r\n * @variation 2\r\n */\r\n// function load(filename:string, callback:LoadCallback):undefined\r\n\r\n/**\r\n * Loads one or multiple .proto or preprocessed .json files into a common root namespace and returns a promise.\r\n * @name load\r\n * @function\r\n * @param {string|string[]} filename One or multiple files to load\r\n * @param {Root} [root] Root namespace, defaults to create a new one if omitted.\r\n * @returns {Promise} Promise\r\n * @see {@link Root#load}\r\n * @variation 3\r\n */\r\n// function load(filename:string, [root:Root]):Promise\r\n\r\nprotobuf.load = load;\r\n\r\n/**\r\n * Synchronously loads one or multiple .proto or preprocessed .json files into a common root namespace (node only).\r\n * @param {string|string[]} filename One or multiple files to load\r\n * @param {Root} [root] Root namespace, defaults to create a new one if omitted.\r\n * @returns {Root} Root namespace\r\n * @throws {Error} If synchronous fetching is not supported (i.e. in browsers) or if a file's syntax is invalid\r\n * @see {@link Root#loadSync}\r\n */\r\nfunction loadSync(filename, root) {\r\n if (!root)\r\n root = new protobuf.Root();\r\n return root.loadSync(filename);\r\n}\r\n\r\nprotobuf.loadSync = loadSync;\r\n\r\n// Serialization\r\nprotobuf.encoder = require(14);\r\nprotobuf.decoder = require(13);\r\nprotobuf.verifier = require(40);\r\nprotobuf.converter = require(12);\r\n\r\n// Reflection\r\nprotobuf.ReflectionObject = require(24);\r\nprotobuf.Namespace = require(23);\r\nprotobuf.Root = require(29);\r\nprotobuf.Enum = require(15);\r\nprotobuf.Type = require(35);\r\nprotobuf.Field = require(16);\r\nprotobuf.OneOf = require(25);\r\nprotobuf.MapField = require(20);\r\nprotobuf.Service = require(33);\r\nprotobuf.Method = require(22);\r\n\r\n// Runtime\r\nprotobuf.Message = require(21);\r\nprotobuf.wrappers = require(41);\r\n\r\n// Utility\r\nprotobuf.types = require(36);\r\nprotobuf.util = require(37);\r\n\r\n// Set up possibly cyclic reflection dependencies\r\nprotobuf.ReflectionObject._configure(protobuf.Root);\r\nprotobuf.Namespace._configure(protobuf.Type, protobuf.Service, protobuf.Enum);\r\nprotobuf.Root._configure(protobuf.Type);\r\nprotobuf.Field._configure(protobuf.Type);\r\n","\"use strict\";\r\nvar protobuf = exports;\r\n\r\n/**\r\n * Build type, one of `\"full\"`, `\"light\"` or `\"minimal\"`.\r\n * @name build\r\n * @type {string}\r\n * @const\r\n */\r\nprotobuf.build = \"minimal\";\r\n\r\n// Serialization\r\nprotobuf.Writer = require(42);\r\nprotobuf.BufferWriter = require(43);\r\nprotobuf.Reader = require(27);\r\nprotobuf.BufferReader = require(28);\r\n\r\n// Utility\r\nprotobuf.util = require(39);\r\nprotobuf.rpc = require(31);\r\nprotobuf.roots = require(30);\r\nprotobuf.configure = configure;\r\n\r\n/* istanbul ignore next */\r\n/**\r\n * Reconfigures the library according to the environment.\r\n * @returns {undefined}\r\n */\r\nfunction configure() {\r\n protobuf.Reader._configure(protobuf.BufferReader);\r\n protobuf.util._configure();\r\n}\r\n\r\n// Set up buffer utility according to the environment\r\nprotobuf.Writer._configure(protobuf.BufferWriter);\r\nconfigure();\r\n","\"use strict\";\r\nvar protobuf = module.exports = require(17);\r\n\r\nprotobuf.build = \"full\";\r\n\r\n// Parser\r\nprotobuf.tokenize = require(34);\r\nprotobuf.parse = require(26);\r\nprotobuf.common = require(11);\r\n\r\n// Configure parser\r\nprotobuf.Root._configure(protobuf.Type, protobuf.parse, protobuf.common);\r\n","\"use strict\";\r\nmodule.exports = MapField;\r\n\r\n// extends Field\r\nvar Field = require(16);\r\n((MapField.prototype = Object.create(Field.prototype)).constructor = MapField).className = \"MapField\";\r\n\r\nvar types = require(36),\r\n util = require(37);\r\n\r\n/**\r\n * Constructs a new map field instance.\r\n * @classdesc Reflected map field.\r\n * @extends FieldBase\r\n * @constructor\r\n * @param {string} name Unique name within its namespace\r\n * @param {number} id Unique id within its namespace\r\n * @param {string} keyType Key type\r\n * @param {string} type Value type\r\n * @param {Object.} [options] Declared options\r\n * @param {string} [comment] Comment associated with this field\r\n */\r\nfunction MapField(name, id, keyType, type, options, comment) {\r\n Field.call(this, name, id, type, undefined, undefined, options, comment);\r\n\r\n /* istanbul ignore if */\r\n if (!util.isString(keyType))\r\n throw TypeError(\"keyType must be a string\");\r\n\r\n /**\r\n * Key type.\r\n * @type {string}\r\n */\r\n this.keyType = keyType; // toJSON, marker\r\n\r\n /**\r\n * Resolved key type if not a basic type.\r\n * @type {ReflectionObject|null}\r\n */\r\n this.resolvedKeyType = null;\r\n\r\n // Overrides Field#map\r\n this.map = true;\r\n}\r\n\r\n/**\r\n * Map field descriptor.\r\n * @interface IMapField\r\n * @extends {IField}\r\n * @property {string} keyType Key type\r\n */\r\n\r\n/**\r\n * Extension map field descriptor.\r\n * @interface IExtensionMapField\r\n * @extends IMapField\r\n * @property {string} extend Extended type\r\n */\r\n\r\n/**\r\n * Constructs a map field from a map field descriptor.\r\n * @param {string} name Field name\r\n * @param {IMapField} json Map field descriptor\r\n * @returns {MapField} Created map field\r\n * @throws {TypeError} If arguments are invalid\r\n */\r\nMapField.fromJSON = function fromJSON(name, json) {\r\n return new MapField(name, json.id, json.keyType, json.type, json.options, json.comment);\r\n};\r\n\r\n/**\r\n * Converts this map field to a map field descriptor.\r\n * @param {IToJSONOptions} [toJSONOptions] JSON conversion options\r\n * @returns {IMapField} Map field descriptor\r\n */\r\nMapField.prototype.toJSON = function toJSON(toJSONOptions) {\r\n var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false;\r\n return util.toObject([\r\n \"keyType\" , this.keyType,\r\n \"type\" , this.type,\r\n \"id\" , this.id,\r\n \"extend\" , this.extend,\r\n \"options\" , this.options,\r\n \"comment\" , keepComments ? this.comment : undefined\r\n ]);\r\n};\r\n\r\n/**\r\n * @override\r\n */\r\nMapField.prototype.resolve = function resolve() {\r\n if (this.resolved)\r\n return this;\r\n\r\n // Besides a value type, map fields have a key type that may be \"any scalar type except for floating point types and bytes\"\r\n if (types.mapKey[this.keyType] === undefined)\r\n throw Error(\"invalid key type: \" + this.keyType);\r\n\r\n return Field.prototype.resolve.call(this);\r\n};\r\n\r\n/**\r\n * Map field decorator (TypeScript).\r\n * @name MapField.d\r\n * @function\r\n * @param {number} fieldId Field id\r\n * @param {\"int32\"|\"uint32\"|\"sint32\"|\"fixed32\"|\"sfixed32\"|\"int64\"|\"uint64\"|\"sint64\"|\"fixed64\"|\"sfixed64\"|\"bool\"|\"string\"} fieldKeyType Field key type\r\n * @param {\"double\"|\"float\"|\"int32\"|\"uint32\"|\"sint32\"|\"fixed32\"|\"sfixed32\"|\"int64\"|\"uint64\"|\"sint64\"|\"fixed64\"|\"sfixed64\"|\"bool\"|\"string\"|\"bytes\"|Object|Constructor<{}>} fieldValueType Field value type\r\n * @returns {FieldDecorator} Decorator function\r\n * @template T extends { [key: string]: number | Long | string | boolean | Uint8Array | Buffer | number[] | Message<{}> }\r\n */\r\nMapField.d = function decorateMapField(fieldId, fieldKeyType, fieldValueType) {\r\n\r\n // submessage value: decorate the submessage and use its name as the type\r\n if (typeof fieldValueType === \"function\")\r\n fieldValueType = util.decorateType(fieldValueType).name;\r\n\r\n // enum reference value: create a reflected copy of the enum and keep reuseing it\r\n else if (fieldValueType && typeof fieldValueType === \"object\")\r\n fieldValueType = util.decorateEnum(fieldValueType).name;\r\n\r\n return function mapFieldDecorator(prototype, fieldName) {\r\n util.decorateType(prototype.constructor)\r\n .add(new MapField(fieldName, fieldId, fieldKeyType, fieldValueType));\r\n };\r\n};\r\n","\"use strict\";\r\nmodule.exports = Message;\r\n\r\nvar util = require(39);\r\n\r\n/**\r\n * Constructs a new message instance.\r\n * @classdesc Abstract runtime message.\r\n * @constructor\r\n * @param {Properties} [properties] Properties to set\r\n * @template T extends object = object\r\n */\r\nfunction Message(properties) {\r\n // not used internally\r\n if (properties)\r\n for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)\r\n this[keys[i]] = properties[keys[i]];\r\n}\r\n\r\n/**\r\n * Reference to the reflected type.\r\n * @name Message.$type\r\n * @type {Type}\r\n * @readonly\r\n */\r\n\r\n/**\r\n * Reference to the reflected type.\r\n * @name Message#$type\r\n * @type {Type}\r\n * @readonly\r\n */\r\n\r\n/*eslint-disable valid-jsdoc*/\r\n\r\n/**\r\n * Creates a new message of this type using the specified properties.\r\n * @param {Object.} [properties] Properties to set\r\n * @returns {Message} Message instance\r\n * @template T extends Message\r\n * @this Constructor\r\n */\r\nMessage.create = function create(properties) {\r\n return this.$type.create(properties);\r\n};\r\n\r\n/**\r\n * Encodes a message of this type.\r\n * @param {T|Object.} message Message to encode\r\n * @param {Writer} [writer] Writer to use\r\n * @returns {Writer} Writer\r\n * @template T extends Message\r\n * @this Constructor\r\n */\r\nMessage.encode = function encode(message, writer) {\r\n return this.$type.encode(message, writer);\r\n};\r\n\r\n/**\r\n * Encodes a message of this type preceeded by its length as a varint.\r\n * @param {T|Object.} message Message to encode\r\n * @param {Writer} [writer] Writer to use\r\n * @returns {Writer} Writer\r\n * @template T extends Message\r\n * @this Constructor\r\n */\r\nMessage.encodeDelimited = function encodeDelimited(message, writer) {\r\n return this.$type.encodeDelimited(message, writer);\r\n};\r\n\r\n/**\r\n * Decodes a message of this type.\r\n * @name Message.decode\r\n * @function\r\n * @param {Reader|Uint8Array} reader Reader or buffer to decode\r\n * @returns {T} Decoded message\r\n * @template T extends Message\r\n * @this Constructor\r\n */\r\nMessage.decode = function decode(reader) {\r\n return this.$type.decode(reader);\r\n};\r\n\r\n/**\r\n * Decodes a message of this type preceeded by its length as a varint.\r\n * @name Message.decodeDelimited\r\n * @function\r\n * @param {Reader|Uint8Array} reader Reader or buffer to decode\r\n * @returns {T} Decoded message\r\n * @template T extends Message\r\n * @this Constructor\r\n */\r\nMessage.decodeDelimited = function decodeDelimited(reader) {\r\n return this.$type.decodeDelimited(reader);\r\n};\r\n\r\n/**\r\n * Verifies a message of this type.\r\n * @name Message.verify\r\n * @function\r\n * @param {Object.} message Plain object to verify\r\n * @returns {string|null} `null` if valid, otherwise the reason why it is not\r\n */\r\nMessage.verify = function verify(message) {\r\n return this.$type.verify(message);\r\n};\r\n\r\n/**\r\n * Creates a new message of this type from a plain object. Also converts values to their respective internal types.\r\n * @param {Object.} object Plain object\r\n * @returns {T} Message instance\r\n * @template T extends Message\r\n * @this Constructor\r\n */\r\nMessage.fromObject = function fromObject(object) {\r\n return this.$type.fromObject(object);\r\n};\r\n\r\n/**\r\n * Creates a plain object from a message of this type. Also converts values to other types if specified.\r\n * @param {T} message Message instance\r\n * @param {IConversionOptions} [options] Conversion options\r\n * @returns {Object.} Plain object\r\n * @template T extends Message\r\n * @this Constructor\r\n */\r\nMessage.toObject = function toObject(message, options) {\r\n return this.$type.toObject(message, options);\r\n};\r\n\r\n/**\r\n * Converts this message to JSON.\r\n * @returns {Object.} JSON object\r\n */\r\nMessage.prototype.toJSON = function toJSON() {\r\n return this.$type.toObject(this, util.toJSONOptions);\r\n};\r\n\r\n/*eslint-enable valid-jsdoc*/","\"use strict\";\r\nmodule.exports = Method;\r\n\r\n// extends ReflectionObject\r\nvar ReflectionObject = require(24);\r\n((Method.prototype = Object.create(ReflectionObject.prototype)).constructor = Method).className = \"Method\";\r\n\r\nvar util = require(37);\r\n\r\n/**\r\n * Constructs a new service method instance.\r\n * @classdesc Reflected service method.\r\n * @extends ReflectionObject\r\n * @constructor\r\n * @param {string} name Method name\r\n * @param {string|undefined} type Method type, usually `\"rpc\"`\r\n * @param {string} requestType Request message type\r\n * @param {string} responseType Response message type\r\n * @param {boolean|Object.} [requestStream] Whether the request is streamed\r\n * @param {boolean|Object.} [responseStream] Whether the response is streamed\r\n * @param {Object.} [options] Declared options\r\n * @param {string} [comment] The comment for this method\r\n */\r\nfunction Method(name, type, requestType, responseType, requestStream, responseStream, options, comment) {\r\n\r\n /* istanbul ignore next */\r\n if (util.isObject(requestStream)) {\r\n options = requestStream;\r\n requestStream = responseStream = undefined;\r\n } else if (util.isObject(responseStream)) {\r\n options = responseStream;\r\n responseStream = undefined;\r\n }\r\n\r\n /* istanbul ignore if */\r\n if (!(type === undefined || util.isString(type)))\r\n throw TypeError(\"type must be a string\");\r\n\r\n /* istanbul ignore if */\r\n if (!util.isString(requestType))\r\n throw TypeError(\"requestType must be a string\");\r\n\r\n /* istanbul ignore if */\r\n if (!util.isString(responseType))\r\n throw TypeError(\"responseType must be a string\");\r\n\r\n ReflectionObject.call(this, name, options);\r\n\r\n /**\r\n * Method type.\r\n * @type {string}\r\n */\r\n this.type = type || \"rpc\"; // toJSON\r\n\r\n /**\r\n * Request type.\r\n * @type {string}\r\n */\r\n this.requestType = requestType; // toJSON, marker\r\n\r\n /**\r\n * Whether requests are streamed or not.\r\n * @type {boolean|undefined}\r\n */\r\n this.requestStream = requestStream ? true : undefined; // toJSON\r\n\r\n /**\r\n * Response type.\r\n * @type {string}\r\n */\r\n this.responseType = responseType; // toJSON\r\n\r\n /**\r\n * Whether responses are streamed or not.\r\n * @type {boolean|undefined}\r\n */\r\n this.responseStream = responseStream ? true : undefined; // toJSON\r\n\r\n /**\r\n * Resolved request type.\r\n * @type {Type|null}\r\n */\r\n this.resolvedRequestType = null;\r\n\r\n /**\r\n * Resolved response type.\r\n * @type {Type|null}\r\n */\r\n this.resolvedResponseType = null;\r\n\r\n /**\r\n * Comment for this method\r\n * @type {string|null}\r\n */\r\n this.comment = comment;\r\n}\r\n\r\n/**\r\n * Method descriptor.\r\n * @interface IMethod\r\n * @property {string} [type=\"rpc\"] Method type\r\n * @property {string} requestType Request type\r\n * @property {string} responseType Response type\r\n * @property {boolean} [requestStream=false] Whether requests are streamed\r\n * @property {boolean} [responseStream=false] Whether responses are streamed\r\n * @property {Object.} [options] Method options\r\n */\r\n\r\n/**\r\n * Constructs a method from a method descriptor.\r\n * @param {string} name Method name\r\n * @param {IMethod} json Method descriptor\r\n * @returns {Method} Created method\r\n * @throws {TypeError} If arguments are invalid\r\n */\r\nMethod.fromJSON = function fromJSON(name, json) {\r\n return new Method(name, json.type, json.requestType, json.responseType, json.requestStream, json.responseStream, json.options, json.comment);\r\n};\r\n\r\n/**\r\n * Converts this method to a method descriptor.\r\n * @param {IToJSONOptions} [toJSONOptions] JSON conversion options\r\n * @returns {IMethod} Method descriptor\r\n */\r\nMethod.prototype.toJSON = function toJSON(toJSONOptions) {\r\n var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false;\r\n return util.toObject([\r\n \"type\" , this.type !== \"rpc\" && /* istanbul ignore next */ this.type || undefined,\r\n \"requestType\" , this.requestType,\r\n \"requestStream\" , this.requestStream,\r\n \"responseType\" , this.responseType,\r\n \"responseStream\" , this.responseStream,\r\n \"options\" , this.options,\r\n \"comment\" , keepComments ? this.comment : undefined\r\n ]);\r\n};\r\n\r\n/**\r\n * @override\r\n */\r\nMethod.prototype.resolve = function resolve() {\r\n\r\n /* istanbul ignore if */\r\n if (this.resolved)\r\n return this;\r\n\r\n this.resolvedRequestType = this.parent.lookupType(this.requestType);\r\n this.resolvedResponseType = this.parent.lookupType(this.responseType);\r\n\r\n return ReflectionObject.prototype.resolve.call(this);\r\n};\r\n","\"use strict\";\r\nmodule.exports = Namespace;\r\n\r\n// extends ReflectionObject\r\nvar ReflectionObject = require(24);\r\n((Namespace.prototype = Object.create(ReflectionObject.prototype)).constructor = Namespace).className = \"Namespace\";\r\n\r\nvar Field = require(16),\r\n util = require(37);\r\n\r\nvar Type, // cyclic\r\n Service,\r\n Enum;\r\n\r\n/**\r\n * Constructs a new namespace instance.\r\n * @name Namespace\r\n * @classdesc Reflected namespace.\r\n * @extends NamespaceBase\r\n * @constructor\r\n * @param {string} name Namespace name\r\n * @param {Object.} [options] Declared options\r\n */\r\n\r\n/**\r\n * Constructs a namespace from JSON.\r\n * @memberof Namespace\r\n * @function\r\n * @param {string} name Namespace name\r\n * @param {Object.} json JSON object\r\n * @returns {Namespace} Created namespace\r\n * @throws {TypeError} If arguments are invalid\r\n */\r\nNamespace.fromJSON = function fromJSON(name, json) {\r\n return new Namespace(name, json.options).addJSON(json.nested);\r\n};\r\n\r\n/**\r\n * Converts an array of reflection objects to JSON.\r\n * @memberof Namespace\r\n * @param {ReflectionObject[]} array Object array\r\n * @param {IToJSONOptions} [toJSONOptions] JSON conversion options\r\n * @returns {Object.|undefined} JSON object or `undefined` when array is empty\r\n */\r\nfunction arrayToJSON(array, toJSONOptions) {\r\n if (!(array && array.length))\r\n return undefined;\r\n var obj = {};\r\n for (var i = 0; i < array.length; ++i)\r\n obj[array[i].name] = array[i].toJSON(toJSONOptions);\r\n return obj;\r\n}\r\n\r\nNamespace.arrayToJSON = arrayToJSON;\r\n\r\n/**\r\n * Tests if the specified id is reserved.\r\n * @param {Array.|undefined} reserved Array of reserved ranges and names\r\n * @param {number} id Id to test\r\n * @returns {boolean} `true` if reserved, otherwise `false`\r\n */\r\nNamespace.isReservedId = function isReservedId(reserved, id) {\r\n if (reserved)\r\n for (var i = 0; i < reserved.length; ++i)\r\n if (typeof reserved[i] !== \"string\" && reserved[i][0] <= id && reserved[i][1] >= id)\r\n return true;\r\n return false;\r\n};\r\n\r\n/**\r\n * Tests if the specified name is reserved.\r\n * @param {Array.|undefined} reserved Array of reserved ranges and names\r\n * @param {string} name Name to test\r\n * @returns {boolean} `true` if reserved, otherwise `false`\r\n */\r\nNamespace.isReservedName = function isReservedName(reserved, name) {\r\n if (reserved)\r\n for (var i = 0; i < reserved.length; ++i)\r\n if (reserved[i] === name)\r\n return true;\r\n return false;\r\n};\r\n\r\n/**\r\n * Not an actual constructor. Use {@link Namespace} instead.\r\n * @classdesc Base class of all reflection objects containing nested objects. This is not an actual class but here for the sake of having consistent type definitions.\r\n * @exports NamespaceBase\r\n * @extends ReflectionObject\r\n * @abstract\r\n * @constructor\r\n * @param {string} name Namespace name\r\n * @param {Object.} [options] Declared options\r\n * @see {@link Namespace}\r\n */\r\nfunction Namespace(name, options) {\r\n ReflectionObject.call(this, name, options);\r\n\r\n /**\r\n * Nested objects by name.\r\n * @type {Object.|undefined}\r\n */\r\n this.nested = undefined; // toJSON\r\n\r\n /**\r\n * Cached nested objects as an array.\r\n * @type {ReflectionObject[]|null}\r\n * @private\r\n */\r\n this._nestedArray = null;\r\n}\r\n\r\nfunction clearCache(namespace) {\r\n namespace._nestedArray = null;\r\n return namespace;\r\n}\r\n\r\n/**\r\n * Nested objects of this namespace as an array for iteration.\r\n * @name NamespaceBase#nestedArray\r\n * @type {ReflectionObject[]}\r\n * @readonly\r\n */\r\nObject.defineProperty(Namespace.prototype, \"nestedArray\", {\r\n get: function() {\r\n return this._nestedArray || (this._nestedArray = util.toArray(this.nested));\r\n }\r\n});\r\n\r\n/**\r\n * Namespace descriptor.\r\n * @interface INamespace\r\n * @property {Object.} [options] Namespace options\r\n * @property {Object.} [nested] Nested object descriptors\r\n */\r\n\r\n/**\r\n * Any extension field descriptor.\r\n * @typedef AnyExtensionField\r\n * @type {IExtensionField|IExtensionMapField}\r\n */\r\n\r\n/**\r\n * Any nested object descriptor.\r\n * @typedef AnyNestedObject\r\n * @type {IEnum|IType|IService|AnyExtensionField|INamespace}\r\n */\r\n// ^ BEWARE: VSCode hangs forever when using more than 5 types (that's why AnyExtensionField exists in the first place)\r\n\r\n/**\r\n * Converts this namespace to a namespace descriptor.\r\n * @param {IToJSONOptions} [toJSONOptions] JSON conversion options\r\n * @returns {INamespace} Namespace descriptor\r\n */\r\nNamespace.prototype.toJSON = function toJSON(toJSONOptions) {\r\n return util.toObject([\r\n \"options\" , this.options,\r\n \"nested\" , arrayToJSON(this.nestedArray, toJSONOptions)\r\n ]);\r\n};\r\n\r\n/**\r\n * Adds nested objects to this namespace from nested object descriptors.\r\n * @param {Object.} nestedJson Any nested object descriptors\r\n * @returns {Namespace} `this`\r\n */\r\nNamespace.prototype.addJSON = function addJSON(nestedJson) {\r\n var ns = this;\r\n /* istanbul ignore else */\r\n if (nestedJson) {\r\n for (var names = Object.keys(nestedJson), i = 0, nested; i < names.length; ++i) {\r\n nested = nestedJson[names[i]];\r\n ns.add( // most to least likely\r\n ( nested.fields !== undefined\r\n ? Type.fromJSON\r\n : nested.values !== undefined\r\n ? Enum.fromJSON\r\n : nested.methods !== undefined\r\n ? Service.fromJSON\r\n : nested.id !== undefined\r\n ? Field.fromJSON\r\n : Namespace.fromJSON )(names[i], nested)\r\n );\r\n }\r\n }\r\n return this;\r\n};\r\n\r\n/**\r\n * Gets the nested object of the specified name.\r\n * @param {string} name Nested object name\r\n * @returns {ReflectionObject|null} The reflection object or `null` if it doesn't exist\r\n */\r\nNamespace.prototype.get = function get(name) {\r\n return this.nested && this.nested[name]\r\n || null;\r\n};\r\n\r\n/**\r\n * Gets the values of the nested {@link Enum|enum} of the specified name.\r\n * This methods differs from {@link Namespace#get|get} in that it returns an enum's values directly and throws instead of returning `null`.\r\n * @param {string} name Nested enum name\r\n * @returns {Object.} Enum values\r\n * @throws {Error} If there is no such enum\r\n */\r\nNamespace.prototype.getEnum = function getEnum(name) {\r\n if (this.nested && this.nested[name] instanceof Enum)\r\n return this.nested[name].values;\r\n throw Error(\"no such enum: \" + name);\r\n};\r\n\r\n/**\r\n * Adds a nested object to this namespace.\r\n * @param {ReflectionObject} object Nested object to add\r\n * @returns {Namespace} `this`\r\n * @throws {TypeError} If arguments are invalid\r\n * @throws {Error} If there is already a nested object with this name\r\n */\r\nNamespace.prototype.add = function add(object) {\r\n\r\n if (!(object instanceof Field && object.extend !== undefined || object instanceof Type || object instanceof Enum || object instanceof Service || object instanceof Namespace))\r\n throw TypeError(\"object must be a valid nested object\");\r\n\r\n if (!this.nested)\r\n this.nested = {};\r\n else {\r\n var prev = this.get(object.name);\r\n if (prev) {\r\n if (prev instanceof Namespace && object instanceof Namespace && !(prev instanceof Type || prev instanceof Service)) {\r\n // replace plain namespace but keep existing nested elements and options\r\n var nested = prev.nestedArray;\r\n for (var i = 0; i < nested.length; ++i)\r\n object.add(nested[i]);\r\n this.remove(prev);\r\n if (!this.nested)\r\n this.nested = {};\r\n object.setOptions(prev.options, true);\r\n\r\n } else\r\n throw Error(\"duplicate name '\" + object.name + \"' in \" + this);\r\n }\r\n }\r\n this.nested[object.name] = object;\r\n object.onAdd(this);\r\n return clearCache(this);\r\n};\r\n\r\n/**\r\n * Removes a nested object from this namespace.\r\n * @param {ReflectionObject} object Nested object to remove\r\n * @returns {Namespace} `this`\r\n * @throws {TypeError} If arguments are invalid\r\n * @throws {Error} If `object` is not a member of this namespace\r\n */\r\nNamespace.prototype.remove = function remove(object) {\r\n\r\n if (!(object instanceof ReflectionObject))\r\n throw TypeError(\"object must be a ReflectionObject\");\r\n if (object.parent !== this)\r\n throw Error(object + \" is not a member of \" + this);\r\n\r\n delete this.nested[object.name];\r\n if (!Object.keys(this.nested).length)\r\n this.nested = undefined;\r\n\r\n object.onRemove(this);\r\n return clearCache(this);\r\n};\r\n\r\n/**\r\n * Defines additial namespaces within this one if not yet existing.\r\n * @param {string|string[]} path Path to create\r\n * @param {*} [json] Nested types to create from JSON\r\n * @returns {Namespace} Pointer to the last namespace created or `this` if path is empty\r\n */\r\nNamespace.prototype.define = function define(path, json) {\r\n\r\n if (util.isString(path))\r\n path = path.split(\".\");\r\n else if (!Array.isArray(path))\r\n throw TypeError(\"illegal path\");\r\n if (path && path.length && path[0] === \"\")\r\n throw Error(\"path must be relative\");\r\n\r\n var ptr = this;\r\n while (path.length > 0) {\r\n var part = path.shift();\r\n if (ptr.nested && ptr.nested[part]) {\r\n ptr = ptr.nested[part];\r\n if (!(ptr instanceof Namespace))\r\n throw Error(\"path conflicts with non-namespace objects\");\r\n } else\r\n ptr.add(ptr = new Namespace(part));\r\n }\r\n if (json)\r\n ptr.addJSON(json);\r\n return ptr;\r\n};\r\n\r\n/**\r\n * Resolves this namespace's and all its nested objects' type references. Useful to validate a reflection tree, but comes at a cost.\r\n * @returns {Namespace} `this`\r\n */\r\nNamespace.prototype.resolveAll = function resolveAll() {\r\n var nested = this.nestedArray, i = 0;\r\n while (i < nested.length)\r\n if (nested[i] instanceof Namespace)\r\n nested[i++].resolveAll();\r\n else\r\n nested[i++].resolve();\r\n return this.resolve();\r\n};\r\n\r\n/**\r\n * Recursively looks up the reflection object matching the specified path in the scope of this namespace.\r\n * @param {string|string[]} path Path to look up\r\n * @param {*|Array.<*>} filterTypes Filter types, any combination of the constructors of `protobuf.Type`, `protobuf.Enum`, `protobuf.Service` etc.\r\n * @param {boolean} [parentAlreadyChecked=false] If known, whether the parent has already been checked\r\n * @returns {ReflectionObject|null} Looked up object or `null` if none could be found\r\n */\r\nNamespace.prototype.lookup = function lookup(path, filterTypes, parentAlreadyChecked) {\r\n\r\n /* istanbul ignore next */\r\n if (typeof filterTypes === \"boolean\") {\r\n parentAlreadyChecked = filterTypes;\r\n filterTypes = undefined;\r\n } else if (filterTypes && !Array.isArray(filterTypes))\r\n filterTypes = [ filterTypes ];\r\n\r\n if (util.isString(path) && path.length) {\r\n if (path === \".\")\r\n return this.root;\r\n path = path.split(\".\");\r\n } else if (!path.length)\r\n return this;\r\n\r\n // Start at root if path is absolute\r\n if (path[0] === \"\")\r\n return this.root.lookup(path.slice(1), filterTypes);\r\n\r\n // Test if the first part matches any nested object, and if so, traverse if path contains more\r\n var found = this.get(path[0]);\r\n if (found) {\r\n if (path.length === 1) {\r\n if (!filterTypes || filterTypes.indexOf(found.constructor) > -1)\r\n return found;\r\n } else if (found instanceof Namespace && (found = found.lookup(path.slice(1), filterTypes, true)))\r\n return found;\r\n\r\n // Otherwise try each nested namespace\r\n } else\r\n for (var i = 0; i < this.nestedArray.length; ++i)\r\n if (this._nestedArray[i] instanceof Namespace && (found = this._nestedArray[i].lookup(path, filterTypes, true)))\r\n return found;\r\n\r\n // If there hasn't been a match, try again at the parent\r\n if (this.parent === null || parentAlreadyChecked)\r\n return null;\r\n return this.parent.lookup(path, filterTypes);\r\n};\r\n\r\n/**\r\n * Looks up the reflection object at the specified path, relative to this namespace.\r\n * @name NamespaceBase#lookup\r\n * @function\r\n * @param {string|string[]} path Path to look up\r\n * @param {boolean} [parentAlreadyChecked=false] Whether the parent has already been checked\r\n * @returns {ReflectionObject|null} Looked up object or `null` if none could be found\r\n * @variation 2\r\n */\r\n// lookup(path: string, [parentAlreadyChecked: boolean])\r\n\r\n/**\r\n * Looks up the {@link Type|type} at the specified path, relative to this namespace.\r\n * Besides its signature, this methods differs from {@link Namespace#lookup|lookup} in that it throws instead of returning `null`.\r\n * @param {string|string[]} path Path to look up\r\n * @returns {Type} Looked up type\r\n * @throws {Error} If `path` does not point to a type\r\n */\r\nNamespace.prototype.lookupType = function lookupType(path) {\r\n var found = this.lookup(path, [ Type ]);\r\n if (!found)\r\n throw Error(\"no such type: \" + path);\r\n return found;\r\n};\r\n\r\n/**\r\n * Looks up the values of the {@link Enum|enum} at the specified path, relative to this namespace.\r\n * Besides its signature, this methods differs from {@link Namespace#lookup|lookup} in that it throws instead of returning `null`.\r\n * @param {string|string[]} path Path to look up\r\n * @returns {Enum} Looked up enum\r\n * @throws {Error} If `path` does not point to an enum\r\n */\r\nNamespace.prototype.lookupEnum = function lookupEnum(path) {\r\n var found = this.lookup(path, [ Enum ]);\r\n if (!found)\r\n throw Error(\"no such Enum '\" + path + \"' in \" + this);\r\n return found;\r\n};\r\n\r\n/**\r\n * Looks up the {@link Type|type} or {@link Enum|enum} at the specified path, relative to this namespace.\r\n * Besides its signature, this methods differs from {@link Namespace#lookup|lookup} in that it throws instead of returning `null`.\r\n * @param {string|string[]} path Path to look up\r\n * @returns {Type} Looked up type or enum\r\n * @throws {Error} If `path` does not point to a type or enum\r\n */\r\nNamespace.prototype.lookupTypeOrEnum = function lookupTypeOrEnum(path) {\r\n var found = this.lookup(path, [ Type, Enum ]);\r\n if (!found)\r\n throw Error(\"no such Type or Enum '\" + path + \"' in \" + this);\r\n return found;\r\n};\r\n\r\n/**\r\n * Looks up the {@link Service|service} at the specified path, relative to this namespace.\r\n * Besides its signature, this methods differs from {@link Namespace#lookup|lookup} in that it throws instead of returning `null`.\r\n * @param {string|string[]} path Path to look up\r\n * @returns {Service} Looked up service\r\n * @throws {Error} If `path` does not point to a service\r\n */\r\nNamespace.prototype.lookupService = function lookupService(path) {\r\n var found = this.lookup(path, [ Service ]);\r\n if (!found)\r\n throw Error(\"no such Service '\" + path + \"' in \" + this);\r\n return found;\r\n};\r\n\r\n// Sets up cyclic dependencies (called in index-light)\r\nNamespace._configure = function(Type_, Service_, Enum_) {\r\n Type = Type_;\r\n Service = Service_;\r\n Enum = Enum_;\r\n};\r\n","\"use strict\";\r\nmodule.exports = ReflectionObject;\r\n\r\nReflectionObject.className = \"ReflectionObject\";\r\n\r\nvar util = require(37);\r\n\r\nvar Root; // cyclic\r\n\r\n/**\r\n * Constructs a new reflection object instance.\r\n * @classdesc Base class of all reflection objects.\r\n * @constructor\r\n * @param {string} name Object name\r\n * @param {Object.} [options] Declared options\r\n * @abstract\r\n */\r\nfunction ReflectionObject(name, options) {\r\n\r\n if (!util.isString(name))\r\n throw TypeError(\"name must be a string\");\r\n\r\n if (options && !util.isObject(options))\r\n throw TypeError(\"options must be an object\");\r\n\r\n /**\r\n * Options.\r\n * @type {Object.|undefined}\r\n */\r\n this.options = options; // toJSON\r\n\r\n /**\r\n * Unique name within its namespace.\r\n * @type {string}\r\n */\r\n this.name = name;\r\n\r\n /**\r\n * Parent namespace.\r\n * @type {Namespace|null}\r\n */\r\n this.parent = null;\r\n\r\n /**\r\n * Whether already resolved or not.\r\n * @type {boolean}\r\n */\r\n this.resolved = false;\r\n\r\n /**\r\n * Comment text, if any.\r\n * @type {string|null}\r\n */\r\n this.comment = null;\r\n\r\n /**\r\n * Defining file name.\r\n * @type {string|null}\r\n */\r\n this.filename = null;\r\n}\r\n\r\nObject.defineProperties(ReflectionObject.prototype, {\r\n\r\n /**\r\n * Reference to the root namespace.\r\n * @name ReflectionObject#root\r\n * @type {Root}\r\n * @readonly\r\n */\r\n root: {\r\n get: function() {\r\n var ptr = this;\r\n while (ptr.parent !== null)\r\n ptr = ptr.parent;\r\n return ptr;\r\n }\r\n },\r\n\r\n /**\r\n * Full name including leading dot.\r\n * @name ReflectionObject#fullName\r\n * @type {string}\r\n * @readonly\r\n */\r\n fullName: {\r\n get: function() {\r\n var path = [ this.name ],\r\n ptr = this.parent;\r\n while (ptr) {\r\n path.unshift(ptr.name);\r\n ptr = ptr.parent;\r\n }\r\n return path.join(\".\");\r\n }\r\n }\r\n});\r\n\r\n/**\r\n * Converts this reflection object to its descriptor representation.\r\n * @returns {Object.} Descriptor\r\n * @abstract\r\n */\r\nReflectionObject.prototype.toJSON = /* istanbul ignore next */ function toJSON() {\r\n throw Error(); // not implemented, shouldn't happen\r\n};\r\n\r\n/**\r\n * Called when this object is added to a parent.\r\n * @param {ReflectionObject} parent Parent added to\r\n * @returns {undefined}\r\n */\r\nReflectionObject.prototype.onAdd = function onAdd(parent) {\r\n if (this.parent && this.parent !== parent)\r\n this.parent.remove(this);\r\n this.parent = parent;\r\n this.resolved = false;\r\n var root = parent.root;\r\n if (root instanceof Root)\r\n root._handleAdd(this);\r\n};\r\n\r\n/**\r\n * Called when this object is removed from a parent.\r\n * @param {ReflectionObject} parent Parent removed from\r\n * @returns {undefined}\r\n */\r\nReflectionObject.prototype.onRemove = function onRemove(parent) {\r\n var root = parent.root;\r\n if (root instanceof Root)\r\n root._handleRemove(this);\r\n this.parent = null;\r\n this.resolved = false;\r\n};\r\n\r\n/**\r\n * Resolves this objects type references.\r\n * @returns {ReflectionObject} `this`\r\n */\r\nReflectionObject.prototype.resolve = function resolve() {\r\n if (this.resolved)\r\n return this;\r\n if (this.root instanceof Root)\r\n this.resolved = true; // only if part of a root\r\n return this;\r\n};\r\n\r\n/**\r\n * Gets an option value.\r\n * @param {string} name Option name\r\n * @returns {*} Option value or `undefined` if not set\r\n */\r\nReflectionObject.prototype.getOption = function getOption(name) {\r\n if (this.options)\r\n return this.options[name];\r\n return undefined;\r\n};\r\n\r\n/**\r\n * Sets an option.\r\n * @param {string} name Option name\r\n * @param {*} value Option value\r\n * @param {boolean} [ifNotSet] Sets the option only if it isn't currently set\r\n * @returns {ReflectionObject} `this`\r\n */\r\nReflectionObject.prototype.setOption = function setOption(name, value, ifNotSet) {\r\n if (!ifNotSet || !this.options || this.options[name] === undefined)\r\n (this.options || (this.options = {}))[name] = value;\r\n return this;\r\n};\r\n\r\n/**\r\n * Sets multiple options.\r\n * @param {Object.} options Options to set\r\n * @param {boolean} [ifNotSet] Sets an option only if it isn't currently set\r\n * @returns {ReflectionObject} `this`\r\n */\r\nReflectionObject.prototype.setOptions = function setOptions(options, ifNotSet) {\r\n if (options)\r\n for (var keys = Object.keys(options), i = 0; i < keys.length; ++i)\r\n this.setOption(keys[i], options[keys[i]], ifNotSet);\r\n return this;\r\n};\r\n\r\n/**\r\n * Converts this instance to its string representation.\r\n * @returns {string} Class name[, space, full name]\r\n */\r\nReflectionObject.prototype.toString = function toString() {\r\n var className = this.constructor.className,\r\n fullName = this.fullName;\r\n if (fullName.length)\r\n return className + \" \" + fullName;\r\n return className;\r\n};\r\n\r\n// Sets up cyclic dependencies (called in index-light)\r\nReflectionObject._configure = function(Root_) {\r\n Root = Root_;\r\n};\r\n","\"use strict\";\r\nmodule.exports = OneOf;\r\n\r\n// extends ReflectionObject\r\nvar ReflectionObject = require(24);\r\n((OneOf.prototype = Object.create(ReflectionObject.prototype)).constructor = OneOf).className = \"OneOf\";\r\n\r\nvar Field = require(16),\r\n util = require(37);\r\n\r\n/**\r\n * Constructs a new oneof instance.\r\n * @classdesc Reflected oneof.\r\n * @extends ReflectionObject\r\n * @constructor\r\n * @param {string} name Oneof name\r\n * @param {string[]|Object.} [fieldNames] Field names\r\n * @param {Object.} [options] Declared options\r\n * @param {string} [comment] Comment associated with this field\r\n */\r\nfunction OneOf(name, fieldNames, options, comment) {\r\n if (!Array.isArray(fieldNames)) {\r\n options = fieldNames;\r\n fieldNames = undefined;\r\n }\r\n ReflectionObject.call(this, name, options);\r\n\r\n /* istanbul ignore if */\r\n if (!(fieldNames === undefined || Array.isArray(fieldNames)))\r\n throw TypeError(\"fieldNames must be an Array\");\r\n\r\n /**\r\n * Field names that belong to this oneof.\r\n * @type {string[]}\r\n */\r\n this.oneof = fieldNames || []; // toJSON, marker\r\n\r\n /**\r\n * Fields that belong to this oneof as an array for iteration.\r\n * @type {Field[]}\r\n * @readonly\r\n */\r\n this.fieldsArray = []; // declared readonly for conformance, possibly not yet added to parent\r\n\r\n /**\r\n * Comment for this field.\r\n * @type {string|null}\r\n */\r\n this.comment = comment;\r\n}\r\n\r\n/**\r\n * Oneof descriptor.\r\n * @interface IOneOf\r\n * @property {Array.} oneof Oneof field names\r\n * @property {Object.} [options] Oneof options\r\n */\r\n\r\n/**\r\n * Constructs a oneof from a oneof descriptor.\r\n * @param {string} name Oneof name\r\n * @param {IOneOf} json Oneof descriptor\r\n * @returns {OneOf} Created oneof\r\n * @throws {TypeError} If arguments are invalid\r\n */\r\nOneOf.fromJSON = function fromJSON(name, json) {\r\n return new OneOf(name, json.oneof, json.options, json.comment);\r\n};\r\n\r\n/**\r\n * Converts this oneof to a oneof descriptor.\r\n * @param {IToJSONOptions} [toJSONOptions] JSON conversion options\r\n * @returns {IOneOf} Oneof descriptor\r\n */\r\nOneOf.prototype.toJSON = function toJSON(toJSONOptions) {\r\n var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false;\r\n return util.toObject([\r\n \"options\" , this.options,\r\n \"oneof\" , this.oneof,\r\n \"comment\" , keepComments ? this.comment : undefined\r\n ]);\r\n};\r\n\r\n/**\r\n * Adds the fields of the specified oneof to the parent if not already done so.\r\n * @param {OneOf} oneof The oneof\r\n * @returns {undefined}\r\n * @inner\r\n * @ignore\r\n */\r\nfunction addFieldsToParent(oneof) {\r\n if (oneof.parent)\r\n for (var i = 0; i < oneof.fieldsArray.length; ++i)\r\n if (!oneof.fieldsArray[i].parent)\r\n oneof.parent.add(oneof.fieldsArray[i]);\r\n}\r\n\r\n/**\r\n * Adds a field to this oneof and removes it from its current parent, if any.\r\n * @param {Field} field Field to add\r\n * @returns {OneOf} `this`\r\n */\r\nOneOf.prototype.add = function add(field) {\r\n\r\n /* istanbul ignore if */\r\n if (!(field instanceof Field))\r\n throw TypeError(\"field must be a Field\");\r\n\r\n if (field.parent && field.parent !== this.parent)\r\n field.parent.remove(field);\r\n this.oneof.push(field.name);\r\n this.fieldsArray.push(field);\r\n field.partOf = this; // field.parent remains null\r\n addFieldsToParent(this);\r\n return this;\r\n};\r\n\r\n/**\r\n * Removes a field from this oneof and puts it back to the oneof's parent.\r\n * @param {Field} field Field to remove\r\n * @returns {OneOf} `this`\r\n */\r\nOneOf.prototype.remove = function remove(field) {\r\n\r\n /* istanbul ignore if */\r\n if (!(field instanceof Field))\r\n throw TypeError(\"field must be a Field\");\r\n\r\n var index = this.fieldsArray.indexOf(field);\r\n\r\n /* istanbul ignore if */\r\n if (index < 0)\r\n throw Error(field + \" is not a member of \" + this);\r\n\r\n this.fieldsArray.splice(index, 1);\r\n index = this.oneof.indexOf(field.name);\r\n\r\n /* istanbul ignore else */\r\n if (index > -1) // theoretical\r\n this.oneof.splice(index, 1);\r\n\r\n field.partOf = null;\r\n return this;\r\n};\r\n\r\n/**\r\n * @override\r\n */\r\nOneOf.prototype.onAdd = function onAdd(parent) {\r\n ReflectionObject.prototype.onAdd.call(this, parent);\r\n var self = this;\r\n // Collect present fields\r\n for (var i = 0; i < this.oneof.length; ++i) {\r\n var field = parent.get(this.oneof[i]);\r\n if (field && !field.partOf) {\r\n field.partOf = self;\r\n self.fieldsArray.push(field);\r\n }\r\n }\r\n // Add not yet present fields\r\n addFieldsToParent(this);\r\n};\r\n\r\n/**\r\n * @override\r\n */\r\nOneOf.prototype.onRemove = function onRemove(parent) {\r\n for (var i = 0, field; i < this.fieldsArray.length; ++i)\r\n if ((field = this.fieldsArray[i]).parent)\r\n field.parent.remove(field);\r\n ReflectionObject.prototype.onRemove.call(this, parent);\r\n};\r\n\r\n/**\r\n * Decorator function as returned by {@link OneOf.d} (TypeScript).\r\n * @typedef OneOfDecorator\r\n * @type {function}\r\n * @param {Object} prototype Target prototype\r\n * @param {string} oneofName OneOf name\r\n * @returns {undefined}\r\n */\r\n\r\n/**\r\n * OneOf decorator (TypeScript).\r\n * @function\r\n * @param {...string} fieldNames Field names\r\n * @returns {OneOfDecorator} Decorator function\r\n * @template T extends string\r\n */\r\nOneOf.d = function decorateOneOf() {\r\n var fieldNames = new Array(arguments.length),\r\n index = 0;\r\n while (index < arguments.length)\r\n fieldNames[index] = arguments[index++];\r\n return function oneOfDecorator(prototype, oneofName) {\r\n util.decorateType(prototype.constructor)\r\n .add(new OneOf(oneofName, fieldNames));\r\n Object.defineProperty(prototype, oneofName, {\r\n get: util.oneOfGetter(fieldNames),\r\n set: util.oneOfSetter(fieldNames)\r\n });\r\n };\r\n};\r\n","\"use strict\";\r\nmodule.exports = parse;\r\n\r\nparse.filename = null;\r\nparse.defaults = { keepCase: false };\r\n\r\nvar tokenize = require(34),\r\n Root = require(29),\r\n Type = require(35),\r\n Field = require(16),\r\n MapField = require(20),\r\n OneOf = require(25),\r\n Enum = require(15),\r\n Service = require(33),\r\n Method = require(22),\r\n types = require(36),\r\n util = require(37);\r\n\r\nvar base10Re = /^[1-9][0-9]*$/,\r\n base10NegRe = /^-?[1-9][0-9]*$/,\r\n base16Re = /^0[x][0-9a-fA-F]+$/,\r\n base16NegRe = /^-?0[x][0-9a-fA-F]+$/,\r\n base8Re = /^0[0-7]+$/,\r\n base8NegRe = /^-?0[0-7]+$/,\r\n numberRe = /^(?![eE])[0-9]*(?:\\.[0-9]*)?(?:[eE][+-]?[0-9]+)?$/,\r\n nameRe = /^[a-zA-Z_][a-zA-Z_0-9]*$/,\r\n typeRefRe = /^(?:\\.?[a-zA-Z_][a-zA-Z_0-9]*)(?:\\.[a-zA-Z_][a-zA-Z_0-9]*)*$/,\r\n fqTypeRefRe = /^(?:\\.[a-zA-Z_][a-zA-Z_0-9]*)+$/;\r\n\r\n/**\r\n * Result object returned from {@link parse}.\r\n * @interface IParserResult\r\n * @property {string|undefined} package Package name, if declared\r\n * @property {string[]|undefined} imports Imports, if any\r\n * @property {string[]|undefined} weakImports Weak imports, if any\r\n * @property {string|undefined} syntax Syntax, if specified (either `\"proto2\"` or `\"proto3\"`)\r\n * @property {Root} root Populated root instance\r\n */\r\n\r\n/**\r\n * Options modifying the behavior of {@link parse}.\r\n * @interface IParseOptions\r\n * @property {boolean} [keepCase=false] Keeps field casing instead of converting to camel case\r\n * @property {boolean} [alternateCommentMode=false] Recognize double-slash comments in addition to doc-block comments.\r\n */\r\n\r\n/**\r\n * Options modifying the behavior of JSON serialization.\r\n * @interface IToJSONOptions\r\n * @property {boolean} [keepComments=false] Serializes comments.\r\n */\r\n\r\n/**\r\n * Parses the given .proto source and returns an object with the parsed contents.\r\n * @param {string} source Source contents\r\n * @param {Root} root Root to populate\r\n * @param {IParseOptions} [options] Parse options. Defaults to {@link parse.defaults} when omitted.\r\n * @returns {IParserResult} Parser result\r\n * @property {string} filename=null Currently processing file name for error reporting, if known\r\n * @property {IParseOptions} defaults Default {@link IParseOptions}\r\n */\r\nfunction parse(source, root, options) {\r\n /* eslint-disable callback-return */\r\n if (!(root instanceof Root)) {\r\n options = root;\r\n root = new Root();\r\n }\r\n if (!options)\r\n options = parse.defaults;\r\n\r\n var tn = tokenize(source, options.alternateCommentMode || false),\r\n next = tn.next,\r\n push = tn.push,\r\n peek = tn.peek,\r\n skip = tn.skip,\r\n cmnt = tn.cmnt;\r\n\r\n var head = true,\r\n pkg,\r\n imports,\r\n weakImports,\r\n syntax,\r\n isProto3 = false;\r\n\r\n var ptr = root;\r\n\r\n var applyCase = options.keepCase ? function(name) { return name; } : util.camelCase;\r\n\r\n /* istanbul ignore next */\r\n function illegal(token, name, insideTryCatch) {\r\n var filename = parse.filename;\r\n if (!insideTryCatch)\r\n parse.filename = null;\r\n return Error(\"illegal \" + (name || \"token\") + \" '\" + token + \"' (\" + (filename ? filename + \", \" : \"\") + \"line \" + tn.line + \")\");\r\n }\r\n\r\n function readString() {\r\n var values = [],\r\n token;\r\n do {\r\n /* istanbul ignore if */\r\n if ((token = next()) !== \"\\\"\" && token !== \"'\")\r\n throw illegal(token);\r\n\r\n values.push(next());\r\n skip(token);\r\n token = peek();\r\n } while (token === \"\\\"\" || token === \"'\");\r\n return values.join(\"\");\r\n }\r\n\r\n function readValue(acceptTypeRef) {\r\n var token = next();\r\n switch (token) {\r\n case \"'\":\r\n case \"\\\"\":\r\n push(token);\r\n return readString();\r\n case \"true\": case \"TRUE\":\r\n return true;\r\n case \"false\": case \"FALSE\":\r\n return false;\r\n }\r\n try {\r\n return parseNumber(token, /* insideTryCatch */ true);\r\n } catch (e) {\r\n\r\n /* istanbul ignore else */\r\n if (acceptTypeRef && typeRefRe.test(token))\r\n return token;\r\n\r\n /* istanbul ignore next */\r\n throw illegal(token, \"value\");\r\n }\r\n }\r\n\r\n function readRanges(target, acceptStrings) {\r\n var token, start;\r\n do {\r\n if (acceptStrings && ((token = peek()) === \"\\\"\" || token === \"'\"))\r\n target.push(readString());\r\n else\r\n target.push([ start = parseId(next()), skip(\"to\", true) ? parseId(next()) : start ]);\r\n } while (skip(\",\", true));\r\n skip(\";\");\r\n }\r\n\r\n function parseNumber(token, insideTryCatch) {\r\n var sign = 1;\r\n if (token.charAt(0) === \"-\") {\r\n sign = -1;\r\n token = token.substring(1);\r\n }\r\n switch (token) {\r\n case \"inf\": case \"INF\": case \"Inf\":\r\n return sign * Infinity;\r\n case \"nan\": case \"NAN\": case \"Nan\": case \"NaN\":\r\n return NaN;\r\n case \"0\":\r\n return 0;\r\n }\r\n if (base10Re.test(token))\r\n return sign * parseInt(token, 10);\r\n if (base16Re.test(token))\r\n return sign * parseInt(token, 16);\r\n if (base8Re.test(token))\r\n return sign * parseInt(token, 8);\r\n\r\n /* istanbul ignore else */\r\n if (numberRe.test(token))\r\n return sign * parseFloat(token);\r\n\r\n /* istanbul ignore next */\r\n throw illegal(token, \"number\", insideTryCatch);\r\n }\r\n\r\n function parseId(token, acceptNegative) {\r\n switch (token) {\r\n case \"max\": case \"MAX\": case \"Max\":\r\n return 536870911;\r\n case \"0\":\r\n return 0;\r\n }\r\n\r\n /* istanbul ignore if */\r\n if (!acceptNegative && token.charAt(0) === \"-\")\r\n throw illegal(token, \"id\");\r\n\r\n if (base10NegRe.test(token))\r\n return parseInt(token, 10);\r\n if (base16NegRe.test(token))\r\n return parseInt(token, 16);\r\n\r\n /* istanbul ignore else */\r\n if (base8NegRe.test(token))\r\n return parseInt(token, 8);\r\n\r\n /* istanbul ignore next */\r\n throw illegal(token, \"id\");\r\n }\r\n\r\n function parsePackage() {\r\n\r\n /* istanbul ignore if */\r\n if (pkg !== undefined)\r\n throw illegal(\"package\");\r\n\r\n pkg = next();\r\n\r\n /* istanbul ignore if */\r\n if (!typeRefRe.test(pkg))\r\n throw illegal(pkg, \"name\");\r\n\r\n ptr = ptr.define(pkg);\r\n skip(\";\");\r\n }\r\n\r\n function parseImport() {\r\n var token = peek();\r\n var whichImports;\r\n switch (token) {\r\n case \"weak\":\r\n whichImports = weakImports || (weakImports = []);\r\n next();\r\n break;\r\n case \"public\":\r\n next();\r\n // eslint-disable-line no-fallthrough\r\n default:\r\n whichImports = imports || (imports = []);\r\n break;\r\n }\r\n token = readString();\r\n skip(\";\");\r\n whichImports.push(token);\r\n }\r\n\r\n function parseSyntax() {\r\n skip(\"=\");\r\n syntax = readString();\r\n isProto3 = syntax === \"proto3\";\r\n\r\n /* istanbul ignore if */\r\n if (!isProto3 && syntax !== \"proto2\")\r\n throw illegal(syntax, \"syntax\");\r\n\r\n skip(\";\");\r\n }\r\n\r\n function parseCommon(parent, token) {\r\n switch (token) {\r\n\r\n case \"option\":\r\n parseOption(parent, token);\r\n skip(\";\");\r\n return true;\r\n\r\n case \"message\":\r\n parseType(parent, token);\r\n return true;\r\n\r\n case \"enum\":\r\n parseEnum(parent, token);\r\n return true;\r\n\r\n case \"service\":\r\n parseService(parent, token);\r\n return true;\r\n\r\n case \"extend\":\r\n parseExtension(parent, token);\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n function ifBlock(obj, fnIf, fnElse) {\r\n var trailingLine = tn.line;\r\n if (obj) {\r\n obj.comment = cmnt(); // try block-type comment\r\n obj.filename = parse.filename;\r\n }\r\n if (skip(\"{\", true)) {\r\n var token;\r\n while ((token = next()) !== \"}\")\r\n fnIf(token);\r\n skip(\";\", true);\r\n } else {\r\n if (fnElse)\r\n fnElse();\r\n skip(\";\");\r\n if (obj && typeof obj.comment !== \"string\")\r\n obj.comment = cmnt(trailingLine); // try line-type comment if no block\r\n }\r\n }\r\n\r\n function parseType(parent, token) {\r\n\r\n /* istanbul ignore if */\r\n if (!nameRe.test(token = next()))\r\n throw illegal(token, \"type name\");\r\n\r\n var type = new Type(token);\r\n ifBlock(type, function parseType_block(token) {\r\n if (parseCommon(type, token))\r\n return;\r\n\r\n switch (token) {\r\n\r\n case \"map\":\r\n parseMapField(type, token);\r\n break;\r\n\r\n case \"required\":\r\n case \"optional\":\r\n case \"repeated\":\r\n parseField(type, token);\r\n break;\r\n\r\n case \"oneof\":\r\n parseOneOf(type, token);\r\n break;\r\n\r\n case \"extensions\":\r\n readRanges(type.extensions || (type.extensions = []));\r\n break;\r\n\r\n case \"reserved\":\r\n readRanges(type.reserved || (type.reserved = []), true);\r\n break;\r\n\r\n default:\r\n /* istanbul ignore if */\r\n if (!isProto3 || !typeRefRe.test(token))\r\n throw illegal(token);\r\n\r\n push(token);\r\n parseField(type, \"optional\");\r\n break;\r\n }\r\n });\r\n parent.add(type);\r\n }\r\n\r\n function parseField(parent, rule, extend) {\r\n var type = next();\r\n if (type === \"group\") {\r\n parseGroup(parent, rule);\r\n return;\r\n }\r\n\r\n /* istanbul ignore if */\r\n if (!typeRefRe.test(type))\r\n throw illegal(type, \"type\");\r\n\r\n var name = next();\r\n\r\n /* istanbul ignore if */\r\n if (!nameRe.test(name))\r\n throw illegal(name, \"name\");\r\n\r\n name = applyCase(name);\r\n skip(\"=\");\r\n\r\n var field = new Field(name, parseId(next()), type, rule, extend);\r\n ifBlock(field, function parseField_block(token) {\r\n\r\n /* istanbul ignore else */\r\n if (token === \"option\") {\r\n parseOption(field, token);\r\n skip(\";\");\r\n } else\r\n throw illegal(token);\r\n\r\n }, function parseField_line() {\r\n parseInlineOptions(field);\r\n });\r\n parent.add(field);\r\n\r\n // JSON defaults to packed=true if not set so we have to set packed=false explicity when\r\n // parsing proto2 descriptors without the option, where applicable. This must be done for\r\n // all known packable types and anything that could be an enum (= is not a basic type).\r\n if (!isProto3 && field.repeated && (types.packed[type] !== undefined || types.basic[type] === undefined))\r\n field.setOption(\"packed\", false, /* ifNotSet */ true);\r\n }\r\n\r\n function parseGroup(parent, rule) {\r\n var name = next();\r\n\r\n /* istanbul ignore if */\r\n if (!nameRe.test(name))\r\n throw illegal(name, \"name\");\r\n\r\n var fieldName = util.lcFirst(name);\r\n if (name === fieldName)\r\n name = util.ucFirst(name);\r\n skip(\"=\");\r\n var id = parseId(next());\r\n var type = new Type(name);\r\n type.group = true;\r\n var field = new Field(fieldName, id, name, rule);\r\n field.filename = parse.filename;\r\n ifBlock(type, function parseGroup_block(token) {\r\n switch (token) {\r\n\r\n case \"option\":\r\n parseOption(type, token);\r\n skip(\";\");\r\n break;\r\n\r\n case \"required\":\r\n case \"optional\":\r\n case \"repeated\":\r\n parseField(type, token);\r\n break;\r\n\r\n /* istanbul ignore next */\r\n default:\r\n throw illegal(token); // there are no groups with proto3 semantics\r\n }\r\n });\r\n parent.add(type)\r\n .add(field);\r\n }\r\n\r\n function parseMapField(parent) {\r\n skip(\"<\");\r\n var keyType = next();\r\n\r\n /* istanbul ignore if */\r\n if (types.mapKey[keyType] === undefined)\r\n throw illegal(keyType, \"type\");\r\n\r\n skip(\",\");\r\n var valueType = next();\r\n\r\n /* istanbul ignore if */\r\n if (!typeRefRe.test(valueType))\r\n throw illegal(valueType, \"type\");\r\n\r\n skip(\">\");\r\n var name = next();\r\n\r\n /* istanbul ignore if */\r\n if (!nameRe.test(name))\r\n throw illegal(name, \"name\");\r\n\r\n skip(\"=\");\r\n var field = new MapField(applyCase(name), parseId(next()), keyType, valueType);\r\n ifBlock(field, function parseMapField_block(token) {\r\n\r\n /* istanbul ignore else */\r\n if (token === \"option\") {\r\n parseOption(field, token);\r\n skip(\";\");\r\n } else\r\n throw illegal(token);\r\n\r\n }, function parseMapField_line() {\r\n parseInlineOptions(field);\r\n });\r\n parent.add(field);\r\n }\r\n\r\n function parseOneOf(parent, token) {\r\n\r\n /* istanbul ignore if */\r\n if (!nameRe.test(token = next()))\r\n throw illegal(token, \"name\");\r\n\r\n var oneof = new OneOf(applyCase(token));\r\n ifBlock(oneof, function parseOneOf_block(token) {\r\n if (token === \"option\") {\r\n parseOption(oneof, token);\r\n skip(\";\");\r\n } else {\r\n push(token);\r\n parseField(oneof, \"optional\");\r\n }\r\n });\r\n parent.add(oneof);\r\n }\r\n\r\n function parseEnum(parent, token) {\r\n\r\n /* istanbul ignore if */\r\n if (!nameRe.test(token = next()))\r\n throw illegal(token, \"name\");\r\n\r\n var enm = new Enum(token);\r\n ifBlock(enm, function parseEnum_block(token) {\r\n switch(token) {\r\n case \"option\":\r\n parseOption(enm, token);\r\n skip(\";\");\r\n break;\r\n\r\n case \"reserved\":\r\n readRanges(enm.reserved || (enm.reserved = []), true);\r\n break;\r\n\r\n default:\r\n parseEnumValue(enm, token);\r\n }\r\n });\r\n parent.add(enm);\r\n }\r\n\r\n function parseEnumValue(parent, token) {\r\n\r\n /* istanbul ignore if */\r\n if (!nameRe.test(token))\r\n throw illegal(token, \"name\");\r\n\r\n skip(\"=\");\r\n var value = parseId(next(), true),\r\n dummy = {};\r\n ifBlock(dummy, function parseEnumValue_block(token) {\r\n\r\n /* istanbul ignore else */\r\n if (token === \"option\") {\r\n parseOption(dummy, token); // skip\r\n skip(\";\");\r\n } else\r\n throw illegal(token);\r\n\r\n }, function parseEnumValue_line() {\r\n parseInlineOptions(dummy); // skip\r\n });\r\n parent.add(token, value, dummy.comment);\r\n }\r\n\r\n function parseOption(parent, token) {\r\n var isCustom = skip(\"(\", true);\r\n\r\n /* istanbul ignore if */\r\n if (!typeRefRe.test(token = next()))\r\n throw illegal(token, \"name\");\r\n\r\n var name = token;\r\n if (isCustom) {\r\n skip(\")\");\r\n name = \"(\" + name + \")\";\r\n token = peek();\r\n if (fqTypeRefRe.test(token)) {\r\n name += token;\r\n next();\r\n }\r\n }\r\n skip(\"=\");\r\n parseOptionValue(parent, name);\r\n }\r\n\r\n function parseOptionValue(parent, name) {\r\n if (skip(\"{\", true)) { // { a: \"foo\" b { c: \"bar\" } }\r\n do {\r\n /* istanbul ignore if */\r\n if (!nameRe.test(token = next()))\r\n throw illegal(token, \"name\");\r\n\r\n if (peek() === \"{\")\r\n parseOptionValue(parent, name + \".\" + token);\r\n else {\r\n skip(\":\");\r\n if (peek() === \"{\")\r\n parseOptionValue(parent, name + \".\" + token);\r\n else\r\n setOption(parent, name + \".\" + token, readValue(true));\r\n }\r\n skip(\",\", true);\r\n } while (!skip(\"}\", true));\r\n } else\r\n setOption(parent, name, readValue(true));\r\n // Does not enforce a delimiter to be universal\r\n }\r\n\r\n function setOption(parent, name, value) {\r\n if (parent.setOption)\r\n parent.setOption(name, value);\r\n }\r\n\r\n function parseInlineOptions(parent) {\r\n if (skip(\"[\", true)) {\r\n do {\r\n parseOption(parent, \"option\");\r\n } while (skip(\",\", true));\r\n skip(\"]\");\r\n }\r\n return parent;\r\n }\r\n\r\n function parseService(parent, token) {\r\n\r\n /* istanbul ignore if */\r\n if (!nameRe.test(token = next()))\r\n throw illegal(token, \"service name\");\r\n\r\n var service = new Service(token);\r\n ifBlock(service, function parseService_block(token) {\r\n if (parseCommon(service, token))\r\n return;\r\n\r\n /* istanbul ignore else */\r\n if (token === \"rpc\")\r\n parseMethod(service, token);\r\n else\r\n throw illegal(token);\r\n });\r\n parent.add(service);\r\n }\r\n\r\n function parseMethod(parent, token) {\r\n var type = token;\r\n\r\n /* istanbul ignore if */\r\n if (!nameRe.test(token = next()))\r\n throw illegal(token, \"name\");\r\n\r\n var name = token,\r\n requestType, requestStream,\r\n responseType, responseStream;\r\n\r\n skip(\"(\");\r\n if (skip(\"stream\", true))\r\n requestStream = true;\r\n\r\n /* istanbul ignore if */\r\n if (!typeRefRe.test(token = next()))\r\n throw illegal(token);\r\n\r\n requestType = token;\r\n skip(\")\"); skip(\"returns\"); skip(\"(\");\r\n if (skip(\"stream\", true))\r\n responseStream = true;\r\n\r\n /* istanbul ignore if */\r\n if (!typeRefRe.test(token = next()))\r\n throw illegal(token);\r\n\r\n responseType = token;\r\n skip(\")\");\r\n\r\n var method = new Method(name, type, requestType, responseType, requestStream, responseStream);\r\n ifBlock(method, function parseMethod_block(token) {\r\n\r\n /* istanbul ignore else */\r\n if (token === \"option\") {\r\n parseOption(method, token);\r\n skip(\";\");\r\n } else\r\n throw illegal(token);\r\n\r\n });\r\n parent.add(method);\r\n }\r\n\r\n function parseExtension(parent, token) {\r\n\r\n /* istanbul ignore if */\r\n if (!typeRefRe.test(token = next()))\r\n throw illegal(token, \"reference\");\r\n\r\n var reference = token;\r\n ifBlock(null, function parseExtension_block(token) {\r\n switch (token) {\r\n\r\n case \"required\":\r\n case \"repeated\":\r\n case \"optional\":\r\n parseField(parent, token, reference);\r\n break;\r\n\r\n default:\r\n /* istanbul ignore if */\r\n if (!isProto3 || !typeRefRe.test(token))\r\n throw illegal(token);\r\n push(token);\r\n parseField(parent, \"optional\", reference);\r\n break;\r\n }\r\n });\r\n }\r\n\r\n var token;\r\n while ((token = next()) !== null) {\r\n switch (token) {\r\n\r\n case \"package\":\r\n\r\n /* istanbul ignore if */\r\n if (!head)\r\n throw illegal(token);\r\n\r\n parsePackage();\r\n break;\r\n\r\n case \"import\":\r\n\r\n /* istanbul ignore if */\r\n if (!head)\r\n throw illegal(token);\r\n\r\n parseImport();\r\n break;\r\n\r\n case \"syntax\":\r\n\r\n /* istanbul ignore if */\r\n if (!head)\r\n throw illegal(token);\r\n\r\n parseSyntax();\r\n break;\r\n\r\n case \"option\":\r\n\r\n /* istanbul ignore if */\r\n if (!head)\r\n throw illegal(token);\r\n\r\n parseOption(ptr, token);\r\n skip(\";\");\r\n break;\r\n\r\n default:\r\n\r\n /* istanbul ignore else */\r\n if (parseCommon(ptr, token)) {\r\n head = false;\r\n continue;\r\n }\r\n\r\n /* istanbul ignore next */\r\n throw illegal(token);\r\n }\r\n }\r\n\r\n parse.filename = null;\r\n return {\r\n \"package\" : pkg,\r\n \"imports\" : imports,\r\n weakImports : weakImports,\r\n syntax : syntax,\r\n root : root\r\n };\r\n}\r\n\r\n/**\r\n * Parses the given .proto source and returns an object with the parsed contents.\r\n * @name parse\r\n * @function\r\n * @param {string} source Source contents\r\n * @param {IParseOptions} [options] Parse options. Defaults to {@link parse.defaults} when omitted.\r\n * @returns {IParserResult} Parser result\r\n * @property {string} filename=null Currently processing file name for error reporting, if known\r\n * @property {IParseOptions} defaults Default {@link IParseOptions}\r\n * @variation 2\r\n */\r\n","\"use strict\";\r\nmodule.exports = Reader;\r\n\r\nvar util = require(39);\r\n\r\nvar BufferReader; // cyclic\r\n\r\nvar LongBits = util.LongBits,\r\n utf8 = util.utf8;\r\n\r\n/* istanbul ignore next */\r\nfunction indexOutOfRange(reader, writeLength) {\r\n return RangeError(\"index out of range: \" + reader.pos + \" + \" + (writeLength || 1) + \" > \" + reader.len);\r\n}\r\n\r\n/**\r\n * Constructs a new reader instance using the specified buffer.\r\n * @classdesc Wire format reader using `Uint8Array` if available, otherwise `Array`.\r\n * @constructor\r\n * @param {Uint8Array} buffer Buffer to read from\r\n */\r\nfunction Reader(buffer) {\r\n\r\n /**\r\n * Read buffer.\r\n * @type {Uint8Array}\r\n */\r\n this.buf = buffer;\r\n\r\n /**\r\n * Read buffer position.\r\n * @type {number}\r\n */\r\n this.pos = 0;\r\n\r\n /**\r\n * Read buffer length.\r\n * @type {number}\r\n */\r\n this.len = buffer.length;\r\n}\r\n\r\nvar create_array = typeof Uint8Array !== \"undefined\"\r\n ? function create_typed_array(buffer) {\r\n if (buffer instanceof Uint8Array || Array.isArray(buffer))\r\n return new Reader(buffer);\r\n throw Error(\"illegal buffer\");\r\n }\r\n /* istanbul ignore next */\r\n : function create_array(buffer) {\r\n if (Array.isArray(buffer))\r\n return new Reader(buffer);\r\n throw Error(\"illegal buffer\");\r\n };\r\n\r\n/**\r\n * Creates a new reader using the specified buffer.\r\n * @function\r\n * @param {Uint8Array|Buffer} buffer Buffer to read from\r\n * @returns {Reader|BufferReader} A {@link BufferReader} if `buffer` is a Buffer, otherwise a {@link Reader}\r\n * @throws {Error} If `buffer` is not a valid buffer\r\n */\r\nReader.create = util.Buffer\r\n ? function create_buffer_setup(buffer) {\r\n return (Reader.create = function create_buffer(buffer) {\r\n return util.Buffer.isBuffer(buffer)\r\n ? new BufferReader(buffer)\r\n /* istanbul ignore next */\r\n : create_array(buffer);\r\n })(buffer);\r\n }\r\n /* istanbul ignore next */\r\n : create_array;\r\n\r\nReader.prototype._slice = util.Array.prototype.subarray || /* istanbul ignore next */ util.Array.prototype.slice;\r\n\r\n/**\r\n * Reads a varint as an unsigned 32 bit value.\r\n * @function\r\n * @returns {number} Value read\r\n */\r\nReader.prototype.uint32 = (function read_uint32_setup() {\r\n var value = 4294967295; // optimizer type-hint, tends to deopt otherwise (?!)\r\n return function read_uint32() {\r\n value = ( this.buf[this.pos] & 127 ) >>> 0; if (this.buf[this.pos++] < 128) return value;\r\n value = (value | (this.buf[this.pos] & 127) << 7) >>> 0; if (this.buf[this.pos++] < 128) return value;\r\n value = (value | (this.buf[this.pos] & 127) << 14) >>> 0; if (this.buf[this.pos++] < 128) return value;\r\n value = (value | (this.buf[this.pos] & 127) << 21) >>> 0; if (this.buf[this.pos++] < 128) return value;\r\n value = (value | (this.buf[this.pos] & 15) << 28) >>> 0; if (this.buf[this.pos++] < 128) return value;\r\n\r\n /* istanbul ignore if */\r\n if ((this.pos += 5) > this.len) {\r\n this.pos = this.len;\r\n throw indexOutOfRange(this, 10);\r\n }\r\n return value;\r\n };\r\n})();\r\n\r\n/**\r\n * Reads a varint as a signed 32 bit value.\r\n * @returns {number} Value read\r\n */\r\nReader.prototype.int32 = function read_int32() {\r\n return this.uint32() | 0;\r\n};\r\n\r\n/**\r\n * Reads a zig-zag encoded varint as a signed 32 bit value.\r\n * @returns {number} Value read\r\n */\r\nReader.prototype.sint32 = function read_sint32() {\r\n var value = this.uint32();\r\n return value >>> 1 ^ -(value & 1) | 0;\r\n};\r\n\r\n/* eslint-disable no-invalid-this */\r\n\r\nfunction readLongVarint() {\r\n // tends to deopt with local vars for octet etc.\r\n var bits = new LongBits(0, 0);\r\n var i = 0;\r\n if (this.len - this.pos > 4) { // fast route (lo)\r\n for (; i < 4; ++i) {\r\n // 1st..4th\r\n bits.lo = (bits.lo | (this.buf[this.pos] & 127) << i * 7) >>> 0;\r\n if (this.buf[this.pos++] < 128)\r\n return bits;\r\n }\r\n // 5th\r\n bits.lo = (bits.lo | (this.buf[this.pos] & 127) << 28) >>> 0;\r\n bits.hi = (bits.hi | (this.buf[this.pos] & 127) >> 4) >>> 0;\r\n if (this.buf[this.pos++] < 128)\r\n return bits;\r\n i = 0;\r\n } else {\r\n for (; i < 3; ++i) {\r\n /* istanbul ignore if */\r\n if (this.pos >= this.len)\r\n throw indexOutOfRange(this);\r\n // 1st..3th\r\n bits.lo = (bits.lo | (this.buf[this.pos] & 127) << i * 7) >>> 0;\r\n if (this.buf[this.pos++] < 128)\r\n return bits;\r\n }\r\n // 4th\r\n bits.lo = (bits.lo | (this.buf[this.pos++] & 127) << i * 7) >>> 0;\r\n return bits;\r\n }\r\n if (this.len - this.pos > 4) { // fast route (hi)\r\n for (; i < 5; ++i) {\r\n // 6th..10th\r\n bits.hi = (bits.hi | (this.buf[this.pos] & 127) << i * 7 + 3) >>> 0;\r\n if (this.buf[this.pos++] < 128)\r\n return bits;\r\n }\r\n } else {\r\n for (; i < 5; ++i) {\r\n /* istanbul ignore if */\r\n if (this.pos >= this.len)\r\n throw indexOutOfRange(this);\r\n // 6th..10th\r\n bits.hi = (bits.hi | (this.buf[this.pos] & 127) << i * 7 + 3) >>> 0;\r\n if (this.buf[this.pos++] < 128)\r\n return bits;\r\n }\r\n }\r\n /* istanbul ignore next */\r\n throw Error(\"invalid varint encoding\");\r\n}\r\n\r\n/* eslint-enable no-invalid-this */\r\n\r\n/**\r\n * Reads a varint as a signed 64 bit value.\r\n * @name Reader#int64\r\n * @function\r\n * @returns {Long} Value read\r\n */\r\n\r\n/**\r\n * Reads a varint as an unsigned 64 bit value.\r\n * @name Reader#uint64\r\n * @function\r\n * @returns {Long} Value read\r\n */\r\n\r\n/**\r\n * Reads a zig-zag encoded varint as a signed 64 bit value.\r\n * @name Reader#sint64\r\n * @function\r\n * @returns {Long} Value read\r\n */\r\n\r\n/**\r\n * Reads a varint as a boolean.\r\n * @returns {boolean} Value read\r\n */\r\nReader.prototype.bool = function read_bool() {\r\n return this.uint32() !== 0;\r\n};\r\n\r\nfunction readFixed32_end(buf, end) { // note that this uses `end`, not `pos`\r\n return (buf[end - 4]\r\n | buf[end - 3] << 8\r\n | buf[end - 2] << 16\r\n | buf[end - 1] << 24) >>> 0;\r\n}\r\n\r\n/**\r\n * Reads fixed 32 bits as an unsigned 32 bit integer.\r\n * @returns {number} Value read\r\n */\r\nReader.prototype.fixed32 = function read_fixed32() {\r\n\r\n /* istanbul ignore if */\r\n if (this.pos + 4 > this.len)\r\n throw indexOutOfRange(this, 4);\r\n\r\n return readFixed32_end(this.buf, this.pos += 4);\r\n};\r\n\r\n/**\r\n * Reads fixed 32 bits as a signed 32 bit integer.\r\n * @returns {number} Value read\r\n */\r\nReader.prototype.sfixed32 = function read_sfixed32() {\r\n\r\n /* istanbul ignore if */\r\n if (this.pos + 4 > this.len)\r\n throw indexOutOfRange(this, 4);\r\n\r\n return readFixed32_end(this.buf, this.pos += 4) | 0;\r\n};\r\n\r\n/* eslint-disable no-invalid-this */\r\n\r\nfunction readFixed64(/* this: Reader */) {\r\n\r\n /* istanbul ignore if */\r\n if (this.pos + 8 > this.len)\r\n throw indexOutOfRange(this, 8);\r\n\r\n return new LongBits(readFixed32_end(this.buf, this.pos += 4), readFixed32_end(this.buf, this.pos += 4));\r\n}\r\n\r\n/* eslint-enable no-invalid-this */\r\n\r\n/**\r\n * Reads fixed 64 bits.\r\n * @name Reader#fixed64\r\n * @function\r\n * @returns {Long} Value read\r\n */\r\n\r\n/**\r\n * Reads zig-zag encoded fixed 64 bits.\r\n * @name Reader#sfixed64\r\n * @function\r\n * @returns {Long} Value read\r\n */\r\n\r\n/**\r\n * Reads a float (32 bit) as a number.\r\n * @function\r\n * @returns {number} Value read\r\n */\r\nReader.prototype.float = function read_float() {\r\n\r\n /* istanbul ignore if */\r\n if (this.pos + 4 > this.len)\r\n throw indexOutOfRange(this, 4);\r\n\r\n var value = util.float.readFloatLE(this.buf, this.pos);\r\n this.pos += 4;\r\n return value;\r\n};\r\n\r\n/**\r\n * Reads a double (64 bit float) as a number.\r\n * @function\r\n * @returns {number} Value read\r\n */\r\nReader.prototype.double = function read_double() {\r\n\r\n /* istanbul ignore if */\r\n if (this.pos + 8 > this.len)\r\n throw indexOutOfRange(this, 4);\r\n\r\n var value = util.float.readDoubleLE(this.buf, this.pos);\r\n this.pos += 8;\r\n return value;\r\n};\r\n\r\n/**\r\n * Reads a sequence of bytes preceeded by its length as a varint.\r\n * @returns {Uint8Array} Value read\r\n */\r\nReader.prototype.bytes = function read_bytes() {\r\n var length = this.uint32(),\r\n start = this.pos,\r\n end = this.pos + length;\r\n\r\n /* istanbul ignore if */\r\n if (end > this.len)\r\n throw indexOutOfRange(this, length);\r\n\r\n this.pos += length;\r\n if (Array.isArray(this.buf)) // plain array\r\n return this.buf.slice(start, end);\r\n return start === end // fix for IE 10/Win8 and others' subarray returning array of size 1\r\n ? new this.buf.constructor(0)\r\n : this._slice.call(this.buf, start, end);\r\n};\r\n\r\n/**\r\n * Reads a string preceeded by its byte length as a varint.\r\n * @returns {string} Value read\r\n */\r\nReader.prototype.string = function read_string() {\r\n var bytes = this.bytes();\r\n return utf8.read(bytes, 0, bytes.length);\r\n};\r\n\r\n/**\r\n * Skips the specified number of bytes if specified, otherwise skips a varint.\r\n * @param {number} [length] Length if known, otherwise a varint is assumed\r\n * @returns {Reader} `this`\r\n */\r\nReader.prototype.skip = function skip(length) {\r\n if (typeof length === \"number\") {\r\n /* istanbul ignore if */\r\n if (this.pos + length > this.len)\r\n throw indexOutOfRange(this, length);\r\n this.pos += length;\r\n } else {\r\n do {\r\n /* istanbul ignore if */\r\n if (this.pos >= this.len)\r\n throw indexOutOfRange(this);\r\n } while (this.buf[this.pos++] & 128);\r\n }\r\n return this;\r\n};\r\n\r\n/**\r\n * Skips the next element of the specified wire type.\r\n * @param {number} wireType Wire type received\r\n * @returns {Reader} `this`\r\n */\r\nReader.prototype.skipType = function(wireType) {\r\n switch (wireType) {\r\n case 0:\r\n this.skip();\r\n break;\r\n case 1:\r\n this.skip(8);\r\n break;\r\n case 2:\r\n this.skip(this.uint32());\r\n break;\r\n case 3:\r\n while ((wireType = this.uint32() & 7) !== 4) {\r\n this.skipType(wireType);\r\n }\r\n break;\r\n case 5:\r\n this.skip(4);\r\n break;\r\n\r\n /* istanbul ignore next */\r\n default:\r\n throw Error(\"invalid wire type \" + wireType + \" at offset \" + this.pos);\r\n }\r\n return this;\r\n};\r\n\r\nReader._configure = function(BufferReader_) {\r\n BufferReader = BufferReader_;\r\n\r\n var fn = util.Long ? \"toLong\" : /* istanbul ignore next */ \"toNumber\";\r\n util.merge(Reader.prototype, {\r\n\r\n int64: function read_int64() {\r\n return readLongVarint.call(this)[fn](false);\r\n },\r\n\r\n uint64: function read_uint64() {\r\n return readLongVarint.call(this)[fn](true);\r\n },\r\n\r\n sint64: function read_sint64() {\r\n return readLongVarint.call(this).zzDecode()[fn](false);\r\n },\r\n\r\n fixed64: function read_fixed64() {\r\n return readFixed64.call(this)[fn](true);\r\n },\r\n\r\n sfixed64: function read_sfixed64() {\r\n return readFixed64.call(this)[fn](false);\r\n }\r\n\r\n });\r\n};\r\n","\"use strict\";\r\nmodule.exports = BufferReader;\r\n\r\n// extends Reader\r\nvar Reader = require(27);\r\n(BufferReader.prototype = Object.create(Reader.prototype)).constructor = BufferReader;\r\n\r\nvar util = require(39);\r\n\r\n/**\r\n * Constructs a new buffer reader instance.\r\n * @classdesc Wire format reader using node buffers.\r\n * @extends Reader\r\n * @constructor\r\n * @param {Buffer} buffer Buffer to read from\r\n */\r\nfunction BufferReader(buffer) {\r\n Reader.call(this, buffer);\r\n\r\n /**\r\n * Read buffer.\r\n * @name BufferReader#buf\r\n * @type {Buffer}\r\n */\r\n}\r\n\r\n/* istanbul ignore else */\r\nif (util.Buffer)\r\n BufferReader.prototype._slice = util.Buffer.prototype.slice;\r\n\r\n/**\r\n * @override\r\n */\r\nBufferReader.prototype.string = function read_string_buffer() {\r\n var len = this.uint32(); // modifies pos\r\n return this.buf.utf8Slice(this.pos, this.pos = Math.min(this.pos + len, this.len));\r\n};\r\n\r\n/**\r\n * Reads a sequence of bytes preceeded by its length as a varint.\r\n * @name BufferReader#bytes\r\n * @function\r\n * @returns {Buffer} Value read\r\n */\r\n","\"use strict\";\r\nmodule.exports = Root;\r\n\r\n// extends Namespace\r\nvar Namespace = require(23);\r\n((Root.prototype = Object.create(Namespace.prototype)).constructor = Root).className = \"Root\";\r\n\r\nvar Field = require(16),\r\n Enum = require(15),\r\n OneOf = require(25),\r\n util = require(37);\r\n\r\nvar Type, // cyclic\r\n parse, // might be excluded\r\n common; // \"\r\n\r\n/**\r\n * Constructs a new root namespace instance.\r\n * @classdesc Root namespace wrapping all types, enums, services, sub-namespaces etc. that belong together.\r\n * @extends NamespaceBase\r\n * @constructor\r\n * @param {Object.} [options] Top level options\r\n */\r\nfunction Root(options) {\r\n Namespace.call(this, \"\", options);\r\n\r\n /**\r\n * Deferred extension fields.\r\n * @type {Field[]}\r\n */\r\n this.deferred = [];\r\n\r\n /**\r\n * Resolved file names of loaded files.\r\n * @type {string[]}\r\n */\r\n this.files = [];\r\n}\r\n\r\n/**\r\n * Loads a namespace descriptor into a root namespace.\r\n * @param {INamespace} json Nameespace descriptor\r\n * @param {Root} [root] Root namespace, defaults to create a new one if omitted\r\n * @returns {Root} Root namespace\r\n */\r\nRoot.fromJSON = function fromJSON(json, root) {\r\n if (!root)\r\n root = new Root();\r\n if (json.options)\r\n root.setOptions(json.options);\r\n return root.addJSON(json.nested);\r\n};\r\n\r\n/**\r\n * Resolves the path of an imported file, relative to the importing origin.\r\n * This method exists so you can override it with your own logic in case your imports are scattered over multiple directories.\r\n * @function\r\n * @param {string} origin The file name of the importing file\r\n * @param {string} target The file name being imported\r\n * @returns {string|null} Resolved path to `target` or `null` to skip the file\r\n */\r\nRoot.prototype.resolvePath = util.path.resolve;\r\n\r\n// A symbol-like function to safely signal synchronous loading\r\n/* istanbul ignore next */\r\nfunction SYNC() {} // eslint-disable-line no-empty-function\r\n\r\n/**\r\n * Loads one or multiple .proto or preprocessed .json files into this root namespace and calls the callback.\r\n * @param {string|string[]} filename Names of one or multiple files to load\r\n * @param {IParseOptions} options Parse options\r\n * @param {LoadCallback} callback Callback function\r\n * @returns {undefined}\r\n */\r\nRoot.prototype.load = function load(filename, options, callback) {\r\n if (typeof options === \"function\") {\r\n callback = options;\r\n options = undefined;\r\n }\r\n var self = this;\r\n if (!callback)\r\n return util.asPromise(load, self, filename, options);\r\n\r\n var sync = callback === SYNC; // undocumented\r\n\r\n // Finishes loading by calling the callback (exactly once)\r\n function finish(err, root) {\r\n /* istanbul ignore if */\r\n if (!callback)\r\n return;\r\n var cb = callback;\r\n callback = null;\r\n if (sync)\r\n throw err;\r\n cb(err, root);\r\n }\r\n\r\n // Processes a single file\r\n function process(filename, source) {\r\n try {\r\n if (util.isString(source) && source.charAt(0) === \"{\")\r\n source = JSON.parse(source);\r\n if (!util.isString(source))\r\n self.setOptions(source.options).addJSON(source.nested);\r\n else {\r\n parse.filename = filename;\r\n var parsed = parse(source, self, options),\r\n resolved,\r\n i = 0;\r\n if (parsed.imports)\r\n for (; i < parsed.imports.length; ++i)\r\n if (resolved = self.resolvePath(filename, parsed.imports[i]))\r\n fetch(resolved);\r\n if (parsed.weakImports)\r\n for (i = 0; i < parsed.weakImports.length; ++i)\r\n if (resolved = self.resolvePath(filename, parsed.weakImports[i]))\r\n fetch(resolved, true);\r\n }\r\n } catch (err) {\r\n finish(err);\r\n }\r\n if (!sync && !queued)\r\n finish(null, self); // only once anyway\r\n }\r\n\r\n // Fetches a single file\r\n function fetch(filename, weak) {\r\n\r\n // Strip path if this file references a bundled definition\r\n var idx = filename.lastIndexOf(\"google/protobuf/\");\r\n if (idx > -1) {\r\n var altname = filename.substring(idx);\r\n if (altname in common)\r\n filename = altname;\r\n }\r\n\r\n // Skip if already loaded / attempted\r\n if (self.files.indexOf(filename) > -1)\r\n return;\r\n self.files.push(filename);\r\n\r\n // Shortcut bundled definitions\r\n if (filename in common) {\r\n if (sync)\r\n process(filename, common[filename]);\r\n else {\r\n ++queued;\r\n setTimeout(function() {\r\n --queued;\r\n process(filename, common[filename]);\r\n });\r\n }\r\n return;\r\n }\r\n\r\n // Otherwise fetch from disk or network\r\n if (sync) {\r\n var source;\r\n try {\r\n source = util.fs.readFileSync(filename).toString(\"utf8\");\r\n } catch (err) {\r\n if (!weak)\r\n finish(err);\r\n return;\r\n }\r\n process(filename, source);\r\n } else {\r\n ++queued;\r\n util.fetch(filename, function(err, source) {\r\n --queued;\r\n /* istanbul ignore if */\r\n if (!callback)\r\n return; // terminated meanwhile\r\n if (err) {\r\n /* istanbul ignore else */\r\n if (!weak)\r\n finish(err);\r\n else if (!queued) // can't be covered reliably\r\n finish(null, self);\r\n return;\r\n }\r\n process(filename, source);\r\n });\r\n }\r\n }\r\n var queued = 0;\r\n\r\n // Assembling the root namespace doesn't require working type\r\n // references anymore, so we can load everything in parallel\r\n if (util.isString(filename))\r\n filename = [ filename ];\r\n for (var i = 0, resolved; i < filename.length; ++i)\r\n if (resolved = self.resolvePath(\"\", filename[i]))\r\n fetch(resolved);\r\n\r\n if (sync)\r\n return self;\r\n if (!queued)\r\n finish(null, self);\r\n return undefined;\r\n};\r\n// function load(filename:string, options:IParseOptions, callback:LoadCallback):undefined\r\n\r\n/**\r\n * Loads one or multiple .proto or preprocessed .json files into this root namespace and calls the callback.\r\n * @function Root#load\r\n * @param {string|string[]} filename Names of one or multiple files to load\r\n * @param {LoadCallback} callback Callback function\r\n * @returns {undefined}\r\n * @variation 2\r\n */\r\n// function load(filename:string, callback:LoadCallback):undefined\r\n\r\n/**\r\n * Loads one or multiple .proto or preprocessed .json files into this root namespace and returns a promise.\r\n * @function Root#load\r\n * @param {string|string[]} filename Names of one or multiple files to load\r\n * @param {IParseOptions} [options] Parse options. Defaults to {@link parse.defaults} when omitted.\r\n * @returns {Promise} Promise\r\n * @variation 3\r\n */\r\n// function load(filename:string, [options:IParseOptions]):Promise\r\n\r\n/**\r\n * Synchronously loads one or multiple .proto or preprocessed .json files into this root namespace (node only).\r\n * @function Root#loadSync\r\n * @param {string|string[]} filename Names of one or multiple files to load\r\n * @param {IParseOptions} [options] Parse options. Defaults to {@link parse.defaults} when omitted.\r\n * @returns {Root} Root namespace\r\n * @throws {Error} If synchronous fetching is not supported (i.e. in browsers) or if a file's syntax is invalid\r\n */\r\nRoot.prototype.loadSync = function loadSync(filename, options) {\r\n if (!util.isNode)\r\n throw Error(\"not supported\");\r\n return this.load(filename, options, SYNC);\r\n};\r\n\r\n/**\r\n * @override\r\n */\r\nRoot.prototype.resolveAll = function resolveAll() {\r\n if (this.deferred.length)\r\n throw Error(\"unresolvable extensions: \" + this.deferred.map(function(field) {\r\n return \"'extend \" + field.extend + \"' in \" + field.parent.fullName;\r\n }).join(\", \"));\r\n return Namespace.prototype.resolveAll.call(this);\r\n};\r\n\r\n// only uppercased (and thus conflict-free) children are exposed, see below\r\nvar exposeRe = /^[A-Z]/;\r\n\r\n/**\r\n * Handles a deferred declaring extension field by creating a sister field to represent it within its extended type.\r\n * @param {Root} root Root instance\r\n * @param {Field} field Declaring extension field witin the declaring type\r\n * @returns {boolean} `true` if successfully added to the extended type, `false` otherwise\r\n * @inner\r\n * @ignore\r\n */\r\nfunction tryHandleExtension(root, field) {\r\n var extendedType = field.parent.lookup(field.extend);\r\n if (extendedType) {\r\n var sisterField = new Field(field.fullName, field.id, field.type, field.rule, undefined, field.options);\r\n sisterField.declaringField = field;\r\n field.extensionField = sisterField;\r\n extendedType.add(sisterField);\r\n return true;\r\n }\r\n return false;\r\n}\r\n\r\n/**\r\n * Called when any object is added to this root or its sub-namespaces.\r\n * @param {ReflectionObject} object Object added\r\n * @returns {undefined}\r\n * @private\r\n */\r\nRoot.prototype._handleAdd = function _handleAdd(object) {\r\n if (object instanceof Field) {\r\n\r\n if (/* an extension field (implies not part of a oneof) */ object.extend !== undefined && /* not already handled */ !object.extensionField)\r\n if (!tryHandleExtension(this, object))\r\n this.deferred.push(object);\r\n\r\n } else if (object instanceof Enum) {\r\n\r\n if (exposeRe.test(object.name))\r\n object.parent[object.name] = object.values; // expose enum values as property of its parent\r\n\r\n } else if (!(object instanceof OneOf)) /* everything else is a namespace */ {\r\n\r\n if (object instanceof Type) // Try to handle any deferred extensions\r\n for (var i = 0; i < this.deferred.length;)\r\n if (tryHandleExtension(this, this.deferred[i]))\r\n this.deferred.splice(i, 1);\r\n else\r\n ++i;\r\n for (var j = 0; j < /* initializes */ object.nestedArray.length; ++j) // recurse into the namespace\r\n this._handleAdd(object._nestedArray[j]);\r\n if (exposeRe.test(object.name))\r\n object.parent[object.name] = object; // expose namespace as property of its parent\r\n }\r\n\r\n // The above also adds uppercased (and thus conflict-free) nested types, services and enums as\r\n // properties of namespaces just like static code does. This allows using a .d.ts generated for\r\n // a static module with reflection-based solutions where the condition is met.\r\n};\r\n\r\n/**\r\n * Called when any object is removed from this root or its sub-namespaces.\r\n * @param {ReflectionObject} object Object removed\r\n * @returns {undefined}\r\n * @private\r\n */\r\nRoot.prototype._handleRemove = function _handleRemove(object) {\r\n if (object instanceof Field) {\r\n\r\n if (/* an extension field */ object.extend !== undefined) {\r\n if (/* already handled */ object.extensionField) { // remove its sister field\r\n object.extensionField.parent.remove(object.extensionField);\r\n object.extensionField = null;\r\n } else { // cancel the extension\r\n var index = this.deferred.indexOf(object);\r\n /* istanbul ignore else */\r\n if (index > -1)\r\n this.deferred.splice(index, 1);\r\n }\r\n }\r\n\r\n } else if (object instanceof Enum) {\r\n\r\n if (exposeRe.test(object.name))\r\n delete object.parent[object.name]; // unexpose enum values\r\n\r\n } else if (object instanceof Namespace) {\r\n\r\n for (var i = 0; i < /* initializes */ object.nestedArray.length; ++i) // recurse into the namespace\r\n this._handleRemove(object._nestedArray[i]);\r\n\r\n if (exposeRe.test(object.name))\r\n delete object.parent[object.name]; // unexpose namespaces\r\n\r\n }\r\n};\r\n\r\n// Sets up cyclic dependencies (called in index-light)\r\nRoot._configure = function(Type_, parse_, common_) {\r\n Type = Type_;\r\n parse = parse_;\r\n common = common_;\r\n};\r\n","\"use strict\";\r\nmodule.exports = {};\r\n\r\n/**\r\n * Named roots.\r\n * This is where pbjs stores generated structures (the option `-r, --root` specifies a name).\r\n * Can also be used manually to make roots available accross modules.\r\n * @name roots\r\n * @type {Object.}\r\n * @example\r\n * // pbjs -r myroot -o compiled.js ...\r\n *\r\n * // in another module:\r\n * require(\"./compiled.js\");\r\n *\r\n * // in any subsequent module:\r\n * var root = protobuf.roots[\"myroot\"];\r\n */\r\n","\"use strict\";\r\n\r\n/**\r\n * Streaming RPC helpers.\r\n * @namespace\r\n */\r\nvar rpc = exports;\r\n\r\n/**\r\n * RPC implementation passed to {@link Service#create} performing a service request on network level, i.e. by utilizing http requests or websockets.\r\n * @typedef RPCImpl\r\n * @type {function}\r\n * @param {Method|rpc.ServiceMethod,Message<{}>>} method Reflected or static method being called\r\n * @param {Uint8Array} requestData Request data\r\n * @param {RPCImplCallback} callback Callback function\r\n * @returns {undefined}\r\n * @example\r\n * function rpcImpl(method, requestData, callback) {\r\n * if (protobuf.util.lcFirst(method.name) !== \"myMethod\") // compatible with static code\r\n * throw Error(\"no such method\");\r\n * asynchronouslyObtainAResponse(requestData, function(err, responseData) {\r\n * callback(err, responseData);\r\n * });\r\n * }\r\n */\r\n\r\n/**\r\n * Node-style callback as used by {@link RPCImpl}.\r\n * @typedef RPCImplCallback\r\n * @type {function}\r\n * @param {Error|null} error Error, if any, otherwise `null`\r\n * @param {Uint8Array|null} [response] Response data or `null` to signal end of stream, if there hasn't been an error\r\n * @returns {undefined}\r\n */\r\n\r\nrpc.Service = require(32);\r\n","\"use strict\";\r\nmodule.exports = Service;\r\n\r\nvar util = require(39);\r\n\r\n// Extends EventEmitter\r\n(Service.prototype = Object.create(util.EventEmitter.prototype)).constructor = Service;\r\n\r\n/**\r\n * A service method callback as used by {@link rpc.ServiceMethod|ServiceMethod}.\r\n *\r\n * Differs from {@link RPCImplCallback} in that it is an actual callback of a service method which may not return `response = null`.\r\n * @typedef rpc.ServiceMethodCallback\r\n * @template TRes extends Message\r\n * @type {function}\r\n * @param {Error|null} error Error, if any\r\n * @param {TRes} [response] Response message\r\n * @returns {undefined}\r\n */\r\n\r\n/**\r\n * A service method part of a {@link rpc.Service} as created by {@link Service.create}.\r\n * @typedef rpc.ServiceMethod\r\n * @template TReq extends Message\r\n * @template TRes extends Message\r\n * @type {function}\r\n * @param {TReq|Properties} request Request message or plain object\r\n * @param {rpc.ServiceMethodCallback} [callback] Node-style callback called with the error, if any, and the response message\r\n * @returns {Promise>} Promise if `callback` has been omitted, otherwise `undefined`\r\n */\r\n\r\n/**\r\n * Constructs a new RPC service instance.\r\n * @classdesc An RPC service as returned by {@link Service#create}.\r\n * @exports rpc.Service\r\n * @extends util.EventEmitter\r\n * @constructor\r\n * @param {RPCImpl} rpcImpl RPC implementation\r\n * @param {boolean} [requestDelimited=false] Whether requests are length-delimited\r\n * @param {boolean} [responseDelimited=false] Whether responses are length-delimited\r\n */\r\nfunction Service(rpcImpl, requestDelimited, responseDelimited) {\r\n\r\n if (typeof rpcImpl !== \"function\")\r\n throw TypeError(\"rpcImpl must be a function\");\r\n\r\n util.EventEmitter.call(this);\r\n\r\n /**\r\n * RPC implementation. Becomes `null` once the service is ended.\r\n * @type {RPCImpl|null}\r\n */\r\n this.rpcImpl = rpcImpl;\r\n\r\n /**\r\n * Whether requests are length-delimited.\r\n * @type {boolean}\r\n */\r\n this.requestDelimited = Boolean(requestDelimited);\r\n\r\n /**\r\n * Whether responses are length-delimited.\r\n * @type {boolean}\r\n */\r\n this.responseDelimited = Boolean(responseDelimited);\r\n}\r\n\r\n/**\r\n * Calls a service method through {@link rpc.Service#rpcImpl|rpcImpl}.\r\n * @param {Method|rpc.ServiceMethod} method Reflected or static method\r\n * @param {Constructor} requestCtor Request constructor\r\n * @param {Constructor} responseCtor Response constructor\r\n * @param {TReq|Properties} request Request message or plain object\r\n * @param {rpc.ServiceMethodCallback} callback Service callback\r\n * @returns {undefined}\r\n * @template TReq extends Message\r\n * @template TRes extends Message\r\n */\r\nService.prototype.rpcCall = function rpcCall(method, requestCtor, responseCtor, request, callback) {\r\n\r\n if (!request)\r\n throw TypeError(\"request must be specified\");\r\n\r\n var self = this;\r\n if (!callback)\r\n return util.asPromise(rpcCall, self, method, requestCtor, responseCtor, request);\r\n\r\n if (!self.rpcImpl) {\r\n setTimeout(function() { callback(Error(\"already ended\")); }, 0);\r\n return undefined;\r\n }\r\n\r\n try {\r\n return self.rpcImpl(\r\n method,\r\n requestCtor[self.requestDelimited ? \"encodeDelimited\" : \"encode\"](request).finish(),\r\n function rpcCallback(err, response) {\r\n\r\n if (err) {\r\n self.emit(\"error\", err, method);\r\n return callback(err);\r\n }\r\n\r\n if (response === null) {\r\n self.end(/* endedByRPC */ true);\r\n return undefined;\r\n }\r\n\r\n if (!(response instanceof responseCtor)) {\r\n try {\r\n response = responseCtor[self.responseDelimited ? \"decodeDelimited\" : \"decode\"](response);\r\n } catch (err) {\r\n self.emit(\"error\", err, method);\r\n return callback(err);\r\n }\r\n }\r\n\r\n self.emit(\"data\", response, method);\r\n return callback(null, response);\r\n }\r\n );\r\n } catch (err) {\r\n self.emit(\"error\", err, method);\r\n setTimeout(function() { callback(err); }, 0);\r\n return undefined;\r\n }\r\n};\r\n\r\n/**\r\n * Ends this service and emits the `end` event.\r\n * @param {boolean} [endedByRPC=false] Whether the service has been ended by the RPC implementation.\r\n * @returns {rpc.Service} `this`\r\n */\r\nService.prototype.end = function end(endedByRPC) {\r\n if (this.rpcImpl) {\r\n if (!endedByRPC) // signal end to rpcImpl\r\n this.rpcImpl(null, null, null);\r\n this.rpcImpl = null;\r\n this.emit(\"end\").off();\r\n }\r\n return this;\r\n};\r\n","\"use strict\";\r\nmodule.exports = Service;\r\n\r\n// extends Namespace\r\nvar Namespace = require(23);\r\n((Service.prototype = Object.create(Namespace.prototype)).constructor = Service).className = \"Service\";\r\n\r\nvar Method = require(22),\r\n util = require(37),\r\n rpc = require(31);\r\n\r\n/**\r\n * Constructs a new service instance.\r\n * @classdesc Reflected service.\r\n * @extends NamespaceBase\r\n * @constructor\r\n * @param {string} name Service name\r\n * @param {Object.} [options] Service options\r\n * @throws {TypeError} If arguments are invalid\r\n */\r\nfunction Service(name, options) {\r\n Namespace.call(this, name, options);\r\n\r\n /**\r\n * Service methods.\r\n * @type {Object.}\r\n */\r\n this.methods = {}; // toJSON, marker\r\n\r\n /**\r\n * Cached methods as an array.\r\n * @type {Method[]|null}\r\n * @private\r\n */\r\n this._methodsArray = null;\r\n}\r\n\r\n/**\r\n * Service descriptor.\r\n * @interface IService\r\n * @extends INamespace\r\n * @property {Object.} methods Method descriptors\r\n */\r\n\r\n/**\r\n * Constructs a service from a service descriptor.\r\n * @param {string} name Service name\r\n * @param {IService} json Service descriptor\r\n * @returns {Service} Created service\r\n * @throws {TypeError} If arguments are invalid\r\n */\r\nService.fromJSON = function fromJSON(name, json) {\r\n var service = new Service(name, json.options);\r\n /* istanbul ignore else */\r\n if (json.methods)\r\n for (var names = Object.keys(json.methods), i = 0; i < names.length; ++i)\r\n service.add(Method.fromJSON(names[i], json.methods[names[i]]));\r\n if (json.nested)\r\n service.addJSON(json.nested);\r\n service.comment = json.comment;\r\n return service;\r\n};\r\n\r\n/**\r\n * Converts this service to a service descriptor.\r\n * @param {IToJSONOptions} [toJSONOptions] JSON conversion options\r\n * @returns {IService} Service descriptor\r\n */\r\nService.prototype.toJSON = function toJSON(toJSONOptions) {\r\n var inherited = Namespace.prototype.toJSON.call(this, toJSONOptions);\r\n var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false;\r\n return util.toObject([\r\n \"options\" , inherited && inherited.options || undefined,\r\n \"methods\" , Namespace.arrayToJSON(this.methodsArray, toJSONOptions) || /* istanbul ignore next */ {},\r\n \"nested\" , inherited && inherited.nested || undefined,\r\n \"comment\" , keepComments ? this.comment : undefined\r\n ]);\r\n};\r\n\r\n/**\r\n * Methods of this service as an array for iteration.\r\n * @name Service#methodsArray\r\n * @type {Method[]}\r\n * @readonly\r\n */\r\nObject.defineProperty(Service.prototype, \"methodsArray\", {\r\n get: function() {\r\n return this._methodsArray || (this._methodsArray = util.toArray(this.methods));\r\n }\r\n});\r\n\r\nfunction clearCache(service) {\r\n service._methodsArray = null;\r\n return service;\r\n}\r\n\r\n/**\r\n * @override\r\n */\r\nService.prototype.get = function get(name) {\r\n return this.methods[name]\r\n || Namespace.prototype.get.call(this, name);\r\n};\r\n\r\n/**\r\n * @override\r\n */\r\nService.prototype.resolveAll = function resolveAll() {\r\n var methods = this.methodsArray;\r\n for (var i = 0; i < methods.length; ++i)\r\n methods[i].resolve();\r\n return Namespace.prototype.resolve.call(this);\r\n};\r\n\r\n/**\r\n * @override\r\n */\r\nService.prototype.add = function add(object) {\r\n\r\n /* istanbul ignore if */\r\n if (this.get(object.name))\r\n throw Error(\"duplicate name '\" + object.name + \"' in \" + this);\r\n\r\n if (object instanceof Method) {\r\n this.methods[object.name] = object;\r\n object.parent = this;\r\n return clearCache(this);\r\n }\r\n return Namespace.prototype.add.call(this, object);\r\n};\r\n\r\n/**\r\n * @override\r\n */\r\nService.prototype.remove = function remove(object) {\r\n if (object instanceof Method) {\r\n\r\n /* istanbul ignore if */\r\n if (this.methods[object.name] !== object)\r\n throw Error(object + \" is not a member of \" + this);\r\n\r\n delete this.methods[object.name];\r\n object.parent = null;\r\n return clearCache(this);\r\n }\r\n return Namespace.prototype.remove.call(this, object);\r\n};\r\n\r\n/**\r\n * Creates a runtime service using the specified rpc implementation.\r\n * @param {RPCImpl} rpcImpl RPC implementation\r\n * @param {boolean} [requestDelimited=false] Whether requests are length-delimited\r\n * @param {boolean} [responseDelimited=false] Whether responses are length-delimited\r\n * @returns {rpc.Service} RPC service. Useful where requests and/or responses are streamed.\r\n */\r\nService.prototype.create = function create(rpcImpl, requestDelimited, responseDelimited) {\r\n var rpcService = new rpc.Service(rpcImpl, requestDelimited, responseDelimited);\r\n for (var i = 0, method; i < /* initializes */ this.methodsArray.length; ++i) {\r\n var methodName = util.lcFirst((method = this._methodsArray[i]).resolve().name).replace(/[^$\\w_]/g, \"\");\r\n rpcService[methodName] = util.codegen([\"r\",\"c\"], util.isReserved(methodName) ? methodName + \"_\" : methodName)(\"return this.rpcCall(m,q,s,r,c)\")({\r\n m: method,\r\n q: method.resolvedRequestType.ctor,\r\n s: method.resolvedResponseType.ctor\r\n });\r\n }\r\n return rpcService;\r\n};\r\n","\"use strict\";\r\nmodule.exports = tokenize;\r\n\r\nvar delimRe = /[\\s{}=;:[\\],'\"()<>]/g,\r\n stringDoubleRe = /(?:\"([^\"\\\\]*(?:\\\\.[^\"\\\\]*)*)\")/g,\r\n stringSingleRe = /(?:'([^'\\\\]*(?:\\\\.[^'\\\\]*)*)')/g;\r\n\r\nvar setCommentRe = /^ *[*/]+ */,\r\n setCommentAltRe = /^\\s*\\*?\\/*/,\r\n setCommentSplitRe = /\\n/g,\r\n whitespaceRe = /\\s/,\r\n unescapeRe = /\\\\(.?)/g;\r\n\r\nvar unescapeMap = {\r\n \"0\": \"\\0\",\r\n \"r\": \"\\r\",\r\n \"n\": \"\\n\",\r\n \"t\": \"\\t\"\r\n};\r\n\r\n/**\r\n * Unescapes a string.\r\n * @param {string} str String to unescape\r\n * @returns {string} Unescaped string\r\n * @property {Object.} map Special characters map\r\n * @memberof tokenize\r\n */\r\nfunction unescape(str) {\r\n return str.replace(unescapeRe, function($0, $1) {\r\n switch ($1) {\r\n case \"\\\\\":\r\n case \"\":\r\n return $1;\r\n default:\r\n return unescapeMap[$1] || \"\";\r\n }\r\n });\r\n}\r\n\r\ntokenize.unescape = unescape;\r\n\r\n/**\r\n * Gets the next token and advances.\r\n * @typedef TokenizerHandleNext\r\n * @type {function}\r\n * @returns {string|null} Next token or `null` on eof\r\n */\r\n\r\n/**\r\n * Peeks for the next token.\r\n * @typedef TokenizerHandlePeek\r\n * @type {function}\r\n * @returns {string|null} Next token or `null` on eof\r\n */\r\n\r\n/**\r\n * Pushes a token back to the stack.\r\n * @typedef TokenizerHandlePush\r\n * @type {function}\r\n * @param {string} token Token\r\n * @returns {undefined}\r\n */\r\n\r\n/**\r\n * Skips the next token.\r\n * @typedef TokenizerHandleSkip\r\n * @type {function}\r\n * @param {string} expected Expected token\r\n * @param {boolean} [optional=false] If optional\r\n * @returns {boolean} Whether the token matched\r\n * @throws {Error} If the token didn't match and is not optional\r\n */\r\n\r\n/**\r\n * Gets the comment on the previous line or, alternatively, the line comment on the specified line.\r\n * @typedef TokenizerHandleCmnt\r\n * @type {function}\r\n * @param {number} [line] Line number\r\n * @returns {string|null} Comment text or `null` if none\r\n */\r\n\r\n/**\r\n * Handle object returned from {@link tokenize}.\r\n * @interface ITokenizerHandle\r\n * @property {TokenizerHandleNext} next Gets the next token and advances (`null` on eof)\r\n * @property {TokenizerHandlePeek} peek Peeks for the next token (`null` on eof)\r\n * @property {TokenizerHandlePush} push Pushes a token back to the stack\r\n * @property {TokenizerHandleSkip} skip Skips a token, returns its presence and advances or, if non-optional and not present, throws\r\n * @property {TokenizerHandleCmnt} cmnt Gets the comment on the previous line or the line comment on the specified line, if any\r\n * @property {number} line Current line number\r\n */\r\n\r\n/**\r\n * Tokenizes the given .proto source and returns an object with useful utility functions.\r\n * @param {string} source Source contents\r\n * @param {boolean} alternateCommentMode Whether we should activate alternate comment parsing mode.\r\n * @returns {ITokenizerHandle} Tokenizer handle\r\n */\r\nfunction tokenize(source, alternateCommentMode) {\r\n /* eslint-disable callback-return */\r\n source = source.toString();\r\n\r\n var offset = 0,\r\n length = source.length,\r\n line = 1,\r\n commentType = null,\r\n commentText = null,\r\n commentLine = 0,\r\n commentLineEmpty = false;\r\n\r\n var stack = [];\r\n\r\n var stringDelim = null;\r\n\r\n /* istanbul ignore next */\r\n /**\r\n * Creates an error for illegal syntax.\r\n * @param {string} subject Subject\r\n * @returns {Error} Error created\r\n * @inner\r\n */\r\n function illegal(subject) {\r\n return Error(\"illegal \" + subject + \" (line \" + line + \")\");\r\n }\r\n\r\n /**\r\n * Reads a string till its end.\r\n * @returns {string} String read\r\n * @inner\r\n */\r\n function readString() {\r\n var re = stringDelim === \"'\" ? stringSingleRe : stringDoubleRe;\r\n re.lastIndex = offset - 1;\r\n var match = re.exec(source);\r\n if (!match)\r\n throw illegal(\"string\");\r\n offset = re.lastIndex;\r\n push(stringDelim);\r\n stringDelim = null;\r\n return unescape(match[1]);\r\n }\r\n\r\n /**\r\n * Gets the character at `pos` within the source.\r\n * @param {number} pos Position\r\n * @returns {string} Character\r\n * @inner\r\n */\r\n function charAt(pos) {\r\n return source.charAt(pos);\r\n }\r\n\r\n /**\r\n * Sets the current comment text.\r\n * @param {number} start Start offset\r\n * @param {number} end End offset\r\n * @returns {undefined}\r\n * @inner\r\n */\r\n function setComment(start, end) {\r\n commentType = source.charAt(start++);\r\n commentLine = line;\r\n commentLineEmpty = false;\r\n var lookback;\r\n if (alternateCommentMode) {\r\n lookback = 2; // alternate comment parsing: \"//\" or \"/*\"\r\n } else {\r\n lookback = 3; // \"///\" or \"/**\"\r\n }\r\n var commentOffset = start - lookback,\r\n c;\r\n do {\r\n if (--commentOffset < 0 ||\r\n (c = source.charAt(commentOffset)) === \"\\n\") {\r\n commentLineEmpty = true;\r\n break;\r\n }\r\n } while (c === \" \" || c === \"\\t\");\r\n var lines = source\r\n .substring(start, end)\r\n .split(setCommentSplitRe);\r\n for (var i = 0; i < lines.length; ++i)\r\n lines[i] = lines[i]\r\n .replace(alternateCommentMode ? setCommentAltRe : setCommentRe, \"\")\r\n .trim();\r\n commentText = lines\r\n .join(\"\\n\")\r\n .trim();\r\n }\r\n\r\n function isDoubleSlashCommentLine(startOffset) {\r\n var endOffset = findEndOfLine(startOffset);\r\n\r\n // see if remaining line matches comment pattern\r\n var lineText = source.substring(startOffset, endOffset);\r\n // look for 1 or 2 slashes since startOffset would already point past\r\n // the first slash that started the comment.\r\n var isComment = /^\\s*\\/{1,2}/.test(lineText);\r\n return isComment;\r\n }\r\n\r\n function findEndOfLine(cursor) {\r\n // find end of cursor's line\r\n var endOffset = cursor;\r\n while (endOffset < length && charAt(endOffset) !== \"\\n\") {\r\n endOffset++;\r\n }\r\n return endOffset;\r\n }\r\n\r\n /**\r\n * Obtains the next token.\r\n * @returns {string|null} Next token or `null` on eof\r\n * @inner\r\n */\r\n function next() {\r\n if (stack.length > 0)\r\n return stack.shift();\r\n if (stringDelim)\r\n return readString();\r\n var repeat,\r\n prev,\r\n curr,\r\n start,\r\n isDoc;\r\n do {\r\n if (offset === length)\r\n return null;\r\n repeat = false;\r\n while (whitespaceRe.test(curr = charAt(offset))) {\r\n if (curr === \"\\n\")\r\n ++line;\r\n if (++offset === length)\r\n return null;\r\n }\r\n\r\n if (charAt(offset) === \"/\") {\r\n if (++offset === length) {\r\n throw illegal(\"comment\");\r\n }\r\n if (charAt(offset) === \"/\") { // Line\r\n if (!alternateCommentMode) {\r\n // check for triple-slash comment\r\n isDoc = charAt(start = offset + 1) === \"/\";\r\n\r\n while (charAt(++offset) !== \"\\n\") {\r\n if (offset === length) {\r\n return null;\r\n }\r\n }\r\n ++offset;\r\n if (isDoc) {\r\n setComment(start, offset - 1);\r\n }\r\n ++line;\r\n repeat = true;\r\n } else {\r\n // check for double-slash comments, consolidating consecutive lines\r\n start = offset;\r\n isDoc = false;\r\n if (isDoubleSlashCommentLine(offset)) {\r\n isDoc = true;\r\n do {\r\n offset = findEndOfLine(offset);\r\n if (offset === length) {\r\n break;\r\n }\r\n offset++;\r\n } while (isDoubleSlashCommentLine(offset));\r\n } else {\r\n offset = Math.min(length, findEndOfLine(offset) + 1);\r\n }\r\n if (isDoc) {\r\n setComment(start, offset);\r\n }\r\n line++;\r\n repeat = true;\r\n }\r\n } else if ((curr = charAt(offset)) === \"*\") { /* Block */\r\n // check for /** (regular comment mode) or /* (alternate comment mode)\r\n start = offset + 1;\r\n isDoc = alternateCommentMode || charAt(start) === \"*\";\r\n do {\r\n if (curr === \"\\n\") {\r\n ++line;\r\n }\r\n if (++offset === length) {\r\n throw illegal(\"comment\");\r\n }\r\n prev = curr;\r\n curr = charAt(offset);\r\n } while (prev !== \"*\" || curr !== \"/\");\r\n ++offset;\r\n if (isDoc) {\r\n setComment(start, offset - 2);\r\n }\r\n repeat = true;\r\n } else {\r\n return \"/\";\r\n }\r\n }\r\n } while (repeat);\r\n\r\n // offset !== length if we got here\r\n\r\n var end = offset;\r\n delimRe.lastIndex = 0;\r\n var delim = delimRe.test(charAt(end++));\r\n if (!delim)\r\n while (end < length && !delimRe.test(charAt(end)))\r\n ++end;\r\n var token = source.substring(offset, offset = end);\r\n if (token === \"\\\"\" || token === \"'\")\r\n stringDelim = token;\r\n return token;\r\n }\r\n\r\n /**\r\n * Pushes a token back to the stack.\r\n * @param {string} token Token\r\n * @returns {undefined}\r\n * @inner\r\n */\r\n function push(token) {\r\n stack.push(token);\r\n }\r\n\r\n /**\r\n * Peeks for the next token.\r\n * @returns {string|null} Token or `null` on eof\r\n * @inner\r\n */\r\n function peek() {\r\n if (!stack.length) {\r\n var token = next();\r\n if (token === null)\r\n return null;\r\n push(token);\r\n }\r\n return stack[0];\r\n }\r\n\r\n /**\r\n * Skips a token.\r\n * @param {string} expected Expected token\r\n * @param {boolean} [optional=false] Whether the token is optional\r\n * @returns {boolean} `true` when skipped, `false` if not\r\n * @throws {Error} When a required token is not present\r\n * @inner\r\n */\r\n function skip(expected, optional) {\r\n var actual = peek(),\r\n equals = actual === expected;\r\n if (equals) {\r\n next();\r\n return true;\r\n }\r\n if (!optional)\r\n throw illegal(\"token '\" + actual + \"', '\" + expected + \"' expected\");\r\n return false;\r\n }\r\n\r\n /**\r\n * Gets a comment.\r\n * @param {number} [trailingLine] Line number if looking for a trailing comment\r\n * @returns {string|null} Comment text\r\n * @inner\r\n */\r\n function cmnt(trailingLine) {\r\n var ret = null;\r\n if (trailingLine === undefined) {\r\n if (commentLine === line - 1 && (alternateCommentMode || commentType === \"*\" || commentLineEmpty)) {\r\n ret = commentText;\r\n }\r\n } else {\r\n /* istanbul ignore else */\r\n if (commentLine < trailingLine) {\r\n peek();\r\n }\r\n if (commentLine === trailingLine && !commentLineEmpty && (alternateCommentMode || commentType === \"/\")) {\r\n ret = commentText;\r\n }\r\n }\r\n return ret;\r\n }\r\n\r\n return Object.defineProperty({\r\n next: next,\r\n peek: peek,\r\n push: push,\r\n skip: skip,\r\n cmnt: cmnt\r\n }, \"line\", {\r\n get: function() { return line; }\r\n });\r\n /* eslint-enable callback-return */\r\n}\r\n","\"use strict\";\r\nmodule.exports = Type;\r\n\r\n// extends Namespace\r\nvar Namespace = require(23);\r\n((Type.prototype = Object.create(Namespace.prototype)).constructor = Type).className = \"Type\";\r\n\r\nvar Enum = require(15),\r\n OneOf = require(25),\r\n Field = require(16),\r\n MapField = require(20),\r\n Service = require(33),\r\n Message = require(21),\r\n Reader = require(27),\r\n Writer = require(42),\r\n util = require(37),\r\n encoder = require(14),\r\n decoder = require(13),\r\n verifier = require(40),\r\n converter = require(12),\r\n wrappers = require(41);\r\n\r\n/**\r\n * Constructs a new reflected message type instance.\r\n * @classdesc Reflected message type.\r\n * @extends NamespaceBase\r\n * @constructor\r\n * @param {string} name Message name\r\n * @param {Object.} [options] Declared options\r\n */\r\nfunction Type(name, options) {\r\n Namespace.call(this, name, options);\r\n\r\n /**\r\n * Message fields.\r\n * @type {Object.}\r\n */\r\n this.fields = {}; // toJSON, marker\r\n\r\n /**\r\n * Oneofs declared within this namespace, if any.\r\n * @type {Object.}\r\n */\r\n this.oneofs = undefined; // toJSON\r\n\r\n /**\r\n * Extension ranges, if any.\r\n * @type {number[][]}\r\n */\r\n this.extensions = undefined; // toJSON\r\n\r\n /**\r\n * Reserved ranges, if any.\r\n * @type {Array.}\r\n */\r\n this.reserved = undefined; // toJSON\r\n\r\n /*?\r\n * Whether this type is a legacy group.\r\n * @type {boolean|undefined}\r\n */\r\n this.group = undefined; // toJSON\r\n\r\n /**\r\n * Cached fields by id.\r\n * @type {Object.|null}\r\n * @private\r\n */\r\n this._fieldsById = null;\r\n\r\n /**\r\n * Cached fields as an array.\r\n * @type {Field[]|null}\r\n * @private\r\n */\r\n this._fieldsArray = null;\r\n\r\n /**\r\n * Cached oneofs as an array.\r\n * @type {OneOf[]|null}\r\n * @private\r\n */\r\n this._oneofsArray = null;\r\n\r\n /**\r\n * Cached constructor.\r\n * @type {Constructor<{}>}\r\n * @private\r\n */\r\n this._ctor = null;\r\n}\r\n\r\nObject.defineProperties(Type.prototype, {\r\n\r\n /**\r\n * Message fields by id.\r\n * @name Type#fieldsById\r\n * @type {Object.}\r\n * @readonly\r\n */\r\n fieldsById: {\r\n get: function() {\r\n\r\n /* istanbul ignore if */\r\n if (this._fieldsById)\r\n return this._fieldsById;\r\n\r\n this._fieldsById = {};\r\n for (var names = Object.keys(this.fields), i = 0; i < names.length; ++i) {\r\n var field = this.fields[names[i]],\r\n id = field.id;\r\n\r\n /* istanbul ignore if */\r\n if (this._fieldsById[id])\r\n throw Error(\"duplicate id \" + id + \" in \" + this);\r\n\r\n this._fieldsById[id] = field;\r\n }\r\n return this._fieldsById;\r\n }\r\n },\r\n\r\n /**\r\n * Fields of this message as an array for iteration.\r\n * @name Type#fieldsArray\r\n * @type {Field[]}\r\n * @readonly\r\n */\r\n fieldsArray: {\r\n get: function() {\r\n return this._fieldsArray || (this._fieldsArray = util.toArray(this.fields));\r\n }\r\n },\r\n\r\n /**\r\n * Oneofs of this message as an array for iteration.\r\n * @name Type#oneofsArray\r\n * @type {OneOf[]}\r\n * @readonly\r\n */\r\n oneofsArray: {\r\n get: function() {\r\n return this._oneofsArray || (this._oneofsArray = util.toArray(this.oneofs));\r\n }\r\n },\r\n\r\n /**\r\n * The registered constructor, if any registered, otherwise a generic constructor.\r\n * Assigning a function replaces the internal constructor. If the function does not extend {@link Message} yet, its prototype will be setup accordingly and static methods will be populated. If it already extends {@link Message}, it will just replace the internal constructor.\r\n * @name Type#ctor\r\n * @type {Constructor<{}>}\r\n */\r\n ctor: {\r\n get: function() {\r\n return this._ctor || (this.ctor = Type.generateConstructor(this)());\r\n },\r\n set: function(ctor) {\r\n\r\n // Ensure proper prototype\r\n var prototype = ctor.prototype;\r\n if (!(prototype instanceof Message)) {\r\n (ctor.prototype = new Message()).constructor = ctor;\r\n util.merge(ctor.prototype, prototype);\r\n }\r\n\r\n // Classes and messages reference their reflected type\r\n ctor.$type = ctor.prototype.$type = this;\r\n\r\n // Mix in static methods\r\n util.merge(ctor, Message, true);\r\n\r\n this._ctor = ctor;\r\n\r\n // Messages have non-enumerable default values on their prototype\r\n var i = 0;\r\n for (; i < /* initializes */ this.fieldsArray.length; ++i)\r\n this._fieldsArray[i].resolve(); // ensures a proper value\r\n\r\n // Messages have non-enumerable getters and setters for each virtual oneof field\r\n var ctorProperties = {};\r\n for (i = 0; i < /* initializes */ this.oneofsArray.length; ++i)\r\n ctorProperties[this._oneofsArray[i].resolve().name] = {\r\n get: util.oneOfGetter(this._oneofsArray[i].oneof),\r\n set: util.oneOfSetter(this._oneofsArray[i].oneof)\r\n };\r\n if (i)\r\n Object.defineProperties(ctor.prototype, ctorProperties);\r\n }\r\n }\r\n});\r\n\r\n/**\r\n * Generates a constructor function for the specified type.\r\n * @param {Type} mtype Message type\r\n * @returns {Codegen} Codegen instance\r\n */\r\nType.generateConstructor = function generateConstructor(mtype) {\r\n /* eslint-disable no-unexpected-multiline */\r\n var gen = util.codegen([\"p\"], mtype.name);\r\n // explicitly initialize mutable object/array fields so that these aren't just inherited from the prototype\r\n for (var i = 0, field; i < mtype.fieldsArray.length; ++i)\r\n if ((field = mtype._fieldsArray[i]).map) gen\r\n (\"this%s={}\", util.safeProp(field.name));\r\n else if (field.repeated) gen\r\n (\"this%s=[]\", util.safeProp(field.name));\r\n return gen\r\n (\"if(p)for(var ks=Object.keys(p),i=0;i} [oneofs] Oneof descriptors\r\n * @property {Object.} fields Field descriptors\r\n * @property {number[][]} [extensions] Extension ranges\r\n * @property {number[][]} [reserved] Reserved ranges\r\n * @property {boolean} [group=false] Whether a legacy group or not\r\n */\r\n\r\n/**\r\n * Creates a message type from a message type descriptor.\r\n * @param {string} name Message name\r\n * @param {IType} json Message type descriptor\r\n * @returns {Type} Created message type\r\n */\r\nType.fromJSON = function fromJSON(name, json) {\r\n var type = new Type(name, json.options);\r\n type.extensions = json.extensions;\r\n type.reserved = json.reserved;\r\n var names = Object.keys(json.fields),\r\n i = 0;\r\n for (; i < names.length; ++i)\r\n type.add(\r\n ( typeof json.fields[names[i]].keyType !== \"undefined\"\r\n ? MapField.fromJSON\r\n : Field.fromJSON )(names[i], json.fields[names[i]])\r\n );\r\n if (json.oneofs)\r\n for (names = Object.keys(json.oneofs), i = 0; i < names.length; ++i)\r\n type.add(OneOf.fromJSON(names[i], json.oneofs[names[i]]));\r\n if (json.nested)\r\n for (names = Object.keys(json.nested), i = 0; i < names.length; ++i) {\r\n var nested = json.nested[names[i]];\r\n type.add( // most to least likely\r\n ( nested.id !== undefined\r\n ? Field.fromJSON\r\n : nested.fields !== undefined\r\n ? Type.fromJSON\r\n : nested.values !== undefined\r\n ? Enum.fromJSON\r\n : nested.methods !== undefined\r\n ? Service.fromJSON\r\n : Namespace.fromJSON )(names[i], nested)\r\n );\r\n }\r\n if (json.extensions && json.extensions.length)\r\n type.extensions = json.extensions;\r\n if (json.reserved && json.reserved.length)\r\n type.reserved = json.reserved;\r\n if (json.group)\r\n type.group = true;\r\n if (json.comment)\r\n type.comment = json.comment;\r\n return type;\r\n};\r\n\r\n/**\r\n * Converts this message type to a message type descriptor.\r\n * @param {IToJSONOptions} [toJSONOptions] JSON conversion options\r\n * @returns {IType} Message type descriptor\r\n */\r\nType.prototype.toJSON = function toJSON(toJSONOptions) {\r\n var inherited = Namespace.prototype.toJSON.call(this, toJSONOptions);\r\n var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false;\r\n return util.toObject([\r\n \"options\" , inherited && inherited.options || undefined,\r\n \"oneofs\" , Namespace.arrayToJSON(this.oneofsArray, toJSONOptions),\r\n \"fields\" , Namespace.arrayToJSON(this.fieldsArray.filter(function(obj) { return !obj.declaringField; }), toJSONOptions) || {},\r\n \"extensions\" , this.extensions && this.extensions.length ? this.extensions : undefined,\r\n \"reserved\" , this.reserved && this.reserved.length ? this.reserved : undefined,\r\n \"group\" , this.group || undefined,\r\n \"nested\" , inherited && inherited.nested || undefined,\r\n \"comment\" , keepComments ? this.comment : undefined\r\n ]);\r\n};\r\n\r\n/**\r\n * @override\r\n */\r\nType.prototype.resolveAll = function resolveAll() {\r\n var fields = this.fieldsArray, i = 0;\r\n while (i < fields.length)\r\n fields[i++].resolve();\r\n var oneofs = this.oneofsArray; i = 0;\r\n while (i < oneofs.length)\r\n oneofs[i++].resolve();\r\n return Namespace.prototype.resolveAll.call(this);\r\n};\r\n\r\n/**\r\n * @override\r\n */\r\nType.prototype.get = function get(name) {\r\n return this.fields[name]\r\n || this.oneofs && this.oneofs[name]\r\n || this.nested && this.nested[name]\r\n || null;\r\n};\r\n\r\n/**\r\n * Adds a nested object to this type.\r\n * @param {ReflectionObject} object Nested object to add\r\n * @returns {Type} `this`\r\n * @throws {TypeError} If arguments are invalid\r\n * @throws {Error} If there is already a nested object with this name or, if a field, when there is already a field with this id\r\n */\r\nType.prototype.add = function add(object) {\r\n\r\n if (this.get(object.name))\r\n throw Error(\"duplicate name '\" + object.name + \"' in \" + this);\r\n\r\n if (object instanceof Field && object.extend === undefined) {\r\n // NOTE: Extension fields aren't actual fields on the declaring type, but nested objects.\r\n // The root object takes care of adding distinct sister-fields to the respective extended\r\n // type instead.\r\n\r\n // avoids calling the getter if not absolutely necessary because it's called quite frequently\r\n if (this._fieldsById ? /* istanbul ignore next */ this._fieldsById[object.id] : this.fieldsById[object.id])\r\n throw Error(\"duplicate id \" + object.id + \" in \" + this);\r\n if (this.isReservedId(object.id))\r\n throw Error(\"id \" + object.id + \" is reserved in \" + this);\r\n if (this.isReservedName(object.name))\r\n throw Error(\"name '\" + object.name + \"' is reserved in \" + this);\r\n\r\n if (object.parent)\r\n object.parent.remove(object);\r\n this.fields[object.name] = object;\r\n object.message = this;\r\n object.onAdd(this);\r\n return clearCache(this);\r\n }\r\n if (object instanceof OneOf) {\r\n if (!this.oneofs)\r\n this.oneofs = {};\r\n this.oneofs[object.name] = object;\r\n object.onAdd(this);\r\n return clearCache(this);\r\n }\r\n return Namespace.prototype.add.call(this, object);\r\n};\r\n\r\n/**\r\n * Removes a nested object from this type.\r\n * @param {ReflectionObject} object Nested object to remove\r\n * @returns {Type} `this`\r\n * @throws {TypeError} If arguments are invalid\r\n * @throws {Error} If `object` is not a member of this type\r\n */\r\nType.prototype.remove = function remove(object) {\r\n if (object instanceof Field && object.extend === undefined) {\r\n // See Type#add for the reason why extension fields are excluded here.\r\n\r\n /* istanbul ignore if */\r\n if (!this.fields || this.fields[object.name] !== object)\r\n throw Error(object + \" is not a member of \" + this);\r\n\r\n delete this.fields[object.name];\r\n object.parent = null;\r\n object.onRemove(this);\r\n return clearCache(this);\r\n }\r\n if (object instanceof OneOf) {\r\n\r\n /* istanbul ignore if */\r\n if (!this.oneofs || this.oneofs[object.name] !== object)\r\n throw Error(object + \" is not a member of \" + this);\r\n\r\n delete this.oneofs[object.name];\r\n object.parent = null;\r\n object.onRemove(this);\r\n return clearCache(this);\r\n }\r\n return Namespace.prototype.remove.call(this, object);\r\n};\r\n\r\n/**\r\n * Tests if the specified id is reserved.\r\n * @param {number} id Id to test\r\n * @returns {boolean} `true` if reserved, otherwise `false`\r\n */\r\nType.prototype.isReservedId = function isReservedId(id) {\r\n return Namespace.isReservedId(this.reserved, id);\r\n};\r\n\r\n/**\r\n * Tests if the specified name is reserved.\r\n * @param {string} name Name to test\r\n * @returns {boolean} `true` if reserved, otherwise `false`\r\n */\r\nType.prototype.isReservedName = function isReservedName(name) {\r\n return Namespace.isReservedName(this.reserved, name);\r\n};\r\n\r\n/**\r\n * Creates a new message of this type using the specified properties.\r\n * @param {Object.} [properties] Properties to set\r\n * @returns {Message<{}>} Message instance\r\n */\r\nType.prototype.create = function create(properties) {\r\n return new this.ctor(properties);\r\n};\r\n\r\n/**\r\n * Sets up {@link Type#encode|encode}, {@link Type#decode|decode} and {@link Type#verify|verify}.\r\n * @returns {Type} `this`\r\n */\r\nType.prototype.setup = function setup() {\r\n // Sets up everything at once so that the prototype chain does not have to be re-evaluated\r\n // multiple times (V8, soft-deopt prototype-check).\r\n\r\n var fullName = this.fullName,\r\n types = [];\r\n for (var i = 0; i < /* initializes */ this.fieldsArray.length; ++i)\r\n types.push(this._fieldsArray[i].resolve().resolvedType);\r\n\r\n // Replace setup methods with type-specific generated functions\r\n this.encode = encoder(this)({\r\n Writer : Writer,\r\n types : types,\r\n util : util\r\n });\r\n this.decode = decoder(this)({\r\n Reader : Reader,\r\n types : types,\r\n util : util\r\n });\r\n this.verify = verifier(this)({\r\n types : types,\r\n util : util\r\n });\r\n this.fromObject = converter.fromObject(this)({\r\n types : types,\r\n util : util\r\n });\r\n this.toObject = converter.toObject(this)({\r\n types : types,\r\n util : util\r\n });\r\n\r\n // Inject custom wrappers for common types\r\n var wrapper = wrappers[fullName];\r\n if (wrapper) {\r\n var originalThis = Object.create(this);\r\n // if (wrapper.fromObject) {\r\n originalThis.fromObject = this.fromObject;\r\n this.fromObject = wrapper.fromObject.bind(originalThis);\r\n // }\r\n // if (wrapper.toObject) {\r\n originalThis.toObject = this.toObject;\r\n this.toObject = wrapper.toObject.bind(originalThis);\r\n // }\r\n }\r\n\r\n return this;\r\n};\r\n\r\n/**\r\n * Encodes a message of this type. Does not implicitly {@link Type#verify|verify} messages.\r\n * @param {Message<{}>|Object.} message Message instance or plain object\r\n * @param {Writer} [writer] Writer to encode to\r\n * @returns {Writer} writer\r\n */\r\nType.prototype.encode = function encode_setup(message, writer) {\r\n return this.setup().encode(message, writer); // overrides this method\r\n};\r\n\r\n/**\r\n * Encodes a message of this type preceeded by its byte length as a varint. Does not implicitly {@link Type#verify|verify} messages.\r\n * @param {Message<{}>|Object.} message Message instance or plain object\r\n * @param {Writer} [writer] Writer to encode to\r\n * @returns {Writer} writer\r\n */\r\nType.prototype.encodeDelimited = function encodeDelimited(message, writer) {\r\n return this.encode(message, writer && writer.len ? writer.fork() : writer).ldelim();\r\n};\r\n\r\n/**\r\n * Decodes a message of this type.\r\n * @param {Reader|Uint8Array} reader Reader or buffer to decode from\r\n * @param {number} [length] Length of the message, if known beforehand\r\n * @returns {Message<{}>} Decoded message\r\n * @throws {Error} If the payload is not a reader or valid buffer\r\n * @throws {util.ProtocolError<{}>} If required fields are missing\r\n */\r\nType.prototype.decode = function decode_setup(reader, length) {\r\n return this.setup().decode(reader, length); // overrides this method\r\n};\r\n\r\n/**\r\n * Decodes a message of this type preceeded by its byte length as a varint.\r\n * @param {Reader|Uint8Array} reader Reader or buffer to decode from\r\n * @returns {Message<{}>} Decoded message\r\n * @throws {Error} If the payload is not a reader or valid buffer\r\n * @throws {util.ProtocolError} If required fields are missing\r\n */\r\nType.prototype.decodeDelimited = function decodeDelimited(reader) {\r\n if (!(reader instanceof Reader))\r\n reader = Reader.create(reader);\r\n return this.decode(reader, reader.uint32());\r\n};\r\n\r\n/**\r\n * Verifies that field values are valid and that required fields are present.\r\n * @param {Object.} message Plain object to verify\r\n * @returns {null|string} `null` if valid, otherwise the reason why it is not\r\n */\r\nType.prototype.verify = function verify_setup(message) {\r\n return this.setup().verify(message); // overrides this method\r\n};\r\n\r\n/**\r\n * Creates a new message of this type from a plain object. Also converts values to their respective internal types.\r\n * @param {Object.} object Plain object to convert\r\n * @returns {Message<{}>} Message instance\r\n */\r\nType.prototype.fromObject = function fromObject(object) {\r\n return this.setup().fromObject(object);\r\n};\r\n\r\n/**\r\n * Conversion options as used by {@link Type#toObject} and {@link Message.toObject}.\r\n * @interface IConversionOptions\r\n * @property {Function} [longs] Long conversion type.\r\n * Valid values are `String` and `Number` (the global types).\r\n * Defaults to copy the present value, which is a possibly unsafe number without and a {@link Long} with a long library.\r\n * @property {Function} [enums] Enum value conversion type.\r\n * Only valid value is `String` (the global type).\r\n * Defaults to copy the present value, which is the numeric id.\r\n * @property {Function} [bytes] Bytes value conversion type.\r\n * Valid values are `Array` and (a base64 encoded) `String` (the global types).\r\n * Defaults to copy the present value, which usually is a Buffer under node and an Uint8Array in the browser.\r\n * @property {boolean} [defaults=false] Also sets default values on the resulting object\r\n * @property {boolean} [arrays=false] Sets empty arrays for missing repeated fields even if `defaults=false`\r\n * @property {boolean} [objects=false] Sets empty objects for missing map fields even if `defaults=false`\r\n * @property {boolean} [oneofs=false] Includes virtual oneof properties set to the present field's name, if any\r\n * @property {boolean} [json=false] Performs additional JSON compatibility conversions, i.e. NaN and Infinity to strings\r\n */\r\n\r\n/**\r\n * Creates a plain object from a message of this type. Also converts values to other types if specified.\r\n * @param {Message<{}>} message Message instance\r\n * @param {IConversionOptions} [options] Conversion options\r\n * @returns {Object.} Plain object\r\n */\r\nType.prototype.toObject = function toObject(message, options) {\r\n return this.setup().toObject(message, options);\r\n};\r\n\r\n/**\r\n * Decorator function as returned by {@link Type.d} (TypeScript).\r\n * @typedef TypeDecorator\r\n * @type {function}\r\n * @param {Constructor} target Target constructor\r\n * @returns {undefined}\r\n * @template T extends Message\r\n */\r\n\r\n/**\r\n * Type decorator (TypeScript).\r\n * @param {string} [typeName] Type name, defaults to the constructor's name\r\n * @returns {TypeDecorator} Decorator function\r\n * @template T extends Message\r\n */\r\nType.d = function decorateType(typeName) {\r\n return function typeDecorator(target) {\r\n util.decorateType(target, typeName);\r\n };\r\n};\r\n","\"use strict\";\r\n\r\n/**\r\n * Common type constants.\r\n * @namespace\r\n */\r\nvar types = exports;\r\n\r\nvar util = require(37);\r\n\r\nvar s = [\r\n \"double\", // 0\r\n \"float\", // 1\r\n \"int32\", // 2\r\n \"uint32\", // 3\r\n \"sint32\", // 4\r\n \"fixed32\", // 5\r\n \"sfixed32\", // 6\r\n \"int64\", // 7\r\n \"uint64\", // 8\r\n \"sint64\", // 9\r\n \"fixed64\", // 10\r\n \"sfixed64\", // 11\r\n \"bool\", // 12\r\n \"string\", // 13\r\n \"bytes\" // 14\r\n];\r\n\r\nfunction bake(values, offset) {\r\n var i = 0, o = {};\r\n offset |= 0;\r\n while (i < values.length) o[s[i + offset]] = values[i++];\r\n return o;\r\n}\r\n\r\n/**\r\n * Basic type wire types.\r\n * @type {Object.}\r\n * @const\r\n * @property {number} double=1 Fixed64 wire type\r\n * @property {number} float=5 Fixed32 wire type\r\n * @property {number} int32=0 Varint wire type\r\n * @property {number} uint32=0 Varint wire type\r\n * @property {number} sint32=0 Varint wire type\r\n * @property {number} fixed32=5 Fixed32 wire type\r\n * @property {number} sfixed32=5 Fixed32 wire type\r\n * @property {number} int64=0 Varint wire type\r\n * @property {number} uint64=0 Varint wire type\r\n * @property {number} sint64=0 Varint wire type\r\n * @property {number} fixed64=1 Fixed64 wire type\r\n * @property {number} sfixed64=1 Fixed64 wire type\r\n * @property {number} bool=0 Varint wire type\r\n * @property {number} string=2 Ldelim wire type\r\n * @property {number} bytes=2 Ldelim wire type\r\n */\r\ntypes.basic = bake([\r\n /* double */ 1,\r\n /* float */ 5,\r\n /* int32 */ 0,\r\n /* uint32 */ 0,\r\n /* sint32 */ 0,\r\n /* fixed32 */ 5,\r\n /* sfixed32 */ 5,\r\n /* int64 */ 0,\r\n /* uint64 */ 0,\r\n /* sint64 */ 0,\r\n /* fixed64 */ 1,\r\n /* sfixed64 */ 1,\r\n /* bool */ 0,\r\n /* string */ 2,\r\n /* bytes */ 2\r\n]);\r\n\r\n/**\r\n * Basic type defaults.\r\n * @type {Object.}\r\n * @const\r\n * @property {number} double=0 Double default\r\n * @property {number} float=0 Float default\r\n * @property {number} int32=0 Int32 default\r\n * @property {number} uint32=0 Uint32 default\r\n * @property {number} sint32=0 Sint32 default\r\n * @property {number} fixed32=0 Fixed32 default\r\n * @property {number} sfixed32=0 Sfixed32 default\r\n * @property {number} int64=0 Int64 default\r\n * @property {number} uint64=0 Uint64 default\r\n * @property {number} sint64=0 Sint32 default\r\n * @property {number} fixed64=0 Fixed64 default\r\n * @property {number} sfixed64=0 Sfixed64 default\r\n * @property {boolean} bool=false Bool default\r\n * @property {string} string=\"\" String default\r\n * @property {Array.} bytes=Array(0) Bytes default\r\n * @property {null} message=null Message default\r\n */\r\ntypes.defaults = bake([\r\n /* double */ 0,\r\n /* float */ 0,\r\n /* int32 */ 0,\r\n /* uint32 */ 0,\r\n /* sint32 */ 0,\r\n /* fixed32 */ 0,\r\n /* sfixed32 */ 0,\r\n /* int64 */ 0,\r\n /* uint64 */ 0,\r\n /* sint64 */ 0,\r\n /* fixed64 */ 0,\r\n /* sfixed64 */ 0,\r\n /* bool */ false,\r\n /* string */ \"\",\r\n /* bytes */ util.emptyArray,\r\n /* message */ null\r\n]);\r\n\r\n/**\r\n * Basic long type wire types.\r\n * @type {Object.}\r\n * @const\r\n * @property {number} int64=0 Varint wire type\r\n * @property {number} uint64=0 Varint wire type\r\n * @property {number} sint64=0 Varint wire type\r\n * @property {number} fixed64=1 Fixed64 wire type\r\n * @property {number} sfixed64=1 Fixed64 wire type\r\n */\r\ntypes.long = bake([\r\n /* int64 */ 0,\r\n /* uint64 */ 0,\r\n /* sint64 */ 0,\r\n /* fixed64 */ 1,\r\n /* sfixed64 */ 1\r\n], 7);\r\n\r\n/**\r\n * Allowed types for map keys with their associated wire type.\r\n * @type {Object.}\r\n * @const\r\n * @property {number} int32=0 Varint wire type\r\n * @property {number} uint32=0 Varint wire type\r\n * @property {number} sint32=0 Varint wire type\r\n * @property {number} fixed32=5 Fixed32 wire type\r\n * @property {number} sfixed32=5 Fixed32 wire type\r\n * @property {number} int64=0 Varint wire type\r\n * @property {number} uint64=0 Varint wire type\r\n * @property {number} sint64=0 Varint wire type\r\n * @property {number} fixed64=1 Fixed64 wire type\r\n * @property {number} sfixed64=1 Fixed64 wire type\r\n * @property {number} bool=0 Varint wire type\r\n * @property {number} string=2 Ldelim wire type\r\n */\r\ntypes.mapKey = bake([\r\n /* int32 */ 0,\r\n /* uint32 */ 0,\r\n /* sint32 */ 0,\r\n /* fixed32 */ 5,\r\n /* sfixed32 */ 5,\r\n /* int64 */ 0,\r\n /* uint64 */ 0,\r\n /* sint64 */ 0,\r\n /* fixed64 */ 1,\r\n /* sfixed64 */ 1,\r\n /* bool */ 0,\r\n /* string */ 2\r\n], 2);\r\n\r\n/**\r\n * Allowed types for packed repeated fields with their associated wire type.\r\n * @type {Object.}\r\n * @const\r\n * @property {number} double=1 Fixed64 wire type\r\n * @property {number} float=5 Fixed32 wire type\r\n * @property {number} int32=0 Varint wire type\r\n * @property {number} uint32=0 Varint wire type\r\n * @property {number} sint32=0 Varint wire type\r\n * @property {number} fixed32=5 Fixed32 wire type\r\n * @property {number} sfixed32=5 Fixed32 wire type\r\n * @property {number} int64=0 Varint wire type\r\n * @property {number} uint64=0 Varint wire type\r\n * @property {number} sint64=0 Varint wire type\r\n * @property {number} fixed64=1 Fixed64 wire type\r\n * @property {number} sfixed64=1 Fixed64 wire type\r\n * @property {number} bool=0 Varint wire type\r\n */\r\ntypes.packed = bake([\r\n /* double */ 1,\r\n /* float */ 5,\r\n /* int32 */ 0,\r\n /* uint32 */ 0,\r\n /* sint32 */ 0,\r\n /* fixed32 */ 5,\r\n /* sfixed32 */ 5,\r\n /* int64 */ 0,\r\n /* uint64 */ 0,\r\n /* sint64 */ 0,\r\n /* fixed64 */ 1,\r\n /* sfixed64 */ 1,\r\n /* bool */ 0\r\n]);\r\n","\"use strict\";\r\n\r\n/**\r\n * Various utility functions.\r\n * @namespace\r\n */\r\nvar util = module.exports = require(39);\r\n\r\nvar roots = require(30);\r\n\r\nvar Type, // cyclic\r\n Enum;\r\n\r\nutil.codegen = require(3);\r\nutil.fetch = require(5);\r\nutil.path = require(8);\r\n\r\n/**\r\n * Node's fs module if available.\r\n * @type {Object.}\r\n */\r\nutil.fs = util.inquire(\"fs\");\r\n\r\n/**\r\n * Converts an object's values to an array.\r\n * @param {Object.} object Object to convert\r\n * @returns {Array.<*>} Converted array\r\n */\r\nutil.toArray = function toArray(object) {\r\n if (object) {\r\n var keys = Object.keys(object),\r\n array = new Array(keys.length),\r\n index = 0;\r\n while (index < keys.length)\r\n array[index] = object[keys[index++]];\r\n return array;\r\n }\r\n return [];\r\n};\r\n\r\n/**\r\n * Converts an array of keys immediately followed by their respective value to an object, omitting undefined values.\r\n * @param {Array.<*>} array Array to convert\r\n * @returns {Object.} Converted object\r\n */\r\nutil.toObject = function toObject(array) {\r\n var object = {},\r\n index = 0;\r\n while (index < array.length) {\r\n var key = array[index++],\r\n val = array[index++];\r\n if (val !== undefined)\r\n object[key] = val;\r\n }\r\n return object;\r\n};\r\n\r\nvar safePropBackslashRe = /\\\\/g,\r\n safePropQuoteRe = /\"/g;\r\n\r\n/**\r\n * Tests whether the specified name is a reserved word in JS.\r\n * @param {string} name Name to test\r\n * @returns {boolean} `true` if reserved, otherwise `false`\r\n */\r\nutil.isReserved = function isReserved(name) {\r\n return /^(?:do|if|in|for|let|new|try|var|case|else|enum|eval|false|null|this|true|void|with|break|catch|class|const|super|throw|while|yield|delete|export|import|public|return|static|switch|typeof|default|extends|finally|package|private|continue|debugger|function|arguments|interface|protected|implements|instanceof)$/.test(name);\r\n};\r\n\r\n/**\r\n * Returns a safe property accessor for the specified property name.\r\n * @param {string} prop Property name\r\n * @returns {string} Safe accessor\r\n */\r\nutil.safeProp = function safeProp(prop) {\r\n if (!/^[$\\w_]+$/.test(prop) || util.isReserved(prop))\r\n return \"[\\\"\" + prop.replace(safePropBackslashRe, \"\\\\\\\\\").replace(safePropQuoteRe, \"\\\\\\\"\") + \"\\\"]\";\r\n return \".\" + prop;\r\n};\r\n\r\n/**\r\n * Converts the first character of a string to upper case.\r\n * @param {string} str String to convert\r\n * @returns {string} Converted string\r\n */\r\nutil.ucFirst = function ucFirst(str) {\r\n return str.charAt(0).toUpperCase() + str.substring(1);\r\n};\r\n\r\nvar camelCaseRe = /_([a-z])/g;\r\n\r\n/**\r\n * Converts a string to camel case.\r\n * @param {string} str String to convert\r\n * @returns {string} Converted string\r\n */\r\nutil.camelCase = function camelCase(str) {\r\n return str.substring(0, 1)\r\n + str.substring(1)\r\n .replace(camelCaseRe, function($0, $1) { return $1.toUpperCase(); });\r\n};\r\n\r\n/**\r\n * Compares reflected fields by id.\r\n * @param {Field} a First field\r\n * @param {Field} b Second field\r\n * @returns {number} Comparison value\r\n */\r\nutil.compareFieldsById = function compareFieldsById(a, b) {\r\n return a.id - b.id;\r\n};\r\n\r\n/**\r\n * Decorator helper for types (TypeScript).\r\n * @param {Constructor} ctor Constructor function\r\n * @param {string} [typeName] Type name, defaults to the constructor's name\r\n * @returns {Type} Reflected type\r\n * @template T extends Message\r\n * @property {Root} root Decorators root\r\n */\r\nutil.decorateType = function decorateType(ctor, typeName) {\r\n\r\n /* istanbul ignore if */\r\n if (ctor.$type) {\r\n if (typeName && ctor.$type.name !== typeName) {\r\n util.decorateRoot.remove(ctor.$type);\r\n ctor.$type.name = typeName;\r\n util.decorateRoot.add(ctor.$type);\r\n }\r\n return ctor.$type;\r\n }\r\n\r\n /* istanbul ignore next */\r\n if (!Type)\r\n Type = require(35);\r\n\r\n var type = new Type(typeName || ctor.name);\r\n util.decorateRoot.add(type);\r\n type.ctor = ctor; // sets up .encode, .decode etc.\r\n Object.defineProperty(ctor, \"$type\", { value: type, enumerable: false });\r\n Object.defineProperty(ctor.prototype, \"$type\", { value: type, enumerable: false });\r\n return type;\r\n};\r\n\r\nvar decorateEnumIndex = 0;\r\n\r\n/**\r\n * Decorator helper for enums (TypeScript).\r\n * @param {Object} object Enum object\r\n * @returns {Enum} Reflected enum\r\n */\r\nutil.decorateEnum = function decorateEnum(object) {\r\n\r\n /* istanbul ignore if */\r\n if (object.$type)\r\n return object.$type;\r\n\r\n /* istanbul ignore next */\r\n if (!Enum)\r\n Enum = require(15);\r\n\r\n var enm = new Enum(\"Enum\" + decorateEnumIndex++, object);\r\n util.decorateRoot.add(enm);\r\n Object.defineProperty(object, \"$type\", { value: enm, enumerable: false });\r\n return enm;\r\n};\r\n\r\n/**\r\n * Decorator root (TypeScript).\r\n * @name util.decorateRoot\r\n * @type {Root}\r\n * @readonly\r\n */\r\nObject.defineProperty(util, \"decorateRoot\", {\r\n get: function() {\r\n return roots[\"decorated\"] || (roots[\"decorated\"] = new (require(29))());\r\n }\r\n});\r\n","\"use strict\";\r\nmodule.exports = LongBits;\r\n\r\nvar util = require(39);\r\n\r\n/**\r\n * Constructs new long bits.\r\n * @classdesc Helper class for working with the low and high bits of a 64 bit value.\r\n * @memberof util\r\n * @constructor\r\n * @param {number} lo Low 32 bits, unsigned\r\n * @param {number} hi High 32 bits, unsigned\r\n */\r\nfunction LongBits(lo, hi) {\r\n\r\n // note that the casts below are theoretically unnecessary as of today, but older statically\r\n // generated converter code might still call the ctor with signed 32bits. kept for compat.\r\n\r\n /**\r\n * Low bits.\r\n * @type {number}\r\n */\r\n this.lo = lo >>> 0;\r\n\r\n /**\r\n * High bits.\r\n * @type {number}\r\n */\r\n this.hi = hi >>> 0;\r\n}\r\n\r\n/**\r\n * Zero bits.\r\n * @memberof util.LongBits\r\n * @type {util.LongBits}\r\n */\r\nvar zero = LongBits.zero = new LongBits(0, 0);\r\n\r\nzero.toNumber = function() { return 0; };\r\nzero.zzEncode = zero.zzDecode = function() { return this; };\r\nzero.length = function() { return 1; };\r\n\r\n/**\r\n * Zero hash.\r\n * @memberof util.LongBits\r\n * @type {string}\r\n */\r\nvar zeroHash = LongBits.zeroHash = \"\\0\\0\\0\\0\\0\\0\\0\\0\";\r\n\r\n/**\r\n * Constructs new long bits from the specified number.\r\n * @param {number} value Value\r\n * @returns {util.LongBits} Instance\r\n */\r\nLongBits.fromNumber = function fromNumber(value) {\r\n if (value === 0)\r\n return zero;\r\n var sign = value < 0;\r\n if (sign)\r\n value = -value;\r\n var lo = value >>> 0,\r\n hi = (value - lo) / 4294967296 >>> 0;\r\n if (sign) {\r\n hi = ~hi >>> 0;\r\n lo = ~lo >>> 0;\r\n if (++lo > 4294967295) {\r\n lo = 0;\r\n if (++hi > 4294967295)\r\n hi = 0;\r\n }\r\n }\r\n return new LongBits(lo, hi);\r\n};\r\n\r\n/**\r\n * Constructs new long bits from a number, long or string.\r\n * @param {Long|number|string} value Value\r\n * @returns {util.LongBits} Instance\r\n */\r\nLongBits.from = function from(value) {\r\n if (typeof value === \"number\")\r\n return LongBits.fromNumber(value);\r\n if (util.isString(value)) {\r\n /* istanbul ignore else */\r\n if (util.Long)\r\n value = util.Long.fromString(value);\r\n else\r\n return LongBits.fromNumber(parseInt(value, 10));\r\n }\r\n return value.low || value.high ? new LongBits(value.low >>> 0, value.high >>> 0) : zero;\r\n};\r\n\r\n/**\r\n * Converts this long bits to a possibly unsafe JavaScript number.\r\n * @param {boolean} [unsigned=false] Whether unsigned or not\r\n * @returns {number} Possibly unsafe number\r\n */\r\nLongBits.prototype.toNumber = function toNumber(unsigned) {\r\n if (!unsigned && this.hi >>> 31) {\r\n var lo = ~this.lo + 1 >>> 0,\r\n hi = ~this.hi >>> 0;\r\n if (!lo)\r\n hi = hi + 1 >>> 0;\r\n return -(lo + hi * 4294967296);\r\n }\r\n return this.lo + this.hi * 4294967296;\r\n};\r\n\r\n/**\r\n * Converts this long bits to a long.\r\n * @param {boolean} [unsigned=false] Whether unsigned or not\r\n * @returns {Long} Long\r\n */\r\nLongBits.prototype.toLong = function toLong(unsigned) {\r\n return util.Long\r\n ? new util.Long(this.lo | 0, this.hi | 0, Boolean(unsigned))\r\n /* istanbul ignore next */\r\n : { low: this.lo | 0, high: this.hi | 0, unsigned: Boolean(unsigned) };\r\n};\r\n\r\nvar charCodeAt = String.prototype.charCodeAt;\r\n\r\n/**\r\n * Constructs new long bits from the specified 8 characters long hash.\r\n * @param {string} hash Hash\r\n * @returns {util.LongBits} Bits\r\n */\r\nLongBits.fromHash = function fromHash(hash) {\r\n if (hash === zeroHash)\r\n return zero;\r\n return new LongBits(\r\n ( charCodeAt.call(hash, 0)\r\n | charCodeAt.call(hash, 1) << 8\r\n | charCodeAt.call(hash, 2) << 16\r\n | charCodeAt.call(hash, 3) << 24) >>> 0\r\n ,\r\n ( charCodeAt.call(hash, 4)\r\n | charCodeAt.call(hash, 5) << 8\r\n | charCodeAt.call(hash, 6) << 16\r\n | charCodeAt.call(hash, 7) << 24) >>> 0\r\n );\r\n};\r\n\r\n/**\r\n * Converts this long bits to a 8 characters long hash.\r\n * @returns {string} Hash\r\n */\r\nLongBits.prototype.toHash = function toHash() {\r\n return String.fromCharCode(\r\n this.lo & 255,\r\n this.lo >>> 8 & 255,\r\n this.lo >>> 16 & 255,\r\n this.lo >>> 24 ,\r\n this.hi & 255,\r\n this.hi >>> 8 & 255,\r\n this.hi >>> 16 & 255,\r\n this.hi >>> 24\r\n );\r\n};\r\n\r\n/**\r\n * Zig-zag encodes this long bits.\r\n * @returns {util.LongBits} `this`\r\n */\r\nLongBits.prototype.zzEncode = function zzEncode() {\r\n var mask = this.hi >> 31;\r\n this.hi = ((this.hi << 1 | this.lo >>> 31) ^ mask) >>> 0;\r\n this.lo = ( this.lo << 1 ^ mask) >>> 0;\r\n return this;\r\n};\r\n\r\n/**\r\n * Zig-zag decodes this long bits.\r\n * @returns {util.LongBits} `this`\r\n */\r\nLongBits.prototype.zzDecode = function zzDecode() {\r\n var mask = -(this.lo & 1);\r\n this.lo = ((this.lo >>> 1 | this.hi << 31) ^ mask) >>> 0;\r\n this.hi = ( this.hi >>> 1 ^ mask) >>> 0;\r\n return this;\r\n};\r\n\r\n/**\r\n * Calculates the length of this longbits when encoded as a varint.\r\n * @returns {number} Length\r\n */\r\nLongBits.prototype.length = function length() {\r\n var part0 = this.lo,\r\n part1 = (this.lo >>> 28 | this.hi << 4) >>> 0,\r\n part2 = this.hi >>> 24;\r\n return part2 === 0\r\n ? part1 === 0\r\n ? part0 < 16384\r\n ? part0 < 128 ? 1 : 2\r\n : part0 < 2097152 ? 3 : 4\r\n : part1 < 16384\r\n ? part1 < 128 ? 5 : 6\r\n : part1 < 2097152 ? 7 : 8\r\n : part2 < 128 ? 9 : 10;\r\n};\r\n","\"use strict\";\r\nvar util = exports;\r\n\r\n// used to return a Promise where callback is omitted\r\nutil.asPromise = require(1);\r\n\r\n// converts to / from base64 encoded strings\r\nutil.base64 = require(2);\r\n\r\n// base class of rpc.Service\r\nutil.EventEmitter = require(4);\r\n\r\n// float handling accross browsers\r\nutil.float = require(6);\r\n\r\n// requires modules optionally and hides the call from bundlers\r\nutil.inquire = require(7);\r\n\r\n// converts to / from utf8 encoded strings\r\nutil.utf8 = require(10);\r\n\r\n// provides a node-like buffer pool in the browser\r\nutil.pool = require(9);\r\n\r\n// utility to work with the low and high bits of a 64 bit value\r\nutil.LongBits = require(38);\r\n\r\n// global object reference\r\nutil.global = typeof window !== \"undefined\" && window\r\n || typeof global !== \"undefined\" && global\r\n || typeof self !== \"undefined\" && self\r\n || this; // eslint-disable-line no-invalid-this\r\n\r\n/**\r\n * An immuable empty array.\r\n * @memberof util\r\n * @type {Array.<*>}\r\n * @const\r\n */\r\nutil.emptyArray = Object.freeze ? Object.freeze([]) : /* istanbul ignore next */ []; // used on prototypes\r\n\r\n/**\r\n * An immutable empty object.\r\n * @type {Object}\r\n * @const\r\n */\r\nutil.emptyObject = Object.freeze ? Object.freeze({}) : /* istanbul ignore next */ {}; // used on prototypes\r\n\r\n/**\r\n * Whether running within node or not.\r\n * @memberof util\r\n * @type {boolean}\r\n * @const\r\n */\r\nutil.isNode = Boolean(util.global.process && util.global.process.versions && util.global.process.versions.node);\r\n\r\n/**\r\n * Tests if the specified value is an integer.\r\n * @function\r\n * @param {*} value Value to test\r\n * @returns {boolean} `true` if the value is an integer\r\n */\r\nutil.isInteger = Number.isInteger || /* istanbul ignore next */ function isInteger(value) {\r\n return typeof value === \"number\" && isFinite(value) && Math.floor(value) === value;\r\n};\r\n\r\n/**\r\n * Tests if the specified value is a string.\r\n * @param {*} value Value to test\r\n * @returns {boolean} `true` if the value is a string\r\n */\r\nutil.isString = function isString(value) {\r\n return typeof value === \"string\" || value instanceof String;\r\n};\r\n\r\n/**\r\n * Tests if the specified value is a non-null object.\r\n * @param {*} value Value to test\r\n * @returns {boolean} `true` if the value is a non-null object\r\n */\r\nutil.isObject = function isObject(value) {\r\n return value && typeof value === \"object\";\r\n};\r\n\r\n/**\r\n * Checks if a property on a message is considered to be present.\r\n * This is an alias of {@link util.isSet}.\r\n * @function\r\n * @param {Object} obj Plain object or message instance\r\n * @param {string} prop Property name\r\n * @returns {boolean} `true` if considered to be present, otherwise `false`\r\n */\r\nutil.isset =\r\n\r\n/**\r\n * Checks if a property on a message is considered to be present.\r\n * @param {Object} obj Plain object or message instance\r\n * @param {string} prop Property name\r\n * @returns {boolean} `true` if considered to be present, otherwise `false`\r\n */\r\nutil.isSet = function isSet(obj, prop) {\r\n var value = obj[prop];\r\n if (value != null && obj.hasOwnProperty(prop)) // eslint-disable-line eqeqeq, no-prototype-builtins\r\n return typeof value !== \"object\" || (Array.isArray(value) ? value.length : Object.keys(value).length) > 0;\r\n return false;\r\n};\r\n\r\n/**\r\n * Any compatible Buffer instance.\r\n * This is a minimal stand-alone definition of a Buffer instance. The actual type is that exported by node's typings.\r\n * @interface Buffer\r\n * @extends Uint8Array\r\n */\r\n\r\n/**\r\n * Node's Buffer class if available.\r\n * @type {Constructor}\r\n */\r\nutil.Buffer = (function() {\r\n try {\r\n var Buffer = util.inquire(\"buffer\").Buffer;\r\n // refuse to use non-node buffers if not explicitly assigned (perf reasons):\r\n return Buffer.prototype.utf8Write ? Buffer : /* istanbul ignore next */ null;\r\n } catch (e) {\r\n /* istanbul ignore next */\r\n return null;\r\n }\r\n})();\r\n\r\n// Internal alias of or polyfull for Buffer.from.\r\nutil._Buffer_from = null;\r\n\r\n// Internal alias of or polyfill for Buffer.allocUnsafe.\r\nutil._Buffer_allocUnsafe = null;\r\n\r\n/**\r\n * Creates a new buffer of whatever type supported by the environment.\r\n * @param {number|number[]} [sizeOrArray=0] Buffer size or number array\r\n * @returns {Uint8Array|Buffer} Buffer\r\n */\r\nutil.newBuffer = function newBuffer(sizeOrArray) {\r\n /* istanbul ignore next */\r\n return typeof sizeOrArray === \"number\"\r\n ? util.Buffer\r\n ? util._Buffer_allocUnsafe(sizeOrArray)\r\n : new util.Array(sizeOrArray)\r\n : util.Buffer\r\n ? util._Buffer_from(sizeOrArray)\r\n : typeof Uint8Array === \"undefined\"\r\n ? sizeOrArray\r\n : new Uint8Array(sizeOrArray);\r\n};\r\n\r\n/**\r\n * Array implementation used in the browser. `Uint8Array` if supported, otherwise `Array`.\r\n * @type {Constructor}\r\n */\r\nutil.Array = typeof Uint8Array !== \"undefined\" ? Uint8Array /* istanbul ignore next */ : Array;\r\n\r\n/**\r\n * Any compatible Long instance.\r\n * This is a minimal stand-alone definition of a Long instance. The actual type is that exported by long.js.\r\n * @interface Long\r\n * @property {number} low Low bits\r\n * @property {number} high High bits\r\n * @property {boolean} unsigned Whether unsigned or not\r\n */\r\n\r\n/**\r\n * Long.js's Long class if available.\r\n * @type {Constructor}\r\n */\r\nutil.Long = /* istanbul ignore next */ util.global.dcodeIO && /* istanbul ignore next */ util.global.dcodeIO.Long\r\n || /* istanbul ignore next */ util.global.Long\r\n || util.inquire(\"long\");\r\n\r\n/**\r\n * Regular expression used to verify 2 bit (`bool`) map keys.\r\n * @type {RegExp}\r\n * @const\r\n */\r\nutil.key2Re = /^true|false|0|1$/;\r\n\r\n/**\r\n * Regular expression used to verify 32 bit (`int32` etc.) map keys.\r\n * @type {RegExp}\r\n * @const\r\n */\r\nutil.key32Re = /^-?(?:0|[1-9][0-9]*)$/;\r\n\r\n/**\r\n * Regular expression used to verify 64 bit (`int64` etc.) map keys.\r\n * @type {RegExp}\r\n * @const\r\n */\r\nutil.key64Re = /^(?:[\\\\x00-\\\\xff]{8}|-?(?:0|[1-9][0-9]*))$/;\r\n\r\n/**\r\n * Converts a number or long to an 8 characters long hash string.\r\n * @param {Long|number} value Value to convert\r\n * @returns {string} Hash\r\n */\r\nutil.longToHash = function longToHash(value) {\r\n return value\r\n ? util.LongBits.from(value).toHash()\r\n : util.LongBits.zeroHash;\r\n};\r\n\r\n/**\r\n * Converts an 8 characters long hash string to a long or number.\r\n * @param {string} hash Hash\r\n * @param {boolean} [unsigned=false] Whether unsigned or not\r\n * @returns {Long|number} Original value\r\n */\r\nutil.longFromHash = function longFromHash(hash, unsigned) {\r\n var bits = util.LongBits.fromHash(hash);\r\n if (util.Long)\r\n return util.Long.fromBits(bits.lo, bits.hi, unsigned);\r\n return bits.toNumber(Boolean(unsigned));\r\n};\r\n\r\n/**\r\n * Merges the properties of the source object into the destination object.\r\n * @memberof util\r\n * @param {Object.} dst Destination object\r\n * @param {Object.} src Source object\r\n * @param {boolean} [ifNotSet=false] Merges only if the key is not already set\r\n * @returns {Object.} Destination object\r\n */\r\nfunction merge(dst, src, ifNotSet) { // used by converters\r\n for (var keys = Object.keys(src), i = 0; i < keys.length; ++i)\r\n if (dst[keys[i]] === undefined || !ifNotSet)\r\n dst[keys[i]] = src[keys[i]];\r\n return dst;\r\n}\r\n\r\nutil.merge = merge;\r\n\r\n/**\r\n * Converts the first character of a string to lower case.\r\n * @param {string} str String to convert\r\n * @returns {string} Converted string\r\n */\r\nutil.lcFirst = function lcFirst(str) {\r\n return str.charAt(0).toLowerCase() + str.substring(1);\r\n};\r\n\r\n/**\r\n * Creates a custom error constructor.\r\n * @memberof util\r\n * @param {string} name Error name\r\n * @returns {Constructor} Custom error constructor\r\n */\r\nfunction newError(name) {\r\n\r\n function CustomError(message, properties) {\r\n\r\n if (!(this instanceof CustomError))\r\n return new CustomError(message, properties);\r\n\r\n // Error.call(this, message);\r\n // ^ just returns a new error instance because the ctor can be called as a function\r\n\r\n Object.defineProperty(this, \"message\", { get: function() { return message; } });\r\n\r\n /* istanbul ignore next */\r\n if (Error.captureStackTrace) // node\r\n Error.captureStackTrace(this, CustomError);\r\n else\r\n Object.defineProperty(this, \"stack\", { value: (new Error()).stack || \"\" });\r\n\r\n if (properties)\r\n merge(this, properties);\r\n }\r\n\r\n (CustomError.prototype = Object.create(Error.prototype)).constructor = CustomError;\r\n\r\n Object.defineProperty(CustomError.prototype, \"name\", { get: function() { return name; } });\r\n\r\n CustomError.prototype.toString = function toString() {\r\n return this.name + \": \" + this.message;\r\n };\r\n\r\n return CustomError;\r\n}\r\n\r\nutil.newError = newError;\r\n\r\n/**\r\n * Constructs a new protocol error.\r\n * @classdesc Error subclass indicating a protocol specifc error.\r\n * @memberof util\r\n * @extends Error\r\n * @template T extends Message\r\n * @constructor\r\n * @param {string} message Error message\r\n * @param {Object.} [properties] Additional properties\r\n * @example\r\n * try {\r\n * MyMessage.decode(someBuffer); // throws if required fields are missing\r\n * } catch (e) {\r\n * if (e instanceof ProtocolError && e.instance)\r\n * console.log(\"decoded so far: \" + JSON.stringify(e.instance));\r\n * }\r\n */\r\nutil.ProtocolError = newError(\"ProtocolError\");\r\n\r\n/**\r\n * So far decoded message instance.\r\n * @name util.ProtocolError#instance\r\n * @type {Message}\r\n */\r\n\r\n/**\r\n * A OneOf getter as returned by {@link util.oneOfGetter}.\r\n * @typedef OneOfGetter\r\n * @type {function}\r\n * @returns {string|undefined} Set field name, if any\r\n */\r\n\r\n/**\r\n * Builds a getter for a oneof's present field name.\r\n * @param {string[]} fieldNames Field names\r\n * @returns {OneOfGetter} Unbound getter\r\n */\r\nutil.oneOfGetter = function getOneOf(fieldNames) {\r\n var fieldMap = {};\r\n for (var i = 0; i < fieldNames.length; ++i)\r\n fieldMap[fieldNames[i]] = 1;\r\n\r\n /**\r\n * @returns {string|undefined} Set field name, if any\r\n * @this Object\r\n * @ignore\r\n */\r\n return function() { // eslint-disable-line consistent-return\r\n for (var keys = Object.keys(this), i = keys.length - 1; i > -1; --i)\r\n if (fieldMap[keys[i]] === 1 && this[keys[i]] !== undefined && this[keys[i]] !== null)\r\n return keys[i];\r\n };\r\n};\r\n\r\n/**\r\n * A OneOf setter as returned by {@link util.oneOfSetter}.\r\n * @typedef OneOfSetter\r\n * @type {function}\r\n * @param {string|undefined} value Field name\r\n * @returns {undefined}\r\n */\r\n\r\n/**\r\n * Builds a setter for a oneof's present field name.\r\n * @param {string[]} fieldNames Field names\r\n * @returns {OneOfSetter} Unbound setter\r\n */\r\nutil.oneOfSetter = function setOneOf(fieldNames) {\r\n\r\n /**\r\n * @param {string} name Field name\r\n * @returns {undefined}\r\n * @this Object\r\n * @ignore\r\n */\r\n return function(name) {\r\n for (var i = 0; i < fieldNames.length; ++i)\r\n if (fieldNames[i] !== name)\r\n delete this[fieldNames[i]];\r\n };\r\n};\r\n\r\n/**\r\n * Default conversion options used for {@link Message#toJSON} implementations.\r\n *\r\n * These options are close to proto3's JSON mapping with the exception that internal types like Any are handled just like messages. More precisely:\r\n *\r\n * - Longs become strings\r\n * - Enums become string keys\r\n * - Bytes become base64 encoded strings\r\n * - (Sub-)Messages become plain objects\r\n * - Maps become plain objects with all string keys\r\n * - Repeated fields become arrays\r\n * - NaN and Infinity for float and double fields become strings\r\n *\r\n * @type {IConversionOptions}\r\n * @see https://developers.google.com/protocol-buffers/docs/proto3?hl=en#json\r\n */\r\nutil.toJSONOptions = {\r\n longs: String,\r\n enums: String,\r\n bytes: String,\r\n json: true\r\n};\r\n\r\n// Sets up buffer utility according to the environment (called in index-minimal)\r\nutil._configure = function() {\r\n var Buffer = util.Buffer;\r\n /* istanbul ignore if */\r\n if (!Buffer) {\r\n util._Buffer_from = util._Buffer_allocUnsafe = null;\r\n return;\r\n }\r\n // because node 4.x buffers are incompatible & immutable\r\n // see: https://github.com/dcodeIO/protobuf.js/pull/665\r\n util._Buffer_from = Buffer.from !== Uint8Array.from && Buffer.from ||\r\n /* istanbul ignore next */\r\n function Buffer_from(value, encoding) {\r\n return new Buffer(value, encoding);\r\n };\r\n util._Buffer_allocUnsafe = Buffer.allocUnsafe ||\r\n /* istanbul ignore next */\r\n function Buffer_allocUnsafe(size) {\r\n return new Buffer(size);\r\n };\r\n};\r\n","\"use strict\";\r\nmodule.exports = verifier;\r\n\r\nvar Enum = require(15),\r\n util = require(37);\r\n\r\nfunction invalid(field, expected) {\r\n return field.name + \": \" + expected + (field.repeated && expected !== \"array\" ? \"[]\" : field.map && expected !== \"object\" ? \"{k:\"+field.keyType+\"}\" : \"\") + \" expected\";\r\n}\r\n\r\n/**\r\n * Generates a partial value verifier.\r\n * @param {Codegen} gen Codegen instance\r\n * @param {Field} field Reflected field\r\n * @param {number} fieldIndex Field index\r\n * @param {string} ref Variable reference\r\n * @returns {Codegen} Codegen instance\r\n * @ignore\r\n */\r\nfunction genVerifyValue(gen, field, fieldIndex, ref) {\r\n /* eslint-disable no-unexpected-multiline */\r\n if (field.resolvedType) {\r\n if (field.resolvedType instanceof Enum) { gen\r\n (\"switch(%s){\", ref)\r\n (\"default:\")\r\n (\"return%j\", invalid(field, \"enum value\"));\r\n for (var keys = Object.keys(field.resolvedType.values), j = 0; j < keys.length; ++j) gen\r\n (\"case %i:\", field.resolvedType.values[keys[j]]);\r\n gen\r\n (\"break\")\r\n (\"}\");\r\n } else {\r\n gen\r\n (\"{\")\r\n (\"var e=types[%i].verify(%s);\", fieldIndex, ref)\r\n (\"if(e)\")\r\n (\"return%j+e\", field.name + \".\")\r\n (\"}\");\r\n }\r\n } else {\r\n switch (field.type) {\r\n case \"int32\":\r\n case \"uint32\":\r\n case \"sint32\":\r\n case \"fixed32\":\r\n case \"sfixed32\": gen\r\n (\"if(!util.isInteger(%s))\", ref)\r\n (\"return%j\", invalid(field, \"integer\"));\r\n break;\r\n case \"int64\":\r\n case \"uint64\":\r\n case \"sint64\":\r\n case \"fixed64\":\r\n case \"sfixed64\": gen\r\n (\"if(!util.isInteger(%s)&&!(%s&&util.isInteger(%s.low)&&util.isInteger(%s.high)))\", ref, ref, ref, ref)\r\n (\"return%j\", invalid(field, \"integer|Long\"));\r\n break;\r\n case \"float\":\r\n case \"double\": gen\r\n (\"if(typeof %s!==\\\"number\\\")\", ref)\r\n (\"return%j\", invalid(field, \"number\"));\r\n break;\r\n case \"bool\": gen\r\n (\"if(typeof %s!==\\\"boolean\\\")\", ref)\r\n (\"return%j\", invalid(field, \"boolean\"));\r\n break;\r\n case \"string\": gen\r\n (\"if(!util.isString(%s))\", ref)\r\n (\"return%j\", invalid(field, \"string\"));\r\n break;\r\n case \"bytes\": gen\r\n (\"if(!(%s&&typeof %s.length===\\\"number\\\"||util.isString(%s)))\", ref, ref, ref)\r\n (\"return%j\", invalid(field, \"buffer\"));\r\n break;\r\n }\r\n }\r\n return gen;\r\n /* eslint-enable no-unexpected-multiline */\r\n}\r\n\r\n/**\r\n * Generates a partial key verifier.\r\n * @param {Codegen} gen Codegen instance\r\n * @param {Field} field Reflected field\r\n * @param {string} ref Variable reference\r\n * @returns {Codegen} Codegen instance\r\n * @ignore\r\n */\r\nfunction genVerifyKey(gen, field, ref) {\r\n /* eslint-disable no-unexpected-multiline */\r\n switch (field.keyType) {\r\n case \"int32\":\r\n case \"uint32\":\r\n case \"sint32\":\r\n case \"fixed32\":\r\n case \"sfixed32\": gen\r\n (\"if(!util.key32Re.test(%s))\", ref)\r\n (\"return%j\", invalid(field, \"integer key\"));\r\n break;\r\n case \"int64\":\r\n case \"uint64\":\r\n case \"sint64\":\r\n case \"fixed64\":\r\n case \"sfixed64\": gen\r\n (\"if(!util.key64Re.test(%s))\", ref) // see comment above: x is ok, d is not\r\n (\"return%j\", invalid(field, \"integer|Long key\"));\r\n break;\r\n case \"bool\": gen\r\n (\"if(!util.key2Re.test(%s))\", ref)\r\n (\"return%j\", invalid(field, \"boolean key\"));\r\n break;\r\n }\r\n return gen;\r\n /* eslint-enable no-unexpected-multiline */\r\n}\r\n\r\n/**\r\n * Generates a verifier specific to the specified message type.\r\n * @param {Type} mtype Message type\r\n * @returns {Codegen} Codegen instance\r\n */\r\nfunction verifier(mtype) {\r\n /* eslint-disable no-unexpected-multiline */\r\n\r\n var gen = util.codegen([\"m\"], mtype.name + \"$verify\")\r\n (\"if(typeof m!==\\\"object\\\"||m===null)\")\r\n (\"return%j\", \"object expected\");\r\n var oneofs = mtype.oneofsArray,\r\n seenFirstField = {};\r\n if (oneofs.length) gen\r\n (\"var p={}\");\r\n\r\n for (var i = 0; i < /* initializes */ mtype.fieldsArray.length; ++i) {\r\n var field = mtype._fieldsArray[i].resolve(),\r\n ref = \"m\" + util.safeProp(field.name);\r\n\r\n if (field.optional) gen\r\n (\"if(%s!=null&&m.hasOwnProperty(%j)){\", ref, field.name); // !== undefined && !== null\r\n\r\n // map fields\r\n if (field.map) { gen\r\n (\"if(!util.isObject(%s))\", ref)\r\n (\"return%j\", invalid(field, \"object\"))\r\n (\"var k=Object.keys(%s)\", ref)\r\n (\"for(var i=0;i}\r\n * @const\r\n */\r\nvar wrappers = exports;\r\n\r\nvar Message = require(21);\r\n\r\n/**\r\n * From object converter part of an {@link IWrapper}.\r\n * @typedef WrapperFromObjectConverter\r\n * @type {function}\r\n * @param {Object.} object Plain object\r\n * @returns {Message<{}>} Message instance\r\n * @this Type\r\n */\r\n\r\n/**\r\n * To object converter part of an {@link IWrapper}.\r\n * @typedef WrapperToObjectConverter\r\n * @type {function}\r\n * @param {Message<{}>} message Message instance\r\n * @param {IConversionOptions} [options] Conversion options\r\n * @returns {Object.} Plain object\r\n * @this Type\r\n */\r\n\r\n/**\r\n * Common type wrapper part of {@link wrappers}.\r\n * @interface IWrapper\r\n * @property {WrapperFromObjectConverter} [fromObject] From object converter\r\n * @property {WrapperToObjectConverter} [toObject] To object converter\r\n */\r\n\r\n// Custom wrapper for Any\r\nwrappers[\".google.protobuf.Any\"] = {\r\n\r\n fromObject: function(object) {\r\n\r\n // unwrap value type if mapped\r\n if (object && object[\"@type\"]) {\r\n var type = this.lookup(object[\"@type\"]);\r\n /* istanbul ignore else */\r\n if (type) {\r\n // type_url does not accept leading \".\"\r\n var type_url = object[\"@type\"].charAt(0) === \".\" ?\r\n object[\"@type\"].substr(1) : object[\"@type\"];\r\n // type_url prefix is optional, but path seperator is required\r\n return this.create({\r\n type_url: \"/\" + type_url,\r\n value: type.encode(type.fromObject(object)).finish()\r\n });\r\n }\r\n }\r\n\r\n return this.fromObject(object);\r\n },\r\n\r\n toObject: function(message, options) {\r\n\r\n // decode value if requested and unmapped\r\n if (options && options.json && message.type_url && message.value) {\r\n // Only use fully qualified type name after the last '/'\r\n var name = message.type_url.substring(message.type_url.lastIndexOf(\"/\") + 1);\r\n var type = this.lookup(name);\r\n /* istanbul ignore else */\r\n if (type)\r\n message = type.decode(message.value);\r\n }\r\n\r\n // wrap value if unmapped\r\n if (!(message instanceof this.ctor) && message instanceof Message) {\r\n var object = message.$type.toObject(message, options);\r\n object[\"@type\"] = message.$type.fullName;\r\n return object;\r\n }\r\n\r\n return this.toObject(message, options);\r\n }\r\n};\r\n","\"use strict\";\r\nmodule.exports = Writer;\r\n\r\nvar util = require(39);\r\n\r\nvar BufferWriter; // cyclic\r\n\r\nvar LongBits = util.LongBits,\r\n base64 = util.base64,\r\n utf8 = util.utf8;\r\n\r\n/**\r\n * Constructs a new writer operation instance.\r\n * @classdesc Scheduled writer operation.\r\n * @constructor\r\n * @param {function(*, Uint8Array, number)} fn Function to call\r\n * @param {number} len Value byte length\r\n * @param {*} val Value to write\r\n * @ignore\r\n */\r\nfunction Op(fn, len, val) {\r\n\r\n /**\r\n * Function to call.\r\n * @type {function(Uint8Array, number, *)}\r\n */\r\n this.fn = fn;\r\n\r\n /**\r\n * Value byte length.\r\n * @type {number}\r\n */\r\n this.len = len;\r\n\r\n /**\r\n * Next operation.\r\n * @type {Writer.Op|undefined}\r\n */\r\n this.next = undefined;\r\n\r\n /**\r\n * Value to write.\r\n * @type {*}\r\n */\r\n this.val = val; // type varies\r\n}\r\n\r\n/* istanbul ignore next */\r\nfunction noop() {} // eslint-disable-line no-empty-function\r\n\r\n/**\r\n * Constructs a new writer state instance.\r\n * @classdesc Copied writer state.\r\n * @memberof Writer\r\n * @constructor\r\n * @param {Writer} writer Writer to copy state from\r\n * @ignore\r\n */\r\nfunction State(writer) {\r\n\r\n /**\r\n * Current head.\r\n * @type {Writer.Op}\r\n */\r\n this.head = writer.head;\r\n\r\n /**\r\n * Current tail.\r\n * @type {Writer.Op}\r\n */\r\n this.tail = writer.tail;\r\n\r\n /**\r\n * Current buffer length.\r\n * @type {number}\r\n */\r\n this.len = writer.len;\r\n\r\n /**\r\n * Next state.\r\n * @type {State|null}\r\n */\r\n this.next = writer.states;\r\n}\r\n\r\n/**\r\n * Constructs a new writer instance.\r\n * @classdesc Wire format writer using `Uint8Array` if available, otherwise `Array`.\r\n * @constructor\r\n */\r\nfunction Writer() {\r\n\r\n /**\r\n * Current length.\r\n * @type {number}\r\n */\r\n this.len = 0;\r\n\r\n /**\r\n * Operations head.\r\n * @type {Object}\r\n */\r\n this.head = new Op(noop, 0, 0);\r\n\r\n /**\r\n * Operations tail\r\n * @type {Object}\r\n */\r\n this.tail = this.head;\r\n\r\n /**\r\n * Linked forked states.\r\n * @type {Object|null}\r\n */\r\n this.states = null;\r\n\r\n // When a value is written, the writer calculates its byte length and puts it into a linked\r\n // list of operations to perform when finish() is called. This both allows us to allocate\r\n // buffers of the exact required size and reduces the amount of work we have to do compared\r\n // to first calculating over objects and then encoding over objects. In our case, the encoding\r\n // part is just a linked list walk calling operations with already prepared values.\r\n}\r\n\r\n/**\r\n * Creates a new writer.\r\n * @function\r\n * @returns {BufferWriter|Writer} A {@link BufferWriter} when Buffers are supported, otherwise a {@link Writer}\r\n */\r\nWriter.create = util.Buffer\r\n ? function create_buffer_setup() {\r\n return (Writer.create = function create_buffer() {\r\n return new BufferWriter();\r\n })();\r\n }\r\n /* istanbul ignore next */\r\n : function create_array() {\r\n return new Writer();\r\n };\r\n\r\n/**\r\n * Allocates a buffer of the specified size.\r\n * @param {number} size Buffer size\r\n * @returns {Uint8Array} Buffer\r\n */\r\nWriter.alloc = function alloc(size) {\r\n return new util.Array(size);\r\n};\r\n\r\n// Use Uint8Array buffer pool in the browser, just like node does with buffers\r\n/* istanbul ignore else */\r\nif (util.Array !== Array)\r\n Writer.alloc = util.pool(Writer.alloc, util.Array.prototype.subarray);\r\n\r\n/**\r\n * Pushes a new operation to the queue.\r\n * @param {function(Uint8Array, number, *)} fn Function to call\r\n * @param {number} len Value byte length\r\n * @param {number} val Value to write\r\n * @returns {Writer} `this`\r\n * @private\r\n */\r\nWriter.prototype._push = function push(fn, len, val) {\r\n this.tail = this.tail.next = new Op(fn, len, val);\r\n this.len += len;\r\n return this;\r\n};\r\n\r\nfunction writeByte(val, buf, pos) {\r\n buf[pos] = val & 255;\r\n}\r\n\r\nfunction writeVarint32(val, buf, pos) {\r\n while (val > 127) {\r\n buf[pos++] = val & 127 | 128;\r\n val >>>= 7;\r\n }\r\n buf[pos] = val;\r\n}\r\n\r\n/**\r\n * Constructs a new varint writer operation instance.\r\n * @classdesc Scheduled varint writer operation.\r\n * @extends Op\r\n * @constructor\r\n * @param {number} len Value byte length\r\n * @param {number} val Value to write\r\n * @ignore\r\n */\r\nfunction VarintOp(len, val) {\r\n this.len = len;\r\n this.next = undefined;\r\n this.val = val;\r\n}\r\n\r\nVarintOp.prototype = Object.create(Op.prototype);\r\nVarintOp.prototype.fn = writeVarint32;\r\n\r\n/**\r\n * Writes an unsigned 32 bit value as a varint.\r\n * @param {number} value Value to write\r\n * @returns {Writer} `this`\r\n */\r\nWriter.prototype.uint32 = function write_uint32(value) {\r\n // here, the call to this.push has been inlined and a varint specific Op subclass is used.\r\n // uint32 is by far the most frequently used operation and benefits significantly from this.\r\n this.len += (this.tail = this.tail.next = new VarintOp(\r\n (value = value >>> 0)\r\n < 128 ? 1\r\n : value < 16384 ? 2\r\n : value < 2097152 ? 3\r\n : value < 268435456 ? 4\r\n : 5,\r\n value)).len;\r\n return this;\r\n};\r\n\r\n/**\r\n * Writes a signed 32 bit value as a varint.\r\n * @function\r\n * @param {number} value Value to write\r\n * @returns {Writer} `this`\r\n */\r\nWriter.prototype.int32 = function write_int32(value) {\r\n return value < 0\r\n ? this._push(writeVarint64, 10, LongBits.fromNumber(value)) // 10 bytes per spec\r\n : this.uint32(value);\r\n};\r\n\r\n/**\r\n * Writes a 32 bit value as a varint, zig-zag encoded.\r\n * @param {number} value Value to write\r\n * @returns {Writer} `this`\r\n */\r\nWriter.prototype.sint32 = function write_sint32(value) {\r\n return this.uint32((value << 1 ^ value >> 31) >>> 0);\r\n};\r\n\r\nfunction writeVarint64(val, buf, pos) {\r\n while (val.hi) {\r\n buf[pos++] = val.lo & 127 | 128;\r\n val.lo = (val.lo >>> 7 | val.hi << 25) >>> 0;\r\n val.hi >>>= 7;\r\n }\r\n while (val.lo > 127) {\r\n buf[pos++] = val.lo & 127 | 128;\r\n val.lo = val.lo >>> 7;\r\n }\r\n buf[pos++] = val.lo;\r\n}\r\n\r\n/**\r\n * Writes an unsigned 64 bit value as a varint.\r\n * @param {Long|number|string} value Value to write\r\n * @returns {Writer} `this`\r\n * @throws {TypeError} If `value` is a string and no long library is present.\r\n */\r\nWriter.prototype.uint64 = function write_uint64(value) {\r\n var bits = LongBits.from(value);\r\n return this._push(writeVarint64, bits.length(), bits);\r\n};\r\n\r\n/**\r\n * Writes a signed 64 bit value as a varint.\r\n * @function\r\n * @param {Long|number|string} value Value to write\r\n * @returns {Writer} `this`\r\n * @throws {TypeError} If `value` is a string and no long library is present.\r\n */\r\nWriter.prototype.int64 = Writer.prototype.uint64;\r\n\r\n/**\r\n * Writes a signed 64 bit value as a varint, zig-zag encoded.\r\n * @param {Long|number|string} value Value to write\r\n * @returns {Writer} `this`\r\n * @throws {TypeError} If `value` is a string and no long library is present.\r\n */\r\nWriter.prototype.sint64 = function write_sint64(value) {\r\n var bits = LongBits.from(value).zzEncode();\r\n return this._push(writeVarint64, bits.length(), bits);\r\n};\r\n\r\n/**\r\n * Writes a boolish value as a varint.\r\n * @param {boolean} value Value to write\r\n * @returns {Writer} `this`\r\n */\r\nWriter.prototype.bool = function write_bool(value) {\r\n return this._push(writeByte, 1, value ? 1 : 0);\r\n};\r\n\r\nfunction writeFixed32(val, buf, pos) {\r\n buf[pos ] = val & 255;\r\n buf[pos + 1] = val >>> 8 & 255;\r\n buf[pos + 2] = val >>> 16 & 255;\r\n buf[pos + 3] = val >>> 24;\r\n}\r\n\r\n/**\r\n * Writes an unsigned 32 bit value as fixed 32 bits.\r\n * @param {number} value Value to write\r\n * @returns {Writer} `this`\r\n */\r\nWriter.prototype.fixed32 = function write_fixed32(value) {\r\n return this._push(writeFixed32, 4, value >>> 0);\r\n};\r\n\r\n/**\r\n * Writes a signed 32 bit value as fixed 32 bits.\r\n * @function\r\n * @param {number} value Value to write\r\n * @returns {Writer} `this`\r\n */\r\nWriter.prototype.sfixed32 = Writer.prototype.fixed32;\r\n\r\n/**\r\n * Writes an unsigned 64 bit value as fixed 64 bits.\r\n * @param {Long|number|string} value Value to write\r\n * @returns {Writer} `this`\r\n * @throws {TypeError} If `value` is a string and no long library is present.\r\n */\r\nWriter.prototype.fixed64 = function write_fixed64(value) {\r\n var bits = LongBits.from(value);\r\n return this._push(writeFixed32, 4, bits.lo)._push(writeFixed32, 4, bits.hi);\r\n};\r\n\r\n/**\r\n * Writes a signed 64 bit value as fixed 64 bits.\r\n * @function\r\n * @param {Long|number|string} value Value to write\r\n * @returns {Writer} `this`\r\n * @throws {TypeError} If `value` is a string and no long library is present.\r\n */\r\nWriter.prototype.sfixed64 = Writer.prototype.fixed64;\r\n\r\n/**\r\n * Writes a float (32 bit).\r\n * @function\r\n * @param {number} value Value to write\r\n * @returns {Writer} `this`\r\n */\r\nWriter.prototype.float = function write_float(value) {\r\n return this._push(util.float.writeFloatLE, 4, value);\r\n};\r\n\r\n/**\r\n * Writes a double (64 bit float).\r\n * @function\r\n * @param {number} value Value to write\r\n * @returns {Writer} `this`\r\n */\r\nWriter.prototype.double = function write_double(value) {\r\n return this._push(util.float.writeDoubleLE, 8, value);\r\n};\r\n\r\nvar writeBytes = util.Array.prototype.set\r\n ? function writeBytes_set(val, buf, pos) {\r\n buf.set(val, pos); // also works for plain array values\r\n }\r\n /* istanbul ignore next */\r\n : function writeBytes_for(val, buf, pos) {\r\n for (var i = 0; i < val.length; ++i)\r\n buf[pos + i] = val[i];\r\n };\r\n\r\n/**\r\n * Writes a sequence of bytes.\r\n * @param {Uint8Array|string} value Buffer or base64 encoded string to write\r\n * @returns {Writer} `this`\r\n */\r\nWriter.prototype.bytes = function write_bytes(value) {\r\n var len = value.length >>> 0;\r\n if (!len)\r\n return this._push(writeByte, 1, 0);\r\n if (util.isString(value)) {\r\n var buf = Writer.alloc(len = base64.length(value));\r\n base64.decode(value, buf, 0);\r\n value = buf;\r\n }\r\n return this.uint32(len)._push(writeBytes, len, value);\r\n};\r\n\r\n/**\r\n * Writes a string.\r\n * @param {string} value Value to write\r\n * @returns {Writer} `this`\r\n */\r\nWriter.prototype.string = function write_string(value) {\r\n var len = utf8.length(value);\r\n return len\r\n ? this.uint32(len)._push(utf8.write, len, value)\r\n : this._push(writeByte, 1, 0);\r\n};\r\n\r\n/**\r\n * Forks this writer's state by pushing it to a stack.\r\n * Calling {@link Writer#reset|reset} or {@link Writer#ldelim|ldelim} resets the writer to the previous state.\r\n * @returns {Writer} `this`\r\n */\r\nWriter.prototype.fork = function fork() {\r\n this.states = new State(this);\r\n this.head = this.tail = new Op(noop, 0, 0);\r\n this.len = 0;\r\n return this;\r\n};\r\n\r\n/**\r\n * Resets this instance to the last state.\r\n * @returns {Writer} `this`\r\n */\r\nWriter.prototype.reset = function reset() {\r\n if (this.states) {\r\n this.head = this.states.head;\r\n this.tail = this.states.tail;\r\n this.len = this.states.len;\r\n this.states = this.states.next;\r\n } else {\r\n this.head = this.tail = new Op(noop, 0, 0);\r\n this.len = 0;\r\n }\r\n return this;\r\n};\r\n\r\n/**\r\n * Resets to the last state and appends the fork state's current write length as a varint followed by its operations.\r\n * @returns {Writer} `this`\r\n */\r\nWriter.prototype.ldelim = function ldelim() {\r\n var head = this.head,\r\n tail = this.tail,\r\n len = this.len;\r\n this.reset().uint32(len);\r\n if (len) {\r\n this.tail.next = head.next; // skip noop\r\n this.tail = tail;\r\n this.len += len;\r\n }\r\n return this;\r\n};\r\n\r\n/**\r\n * Finishes the write operation.\r\n * @returns {Uint8Array} Finished buffer\r\n */\r\nWriter.prototype.finish = function finish() {\r\n var head = this.head.next, // skip noop\r\n buf = this.constructor.alloc(this.len),\r\n pos = 0;\r\n while (head) {\r\n head.fn(head.val, buf, pos);\r\n pos += head.len;\r\n head = head.next;\r\n }\r\n // this.head = this.tail = null;\r\n return buf;\r\n};\r\n\r\nWriter._configure = function(BufferWriter_) {\r\n BufferWriter = BufferWriter_;\r\n};\r\n","\"use strict\";\r\nmodule.exports = BufferWriter;\r\n\r\n// extends Writer\r\nvar Writer = require(42);\r\n(BufferWriter.prototype = Object.create(Writer.prototype)).constructor = BufferWriter;\r\n\r\nvar util = require(39);\r\n\r\nvar Buffer = util.Buffer;\r\n\r\n/**\r\n * Constructs a new buffer writer instance.\r\n * @classdesc Wire format writer using node buffers.\r\n * @extends Writer\r\n * @constructor\r\n */\r\nfunction BufferWriter() {\r\n Writer.call(this);\r\n}\r\n\r\n/**\r\n * Allocates a buffer of the specified size.\r\n * @param {number} size Buffer size\r\n * @returns {Buffer} Buffer\r\n */\r\nBufferWriter.alloc = function alloc_buffer(size) {\r\n return (BufferWriter.alloc = util._Buffer_allocUnsafe)(size);\r\n};\r\n\r\nvar writeBytesBuffer = Buffer && Buffer.prototype instanceof Uint8Array && Buffer.prototype.set.name === \"set\"\r\n ? function writeBytesBuffer_set(val, buf, pos) {\r\n buf.set(val, pos); // faster than copy (requires node >= 4 where Buffers extend Uint8Array and set is properly inherited)\r\n // also works for plain array values\r\n }\r\n /* istanbul ignore next */\r\n : function writeBytesBuffer_copy(val, buf, pos) {\r\n if (val.copy) // Buffer values\r\n val.copy(buf, pos, 0, val.length);\r\n else for (var i = 0; i < val.length;) // plain array values\r\n buf[pos++] = val[i++];\r\n };\r\n\r\n/**\r\n * @override\r\n */\r\nBufferWriter.prototype.bytes = function write_bytes_buffer(value) {\r\n if (util.isString(value))\r\n value = util._Buffer_from(value, \"base64\");\r\n var len = value.length >>> 0;\r\n this.uint32(len);\r\n if (len)\r\n this._push(writeBytesBuffer, len, value);\r\n return this;\r\n};\r\n\r\nfunction writeStringBuffer(val, buf, pos) {\r\n if (val.length < 40) // plain js is faster for short strings (probably due to redundant assertions)\r\n util.utf8.write(val, buf, pos);\r\n else\r\n buf.utf8Write(val, pos);\r\n}\r\n\r\n/**\r\n * @override\r\n */\r\nBufferWriter.prototype.string = function write_string_buffer(value) {\r\n var len = Buffer.byteLength(value);\r\n this.uint32(len);\r\n if (len)\r\n this._push(writeStringBuffer, len, value);\r\n return this;\r\n};\r\n\r\n\r\n/**\r\n * Finishes the write operation.\r\n * @name BufferWriter#finish\r\n * @function\r\n * @returns {Buffer} Finished buffer\r\n */\r\n"],"sourceRoot":"."} \ No newline at end of file diff --git a/frontend/assets/scripts/modules/protobuf.js.map.meta b/frontend/assets/scripts/modules/protobuf.js.map.meta new file mode 100644 index 0000000..99daa5a --- /dev/null +++ b/frontend/assets/scripts/modules/protobuf.js.map.meta @@ -0,0 +1,5 @@ +{ + "ver": "1.0.1", + "uuid": "e646fbd9-7821-4567-9846-fb6e45aeb921", + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/scripts/modules/room_downsync_frame_proto_bundle.forcemsg.js b/frontend/assets/scripts/modules/room_downsync_frame_proto_bundle.forcemsg.js new file mode 100644 index 0000000..6a8d59e --- /dev/null +++ b/frontend/assets/scripts/modules/room_downsync_frame_proto_bundle.forcemsg.js @@ -0,0 +1,6668 @@ +/*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("./protobuf-with-floating-num-decoding-endianess-toggle"); + +// Common aliases +var $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util; + +// Exported root namespace +var $root = $protobuf.roots["default"] || ($protobuf.roots["default"] = {}); + +$root.treasurehunterx = (function() { + + /** + * Namespace treasurehunterx. + * @exports treasurehunterx + * @namespace + */ + var treasurehunterx = {}; + + treasurehunterx.Direction = (function() { + + /** + * Properties of a Direction. + * @memberof treasurehunterx + * @interface IDirection + * @property {number|null} [dx] Direction dx + * @property {number|null} [dy] Direction dy + */ + + /** + * Constructs a new Direction. + * @memberof treasurehunterx + * @classdesc Represents a Direction. + * @implements IDirection + * @constructor + * @param {treasurehunterx.IDirection=} [properties] Properties to set + */ + function Direction(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]]; + } + + /** + * Direction dx. + * @member {number} dx + * @memberof treasurehunterx.Direction + * @instance + */ + Direction.prototype.dx = 0; + + /** + * Direction dy. + * @member {number} dy + * @memberof treasurehunterx.Direction + * @instance + */ + Direction.prototype.dy = 0; + + /** + * Creates a new Direction instance using the specified properties. + * @function create + * @memberof treasurehunterx.Direction + * @static + * @param {treasurehunterx.IDirection=} [properties] Properties to set + * @returns {treasurehunterx.Direction} Direction instance + */ + Direction.create = function create(properties) { + return new Direction(properties); + }; + + /** + * Encodes the specified Direction message. Does not implicitly {@link treasurehunterx.Direction.verify|verify} messages. + * @function encode + * @memberof treasurehunterx.Direction + * @static + * @param {treasurehunterx.Direction} message Direction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Direction.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.dx != null && Object.hasOwnProperty.call(message, "dx")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.dx); + if (message.dy != null && Object.hasOwnProperty.call(message, "dy")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.dy); + return writer; + }; + + /** + * Encodes the specified Direction message, length delimited. Does not implicitly {@link treasurehunterx.Direction.verify|verify} messages. + * @function encodeDelimited + * @memberof treasurehunterx.Direction + * @static + * @param {treasurehunterx.Direction} message Direction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Direction.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Direction message from the specified reader or buffer. + * @function decode + * @memberof treasurehunterx.Direction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {treasurehunterx.Direction} Direction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Direction.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.treasurehunterx.Direction(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.dx = reader.int32(); + break; + } + case 2: { + message.dy = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Direction message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof treasurehunterx.Direction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {treasurehunterx.Direction} Direction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Direction.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Direction message. + * @function verify + * @memberof treasurehunterx.Direction + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Direction.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.dx != null && message.hasOwnProperty("dx")) + if (!$util.isInteger(message.dx)) + return "dx: integer expected"; + if (message.dy != null && message.hasOwnProperty("dy")) + if (!$util.isInteger(message.dy)) + return "dy: integer expected"; + return null; + }; + + /** + * Creates a Direction message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof treasurehunterx.Direction + * @static + * @param {Object.} object Plain object + * @returns {treasurehunterx.Direction} Direction + */ + Direction.fromObject = function fromObject(object) { + if (object instanceof $root.treasurehunterx.Direction) + return object; + var message = new $root.treasurehunterx.Direction(); + if (object.dx != null) + message.dx = object.dx | 0; + if (object.dy != null) + message.dy = object.dy | 0; + return message; + }; + + /** + * Creates a plain object from a Direction message. Also converts values to other types if specified. + * @function toObject + * @memberof treasurehunterx.Direction + * @static + * @param {treasurehunterx.Direction} message Direction + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Direction.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.dx = 0; + object.dy = 0; + } + if (message.dx != null && message.hasOwnProperty("dx")) + object.dx = message.dx; + if (message.dy != null && message.hasOwnProperty("dy")) + object.dy = message.dy; + return object; + }; + + /** + * Converts this Direction to JSON. + * @function toJSON + * @memberof treasurehunterx.Direction + * @instance + * @returns {Object.} JSON object + */ + Direction.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Direction + * @function getTypeUrl + * @memberof treasurehunterx.Direction + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Direction.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/treasurehunterx.Direction"; + }; + + return Direction; + })(); + + treasurehunterx.Vec2D = (function() { + + /** + * Properties of a Vec2D. + * @memberof treasurehunterx + * @interface IVec2D + * @property {number|null} [x] Vec2D x + * @property {number|null} [y] Vec2D y + */ + + /** + * Constructs a new Vec2D. + * @memberof treasurehunterx + * @classdesc Represents a Vec2D. + * @implements IVec2D + * @constructor + * @param {treasurehunterx.IVec2D=} [properties] Properties to set + */ + function Vec2D(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]]; + } + + /** + * Vec2D x. + * @member {number} x + * @memberof treasurehunterx.Vec2D + * @instance + */ + Vec2D.prototype.x = 0; + + /** + * Vec2D y. + * @member {number} y + * @memberof treasurehunterx.Vec2D + * @instance + */ + Vec2D.prototype.y = 0; + + /** + * Creates a new Vec2D instance using the specified properties. + * @function create + * @memberof treasurehunterx.Vec2D + * @static + * @param {treasurehunterx.IVec2D=} [properties] Properties to set + * @returns {treasurehunterx.Vec2D} Vec2D instance + */ + Vec2D.create = function create(properties) { + return new Vec2D(properties); + }; + + /** + * Encodes the specified Vec2D message. Does not implicitly {@link treasurehunterx.Vec2D.verify|verify} messages. + * @function encode + * @memberof treasurehunterx.Vec2D + * @static + * @param {treasurehunterx.Vec2D} message Vec2D message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Vec2D.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.x != null && Object.hasOwnProperty.call(message, "x")) + writer.uint32(/* id 1, wireType 1 =*/9).double(message.x); + if (message.y != null && Object.hasOwnProperty.call(message, "y")) + writer.uint32(/* id 2, wireType 1 =*/17).double(message.y); + return writer; + }; + + /** + * Encodes the specified Vec2D message, length delimited. Does not implicitly {@link treasurehunterx.Vec2D.verify|verify} messages. + * @function encodeDelimited + * @memberof treasurehunterx.Vec2D + * @static + * @param {treasurehunterx.Vec2D} message Vec2D message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Vec2D.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Vec2D message from the specified reader or buffer. + * @function decode + * @memberof treasurehunterx.Vec2D + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {treasurehunterx.Vec2D} Vec2D + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Vec2D.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.treasurehunterx.Vec2D(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.x = reader.double(); + break; + } + case 2: { + message.y = reader.double(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Vec2D message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof treasurehunterx.Vec2D + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {treasurehunterx.Vec2D} Vec2D + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Vec2D.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Vec2D message. + * @function verify + * @memberof treasurehunterx.Vec2D + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Vec2D.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.x != null && message.hasOwnProperty("x")) + if (typeof message.x !== "number") + return "x: number expected"; + if (message.y != null && message.hasOwnProperty("y")) + if (typeof message.y !== "number") + return "y: number expected"; + return null; + }; + + /** + * Creates a Vec2D message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof treasurehunterx.Vec2D + * @static + * @param {Object.} object Plain object + * @returns {treasurehunterx.Vec2D} Vec2D + */ + Vec2D.fromObject = function fromObject(object) { + if (object instanceof $root.treasurehunterx.Vec2D) + return object; + var message = new $root.treasurehunterx.Vec2D(); + if (object.x != null) + message.x = Number(object.x); + if (object.y != null) + message.y = Number(object.y); + return message; + }; + + /** + * Creates a plain object from a Vec2D message. Also converts values to other types if specified. + * @function toObject + * @memberof treasurehunterx.Vec2D + * @static + * @param {treasurehunterx.Vec2D} message Vec2D + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Vec2D.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.x = 0; + object.y = 0; + } + if (message.x != null && message.hasOwnProperty("x")) + object.x = options.json && !isFinite(message.x) ? String(message.x) : message.x; + if (message.y != null && message.hasOwnProperty("y")) + object.y = options.json && !isFinite(message.y) ? String(message.y) : message.y; + return object; + }; + + /** + * Converts this Vec2D to JSON. + * @function toJSON + * @memberof treasurehunterx.Vec2D + * @instance + * @returns {Object.} JSON object + */ + Vec2D.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Vec2D + * @function getTypeUrl + * @memberof treasurehunterx.Vec2D + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Vec2D.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/treasurehunterx.Vec2D"; + }; + + return Vec2D; + })(); + + treasurehunterx.Polygon2D = (function() { + + /** + * Properties of a Polygon2D. + * @memberof treasurehunterx + * @interface IPolygon2D + * @property {treasurehunterx.Vec2D|null} [Anchor] Polygon2D Anchor + * @property {Array.|null} [Points] Polygon2D Points + */ + + /** + * Constructs a new Polygon2D. + * @memberof treasurehunterx + * @classdesc Represents a Polygon2D. + * @implements IPolygon2D + * @constructor + * @param {treasurehunterx.IPolygon2D=} [properties] Properties to set + */ + function Polygon2D(properties) { + this.Points = []; + 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]]; + } + + /** + * Polygon2D Anchor. + * @member {treasurehunterx.Vec2D|null|undefined} Anchor + * @memberof treasurehunterx.Polygon2D + * @instance + */ + Polygon2D.prototype.Anchor = null; + + /** + * Polygon2D Points. + * @member {Array.} Points + * @memberof treasurehunterx.Polygon2D + * @instance + */ + Polygon2D.prototype.Points = $util.emptyArray; + + /** + * Creates a new Polygon2D instance using the specified properties. + * @function create + * @memberof treasurehunterx.Polygon2D + * @static + * @param {treasurehunterx.IPolygon2D=} [properties] Properties to set + * @returns {treasurehunterx.Polygon2D} Polygon2D instance + */ + Polygon2D.create = function create(properties) { + return new Polygon2D(properties); + }; + + /** + * Encodes the specified Polygon2D message. Does not implicitly {@link treasurehunterx.Polygon2D.verify|verify} messages. + * @function encode + * @memberof treasurehunterx.Polygon2D + * @static + * @param {treasurehunterx.Polygon2D} message Polygon2D message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Polygon2D.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.Anchor != null && Object.hasOwnProperty.call(message, "Anchor")) + $root.treasurehunterx.Vec2D.encode(message.Anchor, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.Points != null && message.Points.length) + for (var i = 0; i < message.Points.length; ++i) + $root.treasurehunterx.Vec2D.encode(message.Points[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified Polygon2D message, length delimited. Does not implicitly {@link treasurehunterx.Polygon2D.verify|verify} messages. + * @function encodeDelimited + * @memberof treasurehunterx.Polygon2D + * @static + * @param {treasurehunterx.Polygon2D} message Polygon2D message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Polygon2D.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Polygon2D message from the specified reader or buffer. + * @function decode + * @memberof treasurehunterx.Polygon2D + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {treasurehunterx.Polygon2D} Polygon2D + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Polygon2D.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.treasurehunterx.Polygon2D(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.Anchor = $root.treasurehunterx.Vec2D.decode(reader, reader.uint32()); + break; + } + case 2: { + if (!(message.Points && message.Points.length)) + message.Points = []; + message.Points.push($root.treasurehunterx.Vec2D.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Polygon2D message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof treasurehunterx.Polygon2D + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {treasurehunterx.Polygon2D} Polygon2D + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Polygon2D.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Polygon2D message. + * @function verify + * @memberof treasurehunterx.Polygon2D + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Polygon2D.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.Anchor != null && message.hasOwnProperty("Anchor")) { + var error = $root.treasurehunterx.Vec2D.verify(message.Anchor); + if (error) + return "Anchor." + error; + } + if (message.Points != null && message.hasOwnProperty("Points")) { + if (!Array.isArray(message.Points)) + return "Points: array expected"; + for (var i = 0; i < message.Points.length; ++i) { + var error = $root.treasurehunterx.Vec2D.verify(message.Points[i]); + if (error) + return "Points." + error; + } + } + return null; + }; + + /** + * Creates a Polygon2D message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof treasurehunterx.Polygon2D + * @static + * @param {Object.} object Plain object + * @returns {treasurehunterx.Polygon2D} Polygon2D + */ + Polygon2D.fromObject = function fromObject(object) { + if (object instanceof $root.treasurehunterx.Polygon2D) + return object; + var message = new $root.treasurehunterx.Polygon2D(); + if (object.Anchor != null) { + if (typeof object.Anchor !== "object") + throw TypeError(".treasurehunterx.Polygon2D.Anchor: object expected"); + message.Anchor = $root.treasurehunterx.Vec2D.fromObject(object.Anchor); + } + if (object.Points) { + if (!Array.isArray(object.Points)) + throw TypeError(".treasurehunterx.Polygon2D.Points: array expected"); + message.Points = []; + for (var i = 0; i < object.Points.length; ++i) { + if (typeof object.Points[i] !== "object") + throw TypeError(".treasurehunterx.Polygon2D.Points: object expected"); + message.Points[i] = $root.treasurehunterx.Vec2D.fromObject(object.Points[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a Polygon2D message. Also converts values to other types if specified. + * @function toObject + * @memberof treasurehunterx.Polygon2D + * @static + * @param {treasurehunterx.Polygon2D} message Polygon2D + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Polygon2D.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.Points = []; + if (options.defaults) + object.Anchor = null; + if (message.Anchor != null && message.hasOwnProperty("Anchor")) + object.Anchor = $root.treasurehunterx.Vec2D.toObject(message.Anchor, options); + if (message.Points && message.Points.length) { + object.Points = []; + for (var j = 0; j < message.Points.length; ++j) + object.Points[j] = $root.treasurehunterx.Vec2D.toObject(message.Points[j], options); + } + return object; + }; + + /** + * Converts this Polygon2D to JSON. + * @function toJSON + * @memberof treasurehunterx.Polygon2D + * @instance + * @returns {Object.} JSON object + */ + Polygon2D.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Polygon2D + * @function getTypeUrl + * @memberof treasurehunterx.Polygon2D + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Polygon2D.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/treasurehunterx.Polygon2D"; + }; + + return Polygon2D; + })(); + + treasurehunterx.Vec2DList = (function() { + + /** + * Properties of a Vec2DList. + * @memberof treasurehunterx + * @interface IVec2DList + * @property {Array.|null} [vec2DList] Vec2DList vec2DList + */ + + /** + * Constructs a new Vec2DList. + * @memberof treasurehunterx + * @classdesc Represents a Vec2DList. + * @implements IVec2DList + * @constructor + * @param {treasurehunterx.IVec2DList=} [properties] Properties to set + */ + function Vec2DList(properties) { + this.vec2DList = []; + 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]]; + } + + /** + * Vec2DList vec2DList. + * @member {Array.} vec2DList + * @memberof treasurehunterx.Vec2DList + * @instance + */ + Vec2DList.prototype.vec2DList = $util.emptyArray; + + /** + * Creates a new Vec2DList instance using the specified properties. + * @function create + * @memberof treasurehunterx.Vec2DList + * @static + * @param {treasurehunterx.IVec2DList=} [properties] Properties to set + * @returns {treasurehunterx.Vec2DList} Vec2DList instance + */ + Vec2DList.create = function create(properties) { + return new Vec2DList(properties); + }; + + /** + * Encodes the specified Vec2DList message. Does not implicitly {@link treasurehunterx.Vec2DList.verify|verify} messages. + * @function encode + * @memberof treasurehunterx.Vec2DList + * @static + * @param {treasurehunterx.Vec2DList} message Vec2DList message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Vec2DList.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.vec2DList != null && message.vec2DList.length) + for (var i = 0; i < message.vec2DList.length; ++i) + $root.treasurehunterx.Vec2D.encode(message.vec2DList[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified Vec2DList message, length delimited. Does not implicitly {@link treasurehunterx.Vec2DList.verify|verify} messages. + * @function encodeDelimited + * @memberof treasurehunterx.Vec2DList + * @static + * @param {treasurehunterx.Vec2DList} message Vec2DList message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Vec2DList.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Vec2DList message from the specified reader or buffer. + * @function decode + * @memberof treasurehunterx.Vec2DList + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {treasurehunterx.Vec2DList} Vec2DList + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Vec2DList.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.treasurehunterx.Vec2DList(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.vec2DList && message.vec2DList.length)) + message.vec2DList = []; + message.vec2DList.push($root.treasurehunterx.Vec2D.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Vec2DList message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof treasurehunterx.Vec2DList + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {treasurehunterx.Vec2DList} Vec2DList + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Vec2DList.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Vec2DList message. + * @function verify + * @memberof treasurehunterx.Vec2DList + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Vec2DList.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.vec2DList != null && message.hasOwnProperty("vec2DList")) { + if (!Array.isArray(message.vec2DList)) + return "vec2DList: array expected"; + for (var i = 0; i < message.vec2DList.length; ++i) { + var error = $root.treasurehunterx.Vec2D.verify(message.vec2DList[i]); + if (error) + return "vec2DList." + error; + } + } + return null; + }; + + /** + * Creates a Vec2DList message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof treasurehunterx.Vec2DList + * @static + * @param {Object.} object Plain object + * @returns {treasurehunterx.Vec2DList} Vec2DList + */ + Vec2DList.fromObject = function fromObject(object) { + if (object instanceof $root.treasurehunterx.Vec2DList) + return object; + var message = new $root.treasurehunterx.Vec2DList(); + if (object.vec2DList) { + if (!Array.isArray(object.vec2DList)) + throw TypeError(".treasurehunterx.Vec2DList.vec2DList: array expected"); + message.vec2DList = []; + for (var i = 0; i < object.vec2DList.length; ++i) { + if (typeof object.vec2DList[i] !== "object") + throw TypeError(".treasurehunterx.Vec2DList.vec2DList: object expected"); + message.vec2DList[i] = $root.treasurehunterx.Vec2D.fromObject(object.vec2DList[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a Vec2DList message. Also converts values to other types if specified. + * @function toObject + * @memberof treasurehunterx.Vec2DList + * @static + * @param {treasurehunterx.Vec2DList} message Vec2DList + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Vec2DList.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.vec2DList = []; + if (message.vec2DList && message.vec2DList.length) { + object.vec2DList = []; + for (var j = 0; j < message.vec2DList.length; ++j) + object.vec2DList[j] = $root.treasurehunterx.Vec2D.toObject(message.vec2DList[j], options); + } + return object; + }; + + /** + * Converts this Vec2DList to JSON. + * @function toJSON + * @memberof treasurehunterx.Vec2DList + * @instance + * @returns {Object.} JSON object + */ + Vec2DList.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Vec2DList + * @function getTypeUrl + * @memberof treasurehunterx.Vec2DList + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Vec2DList.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/treasurehunterx.Vec2DList"; + }; + + return Vec2DList; + })(); + + treasurehunterx.Polygon2DList = (function() { + + /** + * Properties of a Polygon2DList. + * @memberof treasurehunterx + * @interface IPolygon2DList + * @property {Array.|null} [polygon2DList] Polygon2DList polygon2DList + */ + + /** + * Constructs a new Polygon2DList. + * @memberof treasurehunterx + * @classdesc Represents a Polygon2DList. + * @implements IPolygon2DList + * @constructor + * @param {treasurehunterx.IPolygon2DList=} [properties] Properties to set + */ + function Polygon2DList(properties) { + this.polygon2DList = []; + 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]]; + } + + /** + * Polygon2DList polygon2DList. + * @member {Array.} polygon2DList + * @memberof treasurehunterx.Polygon2DList + * @instance + */ + Polygon2DList.prototype.polygon2DList = $util.emptyArray; + + /** + * Creates a new Polygon2DList instance using the specified properties. + * @function create + * @memberof treasurehunterx.Polygon2DList + * @static + * @param {treasurehunterx.IPolygon2DList=} [properties] Properties to set + * @returns {treasurehunterx.Polygon2DList} Polygon2DList instance + */ + Polygon2DList.create = function create(properties) { + return new Polygon2DList(properties); + }; + + /** + * Encodes the specified Polygon2DList message. Does not implicitly {@link treasurehunterx.Polygon2DList.verify|verify} messages. + * @function encode + * @memberof treasurehunterx.Polygon2DList + * @static + * @param {treasurehunterx.Polygon2DList} message Polygon2DList message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Polygon2DList.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.polygon2DList != null && message.polygon2DList.length) + for (var i = 0; i < message.polygon2DList.length; ++i) + $root.treasurehunterx.Polygon2D.encode(message.polygon2DList[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified Polygon2DList message, length delimited. Does not implicitly {@link treasurehunterx.Polygon2DList.verify|verify} messages. + * @function encodeDelimited + * @memberof treasurehunterx.Polygon2DList + * @static + * @param {treasurehunterx.Polygon2DList} message Polygon2DList message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Polygon2DList.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Polygon2DList message from the specified reader or buffer. + * @function decode + * @memberof treasurehunterx.Polygon2DList + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {treasurehunterx.Polygon2DList} Polygon2DList + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Polygon2DList.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.treasurehunterx.Polygon2DList(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.polygon2DList && message.polygon2DList.length)) + message.polygon2DList = []; + message.polygon2DList.push($root.treasurehunterx.Polygon2D.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Polygon2DList message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof treasurehunterx.Polygon2DList + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {treasurehunterx.Polygon2DList} Polygon2DList + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Polygon2DList.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Polygon2DList message. + * @function verify + * @memberof treasurehunterx.Polygon2DList + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Polygon2DList.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.polygon2DList != null && message.hasOwnProperty("polygon2DList")) { + if (!Array.isArray(message.polygon2DList)) + return "polygon2DList: array expected"; + for (var i = 0; i < message.polygon2DList.length; ++i) { + var error = $root.treasurehunterx.Polygon2D.verify(message.polygon2DList[i]); + if (error) + return "polygon2DList." + error; + } + } + return null; + }; + + /** + * Creates a Polygon2DList message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof treasurehunterx.Polygon2DList + * @static + * @param {Object.} object Plain object + * @returns {treasurehunterx.Polygon2DList} Polygon2DList + */ + Polygon2DList.fromObject = function fromObject(object) { + if (object instanceof $root.treasurehunterx.Polygon2DList) + return object; + var message = new $root.treasurehunterx.Polygon2DList(); + if (object.polygon2DList) { + if (!Array.isArray(object.polygon2DList)) + throw TypeError(".treasurehunterx.Polygon2DList.polygon2DList: array expected"); + message.polygon2DList = []; + for (var i = 0; i < object.polygon2DList.length; ++i) { + if (typeof object.polygon2DList[i] !== "object") + throw TypeError(".treasurehunterx.Polygon2DList.polygon2DList: object expected"); + message.polygon2DList[i] = $root.treasurehunterx.Polygon2D.fromObject(object.polygon2DList[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a Polygon2DList message. Also converts values to other types if specified. + * @function toObject + * @memberof treasurehunterx.Polygon2DList + * @static + * @param {treasurehunterx.Polygon2DList} message Polygon2DList + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Polygon2DList.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.polygon2DList = []; + if (message.polygon2DList && message.polygon2DList.length) { + object.polygon2DList = []; + for (var j = 0; j < message.polygon2DList.length; ++j) + object.polygon2DList[j] = $root.treasurehunterx.Polygon2D.toObject(message.polygon2DList[j], options); + } + return object; + }; + + /** + * Converts this Polygon2DList to JSON. + * @function toJSON + * @memberof treasurehunterx.Polygon2DList + * @instance + * @returns {Object.} JSON object + */ + Polygon2DList.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Polygon2DList + * @function getTypeUrl + * @memberof treasurehunterx.Polygon2DList + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Polygon2DList.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/treasurehunterx.Polygon2DList"; + }; + + return Polygon2DList; + })(); + + treasurehunterx.BattleColliderInfo = (function() { + + /** + * Properties of a BattleColliderInfo. + * @memberof treasurehunterx + * @interface IBattleColliderInfo + * @property {number|null} [intervalToPing] BattleColliderInfo intervalToPing + * @property {number|null} [willKickIfInactiveFor] BattleColliderInfo willKickIfInactiveFor + * @property {number|null} [boundRoomId] BattleColliderInfo boundRoomId + * @property {string|null} [stageName] BattleColliderInfo stageName + * @property {Object.|null} [strToVec2DListMap] BattleColliderInfo strToVec2DListMap + * @property {Object.|null} [strToPolygon2DListMap] BattleColliderInfo strToPolygon2DListMap + * @property {number|null} [StageDiscreteW] BattleColliderInfo StageDiscreteW + * @property {number|null} [StageDiscreteH] BattleColliderInfo StageDiscreteH + * @property {number|null} [StageTileW] BattleColliderInfo StageTileW + * @property {number|null} [StageTileH] BattleColliderInfo StageTileH + */ + + /** + * Constructs a new BattleColliderInfo. + * @memberof treasurehunterx + * @classdesc Represents a BattleColliderInfo. + * @implements IBattleColliderInfo + * @constructor + * @param {treasurehunterx.IBattleColliderInfo=} [properties] Properties to set + */ + function BattleColliderInfo(properties) { + this.strToVec2DListMap = {}; + this.strToPolygon2DListMap = {}; + 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]]; + } + + /** + * BattleColliderInfo intervalToPing. + * @member {number} intervalToPing + * @memberof treasurehunterx.BattleColliderInfo + * @instance + */ + BattleColliderInfo.prototype.intervalToPing = 0; + + /** + * BattleColliderInfo willKickIfInactiveFor. + * @member {number} willKickIfInactiveFor + * @memberof treasurehunterx.BattleColliderInfo + * @instance + */ + BattleColliderInfo.prototype.willKickIfInactiveFor = 0; + + /** + * BattleColliderInfo boundRoomId. + * @member {number} boundRoomId + * @memberof treasurehunterx.BattleColliderInfo + * @instance + */ + BattleColliderInfo.prototype.boundRoomId = 0; + + /** + * BattleColliderInfo stageName. + * @member {string} stageName + * @memberof treasurehunterx.BattleColliderInfo + * @instance + */ + BattleColliderInfo.prototype.stageName = ""; + + /** + * BattleColliderInfo strToVec2DListMap. + * @member {Object.} strToVec2DListMap + * @memberof treasurehunterx.BattleColliderInfo + * @instance + */ + BattleColliderInfo.prototype.strToVec2DListMap = $util.emptyObject; + + /** + * BattleColliderInfo strToPolygon2DListMap. + * @member {Object.} strToPolygon2DListMap + * @memberof treasurehunterx.BattleColliderInfo + * @instance + */ + BattleColliderInfo.prototype.strToPolygon2DListMap = $util.emptyObject; + + /** + * BattleColliderInfo StageDiscreteW. + * @member {number} StageDiscreteW + * @memberof treasurehunterx.BattleColliderInfo + * @instance + */ + BattleColliderInfo.prototype.StageDiscreteW = 0; + + /** + * BattleColliderInfo StageDiscreteH. + * @member {number} StageDiscreteH + * @memberof treasurehunterx.BattleColliderInfo + * @instance + */ + BattleColliderInfo.prototype.StageDiscreteH = 0; + + /** + * BattleColliderInfo StageTileW. + * @member {number} StageTileW + * @memberof treasurehunterx.BattleColliderInfo + * @instance + */ + BattleColliderInfo.prototype.StageTileW = 0; + + /** + * BattleColliderInfo StageTileH. + * @member {number} StageTileH + * @memberof treasurehunterx.BattleColliderInfo + * @instance + */ + BattleColliderInfo.prototype.StageTileH = 0; + + /** + * Creates a new BattleColliderInfo instance using the specified properties. + * @function create + * @memberof treasurehunterx.BattleColliderInfo + * @static + * @param {treasurehunterx.IBattleColliderInfo=} [properties] Properties to set + * @returns {treasurehunterx.BattleColliderInfo} BattleColliderInfo instance + */ + BattleColliderInfo.create = function create(properties) { + return new BattleColliderInfo(properties); + }; + + /** + * Encodes the specified BattleColliderInfo message. Does not implicitly {@link treasurehunterx.BattleColliderInfo.verify|verify} messages. + * @function encode + * @memberof treasurehunterx.BattleColliderInfo + * @static + * @param {treasurehunterx.BattleColliderInfo} message BattleColliderInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BattleColliderInfo.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.intervalToPing != null && Object.hasOwnProperty.call(message, "intervalToPing")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.intervalToPing); + if (message.willKickIfInactiveFor != null && Object.hasOwnProperty.call(message, "willKickIfInactiveFor")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.willKickIfInactiveFor); + if (message.boundRoomId != null && Object.hasOwnProperty.call(message, "boundRoomId")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.boundRoomId); + if (message.stageName != null && Object.hasOwnProperty.call(message, "stageName")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.stageName); + if (message.strToVec2DListMap != null && Object.hasOwnProperty.call(message, "strToVec2DListMap")) + for (var keys = Object.keys(message.strToVec2DListMap), i = 0; i < keys.length; ++i) { + writer.uint32(/* id 5, wireType 2 =*/42).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]); + $root.treasurehunterx.Vec2DList.encode(message.strToVec2DListMap[keys[i]], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim().ldelim(); + } + if (message.strToPolygon2DListMap != null && Object.hasOwnProperty.call(message, "strToPolygon2DListMap")) + for (var keys = Object.keys(message.strToPolygon2DListMap), i = 0; i < keys.length; ++i) { + writer.uint32(/* id 6, wireType 2 =*/50).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]); + $root.treasurehunterx.Polygon2DList.encode(message.strToPolygon2DListMap[keys[i]], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim().ldelim(); + } + if (message.StageDiscreteW != null && Object.hasOwnProperty.call(message, "StageDiscreteW")) + writer.uint32(/* id 7, wireType 0 =*/56).int32(message.StageDiscreteW); + if (message.StageDiscreteH != null && Object.hasOwnProperty.call(message, "StageDiscreteH")) + writer.uint32(/* id 8, wireType 0 =*/64).int32(message.StageDiscreteH); + if (message.StageTileW != null && Object.hasOwnProperty.call(message, "StageTileW")) + writer.uint32(/* id 9, wireType 0 =*/72).int32(message.StageTileW); + if (message.StageTileH != null && Object.hasOwnProperty.call(message, "StageTileH")) + writer.uint32(/* id 10, wireType 0 =*/80).int32(message.StageTileH); + return writer; + }; + + /** + * Encodes the specified BattleColliderInfo message, length delimited. Does not implicitly {@link treasurehunterx.BattleColliderInfo.verify|verify} messages. + * @function encodeDelimited + * @memberof treasurehunterx.BattleColliderInfo + * @static + * @param {treasurehunterx.BattleColliderInfo} message BattleColliderInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BattleColliderInfo.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a BattleColliderInfo message from the specified reader or buffer. + * @function decode + * @memberof treasurehunterx.BattleColliderInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {treasurehunterx.BattleColliderInfo} BattleColliderInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BattleColliderInfo.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.treasurehunterx.BattleColliderInfo(), key, value; + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.intervalToPing = reader.int32(); + break; + } + case 2: { + message.willKickIfInactiveFor = reader.int32(); + break; + } + case 3: { + message.boundRoomId = reader.int32(); + break; + } + case 4: { + message.stageName = reader.string(); + break; + } + case 5: { + if (message.strToVec2DListMap === $util.emptyObject) + message.strToVec2DListMap = {}; + var end2 = reader.uint32() + reader.pos; + key = ""; + value = null; + while (reader.pos < end2) { + var tag2 = reader.uint32(); + switch (tag2 >>> 3) { + case 1: + key = reader.string(); + break; + case 2: + value = $root.treasurehunterx.Vec2DList.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.strToVec2DListMap[key] = value; + break; + } + case 6: { + if (message.strToPolygon2DListMap === $util.emptyObject) + message.strToPolygon2DListMap = {}; + var end2 = reader.uint32() + reader.pos; + key = ""; + value = null; + while (reader.pos < end2) { + var tag2 = reader.uint32(); + switch (tag2 >>> 3) { + case 1: + key = reader.string(); + break; + case 2: + value = $root.treasurehunterx.Polygon2DList.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.strToPolygon2DListMap[key] = value; + break; + } + case 7: { + message.StageDiscreteW = reader.int32(); + break; + } + case 8: { + message.StageDiscreteH = reader.int32(); + break; + } + case 9: { + message.StageTileW = reader.int32(); + break; + } + case 10: { + message.StageTileH = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a BattleColliderInfo message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof treasurehunterx.BattleColliderInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {treasurehunterx.BattleColliderInfo} BattleColliderInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BattleColliderInfo.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a BattleColliderInfo message. + * @function verify + * @memberof treasurehunterx.BattleColliderInfo + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + BattleColliderInfo.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.intervalToPing != null && message.hasOwnProperty("intervalToPing")) + if (!$util.isInteger(message.intervalToPing)) + return "intervalToPing: integer expected"; + if (message.willKickIfInactiveFor != null && message.hasOwnProperty("willKickIfInactiveFor")) + if (!$util.isInteger(message.willKickIfInactiveFor)) + return "willKickIfInactiveFor: integer expected"; + if (message.boundRoomId != null && message.hasOwnProperty("boundRoomId")) + if (!$util.isInteger(message.boundRoomId)) + return "boundRoomId: integer expected"; + if (message.stageName != null && message.hasOwnProperty("stageName")) + if (!$util.isString(message.stageName)) + return "stageName: string expected"; + if (message.strToVec2DListMap != null && message.hasOwnProperty("strToVec2DListMap")) { + if (!$util.isObject(message.strToVec2DListMap)) + return "strToVec2DListMap: object expected"; + var key = Object.keys(message.strToVec2DListMap); + for (var i = 0; i < key.length; ++i) { + var error = $root.treasurehunterx.Vec2DList.verify(message.strToVec2DListMap[key[i]]); + if (error) + return "strToVec2DListMap." + error; + } + } + if (message.strToPolygon2DListMap != null && message.hasOwnProperty("strToPolygon2DListMap")) { + if (!$util.isObject(message.strToPolygon2DListMap)) + return "strToPolygon2DListMap: object expected"; + var key = Object.keys(message.strToPolygon2DListMap); + for (var i = 0; i < key.length; ++i) { + var error = $root.treasurehunterx.Polygon2DList.verify(message.strToPolygon2DListMap[key[i]]); + if (error) + return "strToPolygon2DListMap." + error; + } + } + if (message.StageDiscreteW != null && message.hasOwnProperty("StageDiscreteW")) + if (!$util.isInteger(message.StageDiscreteW)) + return "StageDiscreteW: integer expected"; + if (message.StageDiscreteH != null && message.hasOwnProperty("StageDiscreteH")) + if (!$util.isInteger(message.StageDiscreteH)) + return "StageDiscreteH: integer expected"; + if (message.StageTileW != null && message.hasOwnProperty("StageTileW")) + if (!$util.isInteger(message.StageTileW)) + return "StageTileW: integer expected"; + if (message.StageTileH != null && message.hasOwnProperty("StageTileH")) + if (!$util.isInteger(message.StageTileH)) + return "StageTileH: integer expected"; + return null; + }; + + /** + * Creates a BattleColliderInfo message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof treasurehunterx.BattleColliderInfo + * @static + * @param {Object.} object Plain object + * @returns {treasurehunterx.BattleColliderInfo} BattleColliderInfo + */ + BattleColliderInfo.fromObject = function fromObject(object) { + if (object instanceof $root.treasurehunterx.BattleColliderInfo) + return object; + var message = new $root.treasurehunterx.BattleColliderInfo(); + if (object.intervalToPing != null) + message.intervalToPing = object.intervalToPing | 0; + if (object.willKickIfInactiveFor != null) + message.willKickIfInactiveFor = object.willKickIfInactiveFor | 0; + if (object.boundRoomId != null) + message.boundRoomId = object.boundRoomId | 0; + if (object.stageName != null) + message.stageName = String(object.stageName); + if (object.strToVec2DListMap) { + if (typeof object.strToVec2DListMap !== "object") + throw TypeError(".treasurehunterx.BattleColliderInfo.strToVec2DListMap: object expected"); + message.strToVec2DListMap = {}; + for (var keys = Object.keys(object.strToVec2DListMap), i = 0; i < keys.length; ++i) { + if (typeof object.strToVec2DListMap[keys[i]] !== "object") + throw TypeError(".treasurehunterx.BattleColliderInfo.strToVec2DListMap: object expected"); + message.strToVec2DListMap[keys[i]] = $root.treasurehunterx.Vec2DList.fromObject(object.strToVec2DListMap[keys[i]]); + } + } + if (object.strToPolygon2DListMap) { + if (typeof object.strToPolygon2DListMap !== "object") + throw TypeError(".treasurehunterx.BattleColliderInfo.strToPolygon2DListMap: object expected"); + message.strToPolygon2DListMap = {}; + for (var keys = Object.keys(object.strToPolygon2DListMap), i = 0; i < keys.length; ++i) { + if (typeof object.strToPolygon2DListMap[keys[i]] !== "object") + throw TypeError(".treasurehunterx.BattleColliderInfo.strToPolygon2DListMap: object expected"); + message.strToPolygon2DListMap[keys[i]] = $root.treasurehunterx.Polygon2DList.fromObject(object.strToPolygon2DListMap[keys[i]]); + } + } + if (object.StageDiscreteW != null) + message.StageDiscreteW = object.StageDiscreteW | 0; + if (object.StageDiscreteH != null) + message.StageDiscreteH = object.StageDiscreteH | 0; + if (object.StageTileW != null) + message.StageTileW = object.StageTileW | 0; + if (object.StageTileH != null) + message.StageTileH = object.StageTileH | 0; + return message; + }; + + /** + * Creates a plain object from a BattleColliderInfo message. Also converts values to other types if specified. + * @function toObject + * @memberof treasurehunterx.BattleColliderInfo + * @static + * @param {treasurehunterx.BattleColliderInfo} message BattleColliderInfo + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BattleColliderInfo.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.objects || options.defaults) { + object.strToVec2DListMap = {}; + object.strToPolygon2DListMap = {}; + } + if (options.defaults) { + object.intervalToPing = 0; + object.willKickIfInactiveFor = 0; + object.boundRoomId = 0; + object.stageName = ""; + object.StageDiscreteW = 0; + object.StageDiscreteH = 0; + object.StageTileW = 0; + object.StageTileH = 0; + } + if (message.intervalToPing != null && message.hasOwnProperty("intervalToPing")) + object.intervalToPing = message.intervalToPing; + if (message.willKickIfInactiveFor != null && message.hasOwnProperty("willKickIfInactiveFor")) + object.willKickIfInactiveFor = message.willKickIfInactiveFor; + if (message.boundRoomId != null && message.hasOwnProperty("boundRoomId")) + object.boundRoomId = message.boundRoomId; + if (message.stageName != null && message.hasOwnProperty("stageName")) + object.stageName = message.stageName; + var keys2; + if (message.strToVec2DListMap && (keys2 = Object.keys(message.strToVec2DListMap)).length) { + object.strToVec2DListMap = {}; + for (var j = 0; j < keys2.length; ++j) + object.strToVec2DListMap[keys2[j]] = $root.treasurehunterx.Vec2DList.toObject(message.strToVec2DListMap[keys2[j]], options); + } + if (message.strToPolygon2DListMap && (keys2 = Object.keys(message.strToPolygon2DListMap)).length) { + object.strToPolygon2DListMap = {}; + for (var j = 0; j < keys2.length; ++j) + object.strToPolygon2DListMap[keys2[j]] = $root.treasurehunterx.Polygon2DList.toObject(message.strToPolygon2DListMap[keys2[j]], options); + } + if (message.StageDiscreteW != null && message.hasOwnProperty("StageDiscreteW")) + object.StageDiscreteW = message.StageDiscreteW; + if (message.StageDiscreteH != null && message.hasOwnProperty("StageDiscreteH")) + object.StageDiscreteH = message.StageDiscreteH; + if (message.StageTileW != null && message.hasOwnProperty("StageTileW")) + object.StageTileW = message.StageTileW; + if (message.StageTileH != null && message.hasOwnProperty("StageTileH")) + object.StageTileH = message.StageTileH; + return object; + }; + + /** + * Converts this BattleColliderInfo to JSON. + * @function toJSON + * @memberof treasurehunterx.BattleColliderInfo + * @instance + * @returns {Object.} JSON object + */ + BattleColliderInfo.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for BattleColliderInfo + * @function getTypeUrl + * @memberof treasurehunterx.BattleColliderInfo + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + BattleColliderInfo.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/treasurehunterx.BattleColliderInfo"; + }; + + return BattleColliderInfo; + })(); + + treasurehunterx.Player = (function() { + + /** + * Properties of a Player. + * @memberof treasurehunterx + * @interface IPlayer + * @property {number|null} [id] Player id + * @property {number|null} [x] Player x + * @property {number|null} [y] Player y + * @property {treasurehunterx.Direction|null} [dir] Player dir + * @property {number|null} [speed] Player speed + * @property {number|null} [battleState] Player battleState + * @property {number|null} [lastMoveGmtMillis] Player lastMoveGmtMillis + * @property {number|null} [score] Player score + * @property {boolean|null} [removed] Player removed + * @property {number|null} [joinIndex] Player joinIndex + */ + + /** + * Constructs a new Player. + * @memberof treasurehunterx + * @classdesc Represents a Player. + * @implements IPlayer + * @constructor + * @param {treasurehunterx.IPlayer=} [properties] Properties to set + */ + function Player(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]]; + } + + /** + * Player id. + * @member {number} id + * @memberof treasurehunterx.Player + * @instance + */ + Player.prototype.id = 0; + + /** + * Player x. + * @member {number} x + * @memberof treasurehunterx.Player + * @instance + */ + Player.prototype.x = 0; + + /** + * Player y. + * @member {number} y + * @memberof treasurehunterx.Player + * @instance + */ + Player.prototype.y = 0; + + /** + * Player dir. + * @member {treasurehunterx.Direction|null|undefined} dir + * @memberof treasurehunterx.Player + * @instance + */ + Player.prototype.dir = null; + + /** + * Player speed. + * @member {number} speed + * @memberof treasurehunterx.Player + * @instance + */ + Player.prototype.speed = 0; + + /** + * Player battleState. + * @member {number} battleState + * @memberof treasurehunterx.Player + * @instance + */ + Player.prototype.battleState = 0; + + /** + * Player lastMoveGmtMillis. + * @member {number} lastMoveGmtMillis + * @memberof treasurehunterx.Player + * @instance + */ + Player.prototype.lastMoveGmtMillis = 0; + + /** + * Player score. + * @member {number} score + * @memberof treasurehunterx.Player + * @instance + */ + Player.prototype.score = 0; + + /** + * Player removed. + * @member {boolean} removed + * @memberof treasurehunterx.Player + * @instance + */ + Player.prototype.removed = false; + + /** + * Player joinIndex. + * @member {number} joinIndex + * @memberof treasurehunterx.Player + * @instance + */ + Player.prototype.joinIndex = 0; + + /** + * Creates a new Player instance using the specified properties. + * @function create + * @memberof treasurehunterx.Player + * @static + * @param {treasurehunterx.IPlayer=} [properties] Properties to set + * @returns {treasurehunterx.Player} Player instance + */ + Player.create = function create(properties) { + return new Player(properties); + }; + + /** + * Encodes the specified Player message. Does not implicitly {@link treasurehunterx.Player.verify|verify} messages. + * @function encode + * @memberof treasurehunterx.Player + * @static + * @param {treasurehunterx.Player} message Player message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Player.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.x != null && Object.hasOwnProperty.call(message, "x")) + writer.uint32(/* id 2, wireType 1 =*/17).double(message.x); + if (message.y != null && Object.hasOwnProperty.call(message, "y")) + writer.uint32(/* id 3, wireType 1 =*/25).double(message.y); + if (message.dir != null && Object.hasOwnProperty.call(message, "dir")) + $root.treasurehunterx.Direction.encode(message.dir, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.speed != null && Object.hasOwnProperty.call(message, "speed")) + writer.uint32(/* id 5, wireType 0 =*/40).int32(message.speed); + if (message.battleState != null && Object.hasOwnProperty.call(message, "battleState")) + writer.uint32(/* id 6, wireType 0 =*/48).int32(message.battleState); + if (message.lastMoveGmtMillis != null && Object.hasOwnProperty.call(message, "lastMoveGmtMillis")) + writer.uint32(/* id 7, wireType 0 =*/56).int32(message.lastMoveGmtMillis); + if (message.score != null && Object.hasOwnProperty.call(message, "score")) + writer.uint32(/* id 10, wireType 0 =*/80).int32(message.score); + if (message.removed != null && Object.hasOwnProperty.call(message, "removed")) + writer.uint32(/* id 11, wireType 0 =*/88).bool(message.removed); + if (message.joinIndex != null && Object.hasOwnProperty.call(message, "joinIndex")) + writer.uint32(/* id 12, wireType 0 =*/96).int32(message.joinIndex); + return writer; + }; + + /** + * Encodes the specified Player message, length delimited. Does not implicitly {@link treasurehunterx.Player.verify|verify} messages. + * @function encodeDelimited + * @memberof treasurehunterx.Player + * @static + * @param {treasurehunterx.Player} message Player message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Player.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Player message from the specified reader or buffer. + * @function decode + * @memberof treasurehunterx.Player + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {treasurehunterx.Player} Player + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Player.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.treasurehunterx.Player(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.id = reader.int32(); + break; + } + case 2: { + message.x = reader.double(); + break; + } + case 3: { + message.y = reader.double(); + break; + } + case 4: { + message.dir = $root.treasurehunterx.Direction.decode(reader, reader.uint32()); + break; + } + case 5: { + message.speed = reader.int32(); + break; + } + case 6: { + message.battleState = reader.int32(); + break; + } + case 7: { + message.lastMoveGmtMillis = reader.int32(); + break; + } + case 10: { + message.score = reader.int32(); + break; + } + case 11: { + message.removed = reader.bool(); + break; + } + case 12: { + message.joinIndex = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Player message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof treasurehunterx.Player + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {treasurehunterx.Player} Player + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Player.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Player message. + * @function verify + * @memberof treasurehunterx.Player + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Player.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.id != null && message.hasOwnProperty("id")) + if (!$util.isInteger(message.id)) + return "id: integer expected"; + if (message.x != null && message.hasOwnProperty("x")) + if (typeof message.x !== "number") + return "x: number expected"; + if (message.y != null && message.hasOwnProperty("y")) + if (typeof message.y !== "number") + return "y: number expected"; + if (message.dir != null && message.hasOwnProperty("dir")) { + var error = $root.treasurehunterx.Direction.verify(message.dir); + if (error) + return "dir." + error; + } + if (message.speed != null && message.hasOwnProperty("speed")) + if (!$util.isInteger(message.speed)) + return "speed: integer expected"; + if (message.battleState != null && message.hasOwnProperty("battleState")) + if (!$util.isInteger(message.battleState)) + return "battleState: integer expected"; + if (message.lastMoveGmtMillis != null && message.hasOwnProperty("lastMoveGmtMillis")) + if (!$util.isInteger(message.lastMoveGmtMillis)) + return "lastMoveGmtMillis: integer expected"; + if (message.score != null && message.hasOwnProperty("score")) + if (!$util.isInteger(message.score)) + return "score: integer expected"; + if (message.removed != null && message.hasOwnProperty("removed")) + if (typeof message.removed !== "boolean") + return "removed: boolean expected"; + if (message.joinIndex != null && message.hasOwnProperty("joinIndex")) + if (!$util.isInteger(message.joinIndex)) + return "joinIndex: integer expected"; + return null; + }; + + /** + * Creates a Player message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof treasurehunterx.Player + * @static + * @param {Object.} object Plain object + * @returns {treasurehunterx.Player} Player + */ + Player.fromObject = function fromObject(object) { + if (object instanceof $root.treasurehunterx.Player) + return object; + var message = new $root.treasurehunterx.Player(); + if (object.id != null) + message.id = object.id | 0; + if (object.x != null) + message.x = Number(object.x); + if (object.y != null) + message.y = Number(object.y); + if (object.dir != null) { + if (typeof object.dir !== "object") + throw TypeError(".treasurehunterx.Player.dir: object expected"); + message.dir = $root.treasurehunterx.Direction.fromObject(object.dir); + } + if (object.speed != null) + message.speed = object.speed | 0; + if (object.battleState != null) + message.battleState = object.battleState | 0; + if (object.lastMoveGmtMillis != null) + message.lastMoveGmtMillis = object.lastMoveGmtMillis | 0; + if (object.score != null) + message.score = object.score | 0; + if (object.removed != null) + message.removed = Boolean(object.removed); + if (object.joinIndex != null) + message.joinIndex = object.joinIndex | 0; + return message; + }; + + /** + * Creates a plain object from a Player message. Also converts values to other types if specified. + * @function toObject + * @memberof treasurehunterx.Player + * @static + * @param {treasurehunterx.Player} message Player + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Player.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.id = 0; + object.x = 0; + object.y = 0; + object.dir = null; + object.speed = 0; + object.battleState = 0; + object.lastMoveGmtMillis = 0; + object.score = 0; + object.removed = false; + object.joinIndex = 0; + } + if (message.id != null && message.hasOwnProperty("id")) + object.id = message.id; + if (message.x != null && message.hasOwnProperty("x")) + object.x = options.json && !isFinite(message.x) ? String(message.x) : message.x; + if (message.y != null && message.hasOwnProperty("y")) + object.y = options.json && !isFinite(message.y) ? String(message.y) : message.y; + if (message.dir != null && message.hasOwnProperty("dir")) + object.dir = $root.treasurehunterx.Direction.toObject(message.dir, options); + if (message.speed != null && message.hasOwnProperty("speed")) + object.speed = message.speed; + if (message.battleState != null && message.hasOwnProperty("battleState")) + object.battleState = message.battleState; + if (message.lastMoveGmtMillis != null && message.hasOwnProperty("lastMoveGmtMillis")) + object.lastMoveGmtMillis = message.lastMoveGmtMillis; + if (message.score != null && message.hasOwnProperty("score")) + object.score = message.score; + if (message.removed != null && message.hasOwnProperty("removed")) + object.removed = message.removed; + if (message.joinIndex != null && message.hasOwnProperty("joinIndex")) + object.joinIndex = message.joinIndex; + return object; + }; + + /** + * Converts this Player to JSON. + * @function toJSON + * @memberof treasurehunterx.Player + * @instance + * @returns {Object.} JSON object + */ + Player.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Player + * @function getTypeUrl + * @memberof treasurehunterx.Player + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Player.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/treasurehunterx.Player"; + }; + + return Player; + })(); + + treasurehunterx.PlayerMeta = (function() { + + /** + * Properties of a PlayerMeta. + * @memberof treasurehunterx + * @interface IPlayerMeta + * @property {number|null} [id] PlayerMeta id + * @property {string|null} [name] PlayerMeta name + * @property {string|null} [displayName] PlayerMeta displayName + * @property {string|null} [avatar] PlayerMeta avatar + * @property {number|null} [joinIndex] PlayerMeta joinIndex + */ + + /** + * Constructs a new PlayerMeta. + * @memberof treasurehunterx + * @classdesc Represents a PlayerMeta. + * @implements IPlayerMeta + * @constructor + * @param {treasurehunterx.IPlayerMeta=} [properties] Properties to set + */ + function PlayerMeta(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]]; + } + + /** + * PlayerMeta id. + * @member {number} id + * @memberof treasurehunterx.PlayerMeta + * @instance + */ + PlayerMeta.prototype.id = 0; + + /** + * PlayerMeta name. + * @member {string} name + * @memberof treasurehunterx.PlayerMeta + * @instance + */ + PlayerMeta.prototype.name = ""; + + /** + * PlayerMeta displayName. + * @member {string} displayName + * @memberof treasurehunterx.PlayerMeta + * @instance + */ + PlayerMeta.prototype.displayName = ""; + + /** + * PlayerMeta avatar. + * @member {string} avatar + * @memberof treasurehunterx.PlayerMeta + * @instance + */ + PlayerMeta.prototype.avatar = ""; + + /** + * PlayerMeta joinIndex. + * @member {number} joinIndex + * @memberof treasurehunterx.PlayerMeta + * @instance + */ + PlayerMeta.prototype.joinIndex = 0; + + /** + * Creates a new PlayerMeta instance using the specified properties. + * @function create + * @memberof treasurehunterx.PlayerMeta + * @static + * @param {treasurehunterx.IPlayerMeta=} [properties] Properties to set + * @returns {treasurehunterx.PlayerMeta} PlayerMeta instance + */ + PlayerMeta.create = function create(properties) { + return new PlayerMeta(properties); + }; + + /** + * Encodes the specified PlayerMeta message. Does not implicitly {@link treasurehunterx.PlayerMeta.verify|verify} messages. + * @function encode + * @memberof treasurehunterx.PlayerMeta + * @static + * @param {treasurehunterx.PlayerMeta} message PlayerMeta message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PlayerMeta.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.displayName != null && Object.hasOwnProperty.call(message, "displayName")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.displayName); + if (message.avatar != null && Object.hasOwnProperty.call(message, "avatar")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.avatar); + if (message.joinIndex != null && Object.hasOwnProperty.call(message, "joinIndex")) + writer.uint32(/* id 5, wireType 0 =*/40).int32(message.joinIndex); + return writer; + }; + + /** + * Encodes the specified PlayerMeta message, length delimited. Does not implicitly {@link treasurehunterx.PlayerMeta.verify|verify} messages. + * @function encodeDelimited + * @memberof treasurehunterx.PlayerMeta + * @static + * @param {treasurehunterx.PlayerMeta} message PlayerMeta message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PlayerMeta.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PlayerMeta message from the specified reader or buffer. + * @function decode + * @memberof treasurehunterx.PlayerMeta + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {treasurehunterx.PlayerMeta} PlayerMeta + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PlayerMeta.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.treasurehunterx.PlayerMeta(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.id = reader.int32(); + break; + } + case 2: { + message.name = reader.string(); + break; + } + case 3: { + message.displayName = reader.string(); + break; + } + case 4: { + message.avatar = reader.string(); + break; + } + case 5: { + message.joinIndex = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PlayerMeta message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof treasurehunterx.PlayerMeta + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {treasurehunterx.PlayerMeta} PlayerMeta + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PlayerMeta.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PlayerMeta message. + * @function verify + * @memberof treasurehunterx.PlayerMeta + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PlayerMeta.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.id != null && message.hasOwnProperty("id")) + if (!$util.isInteger(message.id)) + return "id: integer expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + if (message.displayName != null && message.hasOwnProperty("displayName")) + if (!$util.isString(message.displayName)) + return "displayName: string expected"; + if (message.avatar != null && message.hasOwnProperty("avatar")) + if (!$util.isString(message.avatar)) + return "avatar: string expected"; + if (message.joinIndex != null && message.hasOwnProperty("joinIndex")) + if (!$util.isInteger(message.joinIndex)) + return "joinIndex: integer expected"; + return null; + }; + + /** + * Creates a PlayerMeta message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof treasurehunterx.PlayerMeta + * @static + * @param {Object.} object Plain object + * @returns {treasurehunterx.PlayerMeta} PlayerMeta + */ + PlayerMeta.fromObject = function fromObject(object) { + if (object instanceof $root.treasurehunterx.PlayerMeta) + return object; + var message = new $root.treasurehunterx.PlayerMeta(); + if (object.id != null) + message.id = object.id | 0; + if (object.name != null) + message.name = String(object.name); + if (object.displayName != null) + message.displayName = String(object.displayName); + if (object.avatar != null) + message.avatar = String(object.avatar); + if (object.joinIndex != null) + message.joinIndex = object.joinIndex | 0; + return message; + }; + + /** + * Creates a plain object from a PlayerMeta message. Also converts values to other types if specified. + * @function toObject + * @memberof treasurehunterx.PlayerMeta + * @static + * @param {treasurehunterx.PlayerMeta} message PlayerMeta + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PlayerMeta.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.id = 0; + object.name = ""; + object.displayName = ""; + object.avatar = ""; + object.joinIndex = 0; + } + if (message.id != null && message.hasOwnProperty("id")) + object.id = message.id; + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.displayName != null && message.hasOwnProperty("displayName")) + object.displayName = message.displayName; + if (message.avatar != null && message.hasOwnProperty("avatar")) + object.avatar = message.avatar; + if (message.joinIndex != null && message.hasOwnProperty("joinIndex")) + object.joinIndex = message.joinIndex; + return object; + }; + + /** + * Converts this PlayerMeta to JSON. + * @function toJSON + * @memberof treasurehunterx.PlayerMeta + * @instance + * @returns {Object.} JSON object + */ + PlayerMeta.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PlayerMeta + * @function getTypeUrl + * @memberof treasurehunterx.PlayerMeta + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PlayerMeta.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/treasurehunterx.PlayerMeta"; + }; + + return PlayerMeta; + })(); + + treasurehunterx.Treasure = (function() { + + /** + * Properties of a Treasure. + * @memberof treasurehunterx + * @interface ITreasure + * @property {number|null} [id] Treasure id + * @property {number|null} [localIdInBattle] Treasure localIdInBattle + * @property {number|null} [score] Treasure score + * @property {number|null} [x] Treasure x + * @property {number|null} [y] Treasure y + * @property {boolean|null} [removed] Treasure removed + * @property {number|null} [type] Treasure type + */ + + /** + * Constructs a new Treasure. + * @memberof treasurehunterx + * @classdesc Represents a Treasure. + * @implements ITreasure + * @constructor + * @param {treasurehunterx.ITreasure=} [properties] Properties to set + */ + function Treasure(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]]; + } + + /** + * Treasure id. + * @member {number} id + * @memberof treasurehunterx.Treasure + * @instance + */ + Treasure.prototype.id = 0; + + /** + * Treasure localIdInBattle. + * @member {number} localIdInBattle + * @memberof treasurehunterx.Treasure + * @instance + */ + Treasure.prototype.localIdInBattle = 0; + + /** + * Treasure score. + * @member {number} score + * @memberof treasurehunterx.Treasure + * @instance + */ + Treasure.prototype.score = 0; + + /** + * Treasure x. + * @member {number} x + * @memberof treasurehunterx.Treasure + * @instance + */ + Treasure.prototype.x = 0; + + /** + * Treasure y. + * @member {number} y + * @memberof treasurehunterx.Treasure + * @instance + */ + Treasure.prototype.y = 0; + + /** + * Treasure removed. + * @member {boolean} removed + * @memberof treasurehunterx.Treasure + * @instance + */ + Treasure.prototype.removed = false; + + /** + * Treasure type. + * @member {number} type + * @memberof treasurehunterx.Treasure + * @instance + */ + Treasure.prototype.type = 0; + + /** + * Creates a new Treasure instance using the specified properties. + * @function create + * @memberof treasurehunterx.Treasure + * @static + * @param {treasurehunterx.ITreasure=} [properties] Properties to set + * @returns {treasurehunterx.Treasure} Treasure instance + */ + Treasure.create = function create(properties) { + return new Treasure(properties); + }; + + /** + * Encodes the specified Treasure message. Does not implicitly {@link treasurehunterx.Treasure.verify|verify} messages. + * @function encode + * @memberof treasurehunterx.Treasure + * @static + * @param {treasurehunterx.Treasure} message Treasure message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Treasure.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.localIdInBattle != null && Object.hasOwnProperty.call(message, "localIdInBattle")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.localIdInBattle); + if (message.score != null && Object.hasOwnProperty.call(message, "score")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.score); + if (message.x != null && Object.hasOwnProperty.call(message, "x")) + writer.uint32(/* id 4, wireType 1 =*/33).double(message.x); + if (message.y != null && Object.hasOwnProperty.call(message, "y")) + writer.uint32(/* id 5, wireType 1 =*/41).double(message.y); + if (message.removed != null && Object.hasOwnProperty.call(message, "removed")) + writer.uint32(/* id 6, wireType 0 =*/48).bool(message.removed); + if (message.type != null && Object.hasOwnProperty.call(message, "type")) + writer.uint32(/* id 7, wireType 0 =*/56).int32(message.type); + return writer; + }; + + /** + * Encodes the specified Treasure message, length delimited. Does not implicitly {@link treasurehunterx.Treasure.verify|verify} messages. + * @function encodeDelimited + * @memberof treasurehunterx.Treasure + * @static + * @param {treasurehunterx.Treasure} message Treasure message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Treasure.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Treasure message from the specified reader or buffer. + * @function decode + * @memberof treasurehunterx.Treasure + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {treasurehunterx.Treasure} Treasure + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Treasure.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.treasurehunterx.Treasure(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.id = reader.int32(); + break; + } + case 2: { + message.localIdInBattle = reader.int32(); + break; + } + case 3: { + message.score = reader.int32(); + break; + } + case 4: { + message.x = reader.double(); + break; + } + case 5: { + message.y = reader.double(); + break; + } + case 6: { + message.removed = reader.bool(); + break; + } + case 7: { + message.type = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Treasure message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof treasurehunterx.Treasure + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {treasurehunterx.Treasure} Treasure + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Treasure.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Treasure message. + * @function verify + * @memberof treasurehunterx.Treasure + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Treasure.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.id != null && message.hasOwnProperty("id")) + if (!$util.isInteger(message.id)) + return "id: integer expected"; + if (message.localIdInBattle != null && message.hasOwnProperty("localIdInBattle")) + if (!$util.isInteger(message.localIdInBattle)) + return "localIdInBattle: integer expected"; + if (message.score != null && message.hasOwnProperty("score")) + if (!$util.isInteger(message.score)) + return "score: integer expected"; + if (message.x != null && message.hasOwnProperty("x")) + if (typeof message.x !== "number") + return "x: number expected"; + if (message.y != null && message.hasOwnProperty("y")) + if (typeof message.y !== "number") + return "y: number expected"; + if (message.removed != null && message.hasOwnProperty("removed")) + if (typeof message.removed !== "boolean") + return "removed: boolean expected"; + if (message.type != null && message.hasOwnProperty("type")) + if (!$util.isInteger(message.type)) + return "type: integer expected"; + return null; + }; + + /** + * Creates a Treasure message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof treasurehunterx.Treasure + * @static + * @param {Object.} object Plain object + * @returns {treasurehunterx.Treasure} Treasure + */ + Treasure.fromObject = function fromObject(object) { + if (object instanceof $root.treasurehunterx.Treasure) + return object; + var message = new $root.treasurehunterx.Treasure(); + if (object.id != null) + message.id = object.id | 0; + if (object.localIdInBattle != null) + message.localIdInBattle = object.localIdInBattle | 0; + if (object.score != null) + message.score = object.score | 0; + if (object.x != null) + message.x = Number(object.x); + if (object.y != null) + message.y = Number(object.y); + if (object.removed != null) + message.removed = Boolean(object.removed); + if (object.type != null) + message.type = object.type | 0; + return message; + }; + + /** + * Creates a plain object from a Treasure message. Also converts values to other types if specified. + * @function toObject + * @memberof treasurehunterx.Treasure + * @static + * @param {treasurehunterx.Treasure} message Treasure + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Treasure.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.id = 0; + object.localIdInBattle = 0; + object.score = 0; + object.x = 0; + object.y = 0; + object.removed = false; + object.type = 0; + } + if (message.id != null && message.hasOwnProperty("id")) + object.id = message.id; + if (message.localIdInBattle != null && message.hasOwnProperty("localIdInBattle")) + object.localIdInBattle = message.localIdInBattle; + if (message.score != null && message.hasOwnProperty("score")) + object.score = message.score; + if (message.x != null && message.hasOwnProperty("x")) + object.x = options.json && !isFinite(message.x) ? String(message.x) : message.x; + if (message.y != null && message.hasOwnProperty("y")) + object.y = options.json && !isFinite(message.y) ? String(message.y) : message.y; + if (message.removed != null && message.hasOwnProperty("removed")) + object.removed = message.removed; + if (message.type != null && message.hasOwnProperty("type")) + object.type = message.type; + return object; + }; + + /** + * Converts this Treasure to JSON. + * @function toJSON + * @memberof treasurehunterx.Treasure + * @instance + * @returns {Object.} JSON object + */ + Treasure.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Treasure + * @function getTypeUrl + * @memberof treasurehunterx.Treasure + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Treasure.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/treasurehunterx.Treasure"; + }; + + return Treasure; + })(); + + treasurehunterx.Bullet = (function() { + + /** + * Properties of a Bullet. + * @memberof treasurehunterx + * @interface IBullet + * @property {number|null} [localIdInBattle] Bullet localIdInBattle + * @property {number|null} [linearSpeed] Bullet linearSpeed + * @property {number|null} [x] Bullet x + * @property {number|null} [y] Bullet y + * @property {boolean|null} [removed] Bullet removed + * @property {treasurehunterx.Vec2D|null} [startAtPoint] Bullet startAtPoint + * @property {treasurehunterx.Vec2D|null} [endAtPoint] Bullet endAtPoint + */ + + /** + * Constructs a new Bullet. + * @memberof treasurehunterx + * @classdesc Represents a Bullet. + * @implements IBullet + * @constructor + * @param {treasurehunterx.IBullet=} [properties] Properties to set + */ + function Bullet(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]]; + } + + /** + * Bullet localIdInBattle. + * @member {number} localIdInBattle + * @memberof treasurehunterx.Bullet + * @instance + */ + Bullet.prototype.localIdInBattle = 0; + + /** + * Bullet linearSpeed. + * @member {number} linearSpeed + * @memberof treasurehunterx.Bullet + * @instance + */ + Bullet.prototype.linearSpeed = 0; + + /** + * Bullet x. + * @member {number} x + * @memberof treasurehunterx.Bullet + * @instance + */ + Bullet.prototype.x = 0; + + /** + * Bullet y. + * @member {number} y + * @memberof treasurehunterx.Bullet + * @instance + */ + Bullet.prototype.y = 0; + + /** + * Bullet removed. + * @member {boolean} removed + * @memberof treasurehunterx.Bullet + * @instance + */ + Bullet.prototype.removed = false; + + /** + * Bullet startAtPoint. + * @member {treasurehunterx.Vec2D|null|undefined} startAtPoint + * @memberof treasurehunterx.Bullet + * @instance + */ + Bullet.prototype.startAtPoint = null; + + /** + * Bullet endAtPoint. + * @member {treasurehunterx.Vec2D|null|undefined} endAtPoint + * @memberof treasurehunterx.Bullet + * @instance + */ + Bullet.prototype.endAtPoint = null; + + /** + * Creates a new Bullet instance using the specified properties. + * @function create + * @memberof treasurehunterx.Bullet + * @static + * @param {treasurehunterx.IBullet=} [properties] Properties to set + * @returns {treasurehunterx.Bullet} Bullet instance + */ + Bullet.create = function create(properties) { + return new Bullet(properties); + }; + + /** + * Encodes the specified Bullet message. Does not implicitly {@link treasurehunterx.Bullet.verify|verify} messages. + * @function encode + * @memberof treasurehunterx.Bullet + * @static + * @param {treasurehunterx.Bullet} message Bullet message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Bullet.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.localIdInBattle != null && Object.hasOwnProperty.call(message, "localIdInBattle")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.localIdInBattle); + if (message.linearSpeed != null && Object.hasOwnProperty.call(message, "linearSpeed")) + writer.uint32(/* id 2, wireType 1 =*/17).double(message.linearSpeed); + if (message.x != null && Object.hasOwnProperty.call(message, "x")) + writer.uint32(/* id 3, wireType 1 =*/25).double(message.x); + if (message.y != null && Object.hasOwnProperty.call(message, "y")) + writer.uint32(/* id 4, wireType 1 =*/33).double(message.y); + if (message.removed != null && Object.hasOwnProperty.call(message, "removed")) + writer.uint32(/* id 5, wireType 0 =*/40).bool(message.removed); + if (message.startAtPoint != null && Object.hasOwnProperty.call(message, "startAtPoint")) + $root.treasurehunterx.Vec2D.encode(message.startAtPoint, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + if (message.endAtPoint != null && Object.hasOwnProperty.call(message, "endAtPoint")) + $root.treasurehunterx.Vec2D.encode(message.endAtPoint, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified Bullet message, length delimited. Does not implicitly {@link treasurehunterx.Bullet.verify|verify} messages. + * @function encodeDelimited + * @memberof treasurehunterx.Bullet + * @static + * @param {treasurehunterx.Bullet} message Bullet message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Bullet.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Bullet message from the specified reader or buffer. + * @function decode + * @memberof treasurehunterx.Bullet + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {treasurehunterx.Bullet} Bullet + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Bullet.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.treasurehunterx.Bullet(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.localIdInBattle = reader.int32(); + break; + } + case 2: { + message.linearSpeed = reader.double(); + break; + } + case 3: { + message.x = reader.double(); + break; + } + case 4: { + message.y = reader.double(); + break; + } + case 5: { + message.removed = reader.bool(); + break; + } + case 6: { + message.startAtPoint = $root.treasurehunterx.Vec2D.decode(reader, reader.uint32()); + break; + } + case 7: { + message.endAtPoint = $root.treasurehunterx.Vec2D.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Bullet message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof treasurehunterx.Bullet + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {treasurehunterx.Bullet} Bullet + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Bullet.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Bullet message. + * @function verify + * @memberof treasurehunterx.Bullet + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Bullet.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.localIdInBattle != null && message.hasOwnProperty("localIdInBattle")) + if (!$util.isInteger(message.localIdInBattle)) + return "localIdInBattle: integer expected"; + if (message.linearSpeed != null && message.hasOwnProperty("linearSpeed")) + if (typeof message.linearSpeed !== "number") + return "linearSpeed: number expected"; + if (message.x != null && message.hasOwnProperty("x")) + if (typeof message.x !== "number") + return "x: number expected"; + if (message.y != null && message.hasOwnProperty("y")) + if (typeof message.y !== "number") + return "y: number expected"; + if (message.removed != null && message.hasOwnProperty("removed")) + if (typeof message.removed !== "boolean") + return "removed: boolean expected"; + if (message.startAtPoint != null && message.hasOwnProperty("startAtPoint")) { + var error = $root.treasurehunterx.Vec2D.verify(message.startAtPoint); + if (error) + return "startAtPoint." + error; + } + if (message.endAtPoint != null && message.hasOwnProperty("endAtPoint")) { + var error = $root.treasurehunterx.Vec2D.verify(message.endAtPoint); + if (error) + return "endAtPoint." + error; + } + return null; + }; + + /** + * Creates a Bullet message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof treasurehunterx.Bullet + * @static + * @param {Object.} object Plain object + * @returns {treasurehunterx.Bullet} Bullet + */ + Bullet.fromObject = function fromObject(object) { + if (object instanceof $root.treasurehunterx.Bullet) + return object; + var message = new $root.treasurehunterx.Bullet(); + if (object.localIdInBattle != null) + message.localIdInBattle = object.localIdInBattle | 0; + if (object.linearSpeed != null) + message.linearSpeed = Number(object.linearSpeed); + if (object.x != null) + message.x = Number(object.x); + if (object.y != null) + message.y = Number(object.y); + if (object.removed != null) + message.removed = Boolean(object.removed); + if (object.startAtPoint != null) { + if (typeof object.startAtPoint !== "object") + throw TypeError(".treasurehunterx.Bullet.startAtPoint: object expected"); + message.startAtPoint = $root.treasurehunterx.Vec2D.fromObject(object.startAtPoint); + } + if (object.endAtPoint != null) { + if (typeof object.endAtPoint !== "object") + throw TypeError(".treasurehunterx.Bullet.endAtPoint: object expected"); + message.endAtPoint = $root.treasurehunterx.Vec2D.fromObject(object.endAtPoint); + } + return message; + }; + + /** + * Creates a plain object from a Bullet message. Also converts values to other types if specified. + * @function toObject + * @memberof treasurehunterx.Bullet + * @static + * @param {treasurehunterx.Bullet} message Bullet + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Bullet.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.localIdInBattle = 0; + object.linearSpeed = 0; + object.x = 0; + object.y = 0; + object.removed = false; + object.startAtPoint = null; + object.endAtPoint = null; + } + if (message.localIdInBattle != null && message.hasOwnProperty("localIdInBattle")) + object.localIdInBattle = message.localIdInBattle; + if (message.linearSpeed != null && message.hasOwnProperty("linearSpeed")) + object.linearSpeed = options.json && !isFinite(message.linearSpeed) ? String(message.linearSpeed) : message.linearSpeed; + if (message.x != null && message.hasOwnProperty("x")) + object.x = options.json && !isFinite(message.x) ? String(message.x) : message.x; + if (message.y != null && message.hasOwnProperty("y")) + object.y = options.json && !isFinite(message.y) ? String(message.y) : message.y; + if (message.removed != null && message.hasOwnProperty("removed")) + object.removed = message.removed; + if (message.startAtPoint != null && message.hasOwnProperty("startAtPoint")) + object.startAtPoint = $root.treasurehunterx.Vec2D.toObject(message.startAtPoint, options); + if (message.endAtPoint != null && message.hasOwnProperty("endAtPoint")) + object.endAtPoint = $root.treasurehunterx.Vec2D.toObject(message.endAtPoint, options); + return object; + }; + + /** + * Converts this Bullet to JSON. + * @function toJSON + * @memberof treasurehunterx.Bullet + * @instance + * @returns {Object.} JSON object + */ + Bullet.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Bullet + * @function getTypeUrl + * @memberof treasurehunterx.Bullet + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Bullet.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/treasurehunterx.Bullet"; + }; + + return Bullet; + })(); + + treasurehunterx.Trap = (function() { + + /** + * Properties of a Trap. + * @memberof treasurehunterx + * @interface ITrap + * @property {number|null} [id] Trap id + * @property {number|null} [localIdInBattle] Trap localIdInBattle + * @property {number|null} [type] Trap type + * @property {number|null} [x] Trap x + * @property {number|null} [y] Trap y + * @property {boolean|null} [removed] Trap removed + */ + + /** + * Constructs a new Trap. + * @memberof treasurehunterx + * @classdesc Represents a Trap. + * @implements ITrap + * @constructor + * @param {treasurehunterx.ITrap=} [properties] Properties to set + */ + function Trap(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]]; + } + + /** + * Trap id. + * @member {number} id + * @memberof treasurehunterx.Trap + * @instance + */ + Trap.prototype.id = 0; + + /** + * Trap localIdInBattle. + * @member {number} localIdInBattle + * @memberof treasurehunterx.Trap + * @instance + */ + Trap.prototype.localIdInBattle = 0; + + /** + * Trap type. + * @member {number} type + * @memberof treasurehunterx.Trap + * @instance + */ + Trap.prototype.type = 0; + + /** + * Trap x. + * @member {number} x + * @memberof treasurehunterx.Trap + * @instance + */ + Trap.prototype.x = 0; + + /** + * Trap y. + * @member {number} y + * @memberof treasurehunterx.Trap + * @instance + */ + Trap.prototype.y = 0; + + /** + * Trap removed. + * @member {boolean} removed + * @memberof treasurehunterx.Trap + * @instance + */ + Trap.prototype.removed = false; + + /** + * Creates a new Trap instance using the specified properties. + * @function create + * @memberof treasurehunterx.Trap + * @static + * @param {treasurehunterx.ITrap=} [properties] Properties to set + * @returns {treasurehunterx.Trap} Trap instance + */ + Trap.create = function create(properties) { + return new Trap(properties); + }; + + /** + * Encodes the specified Trap message. Does not implicitly {@link treasurehunterx.Trap.verify|verify} messages. + * @function encode + * @memberof treasurehunterx.Trap + * @static + * @param {treasurehunterx.Trap} message Trap message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Trap.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.localIdInBattle != null && Object.hasOwnProperty.call(message, "localIdInBattle")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.localIdInBattle); + if (message.type != null && Object.hasOwnProperty.call(message, "type")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.type); + if (message.x != null && Object.hasOwnProperty.call(message, "x")) + writer.uint32(/* id 4, wireType 1 =*/33).double(message.x); + if (message.y != null && Object.hasOwnProperty.call(message, "y")) + writer.uint32(/* id 5, wireType 1 =*/41).double(message.y); + if (message.removed != null && Object.hasOwnProperty.call(message, "removed")) + writer.uint32(/* id 6, wireType 0 =*/48).bool(message.removed); + return writer; + }; + + /** + * Encodes the specified Trap message, length delimited. Does not implicitly {@link treasurehunterx.Trap.verify|verify} messages. + * @function encodeDelimited + * @memberof treasurehunterx.Trap + * @static + * @param {treasurehunterx.Trap} message Trap message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Trap.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Trap message from the specified reader or buffer. + * @function decode + * @memberof treasurehunterx.Trap + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {treasurehunterx.Trap} Trap + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Trap.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.treasurehunterx.Trap(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.id = reader.int32(); + break; + } + case 2: { + message.localIdInBattle = reader.int32(); + break; + } + case 3: { + message.type = reader.int32(); + break; + } + case 4: { + message.x = reader.double(); + break; + } + case 5: { + message.y = reader.double(); + break; + } + case 6: { + message.removed = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Trap message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof treasurehunterx.Trap + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {treasurehunterx.Trap} Trap + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Trap.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Trap message. + * @function verify + * @memberof treasurehunterx.Trap + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Trap.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.id != null && message.hasOwnProperty("id")) + if (!$util.isInteger(message.id)) + return "id: integer expected"; + if (message.localIdInBattle != null && message.hasOwnProperty("localIdInBattle")) + if (!$util.isInteger(message.localIdInBattle)) + return "localIdInBattle: integer expected"; + if (message.type != null && message.hasOwnProperty("type")) + if (!$util.isInteger(message.type)) + return "type: integer expected"; + if (message.x != null && message.hasOwnProperty("x")) + if (typeof message.x !== "number") + return "x: number expected"; + if (message.y != null && message.hasOwnProperty("y")) + if (typeof message.y !== "number") + return "y: number expected"; + if (message.removed != null && message.hasOwnProperty("removed")) + if (typeof message.removed !== "boolean") + return "removed: boolean expected"; + return null; + }; + + /** + * Creates a Trap message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof treasurehunterx.Trap + * @static + * @param {Object.} object Plain object + * @returns {treasurehunterx.Trap} Trap + */ + Trap.fromObject = function fromObject(object) { + if (object instanceof $root.treasurehunterx.Trap) + return object; + var message = new $root.treasurehunterx.Trap(); + if (object.id != null) + message.id = object.id | 0; + if (object.localIdInBattle != null) + message.localIdInBattle = object.localIdInBattle | 0; + if (object.type != null) + message.type = object.type | 0; + if (object.x != null) + message.x = Number(object.x); + if (object.y != null) + message.y = Number(object.y); + if (object.removed != null) + message.removed = Boolean(object.removed); + return message; + }; + + /** + * Creates a plain object from a Trap message. Also converts values to other types if specified. + * @function toObject + * @memberof treasurehunterx.Trap + * @static + * @param {treasurehunterx.Trap} message Trap + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Trap.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.id = 0; + object.localIdInBattle = 0; + object.type = 0; + object.x = 0; + object.y = 0; + object.removed = false; + } + if (message.id != null && message.hasOwnProperty("id")) + object.id = message.id; + if (message.localIdInBattle != null && message.hasOwnProperty("localIdInBattle")) + object.localIdInBattle = message.localIdInBattle; + if (message.type != null && message.hasOwnProperty("type")) + object.type = message.type; + if (message.x != null && message.hasOwnProperty("x")) + object.x = options.json && !isFinite(message.x) ? String(message.x) : message.x; + if (message.y != null && message.hasOwnProperty("y")) + object.y = options.json && !isFinite(message.y) ? String(message.y) : message.y; + if (message.removed != null && message.hasOwnProperty("removed")) + object.removed = message.removed; + return object; + }; + + /** + * Converts this Trap to JSON. + * @function toJSON + * @memberof treasurehunterx.Trap + * @instance + * @returns {Object.} JSON object + */ + Trap.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Trap + * @function getTypeUrl + * @memberof treasurehunterx.Trap + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Trap.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/treasurehunterx.Trap"; + }; + + return Trap; + })(); + + treasurehunterx.SpeedShoe = (function() { + + /** + * Properties of a SpeedShoe. + * @memberof treasurehunterx + * @interface ISpeedShoe + * @property {number|null} [id] SpeedShoe id + * @property {number|null} [localIdInBattle] SpeedShoe localIdInBattle + * @property {number|null} [x] SpeedShoe x + * @property {number|null} [y] SpeedShoe y + * @property {boolean|null} [removed] SpeedShoe removed + * @property {number|null} [type] SpeedShoe type + */ + + /** + * Constructs a new SpeedShoe. + * @memberof treasurehunterx + * @classdesc Represents a SpeedShoe. + * @implements ISpeedShoe + * @constructor + * @param {treasurehunterx.ISpeedShoe=} [properties] Properties to set + */ + function SpeedShoe(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]]; + } + + /** + * SpeedShoe id. + * @member {number} id + * @memberof treasurehunterx.SpeedShoe + * @instance + */ + SpeedShoe.prototype.id = 0; + + /** + * SpeedShoe localIdInBattle. + * @member {number} localIdInBattle + * @memberof treasurehunterx.SpeedShoe + * @instance + */ + SpeedShoe.prototype.localIdInBattle = 0; + + /** + * SpeedShoe x. + * @member {number} x + * @memberof treasurehunterx.SpeedShoe + * @instance + */ + SpeedShoe.prototype.x = 0; + + /** + * SpeedShoe y. + * @member {number} y + * @memberof treasurehunterx.SpeedShoe + * @instance + */ + SpeedShoe.prototype.y = 0; + + /** + * SpeedShoe removed. + * @member {boolean} removed + * @memberof treasurehunterx.SpeedShoe + * @instance + */ + SpeedShoe.prototype.removed = false; + + /** + * SpeedShoe type. + * @member {number} type + * @memberof treasurehunterx.SpeedShoe + * @instance + */ + SpeedShoe.prototype.type = 0; + + /** + * Creates a new SpeedShoe instance using the specified properties. + * @function create + * @memberof treasurehunterx.SpeedShoe + * @static + * @param {treasurehunterx.ISpeedShoe=} [properties] Properties to set + * @returns {treasurehunterx.SpeedShoe} SpeedShoe instance + */ + SpeedShoe.create = function create(properties) { + return new SpeedShoe(properties); + }; + + /** + * Encodes the specified SpeedShoe message. Does not implicitly {@link treasurehunterx.SpeedShoe.verify|verify} messages. + * @function encode + * @memberof treasurehunterx.SpeedShoe + * @static + * @param {treasurehunterx.SpeedShoe} message SpeedShoe message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SpeedShoe.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.localIdInBattle != null && Object.hasOwnProperty.call(message, "localIdInBattle")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.localIdInBattle); + if (message.x != null && Object.hasOwnProperty.call(message, "x")) + writer.uint32(/* id 3, wireType 1 =*/25).double(message.x); + if (message.y != null && Object.hasOwnProperty.call(message, "y")) + writer.uint32(/* id 4, wireType 1 =*/33).double(message.y); + if (message.removed != null && Object.hasOwnProperty.call(message, "removed")) + writer.uint32(/* id 5, wireType 0 =*/40).bool(message.removed); + if (message.type != null && Object.hasOwnProperty.call(message, "type")) + writer.uint32(/* id 6, wireType 0 =*/48).int32(message.type); + return writer; + }; + + /** + * Encodes the specified SpeedShoe message, length delimited. Does not implicitly {@link treasurehunterx.SpeedShoe.verify|verify} messages. + * @function encodeDelimited + * @memberof treasurehunterx.SpeedShoe + * @static + * @param {treasurehunterx.SpeedShoe} message SpeedShoe message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SpeedShoe.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SpeedShoe message from the specified reader or buffer. + * @function decode + * @memberof treasurehunterx.SpeedShoe + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {treasurehunterx.SpeedShoe} SpeedShoe + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SpeedShoe.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.treasurehunterx.SpeedShoe(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.id = reader.int32(); + break; + } + case 2: { + message.localIdInBattle = reader.int32(); + break; + } + case 3: { + message.x = reader.double(); + break; + } + case 4: { + message.y = reader.double(); + break; + } + case 5: { + message.removed = reader.bool(); + break; + } + case 6: { + message.type = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SpeedShoe message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof treasurehunterx.SpeedShoe + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {treasurehunterx.SpeedShoe} SpeedShoe + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SpeedShoe.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SpeedShoe message. + * @function verify + * @memberof treasurehunterx.SpeedShoe + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SpeedShoe.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.id != null && message.hasOwnProperty("id")) + if (!$util.isInteger(message.id)) + return "id: integer expected"; + if (message.localIdInBattle != null && message.hasOwnProperty("localIdInBattle")) + if (!$util.isInteger(message.localIdInBattle)) + return "localIdInBattle: integer expected"; + if (message.x != null && message.hasOwnProperty("x")) + if (typeof message.x !== "number") + return "x: number expected"; + if (message.y != null && message.hasOwnProperty("y")) + if (typeof message.y !== "number") + return "y: number expected"; + if (message.removed != null && message.hasOwnProperty("removed")) + if (typeof message.removed !== "boolean") + return "removed: boolean expected"; + if (message.type != null && message.hasOwnProperty("type")) + if (!$util.isInteger(message.type)) + return "type: integer expected"; + return null; + }; + + /** + * Creates a SpeedShoe message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof treasurehunterx.SpeedShoe + * @static + * @param {Object.} object Plain object + * @returns {treasurehunterx.SpeedShoe} SpeedShoe + */ + SpeedShoe.fromObject = function fromObject(object) { + if (object instanceof $root.treasurehunterx.SpeedShoe) + return object; + var message = new $root.treasurehunterx.SpeedShoe(); + if (object.id != null) + message.id = object.id | 0; + if (object.localIdInBattle != null) + message.localIdInBattle = object.localIdInBattle | 0; + if (object.x != null) + message.x = Number(object.x); + if (object.y != null) + message.y = Number(object.y); + if (object.removed != null) + message.removed = Boolean(object.removed); + if (object.type != null) + message.type = object.type | 0; + return message; + }; + + /** + * Creates a plain object from a SpeedShoe message. Also converts values to other types if specified. + * @function toObject + * @memberof treasurehunterx.SpeedShoe + * @static + * @param {treasurehunterx.SpeedShoe} message SpeedShoe + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SpeedShoe.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.id = 0; + object.localIdInBattle = 0; + object.x = 0; + object.y = 0; + object.removed = false; + object.type = 0; + } + if (message.id != null && message.hasOwnProperty("id")) + object.id = message.id; + if (message.localIdInBattle != null && message.hasOwnProperty("localIdInBattle")) + object.localIdInBattle = message.localIdInBattle; + if (message.x != null && message.hasOwnProperty("x")) + object.x = options.json && !isFinite(message.x) ? String(message.x) : message.x; + if (message.y != null && message.hasOwnProperty("y")) + object.y = options.json && !isFinite(message.y) ? String(message.y) : message.y; + if (message.removed != null && message.hasOwnProperty("removed")) + object.removed = message.removed; + if (message.type != null && message.hasOwnProperty("type")) + object.type = message.type; + return object; + }; + + /** + * Converts this SpeedShoe to JSON. + * @function toJSON + * @memberof treasurehunterx.SpeedShoe + * @instance + * @returns {Object.} JSON object + */ + SpeedShoe.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for SpeedShoe + * @function getTypeUrl + * @memberof treasurehunterx.SpeedShoe + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + SpeedShoe.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/treasurehunterx.SpeedShoe"; + }; + + return SpeedShoe; + })(); + + treasurehunterx.Pumpkin = (function() { + + /** + * Properties of a Pumpkin. + * @memberof treasurehunterx + * @interface IPumpkin + * @property {number|null} [localIdInBattle] Pumpkin localIdInBattle + * @property {number|null} [linearSpeed] Pumpkin linearSpeed + * @property {number|null} [x] Pumpkin x + * @property {number|null} [y] Pumpkin y + * @property {boolean|null} [removed] Pumpkin removed + */ + + /** + * Constructs a new Pumpkin. + * @memberof treasurehunterx + * @classdesc Represents a Pumpkin. + * @implements IPumpkin + * @constructor + * @param {treasurehunterx.IPumpkin=} [properties] Properties to set + */ + function Pumpkin(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]]; + } + + /** + * Pumpkin localIdInBattle. + * @member {number} localIdInBattle + * @memberof treasurehunterx.Pumpkin + * @instance + */ + Pumpkin.prototype.localIdInBattle = 0; + + /** + * Pumpkin linearSpeed. + * @member {number} linearSpeed + * @memberof treasurehunterx.Pumpkin + * @instance + */ + Pumpkin.prototype.linearSpeed = 0; + + /** + * Pumpkin x. + * @member {number} x + * @memberof treasurehunterx.Pumpkin + * @instance + */ + Pumpkin.prototype.x = 0; + + /** + * Pumpkin y. + * @member {number} y + * @memberof treasurehunterx.Pumpkin + * @instance + */ + Pumpkin.prototype.y = 0; + + /** + * Pumpkin removed. + * @member {boolean} removed + * @memberof treasurehunterx.Pumpkin + * @instance + */ + Pumpkin.prototype.removed = false; + + /** + * Creates a new Pumpkin instance using the specified properties. + * @function create + * @memberof treasurehunterx.Pumpkin + * @static + * @param {treasurehunterx.IPumpkin=} [properties] Properties to set + * @returns {treasurehunterx.Pumpkin} Pumpkin instance + */ + Pumpkin.create = function create(properties) { + return new Pumpkin(properties); + }; + + /** + * Encodes the specified Pumpkin message. Does not implicitly {@link treasurehunterx.Pumpkin.verify|verify} messages. + * @function encode + * @memberof treasurehunterx.Pumpkin + * @static + * @param {treasurehunterx.Pumpkin} message Pumpkin message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Pumpkin.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.localIdInBattle != null && Object.hasOwnProperty.call(message, "localIdInBattle")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.localIdInBattle); + if (message.linearSpeed != null && Object.hasOwnProperty.call(message, "linearSpeed")) + writer.uint32(/* id 2, wireType 1 =*/17).double(message.linearSpeed); + if (message.x != null && Object.hasOwnProperty.call(message, "x")) + writer.uint32(/* id 3, wireType 1 =*/25).double(message.x); + if (message.y != null && Object.hasOwnProperty.call(message, "y")) + writer.uint32(/* id 4, wireType 1 =*/33).double(message.y); + if (message.removed != null && Object.hasOwnProperty.call(message, "removed")) + writer.uint32(/* id 5, wireType 0 =*/40).bool(message.removed); + return writer; + }; + + /** + * Encodes the specified Pumpkin message, length delimited. Does not implicitly {@link treasurehunterx.Pumpkin.verify|verify} messages. + * @function encodeDelimited + * @memberof treasurehunterx.Pumpkin + * @static + * @param {treasurehunterx.Pumpkin} message Pumpkin message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Pumpkin.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Pumpkin message from the specified reader or buffer. + * @function decode + * @memberof treasurehunterx.Pumpkin + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {treasurehunterx.Pumpkin} Pumpkin + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Pumpkin.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.treasurehunterx.Pumpkin(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.localIdInBattle = reader.int32(); + break; + } + case 2: { + message.linearSpeed = reader.double(); + break; + } + case 3: { + message.x = reader.double(); + break; + } + case 4: { + message.y = reader.double(); + break; + } + case 5: { + message.removed = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Pumpkin message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof treasurehunterx.Pumpkin + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {treasurehunterx.Pumpkin} Pumpkin + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Pumpkin.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Pumpkin message. + * @function verify + * @memberof treasurehunterx.Pumpkin + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Pumpkin.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.localIdInBattle != null && message.hasOwnProperty("localIdInBattle")) + if (!$util.isInteger(message.localIdInBattle)) + return "localIdInBattle: integer expected"; + if (message.linearSpeed != null && message.hasOwnProperty("linearSpeed")) + if (typeof message.linearSpeed !== "number") + return "linearSpeed: number expected"; + if (message.x != null && message.hasOwnProperty("x")) + if (typeof message.x !== "number") + return "x: number expected"; + if (message.y != null && message.hasOwnProperty("y")) + if (typeof message.y !== "number") + return "y: number expected"; + if (message.removed != null && message.hasOwnProperty("removed")) + if (typeof message.removed !== "boolean") + return "removed: boolean expected"; + return null; + }; + + /** + * Creates a Pumpkin message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof treasurehunterx.Pumpkin + * @static + * @param {Object.} object Plain object + * @returns {treasurehunterx.Pumpkin} Pumpkin + */ + Pumpkin.fromObject = function fromObject(object) { + if (object instanceof $root.treasurehunterx.Pumpkin) + return object; + var message = new $root.treasurehunterx.Pumpkin(); + if (object.localIdInBattle != null) + message.localIdInBattle = object.localIdInBattle | 0; + if (object.linearSpeed != null) + message.linearSpeed = Number(object.linearSpeed); + if (object.x != null) + message.x = Number(object.x); + if (object.y != null) + message.y = Number(object.y); + if (object.removed != null) + message.removed = Boolean(object.removed); + return message; + }; + + /** + * Creates a plain object from a Pumpkin message. Also converts values to other types if specified. + * @function toObject + * @memberof treasurehunterx.Pumpkin + * @static + * @param {treasurehunterx.Pumpkin} message Pumpkin + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Pumpkin.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.localIdInBattle = 0; + object.linearSpeed = 0; + object.x = 0; + object.y = 0; + object.removed = false; + } + if (message.localIdInBattle != null && message.hasOwnProperty("localIdInBattle")) + object.localIdInBattle = message.localIdInBattle; + if (message.linearSpeed != null && message.hasOwnProperty("linearSpeed")) + object.linearSpeed = options.json && !isFinite(message.linearSpeed) ? String(message.linearSpeed) : message.linearSpeed; + if (message.x != null && message.hasOwnProperty("x")) + object.x = options.json && !isFinite(message.x) ? String(message.x) : message.x; + if (message.y != null && message.hasOwnProperty("y")) + object.y = options.json && !isFinite(message.y) ? String(message.y) : message.y; + if (message.removed != null && message.hasOwnProperty("removed")) + object.removed = message.removed; + return object; + }; + + /** + * Converts this Pumpkin to JSON. + * @function toJSON + * @memberof treasurehunterx.Pumpkin + * @instance + * @returns {Object.} JSON object + */ + Pumpkin.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Pumpkin + * @function getTypeUrl + * @memberof treasurehunterx.Pumpkin + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Pumpkin.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/treasurehunterx.Pumpkin"; + }; + + return Pumpkin; + })(); + + treasurehunterx.GuardTower = (function() { + + /** + * Properties of a GuardTower. + * @memberof treasurehunterx + * @interface IGuardTower + * @property {number|null} [id] GuardTower id + * @property {number|null} [localIdInBattle] GuardTower localIdInBattle + * @property {number|null} [type] GuardTower type + * @property {number|null} [x] GuardTower x + * @property {number|null} [y] GuardTower y + * @property {boolean|null} [removed] GuardTower removed + */ + + /** + * Constructs a new GuardTower. + * @memberof treasurehunterx + * @classdesc Represents a GuardTower. + * @implements IGuardTower + * @constructor + * @param {treasurehunterx.IGuardTower=} [properties] Properties to set + */ + function GuardTower(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]]; + } + + /** + * GuardTower id. + * @member {number} id + * @memberof treasurehunterx.GuardTower + * @instance + */ + GuardTower.prototype.id = 0; + + /** + * GuardTower localIdInBattle. + * @member {number} localIdInBattle + * @memberof treasurehunterx.GuardTower + * @instance + */ + GuardTower.prototype.localIdInBattle = 0; + + /** + * GuardTower type. + * @member {number} type + * @memberof treasurehunterx.GuardTower + * @instance + */ + GuardTower.prototype.type = 0; + + /** + * GuardTower x. + * @member {number} x + * @memberof treasurehunterx.GuardTower + * @instance + */ + GuardTower.prototype.x = 0; + + /** + * GuardTower y. + * @member {number} y + * @memberof treasurehunterx.GuardTower + * @instance + */ + GuardTower.prototype.y = 0; + + /** + * GuardTower removed. + * @member {boolean} removed + * @memberof treasurehunterx.GuardTower + * @instance + */ + GuardTower.prototype.removed = false; + + /** + * Creates a new GuardTower instance using the specified properties. + * @function create + * @memberof treasurehunterx.GuardTower + * @static + * @param {treasurehunterx.IGuardTower=} [properties] Properties to set + * @returns {treasurehunterx.GuardTower} GuardTower instance + */ + GuardTower.create = function create(properties) { + return new GuardTower(properties); + }; + + /** + * Encodes the specified GuardTower message. Does not implicitly {@link treasurehunterx.GuardTower.verify|verify} messages. + * @function encode + * @memberof treasurehunterx.GuardTower + * @static + * @param {treasurehunterx.GuardTower} message GuardTower message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GuardTower.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.localIdInBattle != null && Object.hasOwnProperty.call(message, "localIdInBattle")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.localIdInBattle); + if (message.type != null && Object.hasOwnProperty.call(message, "type")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.type); + if (message.x != null && Object.hasOwnProperty.call(message, "x")) + writer.uint32(/* id 4, wireType 1 =*/33).double(message.x); + if (message.y != null && Object.hasOwnProperty.call(message, "y")) + writer.uint32(/* id 5, wireType 1 =*/41).double(message.y); + if (message.removed != null && Object.hasOwnProperty.call(message, "removed")) + writer.uint32(/* id 6, wireType 0 =*/48).bool(message.removed); + return writer; + }; + + /** + * Encodes the specified GuardTower message, length delimited. Does not implicitly {@link treasurehunterx.GuardTower.verify|verify} messages. + * @function encodeDelimited + * @memberof treasurehunterx.GuardTower + * @static + * @param {treasurehunterx.GuardTower} message GuardTower message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GuardTower.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GuardTower message from the specified reader or buffer. + * @function decode + * @memberof treasurehunterx.GuardTower + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {treasurehunterx.GuardTower} GuardTower + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GuardTower.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.treasurehunterx.GuardTower(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.id = reader.int32(); + break; + } + case 2: { + message.localIdInBattle = reader.int32(); + break; + } + case 3: { + message.type = reader.int32(); + break; + } + case 4: { + message.x = reader.double(); + break; + } + case 5: { + message.y = reader.double(); + break; + } + case 6: { + message.removed = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GuardTower message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof treasurehunterx.GuardTower + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {treasurehunterx.GuardTower} GuardTower + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GuardTower.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GuardTower message. + * @function verify + * @memberof treasurehunterx.GuardTower + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GuardTower.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.id != null && message.hasOwnProperty("id")) + if (!$util.isInteger(message.id)) + return "id: integer expected"; + if (message.localIdInBattle != null && message.hasOwnProperty("localIdInBattle")) + if (!$util.isInteger(message.localIdInBattle)) + return "localIdInBattle: integer expected"; + if (message.type != null && message.hasOwnProperty("type")) + if (!$util.isInteger(message.type)) + return "type: integer expected"; + if (message.x != null && message.hasOwnProperty("x")) + if (typeof message.x !== "number") + return "x: number expected"; + if (message.y != null && message.hasOwnProperty("y")) + if (typeof message.y !== "number") + return "y: number expected"; + if (message.removed != null && message.hasOwnProperty("removed")) + if (typeof message.removed !== "boolean") + return "removed: boolean expected"; + return null; + }; + + /** + * Creates a GuardTower message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof treasurehunterx.GuardTower + * @static + * @param {Object.} object Plain object + * @returns {treasurehunterx.GuardTower} GuardTower + */ + GuardTower.fromObject = function fromObject(object) { + if (object instanceof $root.treasurehunterx.GuardTower) + return object; + var message = new $root.treasurehunterx.GuardTower(); + if (object.id != null) + message.id = object.id | 0; + if (object.localIdInBattle != null) + message.localIdInBattle = object.localIdInBattle | 0; + if (object.type != null) + message.type = object.type | 0; + if (object.x != null) + message.x = Number(object.x); + if (object.y != null) + message.y = Number(object.y); + if (object.removed != null) + message.removed = Boolean(object.removed); + return message; + }; + + /** + * Creates a plain object from a GuardTower message. Also converts values to other types if specified. + * @function toObject + * @memberof treasurehunterx.GuardTower + * @static + * @param {treasurehunterx.GuardTower} message GuardTower + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GuardTower.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.id = 0; + object.localIdInBattle = 0; + object.type = 0; + object.x = 0; + object.y = 0; + object.removed = false; + } + if (message.id != null && message.hasOwnProperty("id")) + object.id = message.id; + if (message.localIdInBattle != null && message.hasOwnProperty("localIdInBattle")) + object.localIdInBattle = message.localIdInBattle; + if (message.type != null && message.hasOwnProperty("type")) + object.type = message.type; + if (message.x != null && message.hasOwnProperty("x")) + object.x = options.json && !isFinite(message.x) ? String(message.x) : message.x; + if (message.y != null && message.hasOwnProperty("y")) + object.y = options.json && !isFinite(message.y) ? String(message.y) : message.y; + if (message.removed != null && message.hasOwnProperty("removed")) + object.removed = message.removed; + return object; + }; + + /** + * Converts this GuardTower to JSON. + * @function toJSON + * @memberof treasurehunterx.GuardTower + * @instance + * @returns {Object.} JSON object + */ + GuardTower.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for GuardTower + * @function getTypeUrl + * @memberof treasurehunterx.GuardTower + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + GuardTower.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/treasurehunterx.GuardTower"; + }; + + return GuardTower; + })(); + + treasurehunterx.RoomDownsyncFrame = (function() { + + /** + * Properties of a RoomDownsyncFrame. + * @memberof treasurehunterx + * @interface IRoomDownsyncFrame + * @property {number|null} [id] RoomDownsyncFrame id + * @property {number|null} [refFrameId] RoomDownsyncFrame refFrameId + * @property {Object.|null} [players] RoomDownsyncFrame players + * @property {number|Long|null} [sentAt] RoomDownsyncFrame sentAt + * @property {number|Long|null} [countdownNanos] RoomDownsyncFrame countdownNanos + * @property {Object.|null} [treasures] RoomDownsyncFrame treasures + * @property {Object.|null} [traps] RoomDownsyncFrame traps + * @property {Object.|null} [bullets] RoomDownsyncFrame bullets + * @property {Object.|null} [speedShoes] RoomDownsyncFrame speedShoes + * @property {Object.|null} [pumpkin] RoomDownsyncFrame pumpkin + * @property {Object.|null} [guardTowers] RoomDownsyncFrame guardTowers + * @property {Object.|null} [playerMetas] RoomDownsyncFrame playerMetas + */ + + /** + * Constructs a new RoomDownsyncFrame. + * @memberof treasurehunterx + * @classdesc Represents a RoomDownsyncFrame. + * @implements IRoomDownsyncFrame + * @constructor + * @param {treasurehunterx.IRoomDownsyncFrame=} [properties] Properties to set + */ + function RoomDownsyncFrame(properties) { + this.players = {}; + this.treasures = {}; + this.traps = {}; + this.bullets = {}; + this.speedShoes = {}; + this.pumpkin = {}; + this.guardTowers = {}; + this.playerMetas = {}; + 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]]; + } + + /** + * RoomDownsyncFrame id. + * @member {number} id + * @memberof treasurehunterx.RoomDownsyncFrame + * @instance + */ + RoomDownsyncFrame.prototype.id = 0; + + /** + * RoomDownsyncFrame refFrameId. + * @member {number} refFrameId + * @memberof treasurehunterx.RoomDownsyncFrame + * @instance + */ + RoomDownsyncFrame.prototype.refFrameId = 0; + + /** + * RoomDownsyncFrame players. + * @member {Object.} players + * @memberof treasurehunterx.RoomDownsyncFrame + * @instance + */ + RoomDownsyncFrame.prototype.players = $util.emptyObject; + + /** + * RoomDownsyncFrame sentAt. + * @member {number|Long} sentAt + * @memberof treasurehunterx.RoomDownsyncFrame + * @instance + */ + RoomDownsyncFrame.prototype.sentAt = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * RoomDownsyncFrame countdownNanos. + * @member {number|Long} countdownNanos + * @memberof treasurehunterx.RoomDownsyncFrame + * @instance + */ + RoomDownsyncFrame.prototype.countdownNanos = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * RoomDownsyncFrame treasures. + * @member {Object.} treasures + * @memberof treasurehunterx.RoomDownsyncFrame + * @instance + */ + RoomDownsyncFrame.prototype.treasures = $util.emptyObject; + + /** + * RoomDownsyncFrame traps. + * @member {Object.} traps + * @memberof treasurehunterx.RoomDownsyncFrame + * @instance + */ + RoomDownsyncFrame.prototype.traps = $util.emptyObject; + + /** + * RoomDownsyncFrame bullets. + * @member {Object.} bullets + * @memberof treasurehunterx.RoomDownsyncFrame + * @instance + */ + RoomDownsyncFrame.prototype.bullets = $util.emptyObject; + + /** + * RoomDownsyncFrame speedShoes. + * @member {Object.} speedShoes + * @memberof treasurehunterx.RoomDownsyncFrame + * @instance + */ + RoomDownsyncFrame.prototype.speedShoes = $util.emptyObject; + + /** + * RoomDownsyncFrame pumpkin. + * @member {Object.} pumpkin + * @memberof treasurehunterx.RoomDownsyncFrame + * @instance + */ + RoomDownsyncFrame.prototype.pumpkin = $util.emptyObject; + + /** + * RoomDownsyncFrame guardTowers. + * @member {Object.} guardTowers + * @memberof treasurehunterx.RoomDownsyncFrame + * @instance + */ + RoomDownsyncFrame.prototype.guardTowers = $util.emptyObject; + + /** + * RoomDownsyncFrame playerMetas. + * @member {Object.} playerMetas + * @memberof treasurehunterx.RoomDownsyncFrame + * @instance + */ + RoomDownsyncFrame.prototype.playerMetas = $util.emptyObject; + + /** + * Creates a new RoomDownsyncFrame instance using the specified properties. + * @function create + * @memberof treasurehunterx.RoomDownsyncFrame + * @static + * @param {treasurehunterx.IRoomDownsyncFrame=} [properties] Properties to set + * @returns {treasurehunterx.RoomDownsyncFrame} RoomDownsyncFrame instance + */ + RoomDownsyncFrame.create = function create(properties) { + return new RoomDownsyncFrame(properties); + }; + + /** + * Encodes the specified RoomDownsyncFrame message. Does not implicitly {@link treasurehunterx.RoomDownsyncFrame.verify|verify} messages. + * @function encode + * @memberof treasurehunterx.RoomDownsyncFrame + * @static + * @param {treasurehunterx.RoomDownsyncFrame} message RoomDownsyncFrame message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RoomDownsyncFrame.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.refFrameId != null && Object.hasOwnProperty.call(message, "refFrameId")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.refFrameId); + if (message.players != null && Object.hasOwnProperty.call(message, "players")) + for (var keys = Object.keys(message.players), i = 0; i < keys.length; ++i) { + writer.uint32(/* id 3, wireType 2 =*/26).fork().uint32(/* id 1, wireType 0 =*/8).int32(keys[i]); + $root.treasurehunterx.Player.encode(message.players[keys[i]], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim().ldelim(); + } + if (message.sentAt != null && Object.hasOwnProperty.call(message, "sentAt")) + writer.uint32(/* id 4, wireType 0 =*/32).int64(message.sentAt); + if (message.countdownNanos != null && Object.hasOwnProperty.call(message, "countdownNanos")) + writer.uint32(/* id 5, wireType 0 =*/40).int64(message.countdownNanos); + if (message.treasures != null && Object.hasOwnProperty.call(message, "treasures")) + for (var keys = Object.keys(message.treasures), i = 0; i < keys.length; ++i) { + writer.uint32(/* id 6, wireType 2 =*/50).fork().uint32(/* id 1, wireType 0 =*/8).int32(keys[i]); + $root.treasurehunterx.Treasure.encode(message.treasures[keys[i]], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim().ldelim(); + } + if (message.traps != null && Object.hasOwnProperty.call(message, "traps")) + for (var keys = Object.keys(message.traps), i = 0; i < keys.length; ++i) { + writer.uint32(/* id 7, wireType 2 =*/58).fork().uint32(/* id 1, wireType 0 =*/8).int32(keys[i]); + $root.treasurehunterx.Trap.encode(message.traps[keys[i]], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim().ldelim(); + } + if (message.bullets != null && Object.hasOwnProperty.call(message, "bullets")) + for (var keys = Object.keys(message.bullets), i = 0; i < keys.length; ++i) { + writer.uint32(/* id 8, wireType 2 =*/66).fork().uint32(/* id 1, wireType 0 =*/8).int32(keys[i]); + $root.treasurehunterx.Bullet.encode(message.bullets[keys[i]], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim().ldelim(); + } + if (message.speedShoes != null && Object.hasOwnProperty.call(message, "speedShoes")) + for (var keys = Object.keys(message.speedShoes), i = 0; i < keys.length; ++i) { + writer.uint32(/* id 9, wireType 2 =*/74).fork().uint32(/* id 1, wireType 0 =*/8).int32(keys[i]); + $root.treasurehunterx.SpeedShoe.encode(message.speedShoes[keys[i]], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim().ldelim(); + } + if (message.pumpkin != null && Object.hasOwnProperty.call(message, "pumpkin")) + for (var keys = Object.keys(message.pumpkin), i = 0; i < keys.length; ++i) { + writer.uint32(/* id 10, wireType 2 =*/82).fork().uint32(/* id 1, wireType 0 =*/8).int32(keys[i]); + $root.treasurehunterx.Pumpkin.encode(message.pumpkin[keys[i]], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim().ldelim(); + } + if (message.guardTowers != null && Object.hasOwnProperty.call(message, "guardTowers")) + for (var keys = Object.keys(message.guardTowers), i = 0; i < keys.length; ++i) { + writer.uint32(/* id 11, wireType 2 =*/90).fork().uint32(/* id 1, wireType 0 =*/8).int32(keys[i]); + $root.treasurehunterx.GuardTower.encode(message.guardTowers[keys[i]], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim().ldelim(); + } + if (message.playerMetas != null && Object.hasOwnProperty.call(message, "playerMetas")) + for (var keys = Object.keys(message.playerMetas), i = 0; i < keys.length; ++i) { + writer.uint32(/* id 12, wireType 2 =*/98).fork().uint32(/* id 1, wireType 0 =*/8).int32(keys[i]); + $root.treasurehunterx.PlayerMeta.encode(message.playerMetas[keys[i]], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim().ldelim(); + } + return writer; + }; + + /** + * Encodes the specified RoomDownsyncFrame message, length delimited. Does not implicitly {@link treasurehunterx.RoomDownsyncFrame.verify|verify} messages. + * @function encodeDelimited + * @memberof treasurehunterx.RoomDownsyncFrame + * @static + * @param {treasurehunterx.RoomDownsyncFrame} message RoomDownsyncFrame message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RoomDownsyncFrame.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RoomDownsyncFrame message from the specified reader or buffer. + * @function decode + * @memberof treasurehunterx.RoomDownsyncFrame + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {treasurehunterx.RoomDownsyncFrame} RoomDownsyncFrame + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RoomDownsyncFrame.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.treasurehunterx.RoomDownsyncFrame(), key, value; + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.id = reader.int32(); + break; + } + case 2: { + message.refFrameId = reader.int32(); + break; + } + case 3: { + if (message.players === $util.emptyObject) + message.players = {}; + var end2 = reader.uint32() + reader.pos; + key = 0; + value = null; + while (reader.pos < end2) { + var tag2 = reader.uint32(); + switch (tag2 >>> 3) { + case 1: + key = reader.int32(); + break; + case 2: + value = $root.treasurehunterx.Player.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.players[key] = value; + break; + } + case 4: { + message.sentAt = reader.int64(); + break; + } + case 5: { + message.countdownNanos = reader.int64(); + break; + } + case 6: { + if (message.treasures === $util.emptyObject) + message.treasures = {}; + var end2 = reader.uint32() + reader.pos; + key = 0; + value = null; + while (reader.pos < end2) { + var tag2 = reader.uint32(); + switch (tag2 >>> 3) { + case 1: + key = reader.int32(); + break; + case 2: + value = $root.treasurehunterx.Treasure.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.treasures[key] = value; + break; + } + case 7: { + if (message.traps === $util.emptyObject) + message.traps = {}; + var end2 = reader.uint32() + reader.pos; + key = 0; + value = null; + while (reader.pos < end2) { + var tag2 = reader.uint32(); + switch (tag2 >>> 3) { + case 1: + key = reader.int32(); + break; + case 2: + value = $root.treasurehunterx.Trap.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.traps[key] = value; + break; + } + case 8: { + if (message.bullets === $util.emptyObject) + message.bullets = {}; + var end2 = reader.uint32() + reader.pos; + key = 0; + value = null; + while (reader.pos < end2) { + var tag2 = reader.uint32(); + switch (tag2 >>> 3) { + case 1: + key = reader.int32(); + break; + case 2: + value = $root.treasurehunterx.Bullet.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.bullets[key] = value; + break; + } + case 9: { + if (message.speedShoes === $util.emptyObject) + message.speedShoes = {}; + var end2 = reader.uint32() + reader.pos; + key = 0; + value = null; + while (reader.pos < end2) { + var tag2 = reader.uint32(); + switch (tag2 >>> 3) { + case 1: + key = reader.int32(); + break; + case 2: + value = $root.treasurehunterx.SpeedShoe.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.speedShoes[key] = value; + break; + } + case 10: { + if (message.pumpkin === $util.emptyObject) + message.pumpkin = {}; + var end2 = reader.uint32() + reader.pos; + key = 0; + value = null; + while (reader.pos < end2) { + var tag2 = reader.uint32(); + switch (tag2 >>> 3) { + case 1: + key = reader.int32(); + break; + case 2: + value = $root.treasurehunterx.Pumpkin.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.pumpkin[key] = value; + break; + } + case 11: { + if (message.guardTowers === $util.emptyObject) + message.guardTowers = {}; + var end2 = reader.uint32() + reader.pos; + key = 0; + value = null; + while (reader.pos < end2) { + var tag2 = reader.uint32(); + switch (tag2 >>> 3) { + case 1: + key = reader.int32(); + break; + case 2: + value = $root.treasurehunterx.GuardTower.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.guardTowers[key] = value; + break; + } + case 12: { + if (message.playerMetas === $util.emptyObject) + message.playerMetas = {}; + var end2 = reader.uint32() + reader.pos; + key = 0; + value = null; + while (reader.pos < end2) { + var tag2 = reader.uint32(); + switch (tag2 >>> 3) { + case 1: + key = reader.int32(); + break; + case 2: + value = $root.treasurehunterx.PlayerMeta.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.playerMetas[key] = value; + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RoomDownsyncFrame message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof treasurehunterx.RoomDownsyncFrame + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {treasurehunterx.RoomDownsyncFrame} RoomDownsyncFrame + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RoomDownsyncFrame.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RoomDownsyncFrame message. + * @function verify + * @memberof treasurehunterx.RoomDownsyncFrame + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RoomDownsyncFrame.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.id != null && message.hasOwnProperty("id")) + if (!$util.isInteger(message.id)) + return "id: integer expected"; + if (message.refFrameId != null && message.hasOwnProperty("refFrameId")) + if (!$util.isInteger(message.refFrameId)) + return "refFrameId: integer expected"; + if (message.players != null && message.hasOwnProperty("players")) { + if (!$util.isObject(message.players)) + return "players: object expected"; + var key = Object.keys(message.players); + for (var i = 0; i < key.length; ++i) { + if (!$util.key32Re.test(key[i])) + return "players: integer key{k:int32} expected"; + { + var error = $root.treasurehunterx.Player.verify(message.players[key[i]]); + if (error) + return "players." + error; + } + } + } + if (message.sentAt != null && message.hasOwnProperty("sentAt")) + if (!$util.isInteger(message.sentAt) && !(message.sentAt && $util.isInteger(message.sentAt.low) && $util.isInteger(message.sentAt.high))) + return "sentAt: integer|Long expected"; + if (message.countdownNanos != null && message.hasOwnProperty("countdownNanos")) + if (!$util.isInteger(message.countdownNanos) && !(message.countdownNanos && $util.isInteger(message.countdownNanos.low) && $util.isInteger(message.countdownNanos.high))) + return "countdownNanos: integer|Long expected"; + if (message.treasures != null && message.hasOwnProperty("treasures")) { + if (!$util.isObject(message.treasures)) + return "treasures: object expected"; + var key = Object.keys(message.treasures); + for (var i = 0; i < key.length; ++i) { + if (!$util.key32Re.test(key[i])) + return "treasures: integer key{k:int32} expected"; + { + var error = $root.treasurehunterx.Treasure.verify(message.treasures[key[i]]); + if (error) + return "treasures." + error; + } + } + } + if (message.traps != null && message.hasOwnProperty("traps")) { + if (!$util.isObject(message.traps)) + return "traps: object expected"; + var key = Object.keys(message.traps); + for (var i = 0; i < key.length; ++i) { + if (!$util.key32Re.test(key[i])) + return "traps: integer key{k:int32} expected"; + { + var error = $root.treasurehunterx.Trap.verify(message.traps[key[i]]); + if (error) + return "traps." + error; + } + } + } + if (message.bullets != null && message.hasOwnProperty("bullets")) { + if (!$util.isObject(message.bullets)) + return "bullets: object expected"; + var key = Object.keys(message.bullets); + for (var i = 0; i < key.length; ++i) { + if (!$util.key32Re.test(key[i])) + return "bullets: integer key{k:int32} expected"; + { + var error = $root.treasurehunterx.Bullet.verify(message.bullets[key[i]]); + if (error) + return "bullets." + error; + } + } + } + if (message.speedShoes != null && message.hasOwnProperty("speedShoes")) { + if (!$util.isObject(message.speedShoes)) + return "speedShoes: object expected"; + var key = Object.keys(message.speedShoes); + for (var i = 0; i < key.length; ++i) { + if (!$util.key32Re.test(key[i])) + return "speedShoes: integer key{k:int32} expected"; + { + var error = $root.treasurehunterx.SpeedShoe.verify(message.speedShoes[key[i]]); + if (error) + return "speedShoes." + error; + } + } + } + if (message.pumpkin != null && message.hasOwnProperty("pumpkin")) { + if (!$util.isObject(message.pumpkin)) + return "pumpkin: object expected"; + var key = Object.keys(message.pumpkin); + for (var i = 0; i < key.length; ++i) { + if (!$util.key32Re.test(key[i])) + return "pumpkin: integer key{k:int32} expected"; + { + var error = $root.treasurehunterx.Pumpkin.verify(message.pumpkin[key[i]]); + if (error) + return "pumpkin." + error; + } + } + } + if (message.guardTowers != null && message.hasOwnProperty("guardTowers")) { + if (!$util.isObject(message.guardTowers)) + return "guardTowers: object expected"; + var key = Object.keys(message.guardTowers); + for (var i = 0; i < key.length; ++i) { + if (!$util.key32Re.test(key[i])) + return "guardTowers: integer key{k:int32} expected"; + { + var error = $root.treasurehunterx.GuardTower.verify(message.guardTowers[key[i]]); + if (error) + return "guardTowers." + error; + } + } + } + if (message.playerMetas != null && message.hasOwnProperty("playerMetas")) { + if (!$util.isObject(message.playerMetas)) + return "playerMetas: object expected"; + var key = Object.keys(message.playerMetas); + for (var i = 0; i < key.length; ++i) { + if (!$util.key32Re.test(key[i])) + return "playerMetas: integer key{k:int32} expected"; + { + var error = $root.treasurehunterx.PlayerMeta.verify(message.playerMetas[key[i]]); + if (error) + return "playerMetas." + error; + } + } + } + return null; + }; + + /** + * Creates a RoomDownsyncFrame message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof treasurehunterx.RoomDownsyncFrame + * @static + * @param {Object.} object Plain object + * @returns {treasurehunterx.RoomDownsyncFrame} RoomDownsyncFrame + */ + RoomDownsyncFrame.fromObject = function fromObject(object) { + if (object instanceof $root.treasurehunterx.RoomDownsyncFrame) + return object; + var message = new $root.treasurehunterx.RoomDownsyncFrame(); + if (object.id != null) + message.id = object.id | 0; + if (object.refFrameId != null) + message.refFrameId = object.refFrameId | 0; + if (object.players) { + if (typeof object.players !== "object") + throw TypeError(".treasurehunterx.RoomDownsyncFrame.players: object expected"); + message.players = {}; + for (var keys = Object.keys(object.players), i = 0; i < keys.length; ++i) { + if (typeof object.players[keys[i]] !== "object") + throw TypeError(".treasurehunterx.RoomDownsyncFrame.players: object expected"); + message.players[keys[i]] = $root.treasurehunterx.Player.fromObject(object.players[keys[i]]); + } + } + if (object.sentAt != null) + if ($util.Long) + (message.sentAt = $util.Long.fromValue(object.sentAt)).unsigned = false; + else if (typeof object.sentAt === "string") + message.sentAt = parseInt(object.sentAt, 10); + else if (typeof object.sentAt === "number") + message.sentAt = object.sentAt; + else if (typeof object.sentAt === "object") + message.sentAt = new $util.LongBits(object.sentAt.low >>> 0, object.sentAt.high >>> 0).toNumber(); + if (object.countdownNanos != null) + if ($util.Long) + (message.countdownNanos = $util.Long.fromValue(object.countdownNanos)).unsigned = false; + else if (typeof object.countdownNanos === "string") + message.countdownNanos = parseInt(object.countdownNanos, 10); + else if (typeof object.countdownNanos === "number") + message.countdownNanos = object.countdownNanos; + else if (typeof object.countdownNanos === "object") + message.countdownNanos = new $util.LongBits(object.countdownNanos.low >>> 0, object.countdownNanos.high >>> 0).toNumber(); + if (object.treasures) { + if (typeof object.treasures !== "object") + throw TypeError(".treasurehunterx.RoomDownsyncFrame.treasures: object expected"); + message.treasures = {}; + for (var keys = Object.keys(object.treasures), i = 0; i < keys.length; ++i) { + if (typeof object.treasures[keys[i]] !== "object") + throw TypeError(".treasurehunterx.RoomDownsyncFrame.treasures: object expected"); + message.treasures[keys[i]] = $root.treasurehunterx.Treasure.fromObject(object.treasures[keys[i]]); + } + } + if (object.traps) { + if (typeof object.traps !== "object") + throw TypeError(".treasurehunterx.RoomDownsyncFrame.traps: object expected"); + message.traps = {}; + for (var keys = Object.keys(object.traps), i = 0; i < keys.length; ++i) { + if (typeof object.traps[keys[i]] !== "object") + throw TypeError(".treasurehunterx.RoomDownsyncFrame.traps: object expected"); + message.traps[keys[i]] = $root.treasurehunterx.Trap.fromObject(object.traps[keys[i]]); + } + } + if (object.bullets) { + if (typeof object.bullets !== "object") + throw TypeError(".treasurehunterx.RoomDownsyncFrame.bullets: object expected"); + message.bullets = {}; + for (var keys = Object.keys(object.bullets), i = 0; i < keys.length; ++i) { + if (typeof object.bullets[keys[i]] !== "object") + throw TypeError(".treasurehunterx.RoomDownsyncFrame.bullets: object expected"); + message.bullets[keys[i]] = $root.treasurehunterx.Bullet.fromObject(object.bullets[keys[i]]); + } + } + if (object.speedShoes) { + if (typeof object.speedShoes !== "object") + throw TypeError(".treasurehunterx.RoomDownsyncFrame.speedShoes: object expected"); + message.speedShoes = {}; + for (var keys = Object.keys(object.speedShoes), i = 0; i < keys.length; ++i) { + if (typeof object.speedShoes[keys[i]] !== "object") + throw TypeError(".treasurehunterx.RoomDownsyncFrame.speedShoes: object expected"); + message.speedShoes[keys[i]] = $root.treasurehunterx.SpeedShoe.fromObject(object.speedShoes[keys[i]]); + } + } + if (object.pumpkin) { + if (typeof object.pumpkin !== "object") + throw TypeError(".treasurehunterx.RoomDownsyncFrame.pumpkin: object expected"); + message.pumpkin = {}; + for (var keys = Object.keys(object.pumpkin), i = 0; i < keys.length; ++i) { + if (typeof object.pumpkin[keys[i]] !== "object") + throw TypeError(".treasurehunterx.RoomDownsyncFrame.pumpkin: object expected"); + message.pumpkin[keys[i]] = $root.treasurehunterx.Pumpkin.fromObject(object.pumpkin[keys[i]]); + } + } + if (object.guardTowers) { + if (typeof object.guardTowers !== "object") + throw TypeError(".treasurehunterx.RoomDownsyncFrame.guardTowers: object expected"); + message.guardTowers = {}; + for (var keys = Object.keys(object.guardTowers), i = 0; i < keys.length; ++i) { + if (typeof object.guardTowers[keys[i]] !== "object") + throw TypeError(".treasurehunterx.RoomDownsyncFrame.guardTowers: object expected"); + message.guardTowers[keys[i]] = $root.treasurehunterx.GuardTower.fromObject(object.guardTowers[keys[i]]); + } + } + if (object.playerMetas) { + if (typeof object.playerMetas !== "object") + throw TypeError(".treasurehunterx.RoomDownsyncFrame.playerMetas: object expected"); + message.playerMetas = {}; + for (var keys = Object.keys(object.playerMetas), i = 0; i < keys.length; ++i) { + if (typeof object.playerMetas[keys[i]] !== "object") + throw TypeError(".treasurehunterx.RoomDownsyncFrame.playerMetas: object expected"); + message.playerMetas[keys[i]] = $root.treasurehunterx.PlayerMeta.fromObject(object.playerMetas[keys[i]]); + } + } + return message; + }; + + /** + * Creates a plain object from a RoomDownsyncFrame message. Also converts values to other types if specified. + * @function toObject + * @memberof treasurehunterx.RoomDownsyncFrame + * @static + * @param {treasurehunterx.RoomDownsyncFrame} message RoomDownsyncFrame + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RoomDownsyncFrame.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.objects || options.defaults) { + object.players = {}; + object.treasures = {}; + object.traps = {}; + object.bullets = {}; + object.speedShoes = {}; + object.pumpkin = {}; + object.guardTowers = {}; + object.playerMetas = {}; + } + if (options.defaults) { + object.id = 0; + object.refFrameId = 0; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.sentAt = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.sentAt = options.longs === String ? "0" : 0; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.countdownNanos = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.countdownNanos = options.longs === String ? "0" : 0; + } + if (message.id != null && message.hasOwnProperty("id")) + object.id = message.id; + if (message.refFrameId != null && message.hasOwnProperty("refFrameId")) + object.refFrameId = message.refFrameId; + var keys2; + if (message.players && (keys2 = Object.keys(message.players)).length) { + object.players = {}; + for (var j = 0; j < keys2.length; ++j) + object.players[keys2[j]] = $root.treasurehunterx.Player.toObject(message.players[keys2[j]], options); + } + if (message.sentAt != null && message.hasOwnProperty("sentAt")) + if (typeof message.sentAt === "number") + object.sentAt = options.longs === String ? String(message.sentAt) : message.sentAt; + else + object.sentAt = options.longs === String ? $util.Long.prototype.toString.call(message.sentAt) : options.longs === Number ? new $util.LongBits(message.sentAt.low >>> 0, message.sentAt.high >>> 0).toNumber() : message.sentAt; + if (message.countdownNanos != null && message.hasOwnProperty("countdownNanos")) + if (typeof message.countdownNanos === "number") + object.countdownNanos = options.longs === String ? String(message.countdownNanos) : message.countdownNanos; + else + object.countdownNanos = options.longs === String ? $util.Long.prototype.toString.call(message.countdownNanos) : options.longs === Number ? new $util.LongBits(message.countdownNanos.low >>> 0, message.countdownNanos.high >>> 0).toNumber() : message.countdownNanos; + if (message.treasures && (keys2 = Object.keys(message.treasures)).length) { + object.treasures = {}; + for (var j = 0; j < keys2.length; ++j) + object.treasures[keys2[j]] = $root.treasurehunterx.Treasure.toObject(message.treasures[keys2[j]], options); + } + if (message.traps && (keys2 = Object.keys(message.traps)).length) { + object.traps = {}; + for (var j = 0; j < keys2.length; ++j) + object.traps[keys2[j]] = $root.treasurehunterx.Trap.toObject(message.traps[keys2[j]], options); + } + if (message.bullets && (keys2 = Object.keys(message.bullets)).length) { + object.bullets = {}; + for (var j = 0; j < keys2.length; ++j) + object.bullets[keys2[j]] = $root.treasurehunterx.Bullet.toObject(message.bullets[keys2[j]], options); + } + if (message.speedShoes && (keys2 = Object.keys(message.speedShoes)).length) { + object.speedShoes = {}; + for (var j = 0; j < keys2.length; ++j) + object.speedShoes[keys2[j]] = $root.treasurehunterx.SpeedShoe.toObject(message.speedShoes[keys2[j]], options); + } + if (message.pumpkin && (keys2 = Object.keys(message.pumpkin)).length) { + object.pumpkin = {}; + for (var j = 0; j < keys2.length; ++j) + object.pumpkin[keys2[j]] = $root.treasurehunterx.Pumpkin.toObject(message.pumpkin[keys2[j]], options); + } + if (message.guardTowers && (keys2 = Object.keys(message.guardTowers)).length) { + object.guardTowers = {}; + for (var j = 0; j < keys2.length; ++j) + object.guardTowers[keys2[j]] = $root.treasurehunterx.GuardTower.toObject(message.guardTowers[keys2[j]], options); + } + if (message.playerMetas && (keys2 = Object.keys(message.playerMetas)).length) { + object.playerMetas = {}; + for (var j = 0; j < keys2.length; ++j) + object.playerMetas[keys2[j]] = $root.treasurehunterx.PlayerMeta.toObject(message.playerMetas[keys2[j]], options); + } + return object; + }; + + /** + * Converts this RoomDownsyncFrame to JSON. + * @function toJSON + * @memberof treasurehunterx.RoomDownsyncFrame + * @instance + * @returns {Object.} JSON object + */ + RoomDownsyncFrame.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RoomDownsyncFrame + * @function getTypeUrl + * @memberof treasurehunterx.RoomDownsyncFrame + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RoomDownsyncFrame.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/treasurehunterx.RoomDownsyncFrame"; + }; + + return RoomDownsyncFrame; + })(); + + treasurehunterx.InputFrameUpsync = (function() { + + /** + * Properties of an InputFrameUpsync. + * @memberof treasurehunterx + * @interface IInputFrameUpsync + * @property {number|null} [inputFrameId] InputFrameUpsync inputFrameId + * @property {number|null} [encodedDir] InputFrameUpsync encodedDir + */ + + /** + * Constructs a new InputFrameUpsync. + * @memberof treasurehunterx + * @classdesc Represents an InputFrameUpsync. + * @implements IInputFrameUpsync + * @constructor + * @param {treasurehunterx.IInputFrameUpsync=} [properties] Properties to set + */ + function InputFrameUpsync(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]]; + } + + /** + * InputFrameUpsync inputFrameId. + * @member {number} inputFrameId + * @memberof treasurehunterx.InputFrameUpsync + * @instance + */ + InputFrameUpsync.prototype.inputFrameId = 0; + + /** + * InputFrameUpsync encodedDir. + * @member {number} encodedDir + * @memberof treasurehunterx.InputFrameUpsync + * @instance + */ + InputFrameUpsync.prototype.encodedDir = 0; + + /** + * Creates a new InputFrameUpsync instance using the specified properties. + * @function create + * @memberof treasurehunterx.InputFrameUpsync + * @static + * @param {treasurehunterx.IInputFrameUpsync=} [properties] Properties to set + * @returns {treasurehunterx.InputFrameUpsync} InputFrameUpsync instance + */ + InputFrameUpsync.create = function create(properties) { + return new InputFrameUpsync(properties); + }; + + /** + * Encodes the specified InputFrameUpsync message. Does not implicitly {@link treasurehunterx.InputFrameUpsync.verify|verify} messages. + * @function encode + * @memberof treasurehunterx.InputFrameUpsync + * @static + * @param {treasurehunterx.InputFrameUpsync} message InputFrameUpsync message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + InputFrameUpsync.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.inputFrameId != null && Object.hasOwnProperty.call(message, "inputFrameId")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.inputFrameId); + if (message.encodedDir != null && Object.hasOwnProperty.call(message, "encodedDir")) + writer.uint32(/* id 6, wireType 0 =*/48).int32(message.encodedDir); + return writer; + }; + + /** + * Encodes the specified InputFrameUpsync message, length delimited. Does not implicitly {@link treasurehunterx.InputFrameUpsync.verify|verify} messages. + * @function encodeDelimited + * @memberof treasurehunterx.InputFrameUpsync + * @static + * @param {treasurehunterx.InputFrameUpsync} message InputFrameUpsync message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + InputFrameUpsync.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an InputFrameUpsync message from the specified reader or buffer. + * @function decode + * @memberof treasurehunterx.InputFrameUpsync + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {treasurehunterx.InputFrameUpsync} InputFrameUpsync + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + InputFrameUpsync.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.treasurehunterx.InputFrameUpsync(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.inputFrameId = reader.int32(); + break; + } + case 6: { + message.encodedDir = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an InputFrameUpsync message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof treasurehunterx.InputFrameUpsync + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {treasurehunterx.InputFrameUpsync} InputFrameUpsync + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + InputFrameUpsync.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an InputFrameUpsync message. + * @function verify + * @memberof treasurehunterx.InputFrameUpsync + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + InputFrameUpsync.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.inputFrameId != null && message.hasOwnProperty("inputFrameId")) + if (!$util.isInteger(message.inputFrameId)) + return "inputFrameId: integer expected"; + if (message.encodedDir != null && message.hasOwnProperty("encodedDir")) + if (!$util.isInteger(message.encodedDir)) + return "encodedDir: integer expected"; + return null; + }; + + /** + * Creates an InputFrameUpsync message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof treasurehunterx.InputFrameUpsync + * @static + * @param {Object.} object Plain object + * @returns {treasurehunterx.InputFrameUpsync} InputFrameUpsync + */ + InputFrameUpsync.fromObject = function fromObject(object) { + if (object instanceof $root.treasurehunterx.InputFrameUpsync) + return object; + var message = new $root.treasurehunterx.InputFrameUpsync(); + if (object.inputFrameId != null) + message.inputFrameId = object.inputFrameId | 0; + if (object.encodedDir != null) + message.encodedDir = object.encodedDir | 0; + return message; + }; + + /** + * Creates a plain object from an InputFrameUpsync message. Also converts values to other types if specified. + * @function toObject + * @memberof treasurehunterx.InputFrameUpsync + * @static + * @param {treasurehunterx.InputFrameUpsync} message InputFrameUpsync + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + InputFrameUpsync.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.inputFrameId = 0; + object.encodedDir = 0; + } + if (message.inputFrameId != null && message.hasOwnProperty("inputFrameId")) + object.inputFrameId = message.inputFrameId; + if (message.encodedDir != null && message.hasOwnProperty("encodedDir")) + object.encodedDir = message.encodedDir; + return object; + }; + + /** + * Converts this InputFrameUpsync to JSON. + * @function toJSON + * @memberof treasurehunterx.InputFrameUpsync + * @instance + * @returns {Object.} JSON object + */ + InputFrameUpsync.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for InputFrameUpsync + * @function getTypeUrl + * @memberof treasurehunterx.InputFrameUpsync + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + InputFrameUpsync.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/treasurehunterx.InputFrameUpsync"; + }; + + return InputFrameUpsync; + })(); + + treasurehunterx.InputFrameDownsync = (function() { + + /** + * Properties of an InputFrameDownsync. + * @memberof treasurehunterx + * @interface IInputFrameDownsync + * @property {number|null} [inputFrameId] InputFrameDownsync inputFrameId + * @property {Array.|null} [inputList] InputFrameDownsync inputList + * @property {number|Long|null} [confirmedList] InputFrameDownsync confirmedList + */ + + /** + * Constructs a new InputFrameDownsync. + * @memberof treasurehunterx + * @classdesc Represents an InputFrameDownsync. + * @implements IInputFrameDownsync + * @constructor + * @param {treasurehunterx.IInputFrameDownsync=} [properties] Properties to set + */ + function InputFrameDownsync(properties) { + this.inputList = []; + 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]]; + } + + /** + * InputFrameDownsync inputFrameId. + * @member {number} inputFrameId + * @memberof treasurehunterx.InputFrameDownsync + * @instance + */ + InputFrameDownsync.prototype.inputFrameId = 0; + + /** + * InputFrameDownsync inputList. + * @member {Array.} inputList + * @memberof treasurehunterx.InputFrameDownsync + * @instance + */ + InputFrameDownsync.prototype.inputList = $util.emptyArray; + + /** + * InputFrameDownsync confirmedList. + * @member {number|Long} confirmedList + * @memberof treasurehunterx.InputFrameDownsync + * @instance + */ + InputFrameDownsync.prototype.confirmedList = $util.Long ? $util.Long.fromBits(0,0,true) : 0; + + /** + * Creates a new InputFrameDownsync instance using the specified properties. + * @function create + * @memberof treasurehunterx.InputFrameDownsync + * @static + * @param {treasurehunterx.IInputFrameDownsync=} [properties] Properties to set + * @returns {treasurehunterx.InputFrameDownsync} InputFrameDownsync instance + */ + InputFrameDownsync.create = function create(properties) { + return new InputFrameDownsync(properties); + }; + + /** + * Encodes the specified InputFrameDownsync message. Does not implicitly {@link treasurehunterx.InputFrameDownsync.verify|verify} messages. + * @function encode + * @memberof treasurehunterx.InputFrameDownsync + * @static + * @param {treasurehunterx.InputFrameDownsync} message InputFrameDownsync message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + InputFrameDownsync.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.inputFrameId != null && Object.hasOwnProperty.call(message, "inputFrameId")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.inputFrameId); + if (message.inputList != null && message.inputList.length) { + writer.uint32(/* id 2, wireType 2 =*/18).fork(); + for (var i = 0; i < message.inputList.length; ++i) + writer.uint64(message.inputList[i]); + writer.ldelim(); + } + if (message.confirmedList != null && Object.hasOwnProperty.call(message, "confirmedList")) + writer.uint32(/* id 3, wireType 0 =*/24).uint64(message.confirmedList); + return writer; + }; + + /** + * Encodes the specified InputFrameDownsync message, length delimited. Does not implicitly {@link treasurehunterx.InputFrameDownsync.verify|verify} messages. + * @function encodeDelimited + * @memberof treasurehunterx.InputFrameDownsync + * @static + * @param {treasurehunterx.InputFrameDownsync} message InputFrameDownsync message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + InputFrameDownsync.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an InputFrameDownsync message from the specified reader or buffer. + * @function decode + * @memberof treasurehunterx.InputFrameDownsync + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {treasurehunterx.InputFrameDownsync} InputFrameDownsync + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + InputFrameDownsync.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.treasurehunterx.InputFrameDownsync(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.inputFrameId = reader.int32(); + break; + } + case 2: { + if (!(message.inputList && message.inputList.length)) + message.inputList = []; + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) + message.inputList.push(reader.uint64()); + } else + message.inputList.push(reader.uint64()); + break; + } + case 3: { + message.confirmedList = reader.uint64(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an InputFrameDownsync message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof treasurehunterx.InputFrameDownsync + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {treasurehunterx.InputFrameDownsync} InputFrameDownsync + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + InputFrameDownsync.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an InputFrameDownsync message. + * @function verify + * @memberof treasurehunterx.InputFrameDownsync + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + InputFrameDownsync.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.inputFrameId != null && message.hasOwnProperty("inputFrameId")) + if (!$util.isInteger(message.inputFrameId)) + return "inputFrameId: integer expected"; + if (message.inputList != null && message.hasOwnProperty("inputList")) { + if (!Array.isArray(message.inputList)) + return "inputList: array expected"; + for (var i = 0; i < message.inputList.length; ++i) + if (!$util.isInteger(message.inputList[i]) && !(message.inputList[i] && $util.isInteger(message.inputList[i].low) && $util.isInteger(message.inputList[i].high))) + return "inputList: integer|Long[] expected"; + } + if (message.confirmedList != null && message.hasOwnProperty("confirmedList")) + if (!$util.isInteger(message.confirmedList) && !(message.confirmedList && $util.isInteger(message.confirmedList.low) && $util.isInteger(message.confirmedList.high))) + return "confirmedList: integer|Long expected"; + return null; + }; + + /** + * Creates an InputFrameDownsync message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof treasurehunterx.InputFrameDownsync + * @static + * @param {Object.} object Plain object + * @returns {treasurehunterx.InputFrameDownsync} InputFrameDownsync + */ + InputFrameDownsync.fromObject = function fromObject(object) { + if (object instanceof $root.treasurehunterx.InputFrameDownsync) + return object; + var message = new $root.treasurehunterx.InputFrameDownsync(); + if (object.inputFrameId != null) + message.inputFrameId = object.inputFrameId | 0; + if (object.inputList) { + if (!Array.isArray(object.inputList)) + throw TypeError(".treasurehunterx.InputFrameDownsync.inputList: array expected"); + message.inputList = []; + for (var i = 0; i < object.inputList.length; ++i) + if ($util.Long) + (message.inputList[i] = $util.Long.fromValue(object.inputList[i])).unsigned = true; + else if (typeof object.inputList[i] === "string") + message.inputList[i] = parseInt(object.inputList[i], 10); + else if (typeof object.inputList[i] === "number") + message.inputList[i] = object.inputList[i]; + else if (typeof object.inputList[i] === "object") + message.inputList[i] = new $util.LongBits(object.inputList[i].low >>> 0, object.inputList[i].high >>> 0).toNumber(true); + } + if (object.confirmedList != null) + if ($util.Long) + (message.confirmedList = $util.Long.fromValue(object.confirmedList)).unsigned = true; + else if (typeof object.confirmedList === "string") + message.confirmedList = parseInt(object.confirmedList, 10); + else if (typeof object.confirmedList === "number") + message.confirmedList = object.confirmedList; + else if (typeof object.confirmedList === "object") + message.confirmedList = new $util.LongBits(object.confirmedList.low >>> 0, object.confirmedList.high >>> 0).toNumber(true); + return message; + }; + + /** + * Creates a plain object from an InputFrameDownsync message. Also converts values to other types if specified. + * @function toObject + * @memberof treasurehunterx.InputFrameDownsync + * @static + * @param {treasurehunterx.InputFrameDownsync} message InputFrameDownsync + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + InputFrameDownsync.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.inputList = []; + if (options.defaults) { + object.inputFrameId = 0; + if ($util.Long) { + var long = new $util.Long(0, 0, true); + object.confirmedList = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.confirmedList = options.longs === String ? "0" : 0; + } + if (message.inputFrameId != null && message.hasOwnProperty("inputFrameId")) + object.inputFrameId = message.inputFrameId; + if (message.inputList && message.inputList.length) { + object.inputList = []; + for (var j = 0; j < message.inputList.length; ++j) + if (typeof message.inputList[j] === "number") + object.inputList[j] = options.longs === String ? String(message.inputList[j]) : message.inputList[j]; + else + object.inputList[j] = options.longs === String ? $util.Long.prototype.toString.call(message.inputList[j]) : options.longs === Number ? new $util.LongBits(message.inputList[j].low >>> 0, message.inputList[j].high >>> 0).toNumber(true) : message.inputList[j]; + } + if (message.confirmedList != null && message.hasOwnProperty("confirmedList")) + if (typeof message.confirmedList === "number") + object.confirmedList = options.longs === String ? String(message.confirmedList) : message.confirmedList; + else + object.confirmedList = options.longs === String ? $util.Long.prototype.toString.call(message.confirmedList) : options.longs === Number ? new $util.LongBits(message.confirmedList.low >>> 0, message.confirmedList.high >>> 0).toNumber(true) : message.confirmedList; + return object; + }; + + /** + * Converts this InputFrameDownsync to JSON. + * @function toJSON + * @memberof treasurehunterx.InputFrameDownsync + * @instance + * @returns {Object.} JSON object + */ + InputFrameDownsync.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for InputFrameDownsync + * @function getTypeUrl + * @memberof treasurehunterx.InputFrameDownsync + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + InputFrameDownsync.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/treasurehunterx.InputFrameDownsync"; + }; + + return InputFrameDownsync; + })(); + + treasurehunterx.HeartbeatUpsync = (function() { + + /** + * Properties of a HeartbeatUpsync. + * @memberof treasurehunterx + * @interface IHeartbeatUpsync + * @property {number|Long|null} [clientTimestamp] HeartbeatUpsync clientTimestamp + */ + + /** + * Constructs a new HeartbeatUpsync. + * @memberof treasurehunterx + * @classdesc Represents a HeartbeatUpsync. + * @implements IHeartbeatUpsync + * @constructor + * @param {treasurehunterx.IHeartbeatUpsync=} [properties] Properties to set + */ + function HeartbeatUpsync(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]]; + } + + /** + * HeartbeatUpsync clientTimestamp. + * @member {number|Long} clientTimestamp + * @memberof treasurehunterx.HeartbeatUpsync + * @instance + */ + HeartbeatUpsync.prototype.clientTimestamp = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Creates a new HeartbeatUpsync instance using the specified properties. + * @function create + * @memberof treasurehunterx.HeartbeatUpsync + * @static + * @param {treasurehunterx.IHeartbeatUpsync=} [properties] Properties to set + * @returns {treasurehunterx.HeartbeatUpsync} HeartbeatUpsync instance + */ + HeartbeatUpsync.create = function create(properties) { + return new HeartbeatUpsync(properties); + }; + + /** + * Encodes the specified HeartbeatUpsync message. Does not implicitly {@link treasurehunterx.HeartbeatUpsync.verify|verify} messages. + * @function encode + * @memberof treasurehunterx.HeartbeatUpsync + * @static + * @param {treasurehunterx.HeartbeatUpsync} message HeartbeatUpsync message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + HeartbeatUpsync.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.clientTimestamp != null && Object.hasOwnProperty.call(message, "clientTimestamp")) + writer.uint32(/* id 1, wireType 0 =*/8).int64(message.clientTimestamp); + return writer; + }; + + /** + * Encodes the specified HeartbeatUpsync message, length delimited. Does not implicitly {@link treasurehunterx.HeartbeatUpsync.verify|verify} messages. + * @function encodeDelimited + * @memberof treasurehunterx.HeartbeatUpsync + * @static + * @param {treasurehunterx.HeartbeatUpsync} message HeartbeatUpsync message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + HeartbeatUpsync.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a HeartbeatUpsync message from the specified reader or buffer. + * @function decode + * @memberof treasurehunterx.HeartbeatUpsync + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {treasurehunterx.HeartbeatUpsync} HeartbeatUpsync + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + HeartbeatUpsync.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.treasurehunterx.HeartbeatUpsync(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.clientTimestamp = reader.int64(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a HeartbeatUpsync message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof treasurehunterx.HeartbeatUpsync + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {treasurehunterx.HeartbeatUpsync} HeartbeatUpsync + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + HeartbeatUpsync.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a HeartbeatUpsync message. + * @function verify + * @memberof treasurehunterx.HeartbeatUpsync + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + HeartbeatUpsync.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.clientTimestamp != null && message.hasOwnProperty("clientTimestamp")) + if (!$util.isInteger(message.clientTimestamp) && !(message.clientTimestamp && $util.isInteger(message.clientTimestamp.low) && $util.isInteger(message.clientTimestamp.high))) + return "clientTimestamp: integer|Long expected"; + return null; + }; + + /** + * Creates a HeartbeatUpsync message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof treasurehunterx.HeartbeatUpsync + * @static + * @param {Object.} object Plain object + * @returns {treasurehunterx.HeartbeatUpsync} HeartbeatUpsync + */ + HeartbeatUpsync.fromObject = function fromObject(object) { + if (object instanceof $root.treasurehunterx.HeartbeatUpsync) + return object; + var message = new $root.treasurehunterx.HeartbeatUpsync(); + if (object.clientTimestamp != null) + if ($util.Long) + (message.clientTimestamp = $util.Long.fromValue(object.clientTimestamp)).unsigned = false; + else if (typeof object.clientTimestamp === "string") + message.clientTimestamp = parseInt(object.clientTimestamp, 10); + else if (typeof object.clientTimestamp === "number") + message.clientTimestamp = object.clientTimestamp; + else if (typeof object.clientTimestamp === "object") + message.clientTimestamp = new $util.LongBits(object.clientTimestamp.low >>> 0, object.clientTimestamp.high >>> 0).toNumber(); + return message; + }; + + /** + * Creates a plain object from a HeartbeatUpsync message. Also converts values to other types if specified. + * @function toObject + * @memberof treasurehunterx.HeartbeatUpsync + * @static + * @param {treasurehunterx.HeartbeatUpsync} message HeartbeatUpsync + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + HeartbeatUpsync.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.clientTimestamp = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.clientTimestamp = options.longs === String ? "0" : 0; + if (message.clientTimestamp != null && message.hasOwnProperty("clientTimestamp")) + if (typeof message.clientTimestamp === "number") + object.clientTimestamp = options.longs === String ? String(message.clientTimestamp) : message.clientTimestamp; + else + object.clientTimestamp = options.longs === String ? $util.Long.prototype.toString.call(message.clientTimestamp) : options.longs === Number ? new $util.LongBits(message.clientTimestamp.low >>> 0, message.clientTimestamp.high >>> 0).toNumber() : message.clientTimestamp; + return object; + }; + + /** + * Converts this HeartbeatUpsync to JSON. + * @function toJSON + * @memberof treasurehunterx.HeartbeatUpsync + * @instance + * @returns {Object.} JSON object + */ + HeartbeatUpsync.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for HeartbeatUpsync + * @function getTypeUrl + * @memberof treasurehunterx.HeartbeatUpsync + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + HeartbeatUpsync.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/treasurehunterx.HeartbeatUpsync"; + }; + + return HeartbeatUpsync; + })(); + + treasurehunterx.WsReq = (function() { + + /** + * Properties of a WsReq. + * @memberof treasurehunterx + * @interface IWsReq + * @property {number|null} [msgId] WsReq msgId + * @property {number|null} [playerId] WsReq playerId + * @property {number|null} [act] WsReq act + * @property {number|null} [joinIndex] WsReq joinIndex + * @property {number|null} [ackingFrameId] WsReq ackingFrameId + * @property {number|null} [ackingInputFrameId] WsReq ackingInputFrameId + * @property {Array.|null} [inputFrameUpsyncBatch] WsReq inputFrameUpsyncBatch + * @property {treasurehunterx.HeartbeatUpsync|null} [hb] WsReq hb + */ + + /** + * Constructs a new WsReq. + * @memberof treasurehunterx + * @classdesc Represents a WsReq. + * @implements IWsReq + * @constructor + * @param {treasurehunterx.IWsReq=} [properties] Properties to set + */ + function WsReq(properties) { + this.inputFrameUpsyncBatch = []; + 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]]; + } + + /** + * WsReq msgId. + * @member {number} msgId + * @memberof treasurehunterx.WsReq + * @instance + */ + WsReq.prototype.msgId = 0; + + /** + * WsReq playerId. + * @member {number} playerId + * @memberof treasurehunterx.WsReq + * @instance + */ + WsReq.prototype.playerId = 0; + + /** + * WsReq act. + * @member {number} act + * @memberof treasurehunterx.WsReq + * @instance + */ + WsReq.prototype.act = 0; + + /** + * WsReq joinIndex. + * @member {number} joinIndex + * @memberof treasurehunterx.WsReq + * @instance + */ + WsReq.prototype.joinIndex = 0; + + /** + * WsReq ackingFrameId. + * @member {number} ackingFrameId + * @memberof treasurehunterx.WsReq + * @instance + */ + WsReq.prototype.ackingFrameId = 0; + + /** + * WsReq ackingInputFrameId. + * @member {number} ackingInputFrameId + * @memberof treasurehunterx.WsReq + * @instance + */ + WsReq.prototype.ackingInputFrameId = 0; + + /** + * WsReq inputFrameUpsyncBatch. + * @member {Array.} inputFrameUpsyncBatch + * @memberof treasurehunterx.WsReq + * @instance + */ + WsReq.prototype.inputFrameUpsyncBatch = $util.emptyArray; + + /** + * WsReq hb. + * @member {treasurehunterx.HeartbeatUpsync|null|undefined} hb + * @memberof treasurehunterx.WsReq + * @instance + */ + WsReq.prototype.hb = null; + + /** + * Creates a new WsReq instance using the specified properties. + * @function create + * @memberof treasurehunterx.WsReq + * @static + * @param {treasurehunterx.IWsReq=} [properties] Properties to set + * @returns {treasurehunterx.WsReq} WsReq instance + */ + WsReq.create = function create(properties) { + return new WsReq(properties); + }; + + /** + * Encodes the specified WsReq message. Does not implicitly {@link treasurehunterx.WsReq.verify|verify} messages. + * @function encode + * @memberof treasurehunterx.WsReq + * @static + * @param {treasurehunterx.WsReq} message WsReq message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + WsReq.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.msgId != null && Object.hasOwnProperty.call(message, "msgId")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.msgId); + if (message.playerId != null && Object.hasOwnProperty.call(message, "playerId")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.playerId); + if (message.act != null && Object.hasOwnProperty.call(message, "act")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.act); + if (message.joinIndex != null && Object.hasOwnProperty.call(message, "joinIndex")) + writer.uint32(/* id 4, wireType 0 =*/32).int32(message.joinIndex); + if (message.ackingFrameId != null && Object.hasOwnProperty.call(message, "ackingFrameId")) + writer.uint32(/* id 5, wireType 0 =*/40).int32(message.ackingFrameId); + if (message.ackingInputFrameId != null && Object.hasOwnProperty.call(message, "ackingInputFrameId")) + writer.uint32(/* id 6, wireType 0 =*/48).int32(message.ackingInputFrameId); + if (message.inputFrameUpsyncBatch != null && message.inputFrameUpsyncBatch.length) + for (var i = 0; i < message.inputFrameUpsyncBatch.length; ++i) + $root.treasurehunterx.InputFrameUpsync.encode(message.inputFrameUpsyncBatch[i], writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); + if (message.hb != null && Object.hasOwnProperty.call(message, "hb")) + $root.treasurehunterx.HeartbeatUpsync.encode(message.hb, writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified WsReq message, length delimited. Does not implicitly {@link treasurehunterx.WsReq.verify|verify} messages. + * @function encodeDelimited + * @memberof treasurehunterx.WsReq + * @static + * @param {treasurehunterx.WsReq} message WsReq message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + WsReq.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a WsReq message from the specified reader or buffer. + * @function decode + * @memberof treasurehunterx.WsReq + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {treasurehunterx.WsReq} WsReq + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + WsReq.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.treasurehunterx.WsReq(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.msgId = reader.int32(); + break; + } + case 2: { + message.playerId = reader.int32(); + break; + } + case 3: { + message.act = reader.int32(); + break; + } + case 4: { + message.joinIndex = reader.int32(); + break; + } + case 5: { + message.ackingFrameId = reader.int32(); + break; + } + case 6: { + message.ackingInputFrameId = reader.int32(); + break; + } + case 7: { + if (!(message.inputFrameUpsyncBatch && message.inputFrameUpsyncBatch.length)) + message.inputFrameUpsyncBatch = []; + message.inputFrameUpsyncBatch.push($root.treasurehunterx.InputFrameUpsync.decode(reader, reader.uint32())); + break; + } + case 8: { + message.hb = $root.treasurehunterx.HeartbeatUpsync.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a WsReq message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof treasurehunterx.WsReq + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {treasurehunterx.WsReq} WsReq + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + WsReq.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a WsReq message. + * @function verify + * @memberof treasurehunterx.WsReq + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + WsReq.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.msgId != null && message.hasOwnProperty("msgId")) + if (!$util.isInteger(message.msgId)) + return "msgId: integer expected"; + if (message.playerId != null && message.hasOwnProperty("playerId")) + if (!$util.isInteger(message.playerId)) + return "playerId: integer expected"; + if (message.act != null && message.hasOwnProperty("act")) + if (!$util.isInteger(message.act)) + return "act: integer expected"; + if (message.joinIndex != null && message.hasOwnProperty("joinIndex")) + if (!$util.isInteger(message.joinIndex)) + return "joinIndex: integer expected"; + if (message.ackingFrameId != null && message.hasOwnProperty("ackingFrameId")) + if (!$util.isInteger(message.ackingFrameId)) + return "ackingFrameId: integer expected"; + if (message.ackingInputFrameId != null && message.hasOwnProperty("ackingInputFrameId")) + if (!$util.isInteger(message.ackingInputFrameId)) + return "ackingInputFrameId: integer expected"; + if (message.inputFrameUpsyncBatch != null && message.hasOwnProperty("inputFrameUpsyncBatch")) { + if (!Array.isArray(message.inputFrameUpsyncBatch)) + return "inputFrameUpsyncBatch: array expected"; + for (var i = 0; i < message.inputFrameUpsyncBatch.length; ++i) { + var error = $root.treasurehunterx.InputFrameUpsync.verify(message.inputFrameUpsyncBatch[i]); + if (error) + return "inputFrameUpsyncBatch." + error; + } + } + if (message.hb != null && message.hasOwnProperty("hb")) { + var error = $root.treasurehunterx.HeartbeatUpsync.verify(message.hb); + if (error) + return "hb." + error; + } + return null; + }; + + /** + * Creates a WsReq message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof treasurehunterx.WsReq + * @static + * @param {Object.} object Plain object + * @returns {treasurehunterx.WsReq} WsReq + */ + WsReq.fromObject = function fromObject(object) { + if (object instanceof $root.treasurehunterx.WsReq) + return object; + var message = new $root.treasurehunterx.WsReq(); + if (object.msgId != null) + message.msgId = object.msgId | 0; + if (object.playerId != null) + message.playerId = object.playerId | 0; + if (object.act != null) + message.act = object.act | 0; + if (object.joinIndex != null) + message.joinIndex = object.joinIndex | 0; + if (object.ackingFrameId != null) + message.ackingFrameId = object.ackingFrameId | 0; + if (object.ackingInputFrameId != null) + message.ackingInputFrameId = object.ackingInputFrameId | 0; + if (object.inputFrameUpsyncBatch) { + if (!Array.isArray(object.inputFrameUpsyncBatch)) + throw TypeError(".treasurehunterx.WsReq.inputFrameUpsyncBatch: array expected"); + message.inputFrameUpsyncBatch = []; + for (var i = 0; i < object.inputFrameUpsyncBatch.length; ++i) { + if (typeof object.inputFrameUpsyncBatch[i] !== "object") + throw TypeError(".treasurehunterx.WsReq.inputFrameUpsyncBatch: object expected"); + message.inputFrameUpsyncBatch[i] = $root.treasurehunterx.InputFrameUpsync.fromObject(object.inputFrameUpsyncBatch[i]); + } + } + if (object.hb != null) { + if (typeof object.hb !== "object") + throw TypeError(".treasurehunterx.WsReq.hb: object expected"); + message.hb = $root.treasurehunterx.HeartbeatUpsync.fromObject(object.hb); + } + return message; + }; + + /** + * Creates a plain object from a WsReq message. Also converts values to other types if specified. + * @function toObject + * @memberof treasurehunterx.WsReq + * @static + * @param {treasurehunterx.WsReq} message WsReq + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + WsReq.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.inputFrameUpsyncBatch = []; + if (options.defaults) { + object.msgId = 0; + object.playerId = 0; + object.act = 0; + object.joinIndex = 0; + object.ackingFrameId = 0; + object.ackingInputFrameId = 0; + object.hb = null; + } + if (message.msgId != null && message.hasOwnProperty("msgId")) + object.msgId = message.msgId; + if (message.playerId != null && message.hasOwnProperty("playerId")) + object.playerId = message.playerId; + if (message.act != null && message.hasOwnProperty("act")) + object.act = message.act; + if (message.joinIndex != null && message.hasOwnProperty("joinIndex")) + object.joinIndex = message.joinIndex; + if (message.ackingFrameId != null && message.hasOwnProperty("ackingFrameId")) + object.ackingFrameId = message.ackingFrameId; + if (message.ackingInputFrameId != null && message.hasOwnProperty("ackingInputFrameId")) + object.ackingInputFrameId = message.ackingInputFrameId; + if (message.inputFrameUpsyncBatch && message.inputFrameUpsyncBatch.length) { + object.inputFrameUpsyncBatch = []; + for (var j = 0; j < message.inputFrameUpsyncBatch.length; ++j) + object.inputFrameUpsyncBatch[j] = $root.treasurehunterx.InputFrameUpsync.toObject(message.inputFrameUpsyncBatch[j], options); + } + if (message.hb != null && message.hasOwnProperty("hb")) + object.hb = $root.treasurehunterx.HeartbeatUpsync.toObject(message.hb, options); + return object; + }; + + /** + * Converts this WsReq to JSON. + * @function toJSON + * @memberof treasurehunterx.WsReq + * @instance + * @returns {Object.} JSON object + */ + WsReq.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for WsReq + * @function getTypeUrl + * @memberof treasurehunterx.WsReq + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + WsReq.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/treasurehunterx.WsReq"; + }; + + return WsReq; + })(); + + treasurehunterx.WsResp = (function() { + + /** + * Properties of a WsResp. + * @memberof treasurehunterx + * @interface IWsResp + * @property {number|null} [ret] WsResp ret + * @property {number|null} [echoedMsgId] WsResp echoedMsgId + * @property {number|null} [act] WsResp act + * @property {treasurehunterx.RoomDownsyncFrame|null} [rdf] WsResp rdf + * @property {Array.|null} [inputFrameDownsyncBatch] WsResp inputFrameDownsyncBatch + * @property {treasurehunterx.BattleColliderInfo|null} [bciFrame] WsResp bciFrame + */ + + /** + * Constructs a new WsResp. + * @memberof treasurehunterx + * @classdesc Represents a WsResp. + * @implements IWsResp + * @constructor + * @param {treasurehunterx.IWsResp=} [properties] Properties to set + */ + function WsResp(properties) { + this.inputFrameDownsyncBatch = []; + 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]]; + } + + /** + * WsResp ret. + * @member {number} ret + * @memberof treasurehunterx.WsResp + * @instance + */ + WsResp.prototype.ret = 0; + + /** + * WsResp echoedMsgId. + * @member {number} echoedMsgId + * @memberof treasurehunterx.WsResp + * @instance + */ + WsResp.prototype.echoedMsgId = 0; + + /** + * WsResp act. + * @member {number} act + * @memberof treasurehunterx.WsResp + * @instance + */ + WsResp.prototype.act = 0; + + /** + * WsResp rdf. + * @member {treasurehunterx.RoomDownsyncFrame|null|undefined} rdf + * @memberof treasurehunterx.WsResp + * @instance + */ + WsResp.prototype.rdf = null; + + /** + * WsResp inputFrameDownsyncBatch. + * @member {Array.} inputFrameDownsyncBatch + * @memberof treasurehunterx.WsResp + * @instance + */ + WsResp.prototype.inputFrameDownsyncBatch = $util.emptyArray; + + /** + * WsResp bciFrame. + * @member {treasurehunterx.BattleColliderInfo|null|undefined} bciFrame + * @memberof treasurehunterx.WsResp + * @instance + */ + WsResp.prototype.bciFrame = null; + + /** + * Creates a new WsResp instance using the specified properties. + * @function create + * @memberof treasurehunterx.WsResp + * @static + * @param {treasurehunterx.IWsResp=} [properties] Properties to set + * @returns {treasurehunterx.WsResp} WsResp instance + */ + WsResp.create = function create(properties) { + return new WsResp(properties); + }; + + /** + * Encodes the specified WsResp message. Does not implicitly {@link treasurehunterx.WsResp.verify|verify} messages. + * @function encode + * @memberof treasurehunterx.WsResp + * @static + * @param {treasurehunterx.WsResp} message WsResp message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + WsResp.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.ret != null && Object.hasOwnProperty.call(message, "ret")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.ret); + if (message.echoedMsgId != null && Object.hasOwnProperty.call(message, "echoedMsgId")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.echoedMsgId); + if (message.act != null && Object.hasOwnProperty.call(message, "act")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.act); + if (message.rdf != null && Object.hasOwnProperty.call(message, "rdf")) + $root.treasurehunterx.RoomDownsyncFrame.encode(message.rdf, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.inputFrameDownsyncBatch != null && message.inputFrameDownsyncBatch.length) + for (var i = 0; i < message.inputFrameDownsyncBatch.length; ++i) + $root.treasurehunterx.InputFrameDownsync.encode(message.inputFrameDownsyncBatch[i], writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + if (message.bciFrame != null && Object.hasOwnProperty.call(message, "bciFrame")) + $root.treasurehunterx.BattleColliderInfo.encode(message.bciFrame, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified WsResp message, length delimited. Does not implicitly {@link treasurehunterx.WsResp.verify|verify} messages. + * @function encodeDelimited + * @memberof treasurehunterx.WsResp + * @static + * @param {treasurehunterx.WsResp} message WsResp message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + WsResp.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a WsResp message from the specified reader or buffer. + * @function decode + * @memberof treasurehunterx.WsResp + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {treasurehunterx.WsResp} WsResp + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + WsResp.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.treasurehunterx.WsResp(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.ret = reader.int32(); + break; + } + case 2: { + message.echoedMsgId = reader.int32(); + break; + } + case 3: { + message.act = reader.int32(); + break; + } + case 4: { + message.rdf = $root.treasurehunterx.RoomDownsyncFrame.decode(reader, reader.uint32()); + break; + } + case 5: { + if (!(message.inputFrameDownsyncBatch && message.inputFrameDownsyncBatch.length)) + message.inputFrameDownsyncBatch = []; + message.inputFrameDownsyncBatch.push($root.treasurehunterx.InputFrameDownsync.decode(reader, reader.uint32())); + break; + } + case 6: { + message.bciFrame = $root.treasurehunterx.BattleColliderInfo.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a WsResp message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof treasurehunterx.WsResp + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {treasurehunterx.WsResp} WsResp + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + WsResp.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a WsResp message. + * @function verify + * @memberof treasurehunterx.WsResp + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + WsResp.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.ret != null && message.hasOwnProperty("ret")) + if (!$util.isInteger(message.ret)) + return "ret: integer expected"; + if (message.echoedMsgId != null && message.hasOwnProperty("echoedMsgId")) + if (!$util.isInteger(message.echoedMsgId)) + return "echoedMsgId: integer expected"; + if (message.act != null && message.hasOwnProperty("act")) + if (!$util.isInteger(message.act)) + return "act: integer expected"; + if (message.rdf != null && message.hasOwnProperty("rdf")) { + var error = $root.treasurehunterx.RoomDownsyncFrame.verify(message.rdf); + if (error) + return "rdf." + error; + } + if (message.inputFrameDownsyncBatch != null && message.hasOwnProperty("inputFrameDownsyncBatch")) { + if (!Array.isArray(message.inputFrameDownsyncBatch)) + return "inputFrameDownsyncBatch: array expected"; + for (var i = 0; i < message.inputFrameDownsyncBatch.length; ++i) { + var error = $root.treasurehunterx.InputFrameDownsync.verify(message.inputFrameDownsyncBatch[i]); + if (error) + return "inputFrameDownsyncBatch." + error; + } + } + if (message.bciFrame != null && message.hasOwnProperty("bciFrame")) { + var error = $root.treasurehunterx.BattleColliderInfo.verify(message.bciFrame); + if (error) + return "bciFrame." + error; + } + return null; + }; + + /** + * Creates a WsResp message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof treasurehunterx.WsResp + * @static + * @param {Object.} object Plain object + * @returns {treasurehunterx.WsResp} WsResp + */ + WsResp.fromObject = function fromObject(object) { + if (object instanceof $root.treasurehunterx.WsResp) + return object; + var message = new $root.treasurehunterx.WsResp(); + if (object.ret != null) + message.ret = object.ret | 0; + if (object.echoedMsgId != null) + message.echoedMsgId = object.echoedMsgId | 0; + if (object.act != null) + message.act = object.act | 0; + if (object.rdf != null) { + if (typeof object.rdf !== "object") + throw TypeError(".treasurehunterx.WsResp.rdf: object expected"); + message.rdf = $root.treasurehunterx.RoomDownsyncFrame.fromObject(object.rdf); + } + if (object.inputFrameDownsyncBatch) { + if (!Array.isArray(object.inputFrameDownsyncBatch)) + throw TypeError(".treasurehunterx.WsResp.inputFrameDownsyncBatch: array expected"); + message.inputFrameDownsyncBatch = []; + for (var i = 0; i < object.inputFrameDownsyncBatch.length; ++i) { + if (typeof object.inputFrameDownsyncBatch[i] !== "object") + throw TypeError(".treasurehunterx.WsResp.inputFrameDownsyncBatch: object expected"); + message.inputFrameDownsyncBatch[i] = $root.treasurehunterx.InputFrameDownsync.fromObject(object.inputFrameDownsyncBatch[i]); + } + } + if (object.bciFrame != null) { + if (typeof object.bciFrame !== "object") + throw TypeError(".treasurehunterx.WsResp.bciFrame: object expected"); + message.bciFrame = $root.treasurehunterx.BattleColliderInfo.fromObject(object.bciFrame); + } + return message; + }; + + /** + * Creates a plain object from a WsResp message. Also converts values to other types if specified. + * @function toObject + * @memberof treasurehunterx.WsResp + * @static + * @param {treasurehunterx.WsResp} message WsResp + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + WsResp.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.inputFrameDownsyncBatch = []; + if (options.defaults) { + object.ret = 0; + object.echoedMsgId = 0; + object.act = 0; + object.rdf = null; + object.bciFrame = null; + } + if (message.ret != null && message.hasOwnProperty("ret")) + object.ret = message.ret; + if (message.echoedMsgId != null && message.hasOwnProperty("echoedMsgId")) + object.echoedMsgId = message.echoedMsgId; + if (message.act != null && message.hasOwnProperty("act")) + object.act = message.act; + if (message.rdf != null && message.hasOwnProperty("rdf")) + object.rdf = $root.treasurehunterx.RoomDownsyncFrame.toObject(message.rdf, options); + if (message.inputFrameDownsyncBatch && message.inputFrameDownsyncBatch.length) { + object.inputFrameDownsyncBatch = []; + for (var j = 0; j < message.inputFrameDownsyncBatch.length; ++j) + object.inputFrameDownsyncBatch[j] = $root.treasurehunterx.InputFrameDownsync.toObject(message.inputFrameDownsyncBatch[j], options); + } + if (message.bciFrame != null && message.hasOwnProperty("bciFrame")) + object.bciFrame = $root.treasurehunterx.BattleColliderInfo.toObject(message.bciFrame, options); + return object; + }; + + /** + * Converts this WsResp to JSON. + * @function toJSON + * @memberof treasurehunterx.WsResp + * @instance + * @returns {Object.} JSON object + */ + WsResp.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for WsResp + * @function getTypeUrl + * @memberof treasurehunterx.WsResp + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + WsResp.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/treasurehunterx.WsResp"; + }; + + return WsResp; + })(); + + return treasurehunterx; +})(); + +module.exports = $root; diff --git a/frontend/assets/scripts/modules/room_downsync_frame_proto_bundle.forcemsg.js.meta b/frontend/assets/scripts/modules/room_downsync_frame_proto_bundle.forcemsg.js.meta new file mode 100644 index 0000000..65ec566 --- /dev/null +++ b/frontend/assets/scripts/modules/room_downsync_frame_proto_bundle.forcemsg.js.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.5", + "uuid": "77ed160f-d4d5-4654-a502-66b008197da0", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/build-templates/web-mobile/loading.png b/frontend/build-templates/web-mobile/loading.png new file mode 100644 index 0000000..5bd7960 Binary files /dev/null and b/frontend/build-templates/web-mobile/loading.png differ diff --git a/frontend/build-templates/web-mobile/protobuf.js b/frontend/build-templates/web-mobile/protobuf.js new file mode 100644 index 0000000..c3e1c02 --- /dev/null +++ b/frontend/build-templates/web-mobile/protobuf.js @@ -0,0 +1,8726 @@ +/*! + * protobuf.js v6.8.8 (c) 2016, daniel wirtz + * compiled thu, 19 jul 2018 00:33:25 utc + * licensed under the bsd-3-clause license + * see: https://github.com/dcodeio/protobuf.js for details + */ +(function(undefined){"use strict";(function prelude(modules, cache, entries) { + + // This is the prelude used to bundle protobuf.js for the browser. Wraps up the CommonJS + // sources through a conflict-free require shim and is again wrapped within an iife that + // provides a minification-friendly `undefined` var plus a global "use strict" directive + // so that minification can remove the directives of each module. + + function $require(name) { + var $module = cache[name]; + if (!$module) + modules[name][0].call($module = cache[name] = { exports: {} }, $require, $module, $module.exports); + return $module.exports; + } + + var protobuf = $require(entries[0]); + + // Expose globally + protobuf.util.global.protobuf = protobuf; + + // Be nice to AMD + if (typeof define === "function" && define.amd) + define(["long"], function(Long) { + if (Long && Long.isLong) { + protobuf.util.Long = Long; + protobuf.configure(); + } + return protobuf; + }); + + // Be nice to CommonJS + if (typeof module === "object" && module && module.exports) + module.exports = protobuf; + +})/* end of prelude */({1:[function(require,module,exports){ +"use strict"; +module.exports = asPromise; + +/** + * Callback as used by {@link util.asPromise}. + * @typedef asPromiseCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {...*} params Additional arguments + * @returns {undefined} + */ + +/** + * Returns a promise from a node-style callback function. + * @memberof util + * @param {asPromiseCallback} fn Function to call + * @param {*} ctx Function context + * @param {...*} params Function arguments + * @returns {Promise<*>} Promisified function + */ +function asPromise(fn, ctx/*, varargs */) { + var params = new Array(arguments.length - 1), + offset = 0, + index = 2, + pending = true; + while (index < arguments.length) + params[offset++] = arguments[index++]; + return new Promise(function executor(resolve, reject) { + params[offset] = function callback(err/*, varargs */) { + if (pending) { + pending = false; + if (err) + reject(err); + else { + var params = new Array(arguments.length - 1), + offset = 0; + while (offset < params.length) + params[offset++] = arguments[offset]; + resolve.apply(null, params); + } + } + }; + try { + fn.apply(ctx || null, params); + } catch (err) { + if (pending) { + pending = false; + reject(err); + } + } + }); +} + +},{}],2:[function(require,module,exports){ +"use strict"; + +/** + * A minimal base64 implementation for number arrays. + * @memberof util + * @namespace + */ +var base64 = exports; + +/** + * Calculates the byte length of a base64 encoded string. + * @param {string} string Base64 encoded string + * @returns {number} Byte length + */ +base64.length = function length(string) { + var p = string.length; + if (!p) + return 0; + var n = 0; + while (--p % 4 > 1 && string.charAt(p) === "=") + ++n; + return Math.ceil(string.length * 3) / 4 - n; +}; + +// Base64 encoding table +var b64 = new Array(64); + +// Base64 decoding table +var s64 = new Array(123); + +// 65..90, 97..122, 48..57, 43, 47 +for (var i = 0; i < 64;) + s64[b64[i] = i < 26 ? i + 65 : i < 52 ? i + 71 : i < 62 ? i - 4 : i - 59 | 43] = i++; + +/** + * Encodes a buffer to a base64 encoded string. + * @param {Uint8Array} buffer Source buffer + * @param {number} start Source start + * @param {number} end Source end + * @returns {string} Base64 encoded string + */ +base64.encode = function encode(buffer, start, end) { + var parts = null, + chunk = []; + var i = 0, // output index + j = 0, // goto index + t; // temporary + while (start < end) { + var b = buffer[start++]; + switch (j) { + case 0: + chunk[i++] = b64[b >> 2]; + t = (b & 3) << 4; + j = 1; + break; + case 1: + chunk[i++] = b64[t | b >> 4]; + t = (b & 15) << 2; + j = 2; + break; + case 2: + chunk[i++] = b64[t | b >> 6]; + chunk[i++] = b64[b & 63]; + j = 0; + break; + } + if (i > 8191) { + (parts || (parts = [])).push(String.fromCharCode.apply(String, chunk)); + i = 0; + } + } + if (j) { + chunk[i++] = b64[t]; + chunk[i++] = 61; + if (j === 1) + chunk[i++] = 61; + } + if (parts) { + if (i) + parts.push(String.fromCharCode.apply(String, chunk.slice(0, i))); + return parts.join(""); + } + return String.fromCharCode.apply(String, chunk.slice(0, i)); +}; + +var invalidEncoding = "invalid encoding"; + +/** + * Decodes a base64 encoded string to a buffer. + * @param {string} string Source string + * @param {Uint8Array} buffer Destination buffer + * @param {number} offset Destination offset + * @returns {number} Number of bytes written + * @throws {Error} If encoding is invalid + */ +base64.decode = function decode(string, buffer, offset) { + var start = offset; + var j = 0, // goto index + t; // temporary + for (var i = 0; i < string.length;) { + var c = string.charCodeAt(i++); + if (c === 61 && j > 1) + break; + if ((c = s64[c]) === undefined) + throw Error(invalidEncoding); + switch (j) { + case 0: + t = c; + j = 1; + break; + case 1: + buffer[offset++] = t << 2 | (c & 48) >> 4; + t = c; + j = 2; + break; + case 2: + buffer[offset++] = (t & 15) << 4 | (c & 60) >> 2; + t = c; + j = 3; + break; + case 3: + buffer[offset++] = (t & 3) << 6 | c; + j = 0; + break; + } + } + if (j === 1) + throw Error(invalidEncoding); + return offset - start; +}; + +/** + * Tests if the specified string appears to be base64 encoded. + * @param {string} string String to test + * @returns {boolean} `true` if probably base64 encoded, otherwise false + */ +base64.test = function test(string) { + return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(string); +}; + +},{}],3:[function(require,module,exports){ +"use strict"; +module.exports = codegen; + +/** + * Begins generating a function. + * @memberof util + * @param {string[]} functionParams Function parameter names + * @param {string} [functionName] Function name if not anonymous + * @returns {Codegen} Appender that appends code to the function's body + */ +function codegen(functionParams, functionName) { + + /* istanbul ignore if */ + if (typeof functionParams === "string") { + functionName = functionParams; + functionParams = undefined; + } + + var body = []; + + /** + * Appends code to the function's body or finishes generation. + * @typedef Codegen + * @type {function} + * @param {string|Object.} [formatStringOrScope] Format string or, to finish the function, an object of additional scope variables, if any + * @param {...*} [formatParams] Format parameters + * @returns {Codegen|Function} Itself or the generated function if finished + * @throws {Error} If format parameter counts do not match + */ + + function Codegen(formatStringOrScope) { + // note that explicit array handling below makes this ~50% faster + + // finish the function + if (typeof formatStringOrScope !== "string") { + var source = toString(); + if (codegen.verbose) + console.log("codegen: " + source); // eslint-disable-line no-console + source = "return " + source; + if (formatStringOrScope) { + var scopeKeys = Object.keys(formatStringOrScope), + scopeParams = new Array(scopeKeys.length + 1), + scopeValues = new Array(scopeKeys.length), + scopeOffset = 0; + while (scopeOffset < scopeKeys.length) { + scopeParams[scopeOffset] = scopeKeys[scopeOffset]; + scopeValues[scopeOffset] = formatStringOrScope[scopeKeys[scopeOffset++]]; + } + scopeParams[scopeOffset] = source; + return Function.apply(null, scopeParams).apply(null, scopeValues); // eslint-disable-line no-new-func + } + return Function(source)(); // eslint-disable-line no-new-func + } + + // otherwise append to body + var formatParams = new Array(arguments.length - 1), + formatOffset = 0; + while (formatOffset < formatParams.length) + formatParams[formatOffset] = arguments[++formatOffset]; + formatOffset = 0; + formatStringOrScope = formatStringOrScope.replace(/%([%dfijs])/g, function replace($0, $1) { + var value = formatParams[formatOffset++]; + switch ($1) { + case "d": case "f": return String(Number(value)); + case "i": return String(Math.floor(value)); + case "j": return JSON.stringify(value); + case "s": return String(value); + } + return "%"; + }); + if (formatOffset !== formatParams.length) + throw Error("parameter count mismatch"); + body.push(formatStringOrScope); + return Codegen; + } + + function toString(functionNameOverride) { + return "function " + (functionNameOverride || functionName || "") + "(" + (functionParams && functionParams.join(",") || "") + "){\n " + body.join("\n ") + "\n}"; + } + + Codegen.toString = toString; + return Codegen; +} + +/** + * Begins generating a function. + * @memberof util + * @function codegen + * @param {string} [functionName] Function name if not anonymous + * @returns {Codegen} Appender that appends code to the function's body + * @variation 2 + */ + +/** + * When set to `true`, codegen will log generated code to console. Useful for debugging. + * @name util.codegen.verbose + * @type {boolean} + */ +codegen.verbose = false; + +},{}],4:[function(require,module,exports){ +"use strict"; +module.exports = EventEmitter; + +/** + * Constructs a new event emitter instance. + * @classdesc A minimal event emitter. + * @memberof util + * @constructor + */ +function EventEmitter() { + + /** + * Registered listeners. + * @type {Object.} + * @private + */ + this._listeners = {}; +} + +/** + * Registers an event listener. + * @param {string} evt Event name + * @param {function} fn Listener + * @param {*} [ctx] Listener context + * @returns {util.EventEmitter} `this` + */ +EventEmitter.prototype.on = function on(evt, fn, ctx) { + (this._listeners[evt] || (this._listeners[evt] = [])).push({ + fn : fn, + ctx : ctx || this + }); + return this; +}; + +/** + * Removes an event listener or any matching listeners if arguments are omitted. + * @param {string} [evt] Event name. Removes all listeners if omitted. + * @param {function} [fn] Listener to remove. Removes all listeners of `evt` if omitted. + * @returns {util.EventEmitter} `this` + */ +EventEmitter.prototype.off = function off(evt, fn) { + if (evt === undefined) + this._listeners = {}; + else { + if (fn === undefined) + this._listeners[evt] = []; + else { + var listeners = this._listeners[evt]; + for (var i = 0; i < listeners.length;) + if (listeners[i].fn === fn) + listeners.splice(i, 1); + else + ++i; + } + } + return this; +}; + +/** + * Emits an event by calling its listeners with the specified arguments. + * @param {string} evt Event name + * @param {...*} args Arguments + * @returns {util.EventEmitter} `this` + */ +EventEmitter.prototype.emit = function emit(evt) { + var listeners = this._listeners[evt]; + if (listeners) { + var args = [], + i = 1; + for (; i < arguments.length;) + args.push(arguments[i++]); + for (i = 0; i < listeners.length;) + listeners[i].fn.apply(listeners[i++].ctx, args); + } + return this; +}; + +},{}],5:[function(require,module,exports){ +"use strict"; +module.exports = fetch; + +var asPromise = require(1), + inquire = require(7); + +var fs = inquire("fs"); + +/** + * Node-style callback as used by {@link util.fetch}. + * @typedef FetchCallback + * @type {function} + * @param {?Error} error Error, if any, otherwise `null` + * @param {string} [contents] File contents, if there hasn't been an error + * @returns {undefined} + */ + +/** + * Options as used by {@link util.fetch}. + * @typedef FetchOptions + * @type {Object} + * @property {boolean} [binary=false] Whether expecting a binary response + * @property {boolean} [xhr=false] If `true`, forces the use of XMLHttpRequest + */ + +/** + * Fetches the contents of a file. + * @memberof util + * @param {string} filename File path or url + * @param {FetchOptions} options Fetch options + * @param {FetchCallback} callback Callback function + * @returns {undefined} + */ +function fetch(filename, options, callback) { + if (typeof options === "function") { + callback = options; + options = {}; + } else if (!options) + options = {}; + + if (!callback) + return asPromise(fetch, this, filename, options); // eslint-disable-line no-invalid-this + + // if a node-like filesystem is present, try it first but fall back to XHR if nothing is found. + if (!options.xhr && fs && fs.readFile) + return fs.readFile(filename, function fetchReadFileCallback(err, contents) { + return err && typeof XMLHttpRequest !== "undefined" + ? fetch.xhr(filename, options, callback) + : err + ? callback(err) + : callback(null, options.binary ? contents : contents.toString("utf8")); + }); + + // use the XHR version otherwise. + return fetch.xhr(filename, options, callback); +} + +/** + * Fetches the contents of a file. + * @name util.fetch + * @function + * @param {string} path File path or url + * @param {FetchCallback} callback Callback function + * @returns {undefined} + * @variation 2 + */ + +/** + * Fetches the contents of a file. + * @name util.fetch + * @function + * @param {string} path File path or url + * @param {FetchOptions} [options] Fetch options + * @returns {Promise} Promise + * @variation 3 + */ + +/**/ +fetch.xhr = function fetch_xhr(filename, options, callback) { + var xhr = new XMLHttpRequest(); + xhr.onreadystatechange /* works everywhere */ = function fetchOnReadyStateChange() { + + if (xhr.readyState !== 4) + return undefined; + + // local cors security errors return status 0 / empty string, too. afaik this cannot be + // reliably distinguished from an actually empty file for security reasons. feel free + // to send a pull request if you are aware of a solution. + if (xhr.status !== 0 && xhr.status !== 200) + return callback(Error("status " + xhr.status)); + + // if binary data is expected, make sure that some sort of array is returned, even if + // ArrayBuffers are not supported. the binary string fallback, however, is unsafe. + if (options.binary) { + var buffer = xhr.response; + if (!buffer) { + buffer = []; + for (var i = 0; i < xhr.responseText.length; ++i) + buffer.push(xhr.responseText.charCodeAt(i) & 255); + } + return callback(null, typeof Uint8Array !== "undefined" ? new Uint8Array(buffer) : buffer); + } + return callback(null, xhr.responseText); + }; + + if (options.binary) { + // ref: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Sending_and_Receiving_Binary_Data#Receiving_binary_data_in_older_browsers + if ("overrideMimeType" in xhr) + xhr.overrideMimeType("text/plain; charset=x-user-defined"); + xhr.responseType = "arraybuffer"; + } + + xhr.open("GET", filename); + xhr.send(); +}; + +},{"1":1,"7":7}],6:[function(require,module,exports){ +"use strict"; + +module.exports = factory(factory); + +/** + * Reads / writes floats / doubles from / to buffers. + * @name util.float + * @namespace + */ + +/** + * Writes a 32 bit float to a buffer using little endian byte order. + * @name util.float.writeFloatLE + * @function + * @param {number} val Value to write + * @param {Uint8Array} buf Target buffer + * @param {number} pos Target buffer offset + * @returns {undefined} + */ + +/** + * Writes a 32 bit float to a buffer using big endian byte order. + * @name util.float.writeFloatBE + * @function + * @param {number} val Value to write + * @param {Uint8Array} buf Target buffer + * @param {number} pos Target buffer offset + * @returns {undefined} + */ + +/** + * Reads a 32 bit float from a buffer using little endian byte order. + * @name util.float.readFloatLE + * @function + * @param {Uint8Array} buf Source buffer + * @param {number} pos Source buffer offset + * @returns {number} Value read + */ + +/** + * Reads a 32 bit float from a buffer using big endian byte order. + * @name util.float.readFloatBE + * @function + * @param {Uint8Array} buf Source buffer + * @param {number} pos Source buffer offset + * @returns {number} Value read + */ + +/** + * Writes a 64 bit double to a buffer using little endian byte order. + * @name util.float.writeDoubleLE + * @function + * @param {number} val Value to write + * @param {Uint8Array} buf Target buffer + * @param {number} pos Target buffer offset + * @returns {undefined} + */ + +/** + * Writes a 64 bit double to a buffer using big endian byte order. + * @name util.float.writeDoubleBE + * @function + * @param {number} val Value to write + * @param {Uint8Array} buf Target buffer + * @param {number} pos Target buffer offset + * @returns {undefined} + */ + +/** + * Reads a 64 bit double from a buffer using little endian byte order. + * @name util.float.readDoubleLE + * @function + * @param {Uint8Array} buf Source buffer + * @param {number} pos Source buffer offset + * @returns {number} Value read + */ + +/** + * Reads a 64 bit double from a buffer using big endian byte order. + * @name util.float.readDoubleBE + * @function + * @param {Uint8Array} buf Source buffer + * @param {number} pos Source buffer offset + * @returns {number} Value read + */ + +// Factory function for the purpose of node-based testing in modified global environments +function factory(exports) { + + // float: typed array + if (typeof Float32Array !== "undefined") (function() { + + var f32 = new Float32Array([ -0 ]), + f8b = new Uint8Array(f32.buffer), + le = f8b[3] === 128; + + function writeFloat_f32_cpy(val, buf, pos) { + f32[0] = val; + buf[pos ] = f8b[0]; + buf[pos + 1] = f8b[1]; + buf[pos + 2] = f8b[2]; + buf[pos + 3] = f8b[3]; + } + + function writeFloat_f32_rev(val, buf, pos) { + f32[0] = val; + buf[pos ] = f8b[3]; + buf[pos + 1] = f8b[2]; + buf[pos + 2] = f8b[1]; + buf[pos + 3] = f8b[0]; + } + + /* istanbul ignore next */ + exports.writeFloatLE = le ? writeFloat_f32_cpy : writeFloat_f32_rev; + /* istanbul ignore next */ + exports.writeFloatBE = le ? writeFloat_f32_rev : writeFloat_f32_cpy; + + function readFloat_f32_cpy(buf, pos) { + f8b[0] = buf[pos ]; + f8b[1] = buf[pos + 1]; + f8b[2] = buf[pos + 2]; + f8b[3] = buf[pos + 3]; + return f32[0]; + } + + function readFloat_f32_rev(buf, pos) { + f8b[3] = buf[pos ]; + f8b[2] = buf[pos + 1]; + f8b[1] = buf[pos + 2]; + f8b[0] = buf[pos + 3]; + return f32[0]; + } + + /* istanbul ignore next */ + exports.readFloatLE = le ? readFloat_f32_cpy : readFloat_f32_rev; + /* istanbul ignore next */ + exports.readFloatBE = le ? readFloat_f32_rev : readFloat_f32_cpy; + + // float: ieee754 + })(); else (function() { + + function writeFloat_ieee754(writeUint, val, buf, pos) { + var sign = val < 0 ? 1 : 0; + if (sign) + val = -val; + if (val === 0) + writeUint(1 / val > 0 ? /* positive */ 0 : /* negative 0 */ 2147483648, buf, pos); + else if (isNaN(val)) + writeUint(2143289344, buf, pos); + else if (val > 3.4028234663852886e+38) // +-Infinity + writeUint((sign << 31 | 2139095040) >>> 0, buf, pos); + else if (val < 1.1754943508222875e-38) // denormal + writeUint((sign << 31 | Math.round(val / 1.401298464324817e-45)) >>> 0, buf, pos); + else { + var exponent = Math.floor(Math.log(val) / Math.LN2), + mantissa = Math.round(val * Math.pow(2, -exponent) * 8388608) & 8388607; + writeUint((sign << 31 | exponent + 127 << 23 | mantissa) >>> 0, buf, pos); + } + } + + exports.writeFloatLE = writeFloat_ieee754.bind(null, writeUintLE); + exports.writeFloatBE = writeFloat_ieee754.bind(null, writeUintBE); + + function readFloat_ieee754(readUint, buf, pos) { + var uint = readUint(buf, pos), + sign = (uint >> 31) * 2 + 1, + exponent = uint >>> 23 & 255, + mantissa = uint & 8388607; + return exponent === 255 + ? mantissa + ? NaN + : sign * Infinity + : exponent === 0 // denormal + ? sign * 1.401298464324817e-45 * mantissa + : sign * Math.pow(2, exponent - 150) * (mantissa + 8388608); + } + + exports.readFloatLE = readFloat_ieee754.bind(null, readUintLE); + exports.readFloatBE = readFloat_ieee754.bind(null, readUintBE); + + })(); + + // double: typed array + if (typeof Float64Array !== "undefined") (function() { + + var f64 = new Float64Array([-0]), + f8b = new Uint8Array(f64.buffer), + le = f8b[7] === 128; + + function writeDouble_f64_cpy(val, buf, pos) { + f64[0] = val; + buf[pos ] = f8b[0]; + buf[pos + 1] = f8b[1]; + buf[pos + 2] = f8b[2]; + buf[pos + 3] = f8b[3]; + buf[pos + 4] = f8b[4]; + buf[pos + 5] = f8b[5]; + buf[pos + 6] = f8b[6]; + buf[pos + 7] = f8b[7]; + } + + function writeDouble_f64_rev(val, buf, pos) { + f64[0] = val; + buf[pos ] = f8b[7]; + buf[pos + 1] = f8b[6]; + buf[pos + 2] = f8b[5]; + buf[pos + 3] = f8b[4]; + buf[pos + 4] = f8b[3]; + buf[pos + 5] = f8b[2]; + buf[pos + 6] = f8b[1]; + buf[pos + 7] = f8b[0]; + } + + /* istanbul ignore next */ + exports.writeDoubleLE = le ? writeDouble_f64_cpy : writeDouble_f64_rev; + /* istanbul ignore next */ + exports.writeDoubleBE = le ? writeDouble_f64_rev : writeDouble_f64_cpy; + + function readDouble_f64_cpy(buf, pos) { + f8b[0] = buf[pos ]; + f8b[1] = buf[pos + 1]; + f8b[2] = buf[pos + 2]; + f8b[3] = buf[pos + 3]; + f8b[4] = buf[pos + 4]; + f8b[5] = buf[pos + 5]; + f8b[6] = buf[pos + 6]; + f8b[7] = buf[pos + 7]; + return f64[0]; + } + + function readDouble_f64_rev(buf, pos) { + f8b[7] = buf[pos ]; + f8b[6] = buf[pos + 1]; + f8b[5] = buf[pos + 2]; + f8b[4] = buf[pos + 3]; + f8b[3] = buf[pos + 4]; + f8b[2] = buf[pos + 5]; + f8b[1] = buf[pos + 6]; + f8b[0] = buf[pos + 7]; + return f64[0]; + } + + /* istanbul ignore next */ + exports.readDoubleLE = le ? readDouble_f64_cpy : readDouble_f64_rev; + /* istanbul ignore next */ + exports.readDoubleBE = le ? readDouble_f64_rev : readDouble_f64_cpy; + + // double: ieee754 + })(); else (function() { + + function writeDouble_ieee754(writeUint, off0, off1, val, buf, pos) { + var sign = val < 0 ? 1 : 0; + if (sign) + val = -val; + if (val === 0) { + writeUint(0, buf, pos + off0); + writeUint(1 / val > 0 ? /* positive */ 0 : /* negative 0 */ 2147483648, buf, pos + off1); + } else if (isNaN(val)) { + writeUint(0, buf, pos + off0); + writeUint(2146959360, buf, pos + off1); + } else if (val > 1.7976931348623157e+308) { // +-Infinity + writeUint(0, buf, pos + off0); + writeUint((sign << 31 | 2146435072) >>> 0, buf, pos + off1); + } else { + var mantissa; + if (val < 2.2250738585072014e-308) { // denormal + mantissa = val / 5e-324; + writeUint(mantissa >>> 0, buf, pos + off0); + writeUint((sign << 31 | mantissa / 4294967296) >>> 0, buf, pos + off1); + } else { + var exponent = Math.floor(Math.log(val) / Math.LN2); + if (exponent === 1024) + exponent = 1023; + mantissa = val * Math.pow(2, -exponent); + writeUint(mantissa * 4503599627370496 >>> 0, buf, pos + off0); + writeUint((sign << 31 | exponent + 1023 << 20 | mantissa * 1048576 & 1048575) >>> 0, buf, pos + off1); + } + } + } + + exports.writeDoubleLE = writeDouble_ieee754.bind(null, writeUintLE, 0, 4); + exports.writeDoubleBE = writeDouble_ieee754.bind(null, writeUintBE, 4, 0); + + function readDouble_ieee754(readUint, off0, off1, buf, pos) { + var lo = readUint(buf, pos + off0), + hi = readUint(buf, pos + off1); + var sign = (hi >> 31) * 2 + 1, + exponent = hi >>> 20 & 2047, + mantissa = 4294967296 * (hi & 1048575) + lo; + return exponent === 2047 + ? mantissa + ? NaN + : sign * Infinity + : exponent === 0 // denormal + ? sign * 5e-324 * mantissa + : sign * Math.pow(2, exponent - 1075) * (mantissa + 4503599627370496); + } + + exports.readDoubleLE = readDouble_ieee754.bind(null, readUintLE, 0, 4); + exports.readDoubleBE = readDouble_ieee754.bind(null, readUintBE, 4, 0); + + })(); + + return exports; +} + +// uint helpers + +function writeUintLE(val, buf, pos) { + buf[pos ] = val & 255; + buf[pos + 1] = val >>> 8 & 255; + buf[pos + 2] = val >>> 16 & 255; + buf[pos + 3] = val >>> 24; +} + +function writeUintBE(val, buf, pos) { + buf[pos ] = val >>> 24; + buf[pos + 1] = val >>> 16 & 255; + buf[pos + 2] = val >>> 8 & 255; + buf[pos + 3] = val & 255; +} + +function readUintLE(buf, pos) { + return (buf[pos ] + | buf[pos + 1] << 8 + | buf[pos + 2] << 16 + | buf[pos + 3] << 24) >>> 0; +} + +function readUintBE(buf, pos) { + return (buf[pos ] << 24 + | buf[pos + 1] << 16 + | buf[pos + 2] << 8 + | buf[pos + 3]) >>> 0; +} + +},{}],7:[function(require,module,exports){ +"use strict"; +module.exports = inquire; + +/** + * Requires a module only if available. + * @memberof util + * @param {string} moduleName Module to require + * @returns {?Object} Required module if available and not empty, otherwise `null` + */ +function inquire(moduleName) { + try { + var mod = eval("quire".replace(/^/,"re"))(moduleName); // eslint-disable-line no-eval + if (mod && (mod.length || Object.keys(mod).length)) + return mod; + } catch (e) {} // eslint-disable-line no-empty + return null; +} + +},{}],8:[function(require,module,exports){ +"use strict"; + +/** + * A minimal path module to resolve Unix, Windows and URL paths alike. + * @memberof util + * @namespace + */ +var path = exports; + +var isAbsolute = +/** + * Tests if the specified path is absolute. + * @param {string} path Path to test + * @returns {boolean} `true` if path is absolute + */ +path.isAbsolute = function isAbsolute(path) { + return /^(?:\/|\w+:)/.test(path); +}; + +var normalize = +/** + * Normalizes the specified path. + * @param {string} path Path to normalize + * @returns {string} Normalized path + */ +path.normalize = function normalize(path) { + path = path.replace(/\\/g, "/") + .replace(/\/{2,}/g, "/"); + var parts = path.split("/"), + absolute = isAbsolute(path), + prefix = ""; + if (absolute) + prefix = parts.shift() + "/"; + for (var i = 0; i < parts.length;) { + if (parts[i] === "..") { + if (i > 0 && parts[i - 1] !== "..") + parts.splice(--i, 2); + else if (absolute) + parts.splice(i, 1); + else + ++i; + } else if (parts[i] === ".") + parts.splice(i, 1); + else + ++i; + } + return prefix + parts.join("/"); +}; + +/** + * Resolves the specified include path against the specified origin path. + * @param {string} originPath Path to the origin file + * @param {string} includePath Include path relative to origin path + * @param {boolean} [alreadyNormalized=false] `true` if both paths are already known to be normalized + * @returns {string} Path to the include file + */ +path.resolve = function resolve(originPath, includePath, alreadyNormalized) { + if (!alreadyNormalized) + includePath = normalize(includePath); + if (isAbsolute(includePath)) + return includePath; + if (!alreadyNormalized) + originPath = normalize(originPath); + return (originPath = originPath.replace(/(?:\/|^)[^/]+$/, "")).length ? normalize(originPath + "/" + includePath) : includePath; +}; + +},{}],9:[function(require,module,exports){ +"use strict"; +module.exports = pool; + +/** + * An allocator as used by {@link util.pool}. + * @typedef PoolAllocator + * @type {function} + * @param {number} size Buffer size + * @returns {Uint8Array} Buffer + */ + +/** + * A slicer as used by {@link util.pool}. + * @typedef PoolSlicer + * @type {function} + * @param {number} start Start offset + * @param {number} end End offset + * @returns {Uint8Array} Buffer slice + * @this {Uint8Array} + */ + +/** + * A general purpose buffer pool. + * @memberof util + * @function + * @param {PoolAllocator} alloc Allocator + * @param {PoolSlicer} slice Slicer + * @param {number} [size=8192] Slab size + * @returns {PoolAllocator} Pooled allocator + */ +function pool(alloc, slice, size) { + var SIZE = size || 8192; + var MAX = SIZE >>> 1; + var slab = null; + var offset = SIZE; + return function pool_alloc(size) { + if (size < 1 || size > MAX) + return alloc(size); + if (offset + size > SIZE) { + slab = alloc(SIZE); + offset = 0; + } + var buf = slice.call(slab, offset, offset += size); + if (offset & 7) // align to 32 bit + offset = (offset | 7) + 1; + return buf; + }; +} + +},{}],10:[function(require,module,exports){ +"use strict"; + +/** + * A minimal UTF8 implementation for number arrays. + * @memberof util + * @namespace + */ +var utf8 = exports; + +/** + * Calculates the UTF8 byte length of a string. + * @param {string} string String + * @returns {number} Byte length + */ +utf8.length = function utf8_length(string) { + var len = 0, + c = 0; + for (var i = 0; i < string.length; ++i) { + c = string.charCodeAt(i); + if (c < 128) + len += 1; + else if (c < 2048) + len += 2; + else if ((c & 0xFC00) === 0xD800 && (string.charCodeAt(i + 1) & 0xFC00) === 0xDC00) { + ++i; + len += 4; + } else + len += 3; + } + return len; +}; + +/** + * Reads UTF8 bytes as a string. + * @param {Uint8Array} buffer Source buffer + * @param {number} start Source start + * @param {number} end Source end + * @returns {string} String read + */ +utf8.read = function utf8_read(buffer, start, end) { + var len = end - start; + if (len < 1) + return ""; + var parts = null, + chunk = [], + i = 0, // char offset + t; // temporary + while (start < end) { + t = buffer[start++]; + if (t < 128) + chunk[i++] = t; + else if (t > 191 && t < 224) + chunk[i++] = (t & 31) << 6 | buffer[start++] & 63; + else if (t > 239 && t < 365) { + t = ((t & 7) << 18 | (buffer[start++] & 63) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63) - 0x10000; + chunk[i++] = 0xD800 + (t >> 10); + chunk[i++] = 0xDC00 + (t & 1023); + } else + chunk[i++] = (t & 15) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63; + if (i > 8191) { + (parts || (parts = [])).push(String.fromCharCode.apply(String, chunk)); + i = 0; + } + } + if (parts) { + if (i) + parts.push(String.fromCharCode.apply(String, chunk.slice(0, i))); + return parts.join(""); + } + return String.fromCharCode.apply(String, chunk.slice(0, i)); +}; + +/** + * Writes a string as UTF8 bytes. + * @param {string} string Source string + * @param {Uint8Array} buffer Destination buffer + * @param {number} offset Destination offset + * @returns {number} Bytes written + */ +utf8.write = function utf8_write(string, buffer, offset) { + var start = offset, + c1, // character 1 + c2; // character 2 + for (var i = 0; i < string.length; ++i) { + c1 = string.charCodeAt(i); + if (c1 < 128) { + buffer[offset++] = c1; + } else if (c1 < 2048) { + buffer[offset++] = c1 >> 6 | 192; + buffer[offset++] = c1 & 63 | 128; + } else if ((c1 & 0xFC00) === 0xD800 && ((c2 = string.charCodeAt(i + 1)) & 0xFC00) === 0xDC00) { + c1 = 0x10000 + ((c1 & 0x03FF) << 10) + (c2 & 0x03FF); + ++i; + buffer[offset++] = c1 >> 18 | 240; + buffer[offset++] = c1 >> 12 & 63 | 128; + buffer[offset++] = c1 >> 6 & 63 | 128; + buffer[offset++] = c1 & 63 | 128; + } else { + buffer[offset++] = c1 >> 12 | 224; + buffer[offset++] = c1 >> 6 & 63 | 128; + buffer[offset++] = c1 & 63 | 128; + } + } + return offset - start; +}; + +},{}],11:[function(require,module,exports){ +"use strict"; +module.exports = common; + +var commonRe = /\/|\./; + +/** + * Provides common type definitions. + * Can also be used to provide additional google types or your own custom types. + * @param {string} name Short name as in `google/protobuf/[name].proto` or full file name + * @param {Object.} json JSON definition within `google.protobuf` if a short name, otherwise the file's root definition + * @returns {undefined} + * @property {INamespace} google/protobuf/any.proto Any + * @property {INamespace} google/protobuf/duration.proto Duration + * @property {INamespace} google/protobuf/empty.proto Empty + * @property {INamespace} google/protobuf/field_mask.proto FieldMask + * @property {INamespace} google/protobuf/struct.proto Struct, Value, NullValue and ListValue + * @property {INamespace} google/protobuf/timestamp.proto Timestamp + * @property {INamespace} google/protobuf/wrappers.proto Wrappers + * @example + * // manually provides descriptor.proto (assumes google/protobuf/ namespace and .proto extension) + * protobuf.common("descriptor", descriptorJson); + * + * // manually provides a custom definition (uses my.foo namespace) + * protobuf.common("my/foo/bar.proto", myFooBarJson); + */ +function common(name, json) { + if (!commonRe.test(name)) { + name = "google/protobuf/" + name + ".proto"; + json = { nested: { google: { nested: { protobuf: { nested: json } } } } }; + } + common[name] = json; +} + +// Not provided because of limited use (feel free to discuss or to provide yourself): +// +// google/protobuf/descriptor.proto +// google/protobuf/source_context.proto +// google/protobuf/type.proto +// +// Stripped and pre-parsed versions of these non-bundled files are instead available as part of +// the repository or package within the google/protobuf directory. + +common("any", { + + /** + * Properties of a google.protobuf.Any message. + * @interface IAny + * @type {Object} + * @property {string} [typeUrl] + * @property {Uint8Array} [bytes] + * @memberof common + */ + Any: { + fields: { + type_url: { + type: "string", + id: 1 + }, + value: { + type: "bytes", + id: 2 + } + } + } +}); + +var timeType; + +common("duration", { + + /** + * Properties of a google.protobuf.Duration message. + * @interface IDuration + * @type {Object} + * @property {number|Long} [seconds] + * @property {number} [nanos] + * @memberof common + */ + Duration: timeType = { + fields: { + seconds: { + type: "int64", + id: 1 + }, + nanos: { + type: "int32", + id: 2 + } + } + } +}); + +common("timestamp", { + + /** + * Properties of a google.protobuf.Timestamp message. + * @interface ITimestamp + * @type {Object} + * @property {number|Long} [seconds] + * @property {number} [nanos] + * @memberof common + */ + Timestamp: timeType +}); + +common("empty", { + + /** + * Properties of a google.protobuf.Empty message. + * @interface IEmpty + * @memberof common + */ + Empty: { + fields: {} + } +}); + +common("struct", { + + /** + * Properties of a google.protobuf.Struct message. + * @interface IStruct + * @type {Object} + * @property {Object.} [fields] + * @memberof common + */ + Struct: { + fields: { + fields: { + keyType: "string", + type: "Value", + id: 1 + } + } + }, + + /** + * Properties of a google.protobuf.Value message. + * @interface IValue + * @type {Object} + * @property {string} [kind] + * @property {0} [nullValue] + * @property {number} [numberValue] + * @property {string} [stringValue] + * @property {boolean} [boolValue] + * @property {IStruct} [structValue] + * @property {IListValue} [listValue] + * @memberof common + */ + Value: { + oneofs: { + kind: { + oneof: [ + "nullValue", + "numberValue", + "stringValue", + "boolValue", + "structValue", + "listValue" + ] + } + }, + fields: { + nullValue: { + type: "NullValue", + id: 1 + }, + numberValue: { + type: "double", + id: 2 + }, + stringValue: { + type: "string", + id: 3 + }, + boolValue: { + type: "bool", + id: 4 + }, + structValue: { + type: "Struct", + id: 5 + }, + listValue: { + type: "ListValue", + id: 6 + } + } + }, + + NullValue: { + values: { + NULL_VALUE: 0 + } + }, + + /** + * Properties of a google.protobuf.ListValue message. + * @interface IListValue + * @type {Object} + * @property {Array.} [values] + * @memberof common + */ + ListValue: { + fields: { + values: { + rule: "repeated", + type: "Value", + id: 1 + } + } + } +}); + +common("wrappers", { + + /** + * Properties of a google.protobuf.DoubleValue message. + * @interface IDoubleValue + * @type {Object} + * @property {number} [value] + * @memberof common + */ + DoubleValue: { + fields: { + value: { + type: "double", + id: 1 + } + } + }, + + /** + * Properties of a google.protobuf.FloatValue message. + * @interface IFloatValue + * @type {Object} + * @property {number} [value] + * @memberof common + */ + FloatValue: { + fields: { + value: { + type: "float", + id: 1 + } + } + }, + + /** + * Properties of a google.protobuf.Int64Value message. + * @interface IInt64Value + * @type {Object} + * @property {number|Long} [value] + * @memberof common + */ + Int64Value: { + fields: { + value: { + type: "int64", + id: 1 + } + } + }, + + /** + * Properties of a google.protobuf.UInt64Value message. + * @interface IUInt64Value + * @type {Object} + * @property {number|Long} [value] + * @memberof common + */ + UInt64Value: { + fields: { + value: { + type: "uint64", + id: 1 + } + } + }, + + /** + * Properties of a google.protobuf.Int32Value message. + * @interface IInt32Value + * @type {Object} + * @property {number} [value] + * @memberof common + */ + Int32Value: { + fields: { + value: { + type: "int32", + id: 1 + } + } + }, + + /** + * Properties of a google.protobuf.UInt32Value message. + * @interface IUInt32Value + * @type {Object} + * @property {number} [value] + * @memberof common + */ + UInt32Value: { + fields: { + value: { + type: "uint32", + id: 1 + } + } + }, + + /** + * Properties of a google.protobuf.BoolValue message. + * @interface IBoolValue + * @type {Object} + * @property {boolean} [value] + * @memberof common + */ + BoolValue: { + fields: { + value: { + type: "bool", + id: 1 + } + } + }, + + /** + * Properties of a google.protobuf.StringValue message. + * @interface IStringValue + * @type {Object} + * @property {string} [value] + * @memberof common + */ + StringValue: { + fields: { + value: { + type: "string", + id: 1 + } + } + }, + + /** + * Properties of a google.protobuf.BytesValue message. + * @interface IBytesValue + * @type {Object} + * @property {Uint8Array} [value] + * @memberof common + */ + BytesValue: { + fields: { + value: { + type: "bytes", + id: 1 + } + } + } +}); + +common("field_mask", { + + /** + * Properties of a google.protobuf.FieldMask message. + * @interface IDoubleValue + * @type {Object} + * @property {number} [value] + * @memberof common + */ + FieldMask: { + fields: { + paths: { + rule: "repeated", + type: "string", + id: 1 + } + } + } +}); + +/** + * Gets the root definition of the specified common proto file. + * + * Bundled definitions are: + * - google/protobuf/any.proto + * - google/protobuf/duration.proto + * - google/protobuf/empty.proto + * - google/protobuf/field_mask.proto + * - google/protobuf/struct.proto + * - google/protobuf/timestamp.proto + * - google/protobuf/wrappers.proto + * + * @param {string} file Proto file name + * @returns {INamespace|null} Root definition or `null` if not defined + */ +common.get = function get(file) { + return common[file] || null; +}; + +},{}],12:[function(require,module,exports){ +"use strict"; +/** + * Runtime message from/to plain object converters. + * @namespace + */ +var converter = exports; + +var Enum = require(15), + util = require(37); + +/** + * Generates a partial value fromObject conveter. + * @param {Codegen} gen Codegen instance + * @param {Field} field Reflected field + * @param {number} fieldIndex Field index + * @param {string} prop Property reference + * @returns {Codegen} Codegen instance + * @ignore + */ +function genValuePartial_fromObject(gen, field, fieldIndex, prop) { + /* eslint-disable no-unexpected-multiline, block-scoped-var, no-redeclare */ + if (field.resolvedType) { + if (field.resolvedType instanceof Enum) { gen + ("switch(d%s){", prop); + for (var values = field.resolvedType.values, keys = Object.keys(values), i = 0; i < keys.length; ++i) { + if (field.repeated && values[keys[i]] === field.typeDefault) gen + ("default:"); + gen + ("case%j:", keys[i]) + ("case %i:", values[keys[i]]) + ("m%s=%j", prop, values[keys[i]]) + ("break"); + } gen + ("}"); + } else gen + ("if(typeof d%s!==\"object\")", prop) + ("throw TypeError(%j)", field.fullName + ": object expected") + ("m%s=types[%i].fromObject(d%s)", prop, fieldIndex, prop); + } else { + var isUnsigned = false; + switch (field.type) { + case "double": + case "float": gen + ("m%s=Number(d%s)", prop, prop); // also catches "NaN", "Infinity" + break; + case "uint32": + case "fixed32": gen + ("m%s=d%s>>>0", prop, prop); + break; + case "int32": + case "sint32": + case "sfixed32": gen + ("m%s=d%s|0", prop, prop); + break; + case "uint64": + isUnsigned = true; + // eslint-disable-line no-fallthrough + case "int64": + case "sint64": + case "fixed64": + case "sfixed64": gen + ("if(util.Long)") + ("(m%s=util.Long.fromValue(d%s)).unsigned=%j", prop, prop, isUnsigned) + ("else if(typeof d%s===\"string\")", prop) + ("m%s=parseInt(d%s,10)", prop, prop) + ("else if(typeof d%s===\"number\")", prop) + ("m%s=d%s", prop, prop) + ("else if(typeof d%s===\"object\")", prop) + ("m%s=new util.LongBits(d%s.low>>>0,d%s.high>>>0).toNumber(%s)", prop, prop, prop, isUnsigned ? "true" : ""); + break; + case "bytes": gen + ("if(typeof d%s===\"string\")", prop) + ("util.base64.decode(d%s,m%s=util.newBuffer(util.base64.length(d%s)),0)", prop, prop, prop) + ("else if(d%s.length)", prop) + ("m%s=d%s", prop, prop); + break; + case "string": gen + ("m%s=String(d%s)", prop, prop); + break; + case "bool": gen + ("m%s=Boolean(d%s)", prop, prop); + break; + /* default: gen + ("m%s=d%s", prop, prop); + break; */ + } + } + return gen; + /* eslint-enable no-unexpected-multiline, block-scoped-var, no-redeclare */ +} + +/** + * Generates a plain object to runtime message converter specific to the specified message type. + * @param {Type} mtype Message type + * @returns {Codegen} Codegen instance + */ +converter.fromObject = function fromObject(mtype) { + /* eslint-disable no-unexpected-multiline, block-scoped-var, no-redeclare */ + var fields = mtype.fieldsArray; + var gen = util.codegen(["d"], mtype.name + "$fromObject") + ("if(d instanceof this.ctor)") + ("return d"); + if (!fields.length) return gen + ("return new this.ctor"); + gen + ("var m=new this.ctor"); + for (var i = 0; i < fields.length; ++i) { + var field = fields[i].resolve(), + prop = util.safeProp(field.name); + + // Map fields + if (field.map) { gen + ("if(d%s){", prop) + ("if(typeof d%s!==\"object\")", prop) + ("throw TypeError(%j)", field.fullName + ": object expected") + ("m%s={}", prop) + ("for(var ks=Object.keys(d%s),i=0;i>>0,m%s.high>>>0).toNumber(%s):m%s", prop, prop, prop, prop, isUnsigned ? "true": "", prop); + break; + case "bytes": gen + ("d%s=o.bytes===String?util.base64.encode(m%s,0,m%s.length):o.bytes===Array?Array.prototype.slice.call(m%s):m%s", prop, prop, prop, prop, prop); + break; + default: gen + ("d%s=m%s", prop, prop); + break; + } + } + return gen; + /* eslint-enable no-unexpected-multiline, block-scoped-var, no-redeclare */ +} + +/** + * Generates a runtime message to plain object converter specific to the specified message type. + * @param {Type} mtype Message type + * @returns {Codegen} Codegen instance + */ +converter.toObject = function toObject(mtype) { + /* eslint-disable no-unexpected-multiline, block-scoped-var, no-redeclare */ + var fields = mtype.fieldsArray.slice().sort(util.compareFieldsById); + if (!fields.length) + return util.codegen()("return {}"); + var gen = util.codegen(["m", "o"], mtype.name + "$toObject") + ("if(!o)") + ("o={}") + ("var d={}"); + + var repeatedFields = [], + mapFields = [], + normalFields = [], + i = 0; + for (; i < fields.length; ++i) + if (!fields[i].partOf) + ( fields[i].resolve().repeated ? repeatedFields + : fields[i].map ? mapFields + : normalFields).push(fields[i]); + + if (repeatedFields.length) { gen + ("if(o.arrays||o.defaults){"); + for (i = 0; i < repeatedFields.length; ++i) gen + ("d%s=[]", util.safeProp(repeatedFields[i].name)); + gen + ("}"); + } + + if (mapFields.length) { gen + ("if(o.objects||o.defaults){"); + for (i = 0; i < mapFields.length; ++i) gen + ("d%s={}", util.safeProp(mapFields[i].name)); + gen + ("}"); + } + + if (normalFields.length) { gen + ("if(o.defaults){"); + for (i = 0; i < normalFields.length; ++i) { + var field = normalFields[i], + prop = util.safeProp(field.name); + if (field.resolvedType instanceof Enum) gen + ("d%s=o.enums===String?%j:%j", prop, field.resolvedType.valuesById[field.typeDefault], field.typeDefault); + else if (field.long) gen + ("if(util.Long){") + ("var n=new util.Long(%i,%i,%j)", field.typeDefault.low, field.typeDefault.high, field.typeDefault.unsigned) + ("d%s=o.longs===String?n.toString():o.longs===Number?n.toNumber():n", prop) + ("}else") + ("d%s=o.longs===String?%j:%i", prop, field.typeDefault.toString(), field.typeDefault.toNumber()); + else if (field.bytes) { + var arrayDefault = "[" + Array.prototype.slice.call(field.typeDefault).join(",") + "]"; + gen + ("if(o.bytes===String)d%s=%j", prop, String.fromCharCode.apply(String, field.typeDefault)) + ("else{") + ("d%s=%s", prop, arrayDefault) + ("if(o.bytes!==Array)d%s=util.newBuffer(d%s)", prop, prop) + ("}"); + } else gen + ("d%s=%j", prop, field.typeDefault); // also messages (=null) + } gen + ("}"); + } + var hasKs2 = false; + for (i = 0; i < fields.length; ++i) { + var field = fields[i], + index = mtype._fieldsArray.indexOf(field), + prop = util.safeProp(field.name); + if (field.map) { + if (!hasKs2) { hasKs2 = true; gen + ("var ks2"); + } gen + ("if(m%s&&(ks2=Object.keys(m%s)).length){", prop, prop) + ("d%s={}", prop) + ("for(var j=0;j>>3){"); + + var i = 0; + for (; i < /* initializes */ mtype.fieldsArray.length; ++i) { + var field = mtype._fieldsArray[i].resolve(), + type = field.resolvedType instanceof Enum ? "int32" : field.type, + ref = "m" + util.safeProp(field.name); gen + ("case %i:", field.id); + + // Map fields + if (field.map) { gen + ("r.skip().pos++") // assumes id 1 + key wireType + ("if(%s===util.emptyObject)", ref) + ("%s={}", ref) + ("k=r.%s()", field.keyType) + ("r.pos++"); // assumes id 2 + value wireType + if (types.long[field.keyType] !== undefined) { + if (types.basic[type] === undefined) gen + ("%s[typeof k===\"object\"?util.longToHash(k):k]=types[%i].decode(r,r.uint32())", ref, i); // can't be groups + else gen + ("%s[typeof k===\"object\"?util.longToHash(k):k]=r.%s()", ref, type); + } else { + if (types.basic[type] === undefined) gen + ("%s[k]=types[%i].decode(r,r.uint32())", ref, i); // can't be groups + else gen + ("%s[k]=r.%s()", ref, type); + } + + // Repeated fields + } else if (field.repeated) { gen + + ("if(!(%s&&%s.length))", ref, ref) + ("%s=[]", ref); + + // Packable (always check for forward and backward compatiblity) + if (types.packed[type] !== undefined) gen + ("if((t&7)===2){") + ("var c2=r.uint32()+r.pos") + ("while(r.pos>> 0, (field.id << 3 | 4) >>> 0) + : gen("types[%i].encode(%s,w.uint32(%i).fork()).ldelim()", fieldIndex, ref, (field.id << 3 | 2) >>> 0); +} + +/** + * Generates an encoder specific to the specified message type. + * @param {Type} mtype Message type + * @returns {Codegen} Codegen instance + */ +function encoder(mtype) { + /* eslint-disable no-unexpected-multiline, block-scoped-var, no-redeclare */ + var gen = util.codegen(["m", "w"], mtype.name + "$encode") + ("if(!w)") + ("w=Writer.create()"); + + var i, ref; + + // "when a message is serialized its known fields should be written sequentially by field number" + var fields = /* initializes */ mtype.fieldsArray.slice().sort(util.compareFieldsById); + + for (var i = 0; i < fields.length; ++i) { + var field = fields[i].resolve(), + index = mtype._fieldsArray.indexOf(field), + type = field.resolvedType instanceof Enum ? "int32" : field.type, + wireType = types.basic[type]; + ref = "m" + util.safeProp(field.name); + + // Map fields + if (field.map) { + gen + ("if(%s!=null&&m.hasOwnProperty(%j)){", ref, field.name) // !== undefined && !== null + ("for(var ks=Object.keys(%s),i=0;i>> 0, 8 | types.mapKey[field.keyType], field.keyType); + if (wireType === undefined) gen + ("types[%i].encode(%s[ks[i]],w.uint32(18).fork()).ldelim().ldelim()", index, ref); // can't be groups + else gen + (".uint32(%i).%s(%s[ks[i]]).ldelim()", 16 | wireType, type, ref); + gen + ("}") + ("}"); + + // Repeated fields + } else if (field.repeated) { gen + ("if(%s!=null&&%s.length){", ref, ref); // !== undefined && !== null + + // Packed repeated + if (field.packed && types.packed[type] !== undefined) { gen + + ("w.uint32(%i).fork()", (field.id << 3 | 2) >>> 0) + ("for(var i=0;i<%s.length;++i)", ref) + ("w.%s(%s[i])", type, ref) + ("w.ldelim()"); + + // Non-packed + } else { gen + + ("for(var i=0;i<%s.length;++i)", ref); + if (wireType === undefined) + genTypePartial(gen, field, index, ref + "[i]"); + else gen + ("w.uint32(%i).%s(%s[i])", (field.id << 3 | wireType) >>> 0, type, ref); + + } gen + ("}"); + + // Non-repeated + } else { + if (field.optional) gen + ("if(%s!=null&&m.hasOwnProperty(%j))", ref, field.name); // !== undefined && !== null + + if (wireType === undefined) + genTypePartial(gen, field, index, ref); + else gen + ("w.uint32(%i).%s(%s)", (field.id << 3 | wireType) >>> 0, type, ref); + + } + } + + return gen + ("return w"); + /* eslint-enable no-unexpected-multiline, block-scoped-var, no-redeclare */ +} +},{"15":15,"36":36,"37":37}],15:[function(require,module,exports){ +"use strict"; +module.exports = Enum; + +// extends ReflectionObject +var ReflectionObject = require(24); +((Enum.prototype = Object.create(ReflectionObject.prototype)).constructor = Enum).className = "Enum"; + +var Namespace = require(23), + util = require(37); + +/** + * Constructs a new enum instance. + * @classdesc Reflected enum. + * @extends ReflectionObject + * @constructor + * @param {string} name Unique name within its namespace + * @param {Object.} [values] Enum values as an object, by name + * @param {Object.} [options] Declared options + * @param {string} [comment] The comment for this enum + * @param {Object.} [comments] The value comments for this enum + */ +function Enum(name, values, options, comment, comments) { + ReflectionObject.call(this, name, options); + + if (values && typeof values !== "object") + throw TypeError("values must be an object"); + + /** + * Enum values by id. + * @type {Object.} + */ + this.valuesById = {}; + + /** + * Enum values by name. + * @type {Object.} + */ + this.values = Object.create(this.valuesById); // toJSON, marker + + /** + * Enum comment text. + * @type {string|null} + */ + this.comment = comment; + + /** + * Value comment texts, if any. + * @type {Object.} + */ + this.comments = comments || {}; + + /** + * Reserved ranges, if any. + * @type {Array.} + */ + this.reserved = undefined; // toJSON + + // Note that values inherit valuesById on their prototype which makes them a TypeScript- + // compatible enum. This is used by pbts to write actual enum definitions that work for + // static and reflection code alike instead of emitting generic object definitions. + + if (values) + for (var keys = Object.keys(values), i = 0; i < keys.length; ++i) + if (typeof values[keys[i]] === "number") // use forward entries only + this.valuesById[ this.values[keys[i]] = values[keys[i]] ] = keys[i]; +} + +/** + * Enum descriptor. + * @interface IEnum + * @property {Object.} values Enum values + * @property {Object.} [options] Enum options + */ + +/** + * Constructs an enum from an enum descriptor. + * @param {string} name Enum name + * @param {IEnum} json Enum descriptor + * @returns {Enum} Created enum + * @throws {TypeError} If arguments are invalid + */ +Enum.fromJSON = function fromJSON(name, json) { + var enm = new Enum(name, json.values, json.options, json.comment, json.comments); + enm.reserved = json.reserved; + return enm; +}; + +/** + * Converts this enum to an enum descriptor. + * @param {IToJSONOptions} [toJSONOptions] JSON conversion options + * @returns {IEnum} Enum descriptor + */ +Enum.prototype.toJSON = function toJSON(toJSONOptions) { + var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false; + return util.toObject([ + "options" , this.options, + "values" , this.values, + "reserved" , this.reserved && this.reserved.length ? this.reserved : undefined, + "comment" , keepComments ? this.comment : undefined, + "comments" , keepComments ? this.comments : undefined + ]); +}; + +/** + * Adds a value to this enum. + * @param {string} name Value name + * @param {number} id Value id + * @param {string} [comment] Comment, if any + * @returns {Enum} `this` + * @throws {TypeError} If arguments are invalid + * @throws {Error} If there is already a value with this name or id + */ +Enum.prototype.add = function add(name, id, comment) { + // utilized by the parser but not by .fromJSON + + if (!util.isString(name)) + throw TypeError("name must be a string"); + + if (!util.isInteger(id)) + throw TypeError("id must be an integer"); + + if (this.values[name] !== undefined) + throw Error("duplicate name '" + name + "' in " + this); + + if (this.isReservedId(id)) + throw Error("id " + id + " is reserved in " + this); + + if (this.isReservedName(name)) + throw Error("name '" + name + "' is reserved in " + this); + + if (this.valuesById[id] !== undefined) { + if (!(this.options && this.options.allow_alias)) + throw Error("duplicate id " + id + " in " + this); + this.values[name] = id; + } else + this.valuesById[this.values[name] = id] = name; + + this.comments[name] = comment || null; + return this; +}; + +/** + * Removes a value from this enum + * @param {string} name Value name + * @returns {Enum} `this` + * @throws {TypeError} If arguments are invalid + * @throws {Error} If `name` is not a name of this enum + */ +Enum.prototype.remove = function remove(name) { + + if (!util.isString(name)) + throw TypeError("name must be a string"); + + var val = this.values[name]; + if (val == null) + throw Error("name '" + name + "' does not exist in " + this); + + delete this.valuesById[val]; + delete this.values[name]; + delete this.comments[name]; + + return this; +}; + +/** + * Tests if the specified id is reserved. + * @param {number} id Id to test + * @returns {boolean} `true` if reserved, otherwise `false` + */ +Enum.prototype.isReservedId = function isReservedId(id) { + return Namespace.isReservedId(this.reserved, id); +}; + +/** + * Tests if the specified name is reserved. + * @param {string} name Name to test + * @returns {boolean} `true` if reserved, otherwise `false` + */ +Enum.prototype.isReservedName = function isReservedName(name) { + return Namespace.isReservedName(this.reserved, name); +}; + +},{"23":23,"24":24,"37":37}],16:[function(require,module,exports){ +"use strict"; +module.exports = Field; + +// extends ReflectionObject +var ReflectionObject = require(24); +((Field.prototype = Object.create(ReflectionObject.prototype)).constructor = Field).className = "Field"; + +var Enum = require(15), + types = require(36), + util = require(37); + +var Type; // cyclic + +var ruleRe = /^required|optional|repeated$/; + +/** + * Constructs a new message field instance. Note that {@link MapField|map fields} have their own class. + * @name Field + * @classdesc Reflected message field. + * @extends FieldBase + * @constructor + * @param {string} name Unique name within its namespace + * @param {number} id Unique id within its namespace + * @param {string} type Value type + * @param {string|Object.} [rule="optional"] Field rule + * @param {string|Object.} [extend] Extended type if different from parent + * @param {Object.} [options] Declared options + */ + +/** + * Constructs a field from a field descriptor. + * @param {string} name Field name + * @param {IField} json Field descriptor + * @returns {Field} Created field + * @throws {TypeError} If arguments are invalid + */ +Field.fromJSON = function fromJSON(name, json) { + return new Field(name, json.id, json.type, json.rule, json.extend, json.options, json.comment); +}; + +/** + * Not an actual constructor. Use {@link Field} instead. + * @classdesc Base class of all reflected message fields. This is not an actual class but here for the sake of having consistent type definitions. + * @exports FieldBase + * @extends ReflectionObject + * @constructor + * @param {string} name Unique name within its namespace + * @param {number} id Unique id within its namespace + * @param {string} type Value type + * @param {string|Object.} [rule="optional"] Field rule + * @param {string|Object.} [extend] Extended type if different from parent + * @param {Object.} [options] Declared options + * @param {string} [comment] Comment associated with this field + */ +function Field(name, id, type, rule, extend, options, comment) { + + if (util.isObject(rule)) { + comment = extend; + options = rule; + rule = extend = undefined; + } else if (util.isObject(extend)) { + comment = options; + options = extend; + extend = undefined; + } + + ReflectionObject.call(this, name, options); + + if (!util.isInteger(id) || id < 0) + throw TypeError("id must be a non-negative integer"); + + if (!util.isString(type)) + throw TypeError("type must be a string"); + + if (rule !== undefined && !ruleRe.test(rule = rule.toString().toLowerCase())) + throw TypeError("rule must be a string rule"); + + if (extend !== undefined && !util.isString(extend)) + throw TypeError("extend must be a string"); + + /** + * Field rule, if any. + * @type {string|undefined} + */ + this.rule = rule && rule !== "optional" ? rule : undefined; // toJSON + + /** + * Field type. + * @type {string} + */ + this.type = type; // toJSON + + /** + * Unique field id. + * @type {number} + */ + this.id = id; // toJSON, marker + + /** + * Extended type if different from parent. + * @type {string|undefined} + */ + this.extend = extend || undefined; // toJSON + + /** + * Whether this field is required. + * @type {boolean} + */ + this.required = rule === "required"; + + /** + * Whether this field is optional. + * @type {boolean} + */ + this.optional = !this.required; + + /** + * Whether this field is repeated. + * @type {boolean} + */ + this.repeated = rule === "repeated"; + + /** + * Whether this field is a map or not. + * @type {boolean} + */ + this.map = false; + + /** + * Message this field belongs to. + * @type {Type|null} + */ + this.message = null; + + /** + * OneOf this field belongs to, if any, + * @type {OneOf|null} + */ + this.partOf = null; + + /** + * The field type's default value. + * @type {*} + */ + this.typeDefault = null; + + /** + * The field's default value on prototypes. + * @type {*} + */ + this.defaultValue = null; + + /** + * Whether this field's value should be treated as a long. + * @type {boolean} + */ + this.long = util.Long ? types.long[type] !== undefined : /* istanbul ignore next */ false; + + /** + * Whether this field's value is a buffer. + * @type {boolean} + */ + this.bytes = type === "bytes"; + + /** + * Resolved type if not a basic type. + * @type {Type|Enum|null} + */ + this.resolvedType = null; + + /** + * Sister-field within the extended type if a declaring extension field. + * @type {Field|null} + */ + this.extensionField = null; + + /** + * Sister-field within the declaring namespace if an extended field. + * @type {Field|null} + */ + this.declaringField = null; + + /** + * Internally remembers whether this field is packed. + * @type {boolean|null} + * @private + */ + this._packed = null; + + /** + * Comment for this field. + * @type {string|null} + */ + this.comment = comment; +} + +/** + * Determines whether this field is packed. Only relevant when repeated and working with proto2. + * @name Field#packed + * @type {boolean} + * @readonly + */ +Object.defineProperty(Field.prototype, "packed", { + get: function() { + // defaults to packed=true if not explicity set to false + if (this._packed === null) + this._packed = this.getOption("packed") !== false; + return this._packed; + } +}); + +/** + * @override + */ +Field.prototype.setOption = function setOption(name, value, ifNotSet) { + if (name === "packed") // clear cached before setting + this._packed = null; + return ReflectionObject.prototype.setOption.call(this, name, value, ifNotSet); +}; + +/** + * Field descriptor. + * @interface IField + * @property {string} [rule="optional"] Field rule + * @property {string} type Field type + * @property {number} id Field id + * @property {Object.} [options] Field options + */ + +/** + * Extension field descriptor. + * @interface IExtensionField + * @extends IField + * @property {string} extend Extended type + */ + +/** + * Converts this field to a field descriptor. + * @param {IToJSONOptions} [toJSONOptions] JSON conversion options + * @returns {IField} Field descriptor + */ +Field.prototype.toJSON = function toJSON(toJSONOptions) { + var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false; + return util.toObject([ + "rule" , this.rule !== "optional" && this.rule || undefined, + "type" , this.type, + "id" , this.id, + "extend" , this.extend, + "options" , this.options, + "comment" , keepComments ? this.comment : undefined + ]); +}; + +/** + * Resolves this field's type references. + * @returns {Field} `this` + * @throws {Error} If any reference cannot be resolved + */ +Field.prototype.resolve = function resolve() { + + if (this.resolved) + return this; + + if ((this.typeDefault = types.defaults[this.type]) === undefined) { // if not a basic type, resolve it + this.resolvedType = (this.declaringField ? this.declaringField.parent : this.parent).lookupTypeOrEnum(this.type); + if (this.resolvedType instanceof Type) + this.typeDefault = null; + else // instanceof Enum + this.typeDefault = this.resolvedType.values[Object.keys(this.resolvedType.values)[0]]; // first defined + } + + // use explicitly set default value if present + if (this.options && this.options["default"] != null) { + this.typeDefault = this.options["default"]; + if (this.resolvedType instanceof Enum && typeof this.typeDefault === "string") + this.typeDefault = this.resolvedType.values[this.typeDefault]; + } + + // remove unnecessary options + if (this.options) { + if (this.options.packed === true || this.options.packed !== undefined && this.resolvedType && !(this.resolvedType instanceof Enum)) + delete this.options.packed; + if (!Object.keys(this.options).length) + this.options = undefined; + } + + // convert to internal data type if necesssary + if (this.long) { + this.typeDefault = util.Long.fromNumber(this.typeDefault, this.type.charAt(0) === "u"); + + /* istanbul ignore else */ + if (Object.freeze) + Object.freeze(this.typeDefault); // long instances are meant to be immutable anyway (i.e. use small int cache that even requires it) + + } else if (this.bytes && typeof this.typeDefault === "string") { + var buf; + if (util.base64.test(this.typeDefault)) + util.base64.decode(this.typeDefault, buf = util.newBuffer(util.base64.length(this.typeDefault)), 0); + else + util.utf8.write(this.typeDefault, buf = util.newBuffer(util.utf8.length(this.typeDefault)), 0); + this.typeDefault = buf; + } + + // take special care of maps and repeated fields + if (this.map) + this.defaultValue = util.emptyObject; + else if (this.repeated) + this.defaultValue = util.emptyArray; + else + this.defaultValue = this.typeDefault; + + // ensure proper value on prototype + if (this.parent instanceof Type) + this.parent.ctor.prototype[this.name] = this.defaultValue; + + return ReflectionObject.prototype.resolve.call(this); +}; + +/** + * Decorator function as returned by {@link Field.d} and {@link MapField.d} (TypeScript). + * @typedef FieldDecorator + * @type {function} + * @param {Object} prototype Target prototype + * @param {string} fieldName Field name + * @returns {undefined} + */ + +/** + * Field decorator (TypeScript). + * @name Field.d + * @function + * @param {number} fieldId Field id + * @param {"double"|"float"|"int32"|"uint32"|"sint32"|"fixed32"|"sfixed32"|"int64"|"uint64"|"sint64"|"fixed64"|"sfixed64"|"string"|"bool"|"bytes"|Object} fieldType Field type + * @param {"optional"|"required"|"repeated"} [fieldRule="optional"] Field rule + * @param {T} [defaultValue] Default value + * @returns {FieldDecorator} Decorator function + * @template T extends number | number[] | Long | Long[] | string | string[] | boolean | boolean[] | Uint8Array | Uint8Array[] | Buffer | Buffer[] + */ +Field.d = function decorateField(fieldId, fieldType, fieldRule, defaultValue) { + + // submessage: decorate the submessage and use its name as the type + if (typeof fieldType === "function") + fieldType = util.decorateType(fieldType).name; + + // enum reference: create a reflected copy of the enum and keep reuseing it + else if (fieldType && typeof fieldType === "object") + fieldType = util.decorateEnum(fieldType).name; + + return function fieldDecorator(prototype, fieldName) { + util.decorateType(prototype.constructor) + .add(new Field(fieldName, fieldId, fieldType, fieldRule, { "default": defaultValue })); + }; +}; + +/** + * Field decorator (TypeScript). + * @name Field.d + * @function + * @param {number} fieldId Field id + * @param {Constructor|string} fieldType Field type + * @param {"optional"|"required"|"repeated"} [fieldRule="optional"] Field rule + * @returns {FieldDecorator} Decorator function + * @template T extends Message + * @variation 2 + */ +// like Field.d but without a default value + +// Sets up cyclic dependencies (called in index-light) +Field._configure = function configure(Type_) { + Type = Type_; +}; + +},{"15":15,"24":24,"36":36,"37":37}],17:[function(require,module,exports){ +"use strict"; +var protobuf = module.exports = require(18); + +protobuf.build = "light"; + +/** + * A node-style callback as used by {@link load} and {@link Root#load}. + * @typedef LoadCallback + * @type {function} + * @param {Error|null} error Error, if any, otherwise `null` + * @param {Root} [root] Root, if there hasn't been an error + * @returns {undefined} + */ + +/** + * Loads one or multiple .proto or preprocessed .json files into a common root namespace and calls the callback. + * @param {string|string[]} filename One or multiple files to load + * @param {Root} root Root namespace, defaults to create a new one if omitted. + * @param {LoadCallback} callback Callback function + * @returns {undefined} + * @see {@link Root#load} + */ +function load(filename, root, callback) { + if (typeof root === "function") { + callback = root; + root = new protobuf.Root(); + } else if (!root) + root = new protobuf.Root(); + return root.load(filename, callback); +} + +/** + * Loads one or multiple .proto or preprocessed .json files into a common root namespace and calls the callback. + * @name load + * @function + * @param {string|string[]} filename One or multiple files to load + * @param {LoadCallback} callback Callback function + * @returns {undefined} + * @see {@link Root#load} + * @variation 2 + */ +// function load(filename:string, callback:LoadCallback):undefined + +/** + * Loads one or multiple .proto or preprocessed .json files into a common root namespace and returns a promise. + * @name load + * @function + * @param {string|string[]} filename One or multiple files to load + * @param {Root} [root] Root namespace, defaults to create a new one if omitted. + * @returns {Promise} Promise + * @see {@link Root#load} + * @variation 3 + */ +// function load(filename:string, [root:Root]):Promise + +protobuf.load = load; + +/** + * Synchronously loads one or multiple .proto or preprocessed .json files into a common root namespace (node only). + * @param {string|string[]} filename One or multiple files to load + * @param {Root} [root] Root namespace, defaults to create a new one if omitted. + * @returns {Root} Root namespace + * @throws {Error} If synchronous fetching is not supported (i.e. in browsers) or if a file's syntax is invalid + * @see {@link Root#loadSync} + */ +function loadSync(filename, root) { + if (!root) + root = new protobuf.Root(); + return root.loadSync(filename); +} + +protobuf.loadSync = loadSync; + +// Serialization +protobuf.encoder = require(14); +protobuf.decoder = require(13); +protobuf.verifier = require(40); +protobuf.converter = require(12); + +// Reflection +protobuf.ReflectionObject = require(24); +protobuf.Namespace = require(23); +protobuf.Root = require(29); +protobuf.Enum = require(15); +protobuf.Type = require(35); +protobuf.Field = require(16); +protobuf.OneOf = require(25); +protobuf.MapField = require(20); +protobuf.Service = require(33); +protobuf.Method = require(22); + +// Runtime +protobuf.Message = require(21); +protobuf.wrappers = require(41); + +// Utility +protobuf.types = require(36); +protobuf.util = require(37); + +// Set up possibly cyclic reflection dependencies +protobuf.ReflectionObject._configure(protobuf.Root); +protobuf.Namespace._configure(protobuf.Type, protobuf.Service, protobuf.Enum); +protobuf.Root._configure(protobuf.Type); +protobuf.Field._configure(protobuf.Type); + +},{"12":12,"13":13,"14":14,"15":15,"16":16,"18":18,"20":20,"21":21,"22":22,"23":23,"24":24,"25":25,"29":29,"33":33,"35":35,"36":36,"37":37,"40":40,"41":41}],18:[function(require,module,exports){ +"use strict"; +var protobuf = exports; + +/** + * Build type, one of `"full"`, `"light"` or `"minimal"`. + * @name build + * @type {string} + * @const + */ +protobuf.build = "minimal"; + +// Serialization +protobuf.Writer = require(42); +protobuf.BufferWriter = require(43); +protobuf.Reader = require(27); +protobuf.BufferReader = require(28); + +// Utility +protobuf.util = require(39); +protobuf.rpc = require(31); +protobuf.roots = require(30); +protobuf.configure = configure; + +/* istanbul ignore next */ +/** + * Reconfigures the library according to the environment. + * @returns {undefined} + */ +function configure() { + protobuf.Reader._configure(protobuf.BufferReader); + protobuf.util._configure(); +} + +// Set up buffer utility according to the environment +protobuf.Writer._configure(protobuf.BufferWriter); +configure(); + +},{"27":27,"28":28,"30":30,"31":31,"39":39,"42":42,"43":43}],19:[function(require,module,exports){ +"use strict"; +var protobuf = module.exports = require(17); + +protobuf.build = "full"; + +// Parser +protobuf.tokenize = require(34); +protobuf.parse = require(26); +protobuf.common = require(11); + +// Configure parser +protobuf.Root._configure(protobuf.Type, protobuf.parse, protobuf.common); + +},{"11":11,"17":17,"26":26,"34":34}],20:[function(require,module,exports){ +"use strict"; +module.exports = MapField; + +// extends Field +var Field = require(16); +((MapField.prototype = Object.create(Field.prototype)).constructor = MapField).className = "MapField"; + +var types = require(36), + util = require(37); + +/** + * Constructs a new map field instance. + * @classdesc Reflected map field. + * @extends FieldBase + * @constructor + * @param {string} name Unique name within its namespace + * @param {number} id Unique id within its namespace + * @param {string} keyType Key type + * @param {string} type Value type + * @param {Object.} [options] Declared options + * @param {string} [comment] Comment associated with this field + */ +function MapField(name, id, keyType, type, options, comment) { + Field.call(this, name, id, type, undefined, undefined, options, comment); + + /* istanbul ignore if */ + if (!util.isString(keyType)) + throw TypeError("keyType must be a string"); + + /** + * Key type. + * @type {string} + */ + this.keyType = keyType; // toJSON, marker + + /** + * Resolved key type if not a basic type. + * @type {ReflectionObject|null} + */ + this.resolvedKeyType = null; + + // Overrides Field#map + this.map = true; +} + +/** + * Map field descriptor. + * @interface IMapField + * @extends {IField} + * @property {string} keyType Key type + */ + +/** + * Extension map field descriptor. + * @interface IExtensionMapField + * @extends IMapField + * @property {string} extend Extended type + */ + +/** + * Constructs a map field from a map field descriptor. + * @param {string} name Field name + * @param {IMapField} json Map field descriptor + * @returns {MapField} Created map field + * @throws {TypeError} If arguments are invalid + */ +MapField.fromJSON = function fromJSON(name, json) { + return new MapField(name, json.id, json.keyType, json.type, json.options, json.comment); +}; + +/** + * Converts this map field to a map field descriptor. + * @param {IToJSONOptions} [toJSONOptions] JSON conversion options + * @returns {IMapField} Map field descriptor + */ +MapField.prototype.toJSON = function toJSON(toJSONOptions) { + var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false; + return util.toObject([ + "keyType" , this.keyType, + "type" , this.type, + "id" , this.id, + "extend" , this.extend, + "options" , this.options, + "comment" , keepComments ? this.comment : undefined + ]); +}; + +/** + * @override + */ +MapField.prototype.resolve = function resolve() { + if (this.resolved) + return this; + + // Besides a value type, map fields have a key type that may be "any scalar type except for floating point types and bytes" + if (types.mapKey[this.keyType] === undefined) + throw Error("invalid key type: " + this.keyType); + + return Field.prototype.resolve.call(this); +}; + +/** + * Map field decorator (TypeScript). + * @name MapField.d + * @function + * @param {number} fieldId Field id + * @param {"int32"|"uint32"|"sint32"|"fixed32"|"sfixed32"|"int64"|"uint64"|"sint64"|"fixed64"|"sfixed64"|"bool"|"string"} fieldKeyType Field key type + * @param {"double"|"float"|"int32"|"uint32"|"sint32"|"fixed32"|"sfixed32"|"int64"|"uint64"|"sint64"|"fixed64"|"sfixed64"|"bool"|"string"|"bytes"|Object|Constructor<{}>} fieldValueType Field value type + * @returns {FieldDecorator} Decorator function + * @template T extends { [key: string]: number | Long | string | boolean | Uint8Array | Buffer | number[] | Message<{}> } + */ +MapField.d = function decorateMapField(fieldId, fieldKeyType, fieldValueType) { + + // submessage value: decorate the submessage and use its name as the type + if (typeof fieldValueType === "function") + fieldValueType = util.decorateType(fieldValueType).name; + + // enum reference value: create a reflected copy of the enum and keep reuseing it + else if (fieldValueType && typeof fieldValueType === "object") + fieldValueType = util.decorateEnum(fieldValueType).name; + + return function mapFieldDecorator(prototype, fieldName) { + util.decorateType(prototype.constructor) + .add(new MapField(fieldName, fieldId, fieldKeyType, fieldValueType)); + }; +}; + +},{"16":16,"36":36,"37":37}],21:[function(require,module,exports){ +"use strict"; +module.exports = Message; + +var util = require(39); + +/** + * Constructs a new message instance. + * @classdesc Abstract runtime message. + * @constructor + * @param {Properties} [properties] Properties to set + * @template T extends object = object + */ +function Message(properties) { + // not used internally + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + this[keys[i]] = properties[keys[i]]; +} + +/** + * Reference to the reflected type. + * @name Message.$type + * @type {Type} + * @readonly + */ + +/** + * Reference to the reflected type. + * @name Message#$type + * @type {Type} + * @readonly + */ + +/*eslint-disable valid-jsdoc*/ + +/** + * Creates a new message of this type using the specified properties. + * @param {Object.} [properties] Properties to set + * @returns {Message} Message instance + * @template T extends Message + * @this Constructor + */ +Message.create = function create(properties) { + return this.$type.create(properties); +}; + +/** + * Encodes a message of this type. + * @param {T|Object.} message Message to encode + * @param {Writer} [writer] Writer to use + * @returns {Writer} Writer + * @template T extends Message + * @this Constructor + */ +Message.encode = function encode(message, writer) { + return this.$type.encode(message, writer); +}; + +/** + * Encodes a message of this type preceeded by its length as a varint. + * @param {T|Object.} message Message to encode + * @param {Writer} [writer] Writer to use + * @returns {Writer} Writer + * @template T extends Message + * @this Constructor + */ +Message.encodeDelimited = function encodeDelimited(message, writer) { + return this.$type.encodeDelimited(message, writer); +}; + +/** + * Decodes a message of this type. + * @name Message.decode + * @function + * @param {Reader|Uint8Array} reader Reader or buffer to decode + * @returns {T} Decoded message + * @template T extends Message + * @this Constructor + */ +Message.decode = function decode(reader) { + return this.$type.decode(reader); +}; + +/** + * Decodes a message of this type preceeded by its length as a varint. + * @name Message.decodeDelimited + * @function + * @param {Reader|Uint8Array} reader Reader or buffer to decode + * @returns {T} Decoded message + * @template T extends Message + * @this Constructor + */ +Message.decodeDelimited = function decodeDelimited(reader) { + return this.$type.decodeDelimited(reader); +}; + +/** + * Verifies a message of this type. + * @name Message.verify + * @function + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ +Message.verify = function verify(message) { + return this.$type.verify(message); +}; + +/** + * Creates a new message of this type from a plain object. Also converts values to their respective internal types. + * @param {Object.} object Plain object + * @returns {T} Message instance + * @template T extends Message + * @this Constructor + */ +Message.fromObject = function fromObject(object) { + return this.$type.fromObject(object); +}; + +/** + * Creates a plain object from a message of this type. Also converts values to other types if specified. + * @param {T} message Message instance + * @param {IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + * @template T extends Message + * @this Constructor + */ +Message.toObject = function toObject(message, options) { + return this.$type.toObject(message, options); +}; + +/** + * Converts this message to JSON. + * @returns {Object.} JSON object + */ +Message.prototype.toJSON = function toJSON() { + return this.$type.toObject(this, util.toJSONOptions); +}; + +/*eslint-enable valid-jsdoc*/ +},{"39":39}],22:[function(require,module,exports){ +"use strict"; +module.exports = Method; + +// extends ReflectionObject +var ReflectionObject = require(24); +((Method.prototype = Object.create(ReflectionObject.prototype)).constructor = Method).className = "Method"; + +var util = require(37); + +/** + * Constructs a new service method instance. + * @classdesc Reflected service method. + * @extends ReflectionObject + * @constructor + * @param {string} name Method name + * @param {string|undefined} type Method type, usually `"rpc"` + * @param {string} requestType Request message type + * @param {string} responseType Response message type + * @param {boolean|Object.} [requestStream] Whether the request is streamed + * @param {boolean|Object.} [responseStream] Whether the response is streamed + * @param {Object.} [options] Declared options + * @param {string} [comment] The comment for this method + */ +function Method(name, type, requestType, responseType, requestStream, responseStream, options, comment) { + + /* istanbul ignore next */ + if (util.isObject(requestStream)) { + options = requestStream; + requestStream = responseStream = undefined; + } else if (util.isObject(responseStream)) { + options = responseStream; + responseStream = undefined; + } + + /* istanbul ignore if */ + if (!(type === undefined || util.isString(type))) + throw TypeError("type must be a string"); + + /* istanbul ignore if */ + if (!util.isString(requestType)) + throw TypeError("requestType must be a string"); + + /* istanbul ignore if */ + if (!util.isString(responseType)) + throw TypeError("responseType must be a string"); + + ReflectionObject.call(this, name, options); + + /** + * Method type. + * @type {string} + */ + this.type = type || "rpc"; // toJSON + + /** + * Request type. + * @type {string} + */ + this.requestType = requestType; // toJSON, marker + + /** + * Whether requests are streamed or not. + * @type {boolean|undefined} + */ + this.requestStream = requestStream ? true : undefined; // toJSON + + /** + * Response type. + * @type {string} + */ + this.responseType = responseType; // toJSON + + /** + * Whether responses are streamed or not. + * @type {boolean|undefined} + */ + this.responseStream = responseStream ? true : undefined; // toJSON + + /** + * Resolved request type. + * @type {Type|null} + */ + this.resolvedRequestType = null; + + /** + * Resolved response type. + * @type {Type|null} + */ + this.resolvedResponseType = null; + + /** + * Comment for this method + * @type {string|null} + */ + this.comment = comment; +} + +/** + * Method descriptor. + * @interface IMethod + * @property {string} [type="rpc"] Method type + * @property {string} requestType Request type + * @property {string} responseType Response type + * @property {boolean} [requestStream=false] Whether requests are streamed + * @property {boolean} [responseStream=false] Whether responses are streamed + * @property {Object.} [options] Method options + */ + +/** + * Constructs a method from a method descriptor. + * @param {string} name Method name + * @param {IMethod} json Method descriptor + * @returns {Method} Created method + * @throws {TypeError} If arguments are invalid + */ +Method.fromJSON = function fromJSON(name, json) { + return new Method(name, json.type, json.requestType, json.responseType, json.requestStream, json.responseStream, json.options, json.comment); +}; + +/** + * Converts this method to a method descriptor. + * @param {IToJSONOptions} [toJSONOptions] JSON conversion options + * @returns {IMethod} Method descriptor + */ +Method.prototype.toJSON = function toJSON(toJSONOptions) { + var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false; + return util.toObject([ + "type" , this.type !== "rpc" && /* istanbul ignore next */ this.type || undefined, + "requestType" , this.requestType, + "requestStream" , this.requestStream, + "responseType" , this.responseType, + "responseStream" , this.responseStream, + "options" , this.options, + "comment" , keepComments ? this.comment : undefined + ]); +}; + +/** + * @override + */ +Method.prototype.resolve = function resolve() { + + /* istanbul ignore if */ + if (this.resolved) + return this; + + this.resolvedRequestType = this.parent.lookupType(this.requestType); + this.resolvedResponseType = this.parent.lookupType(this.responseType); + + return ReflectionObject.prototype.resolve.call(this); +}; + +},{"24":24,"37":37}],23:[function(require,module,exports){ +"use strict"; +module.exports = Namespace; + +// extends ReflectionObject +var ReflectionObject = require(24); +((Namespace.prototype = Object.create(ReflectionObject.prototype)).constructor = Namespace).className = "Namespace"; + +var Field = require(16), + util = require(37); + +var Type, // cyclic + Service, + Enum; + +/** + * Constructs a new namespace instance. + * @name Namespace + * @classdesc Reflected namespace. + * @extends NamespaceBase + * @constructor + * @param {string} name Namespace name + * @param {Object.} [options] Declared options + */ + +/** + * Constructs a namespace from JSON. + * @memberof Namespace + * @function + * @param {string} name Namespace name + * @param {Object.} json JSON object + * @returns {Namespace} Created namespace + * @throws {TypeError} If arguments are invalid + */ +Namespace.fromJSON = function fromJSON(name, json) { + return new Namespace(name, json.options).addJSON(json.nested); +}; + +/** + * Converts an array of reflection objects to JSON. + * @memberof Namespace + * @param {ReflectionObject[]} array Object array + * @param {IToJSONOptions} [toJSONOptions] JSON conversion options + * @returns {Object.|undefined} JSON object or `undefined` when array is empty + */ +function arrayToJSON(array, toJSONOptions) { + if (!(array && array.length)) + return undefined; + var obj = {}; + for (var i = 0; i < array.length; ++i) + obj[array[i].name] = array[i].toJSON(toJSONOptions); + return obj; +} + +Namespace.arrayToJSON = arrayToJSON; + +/** + * Tests if the specified id is reserved. + * @param {Array.|undefined} reserved Array of reserved ranges and names + * @param {number} id Id to test + * @returns {boolean} `true` if reserved, otherwise `false` + */ +Namespace.isReservedId = function isReservedId(reserved, id) { + if (reserved) + for (var i = 0; i < reserved.length; ++i) + if (typeof reserved[i] !== "string" && reserved[i][0] <= id && reserved[i][1] >= id) + return true; + return false; +}; + +/** + * Tests if the specified name is reserved. + * @param {Array.|undefined} reserved Array of reserved ranges and names + * @param {string} name Name to test + * @returns {boolean} `true` if reserved, otherwise `false` + */ +Namespace.isReservedName = function isReservedName(reserved, name) { + if (reserved) + for (var i = 0; i < reserved.length; ++i) + if (reserved[i] === name) + return true; + return false; +}; + +/** + * Not an actual constructor. Use {@link Namespace} instead. + * @classdesc Base class of all reflection objects containing nested objects. This is not an actual class but here for the sake of having consistent type definitions. + * @exports NamespaceBase + * @extends ReflectionObject + * @abstract + * @constructor + * @param {string} name Namespace name + * @param {Object.} [options] Declared options + * @see {@link Namespace} + */ +function Namespace(name, options) { + ReflectionObject.call(this, name, options); + + /** + * Nested objects by name. + * @type {Object.|undefined} + */ + this.nested = undefined; // toJSON + + /** + * Cached nested objects as an array. + * @type {ReflectionObject[]|null} + * @private + */ + this._nestedArray = null; +} + +function clearCache(namespace) { + namespace._nestedArray = null; + return namespace; +} + +/** + * Nested objects of this namespace as an array for iteration. + * @name NamespaceBase#nestedArray + * @type {ReflectionObject[]} + * @readonly + */ +Object.defineProperty(Namespace.prototype, "nestedArray", { + get: function() { + return this._nestedArray || (this._nestedArray = util.toArray(this.nested)); + } +}); + +/** + * Namespace descriptor. + * @interface INamespace + * @property {Object.} [options] Namespace options + * @property {Object.} [nested] Nested object descriptors + */ + +/** + * Any extension field descriptor. + * @typedef AnyExtensionField + * @type {IExtensionField|IExtensionMapField} + */ + +/** + * Any nested object descriptor. + * @typedef AnyNestedObject + * @type {IEnum|IType|IService|AnyExtensionField|INamespace} + */ +// ^ BEWARE: VSCode hangs forever when using more than 5 types (that's why AnyExtensionField exists in the first place) + +/** + * Converts this namespace to a namespace descriptor. + * @param {IToJSONOptions} [toJSONOptions] JSON conversion options + * @returns {INamespace} Namespace descriptor + */ +Namespace.prototype.toJSON = function toJSON(toJSONOptions) { + return util.toObject([ + "options" , this.options, + "nested" , arrayToJSON(this.nestedArray, toJSONOptions) + ]); +}; + +/** + * Adds nested objects to this namespace from nested object descriptors. + * @param {Object.} nestedJson Any nested object descriptors + * @returns {Namespace} `this` + */ +Namespace.prototype.addJSON = function addJSON(nestedJson) { + var ns = this; + /* istanbul ignore else */ + if (nestedJson) { + for (var names = Object.keys(nestedJson), i = 0, nested; i < names.length; ++i) { + nested = nestedJson[names[i]]; + ns.add( // most to least likely + ( nested.fields !== undefined + ? Type.fromJSON + : nested.values !== undefined + ? Enum.fromJSON + : nested.methods !== undefined + ? Service.fromJSON + : nested.id !== undefined + ? Field.fromJSON + : Namespace.fromJSON )(names[i], nested) + ); + } + } + return this; +}; + +/** + * Gets the nested object of the specified name. + * @param {string} name Nested object name + * @returns {ReflectionObject|null} The reflection object or `null` if it doesn't exist + */ +Namespace.prototype.get = function get(name) { + return this.nested && this.nested[name] + || null; +}; + +/** + * Gets the values of the nested {@link Enum|enum} of the specified name. + * This methods differs from {@link Namespace#get|get} in that it returns an enum's values directly and throws instead of returning `null`. + * @param {string} name Nested enum name + * @returns {Object.} Enum values + * @throws {Error} If there is no such enum + */ +Namespace.prototype.getEnum = function getEnum(name) { + if (this.nested && this.nested[name] instanceof Enum) + return this.nested[name].values; + throw Error("no such enum: " + name); +}; + +/** + * Adds a nested object to this namespace. + * @param {ReflectionObject} object Nested object to add + * @returns {Namespace} `this` + * @throws {TypeError} If arguments are invalid + * @throws {Error} If there is already a nested object with this name + */ +Namespace.prototype.add = function add(object) { + + if (!(object instanceof Field && object.extend !== undefined || object instanceof Type || object instanceof Enum || object instanceof Service || object instanceof Namespace)) + throw TypeError("object must be a valid nested object"); + + if (!this.nested) + this.nested = {}; + else { + var prev = this.get(object.name); + if (prev) { + if (prev instanceof Namespace && object instanceof Namespace && !(prev instanceof Type || prev instanceof Service)) { + // replace plain namespace but keep existing nested elements and options + var nested = prev.nestedArray; + for (var i = 0; i < nested.length; ++i) + object.add(nested[i]); + this.remove(prev); + if (!this.nested) + this.nested = {}; + object.setOptions(prev.options, true); + + } else + throw Error("duplicate name '" + object.name + "' in " + this); + } + } + this.nested[object.name] = object; + object.onAdd(this); + return clearCache(this); +}; + +/** + * Removes a nested object from this namespace. + * @param {ReflectionObject} object Nested object to remove + * @returns {Namespace} `this` + * @throws {TypeError} If arguments are invalid + * @throws {Error} If `object` is not a member of this namespace + */ +Namespace.prototype.remove = function remove(object) { + + if (!(object instanceof ReflectionObject)) + throw TypeError("object must be a ReflectionObject"); + if (object.parent !== this) + throw Error(object + " is not a member of " + this); + + delete this.nested[object.name]; + if (!Object.keys(this.nested).length) + this.nested = undefined; + + object.onRemove(this); + return clearCache(this); +}; + +/** + * Defines additial namespaces within this one if not yet existing. + * @param {string|string[]} path Path to create + * @param {*} [json] Nested types to create from JSON + * @returns {Namespace} Pointer to the last namespace created or `this` if path is empty + */ +Namespace.prototype.define = function define(path, json) { + + if (util.isString(path)) + path = path.split("."); + else if (!Array.isArray(path)) + throw TypeError("illegal path"); + if (path && path.length && path[0] === "") + throw Error("path must be relative"); + + var ptr = this; + while (path.length > 0) { + var part = path.shift(); + if (ptr.nested && ptr.nested[part]) { + ptr = ptr.nested[part]; + if (!(ptr instanceof Namespace)) + throw Error("path conflicts with non-namespace objects"); + } else + ptr.add(ptr = new Namespace(part)); + } + if (json) + ptr.addJSON(json); + return ptr; +}; + +/** + * Resolves this namespace's and all its nested objects' type references. Useful to validate a reflection tree, but comes at a cost. + * @returns {Namespace} `this` + */ +Namespace.prototype.resolveAll = function resolveAll() { + var nested = this.nestedArray, i = 0; + while (i < nested.length) + if (nested[i] instanceof Namespace) + nested[i++].resolveAll(); + else + nested[i++].resolve(); + return this.resolve(); +}; + +/** + * Recursively looks up the reflection object matching the specified path in the scope of this namespace. + * @param {string|string[]} path Path to look up + * @param {*|Array.<*>} filterTypes Filter types, any combination of the constructors of `protobuf.Type`, `protobuf.Enum`, `protobuf.Service` etc. + * @param {boolean} [parentAlreadyChecked=false] If known, whether the parent has already been checked + * @returns {ReflectionObject|null} Looked up object or `null` if none could be found + */ +Namespace.prototype.lookup = function lookup(path, filterTypes, parentAlreadyChecked) { + + /* istanbul ignore next */ + if (typeof filterTypes === "boolean") { + parentAlreadyChecked = filterTypes; + filterTypes = undefined; + } else if (filterTypes && !Array.isArray(filterTypes)) + filterTypes = [ filterTypes ]; + + if (util.isString(path) && path.length) { + if (path === ".") + return this.root; + path = path.split("."); + } else if (!path.length) + return this; + + // Start at root if path is absolute + if (path[0] === "") + return this.root.lookup(path.slice(1), filterTypes); + + // Test if the first part matches any nested object, and if so, traverse if path contains more + var found = this.get(path[0]); + if (found) { + if (path.length === 1) { + if (!filterTypes || filterTypes.indexOf(found.constructor) > -1) + return found; + } else if (found instanceof Namespace && (found = found.lookup(path.slice(1), filterTypes, true))) + return found; + + // Otherwise try each nested namespace + } else + for (var i = 0; i < this.nestedArray.length; ++i) + if (this._nestedArray[i] instanceof Namespace && (found = this._nestedArray[i].lookup(path, filterTypes, true))) + return found; + + // If there hasn't been a match, try again at the parent + if (this.parent === null || parentAlreadyChecked) + return null; + return this.parent.lookup(path, filterTypes); +}; + +/** + * Looks up the reflection object at the specified path, relative to this namespace. + * @name NamespaceBase#lookup + * @function + * @param {string|string[]} path Path to look up + * @param {boolean} [parentAlreadyChecked=false] Whether the parent has already been checked + * @returns {ReflectionObject|null} Looked up object or `null` if none could be found + * @variation 2 + */ +// lookup(path: string, [parentAlreadyChecked: boolean]) + +/** + * Looks up the {@link Type|type} at the specified path, relative to this namespace. + * Besides its signature, this methods differs from {@link Namespace#lookup|lookup} in that it throws instead of returning `null`. + * @param {string|string[]} path Path to look up + * @returns {Type} Looked up type + * @throws {Error} If `path` does not point to a type + */ +Namespace.prototype.lookupType = function lookupType(path) { + var found = this.lookup(path, [ Type ]); + if (!found) + throw Error("no such type: " + path); + return found; +}; + +/** + * Looks up the values of the {@link Enum|enum} at the specified path, relative to this namespace. + * Besides its signature, this methods differs from {@link Namespace#lookup|lookup} in that it throws instead of returning `null`. + * @param {string|string[]} path Path to look up + * @returns {Enum} Looked up enum + * @throws {Error} If `path` does not point to an enum + */ +Namespace.prototype.lookupEnum = function lookupEnum(path) { + var found = this.lookup(path, [ Enum ]); + if (!found) + throw Error("no such Enum '" + path + "' in " + this); + return found; +}; + +/** + * Looks up the {@link Type|type} or {@link Enum|enum} at the specified path, relative to this namespace. + * Besides its signature, this methods differs from {@link Namespace#lookup|lookup} in that it throws instead of returning `null`. + * @param {string|string[]} path Path to look up + * @returns {Type} Looked up type or enum + * @throws {Error} If `path` does not point to a type or enum + */ +Namespace.prototype.lookupTypeOrEnum = function lookupTypeOrEnum(path) { + var found = this.lookup(path, [ Type, Enum ]); + if (!found) + throw Error("no such Type or Enum '" + path + "' in " + this); + return found; +}; + +/** + * Looks up the {@link Service|service} at the specified path, relative to this namespace. + * Besides its signature, this methods differs from {@link Namespace#lookup|lookup} in that it throws instead of returning `null`. + * @param {string|string[]} path Path to look up + * @returns {Service} Looked up service + * @throws {Error} If `path` does not point to a service + */ +Namespace.prototype.lookupService = function lookupService(path) { + var found = this.lookup(path, [ Service ]); + if (!found) + throw Error("no such Service '" + path + "' in " + this); + return found; +}; + +// Sets up cyclic dependencies (called in index-light) +Namespace._configure = function(Type_, Service_, Enum_) { + Type = Type_; + Service = Service_; + Enum = Enum_; +}; + +},{"16":16,"24":24,"37":37}],24:[function(require,module,exports){ +"use strict"; +module.exports = ReflectionObject; + +ReflectionObject.className = "ReflectionObject"; + +var util = require(37); + +var Root; // cyclic + +/** + * Constructs a new reflection object instance. + * @classdesc Base class of all reflection objects. + * @constructor + * @param {string} name Object name + * @param {Object.} [options] Declared options + * @abstract + */ +function ReflectionObject(name, options) { + + if (!util.isString(name)) + throw TypeError("name must be a string"); + + if (options && !util.isObject(options)) + throw TypeError("options must be an object"); + + /** + * Options. + * @type {Object.|undefined} + */ + this.options = options; // toJSON + + /** + * Unique name within its namespace. + * @type {string} + */ + this.name = name; + + /** + * Parent namespace. + * @type {Namespace|null} + */ + this.parent = null; + + /** + * Whether already resolved or not. + * @type {boolean} + */ + this.resolved = false; + + /** + * Comment text, if any. + * @type {string|null} + */ + this.comment = null; + + /** + * Defining file name. + * @type {string|null} + */ + this.filename = null; +} + +Object.defineProperties(ReflectionObject.prototype, { + + /** + * Reference to the root namespace. + * @name ReflectionObject#root + * @type {Root} + * @readonly + */ + root: { + get: function() { + var ptr = this; + while (ptr.parent !== null) + ptr = ptr.parent; + return ptr; + } + }, + + /** + * Full name including leading dot. + * @name ReflectionObject#fullName + * @type {string} + * @readonly + */ + fullName: { + get: function() { + var path = [ this.name ], + ptr = this.parent; + while (ptr) { + path.unshift(ptr.name); + ptr = ptr.parent; + } + return path.join("."); + } + } +}); + +/** + * Converts this reflection object to its descriptor representation. + * @returns {Object.} Descriptor + * @abstract + */ +ReflectionObject.prototype.toJSON = /* istanbul ignore next */ function toJSON() { + throw Error(); // not implemented, shouldn't happen +}; + +/** + * Called when this object is added to a parent. + * @param {ReflectionObject} parent Parent added to + * @returns {undefined} + */ +ReflectionObject.prototype.onAdd = function onAdd(parent) { + if (this.parent && this.parent !== parent) + this.parent.remove(this); + this.parent = parent; + this.resolved = false; + var root = parent.root; + if (root instanceof Root) + root._handleAdd(this); +}; + +/** + * Called when this object is removed from a parent. + * @param {ReflectionObject} parent Parent removed from + * @returns {undefined} + */ +ReflectionObject.prototype.onRemove = function onRemove(parent) { + var root = parent.root; + if (root instanceof Root) + root._handleRemove(this); + this.parent = null; + this.resolved = false; +}; + +/** + * Resolves this objects type references. + * @returns {ReflectionObject} `this` + */ +ReflectionObject.prototype.resolve = function resolve() { + if (this.resolved) + return this; + if (this.root instanceof Root) + this.resolved = true; // only if part of a root + return this; +}; + +/** + * Gets an option value. + * @param {string} name Option name + * @returns {*} Option value or `undefined` if not set + */ +ReflectionObject.prototype.getOption = function getOption(name) { + if (this.options) + return this.options[name]; + return undefined; +}; + +/** + * Sets an option. + * @param {string} name Option name + * @param {*} value Option value + * @param {boolean} [ifNotSet] Sets the option only if it isn't currently set + * @returns {ReflectionObject} `this` + */ +ReflectionObject.prototype.setOption = function setOption(name, value, ifNotSet) { + if (!ifNotSet || !this.options || this.options[name] === undefined) + (this.options || (this.options = {}))[name] = value; + return this; +}; + +/** + * Sets multiple options. + * @param {Object.} options Options to set + * @param {boolean} [ifNotSet] Sets an option only if it isn't currently set + * @returns {ReflectionObject} `this` + */ +ReflectionObject.prototype.setOptions = function setOptions(options, ifNotSet) { + if (options) + for (var keys = Object.keys(options), i = 0; i < keys.length; ++i) + this.setOption(keys[i], options[keys[i]], ifNotSet); + return this; +}; + +/** + * Converts this instance to its string representation. + * @returns {string} Class name[, space, full name] + */ +ReflectionObject.prototype.toString = function toString() { + var className = this.constructor.className, + fullName = this.fullName; + if (fullName.length) + return className + " " + fullName; + return className; +}; + +// Sets up cyclic dependencies (called in index-light) +ReflectionObject._configure = function(Root_) { + Root = Root_; +}; + +},{"37":37}],25:[function(require,module,exports){ +"use strict"; +module.exports = OneOf; + +// extends ReflectionObject +var ReflectionObject = require(24); +((OneOf.prototype = Object.create(ReflectionObject.prototype)).constructor = OneOf).className = "OneOf"; + +var Field = require(16), + util = require(37); + +/** + * Constructs a new oneof instance. + * @classdesc Reflected oneof. + * @extends ReflectionObject + * @constructor + * @param {string} name Oneof name + * @param {string[]|Object.} [fieldNames] Field names + * @param {Object.} [options] Declared options + * @param {string} [comment] Comment associated with this field + */ +function OneOf(name, fieldNames, options, comment) { + if (!Array.isArray(fieldNames)) { + options = fieldNames; + fieldNames = undefined; + } + ReflectionObject.call(this, name, options); + + /* istanbul ignore if */ + if (!(fieldNames === undefined || Array.isArray(fieldNames))) + throw TypeError("fieldNames must be an Array"); + + /** + * Field names that belong to this oneof. + * @type {string[]} + */ + this.oneof = fieldNames || []; // toJSON, marker + + /** + * Fields that belong to this oneof as an array for iteration. + * @type {Field[]} + * @readonly + */ + this.fieldsArray = []; // declared readonly for conformance, possibly not yet added to parent + + /** + * Comment for this field. + * @type {string|null} + */ + this.comment = comment; +} + +/** + * Oneof descriptor. + * @interface IOneOf + * @property {Array.} oneof Oneof field names + * @property {Object.} [options] Oneof options + */ + +/** + * Constructs a oneof from a oneof descriptor. + * @param {string} name Oneof name + * @param {IOneOf} json Oneof descriptor + * @returns {OneOf} Created oneof + * @throws {TypeError} If arguments are invalid + */ +OneOf.fromJSON = function fromJSON(name, json) { + return new OneOf(name, json.oneof, json.options, json.comment); +}; + +/** + * Converts this oneof to a oneof descriptor. + * @param {IToJSONOptions} [toJSONOptions] JSON conversion options + * @returns {IOneOf} Oneof descriptor + */ +OneOf.prototype.toJSON = function toJSON(toJSONOptions) { + var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false; + return util.toObject([ + "options" , this.options, + "oneof" , this.oneof, + "comment" , keepComments ? this.comment : undefined + ]); +}; + +/** + * Adds the fields of the specified oneof to the parent if not already done so. + * @param {OneOf} oneof The oneof + * @returns {undefined} + * @inner + * @ignore + */ +function addFieldsToParent(oneof) { + if (oneof.parent) + for (var i = 0; i < oneof.fieldsArray.length; ++i) + if (!oneof.fieldsArray[i].parent) + oneof.parent.add(oneof.fieldsArray[i]); +} + +/** + * Adds a field to this oneof and removes it from its current parent, if any. + * @param {Field} field Field to add + * @returns {OneOf} `this` + */ +OneOf.prototype.add = function add(field) { + + /* istanbul ignore if */ + if (!(field instanceof Field)) + throw TypeError("field must be a Field"); + + if (field.parent && field.parent !== this.parent) + field.parent.remove(field); + this.oneof.push(field.name); + this.fieldsArray.push(field); + field.partOf = this; // field.parent remains null + addFieldsToParent(this); + return this; +}; + +/** + * Removes a field from this oneof and puts it back to the oneof's parent. + * @param {Field} field Field to remove + * @returns {OneOf} `this` + */ +OneOf.prototype.remove = function remove(field) { + + /* istanbul ignore if */ + if (!(field instanceof Field)) + throw TypeError("field must be a Field"); + + var index = this.fieldsArray.indexOf(field); + + /* istanbul ignore if */ + if (index < 0) + throw Error(field + " is not a member of " + this); + + this.fieldsArray.splice(index, 1); + index = this.oneof.indexOf(field.name); + + /* istanbul ignore else */ + if (index > -1) // theoretical + this.oneof.splice(index, 1); + + field.partOf = null; + return this; +}; + +/** + * @override + */ +OneOf.prototype.onAdd = function onAdd(parent) { + ReflectionObject.prototype.onAdd.call(this, parent); + var self = this; + // Collect present fields + for (var i = 0; i < this.oneof.length; ++i) { + var field = parent.get(this.oneof[i]); + if (field && !field.partOf) { + field.partOf = self; + self.fieldsArray.push(field); + } + } + // Add not yet present fields + addFieldsToParent(this); +}; + +/** + * @override + */ +OneOf.prototype.onRemove = function onRemove(parent) { + for (var i = 0, field; i < this.fieldsArray.length; ++i) + if ((field = this.fieldsArray[i]).parent) + field.parent.remove(field); + ReflectionObject.prototype.onRemove.call(this, parent); +}; + +/** + * Decorator function as returned by {@link OneOf.d} (TypeScript). + * @typedef OneOfDecorator + * @type {function} + * @param {Object} prototype Target prototype + * @param {string} oneofName OneOf name + * @returns {undefined} + */ + +/** + * OneOf decorator (TypeScript). + * @function + * @param {...string} fieldNames Field names + * @returns {OneOfDecorator} Decorator function + * @template T extends string + */ +OneOf.d = function decorateOneOf() { + var fieldNames = new Array(arguments.length), + index = 0; + while (index < arguments.length) + fieldNames[index] = arguments[index++]; + return function oneOfDecorator(prototype, oneofName) { + util.decorateType(prototype.constructor) + .add(new OneOf(oneofName, fieldNames)); + Object.defineProperty(prototype, oneofName, { + get: util.oneOfGetter(fieldNames), + set: util.oneOfSetter(fieldNames) + }); + }; +}; + +},{"16":16,"24":24,"37":37}],26:[function(require,module,exports){ +"use strict"; +module.exports = parse; + +parse.filename = null; +parse.defaults = { keepCase: false }; + +var tokenize = require(34), + Root = require(29), + Type = require(35), + Field = require(16), + MapField = require(20), + OneOf = require(25), + Enum = require(15), + Service = require(33), + Method = require(22), + types = require(36), + util = require(37); + +var base10Re = /^[1-9][0-9]*$/, + base10NegRe = /^-?[1-9][0-9]*$/, + base16Re = /^0[x][0-9a-fA-F]+$/, + base16NegRe = /^-?0[x][0-9a-fA-F]+$/, + base8Re = /^0[0-7]+$/, + base8NegRe = /^-?0[0-7]+$/, + numberRe = /^(?![eE])[0-9]*(?:\.[0-9]*)?(?:[eE][+-]?[0-9]+)?$/, + nameRe = /^[a-zA-Z_][a-zA-Z_0-9]*$/, + typeRefRe = /^(?:\.?[a-zA-Z_][a-zA-Z_0-9]*)(?:\.[a-zA-Z_][a-zA-Z_0-9]*)*$/, + fqTypeRefRe = /^(?:\.[a-zA-Z_][a-zA-Z_0-9]*)+$/; + +/** + * Result object returned from {@link parse}. + * @interface IParserResult + * @property {string|undefined} package Package name, if declared + * @property {string[]|undefined} imports Imports, if any + * @property {string[]|undefined} weakImports Weak imports, if any + * @property {string|undefined} syntax Syntax, if specified (either `"proto2"` or `"proto3"`) + * @property {Root} root Populated root instance + */ + +/** + * Options modifying the behavior of {@link parse}. + * @interface IParseOptions + * @property {boolean} [keepCase=false] Keeps field casing instead of converting to camel case + * @property {boolean} [alternateCommentMode=false] Recognize double-slash comments in addition to doc-block comments. + */ + +/** + * Options modifying the behavior of JSON serialization. + * @interface IToJSONOptions + * @property {boolean} [keepComments=false] Serializes comments. + */ + +/** + * Parses the given .proto source and returns an object with the parsed contents. + * @param {string} source Source contents + * @param {Root} root Root to populate + * @param {IParseOptions} [options] Parse options. Defaults to {@link parse.defaults} when omitted. + * @returns {IParserResult} Parser result + * @property {string} filename=null Currently processing file name for error reporting, if known + * @property {IParseOptions} defaults Default {@link IParseOptions} + */ +function parse(source, root, options) { + /* eslint-disable callback-return */ + if (!(root instanceof Root)) { + options = root; + root = new Root(); + } + if (!options) + options = parse.defaults; + + var tn = tokenize(source, options.alternateCommentMode || false), + next = tn.next, + push = tn.push, + peek = tn.peek, + skip = tn.skip, + cmnt = tn.cmnt; + + var head = true, + pkg, + imports, + weakImports, + syntax, + isProto3 = false; + + var ptr = root; + + var applyCase = options.keepCase ? function(name) { return name; } : util.camelCase; + + /* istanbul ignore next */ + function illegal(token, name, insideTryCatch) { + var filename = parse.filename; + if (!insideTryCatch) + parse.filename = null; + return Error("illegal " + (name || "token") + " '" + token + "' (" + (filename ? filename + ", " : "") + "line " + tn.line + ")"); + } + + function readString() { + var values = [], + token; + do { + /* istanbul ignore if */ + if ((token = next()) !== "\"" && token !== "'") + throw illegal(token); + + values.push(next()); + skip(token); + token = peek(); + } while (token === "\"" || token === "'"); + return values.join(""); + } + + function readValue(acceptTypeRef) { + var token = next(); + switch (token) { + case "'": + case "\"": + push(token); + return readString(); + case "true": case "TRUE": + return true; + case "false": case "FALSE": + return false; + } + try { + return parseNumber(token, /* insideTryCatch */ true); + } catch (e) { + + /* istanbul ignore else */ + if (acceptTypeRef && typeRefRe.test(token)) + return token; + + /* istanbul ignore next */ + throw illegal(token, "value"); + } + } + + function readRanges(target, acceptStrings) { + var token, start; + do { + if (acceptStrings && ((token = peek()) === "\"" || token === "'")) + target.push(readString()); + else + target.push([ start = parseId(next()), skip("to", true) ? parseId(next()) : start ]); + } while (skip(",", true)); + skip(";"); + } + + function parseNumber(token, insideTryCatch) { + var sign = 1; + if (token.charAt(0) === "-") { + sign = -1; + token = token.substring(1); + } + switch (token) { + case "inf": case "INF": case "Inf": + return sign * Infinity; + case "nan": case "NAN": case "Nan": case "NaN": + return NaN; + case "0": + return 0; + } + if (base10Re.test(token)) + return sign * parseInt(token, 10); + if (base16Re.test(token)) + return sign * parseInt(token, 16); + if (base8Re.test(token)) + return sign * parseInt(token, 8); + + /* istanbul ignore else */ + if (numberRe.test(token)) + return sign * parseFloat(token); + + /* istanbul ignore next */ + throw illegal(token, "number", insideTryCatch); + } + + function parseId(token, acceptNegative) { + switch (token) { + case "max": case "MAX": case "Max": + return 536870911; + case "0": + return 0; + } + + /* istanbul ignore if */ + if (!acceptNegative && token.charAt(0) === "-") + throw illegal(token, "id"); + + if (base10NegRe.test(token)) + return parseInt(token, 10); + if (base16NegRe.test(token)) + return parseInt(token, 16); + + /* istanbul ignore else */ + if (base8NegRe.test(token)) + return parseInt(token, 8); + + /* istanbul ignore next */ + throw illegal(token, "id"); + } + + function parsePackage() { + + /* istanbul ignore if */ + if (pkg !== undefined) + throw illegal("package"); + + pkg = next(); + + /* istanbul ignore if */ + if (!typeRefRe.test(pkg)) + throw illegal(pkg, "name"); + + ptr = ptr.define(pkg); + skip(";"); + } + + function parseImport() { + var token = peek(); + var whichImports; + switch (token) { + case "weak": + whichImports = weakImports || (weakImports = []); + next(); + break; + case "public": + next(); + // eslint-disable-line no-fallthrough + default: + whichImports = imports || (imports = []); + break; + } + token = readString(); + skip(";"); + whichImports.push(token); + } + + function parseSyntax() { + skip("="); + syntax = readString(); + isProto3 = syntax === "proto3"; + + /* istanbul ignore if */ + if (!isProto3 && syntax !== "proto2") + throw illegal(syntax, "syntax"); + + skip(";"); + } + + function parseCommon(parent, token) { + switch (token) { + + case "option": + parseOption(parent, token); + skip(";"); + return true; + + case "message": + parseType(parent, token); + return true; + + case "enum": + parseEnum(parent, token); + return true; + + case "service": + parseService(parent, token); + return true; + + case "extend": + parseExtension(parent, token); + return true; + } + return false; + } + + function ifBlock(obj, fnIf, fnElse) { + var trailingLine = tn.line; + if (obj) { + obj.comment = cmnt(); // try block-type comment + obj.filename = parse.filename; + } + if (skip("{", true)) { + var token; + while ((token = next()) !== "}") + fnIf(token); + skip(";", true); + } else { + if (fnElse) + fnElse(); + skip(";"); + if (obj && typeof obj.comment !== "string") + obj.comment = cmnt(trailingLine); // try line-type comment if no block + } + } + + function parseType(parent, token) { + + /* istanbul ignore if */ + if (!nameRe.test(token = next())) + throw illegal(token, "type name"); + + var type = new Type(token); + ifBlock(type, function parseType_block(token) { + if (parseCommon(type, token)) + return; + + switch (token) { + + case "map": + parseMapField(type, token); + break; + + case "required": + case "optional": + case "repeated": + parseField(type, token); + break; + + case "oneof": + parseOneOf(type, token); + break; + + case "extensions": + readRanges(type.extensions || (type.extensions = [])); + break; + + case "reserved": + readRanges(type.reserved || (type.reserved = []), true); + break; + + default: + /* istanbul ignore if */ + if (!isProto3 || !typeRefRe.test(token)) + throw illegal(token); + + push(token); + parseField(type, "optional"); + break; + } + }); + parent.add(type); + } + + function parseField(parent, rule, extend) { + var type = next(); + if (type === "group") { + parseGroup(parent, rule); + return; + } + + /* istanbul ignore if */ + if (!typeRefRe.test(type)) + throw illegal(type, "type"); + + var name = next(); + + /* istanbul ignore if */ + if (!nameRe.test(name)) + throw illegal(name, "name"); + + name = applyCase(name); + skip("="); + + var field = new Field(name, parseId(next()), type, rule, extend); + ifBlock(field, function parseField_block(token) { + + /* istanbul ignore else */ + if (token === "option") { + parseOption(field, token); + skip(";"); + } else + throw illegal(token); + + }, function parseField_line() { + parseInlineOptions(field); + }); + parent.add(field); + + // JSON defaults to packed=true if not set so we have to set packed=false explicity when + // parsing proto2 descriptors without the option, where applicable. This must be done for + // all known packable types and anything that could be an enum (= is not a basic type). + if (!isProto3 && field.repeated && (types.packed[type] !== undefined || types.basic[type] === undefined)) + field.setOption("packed", false, /* ifNotSet */ true); + } + + function parseGroup(parent, rule) { + var name = next(); + + /* istanbul ignore if */ + if (!nameRe.test(name)) + throw illegal(name, "name"); + + var fieldName = util.lcFirst(name); + if (name === fieldName) + name = util.ucFirst(name); + skip("="); + var id = parseId(next()); + var type = new Type(name); + type.group = true; + var field = new Field(fieldName, id, name, rule); + field.filename = parse.filename; + ifBlock(type, function parseGroup_block(token) { + switch (token) { + + case "option": + parseOption(type, token); + skip(";"); + break; + + case "required": + case "optional": + case "repeated": + parseField(type, token); + break; + + /* istanbul ignore next */ + default: + throw illegal(token); // there are no groups with proto3 semantics + } + }); + parent.add(type) + .add(field); + } + + function parseMapField(parent) { + skip("<"); + var keyType = next(); + + /* istanbul ignore if */ + if (types.mapKey[keyType] === undefined) + throw illegal(keyType, "type"); + + skip(","); + var valueType = next(); + + /* istanbul ignore if */ + if (!typeRefRe.test(valueType)) + throw illegal(valueType, "type"); + + skip(">"); + var name = next(); + + /* istanbul ignore if */ + if (!nameRe.test(name)) + throw illegal(name, "name"); + + skip("="); + var field = new MapField(applyCase(name), parseId(next()), keyType, valueType); + ifBlock(field, function parseMapField_block(token) { + + /* istanbul ignore else */ + if (token === "option") { + parseOption(field, token); + skip(";"); + } else + throw illegal(token); + + }, function parseMapField_line() { + parseInlineOptions(field); + }); + parent.add(field); + } + + function parseOneOf(parent, token) { + + /* istanbul ignore if */ + if (!nameRe.test(token = next())) + throw illegal(token, "name"); + + var oneof = new OneOf(applyCase(token)); + ifBlock(oneof, function parseOneOf_block(token) { + if (token === "option") { + parseOption(oneof, token); + skip(";"); + } else { + push(token); + parseField(oneof, "optional"); + } + }); + parent.add(oneof); + } + + function parseEnum(parent, token) { + + /* istanbul ignore if */ + if (!nameRe.test(token = next())) + throw illegal(token, "name"); + + var enm = new Enum(token); + ifBlock(enm, function parseEnum_block(token) { + switch(token) { + case "option": + parseOption(enm, token); + skip(";"); + break; + + case "reserved": + readRanges(enm.reserved || (enm.reserved = []), true); + break; + + default: + parseEnumValue(enm, token); + } + }); + parent.add(enm); + } + + function parseEnumValue(parent, token) { + + /* istanbul ignore if */ + if (!nameRe.test(token)) + throw illegal(token, "name"); + + skip("="); + var value = parseId(next(), true), + dummy = {}; + ifBlock(dummy, function parseEnumValue_block(token) { + + /* istanbul ignore else */ + if (token === "option") { + parseOption(dummy, token); // skip + skip(";"); + } else + throw illegal(token); + + }, function parseEnumValue_line() { + parseInlineOptions(dummy); // skip + }); + parent.add(token, value, dummy.comment); + } + + function parseOption(parent, token) { + var isCustom = skip("(", true); + + /* istanbul ignore if */ + if (!typeRefRe.test(token = next())) + throw illegal(token, "name"); + + var name = token; + if (isCustom) { + skip(")"); + name = "(" + name + ")"; + token = peek(); + if (fqTypeRefRe.test(token)) { + name += token; + next(); + } + } + skip("="); + parseOptionValue(parent, name); + } + + function parseOptionValue(parent, name) { + if (skip("{", true)) { // { a: "foo" b { c: "bar" } } + do { + /* istanbul ignore if */ + if (!nameRe.test(token = next())) + throw illegal(token, "name"); + + if (peek() === "{") + parseOptionValue(parent, name + "." + token); + else { + skip(":"); + if (peek() === "{") + parseOptionValue(parent, name + "." + token); + else + setOption(parent, name + "." + token, readValue(true)); + } + skip(",", true); + } while (!skip("}", true)); + } else + setOption(parent, name, readValue(true)); + // Does not enforce a delimiter to be universal + } + + function setOption(parent, name, value) { + if (parent.setOption) + parent.setOption(name, value); + } + + function parseInlineOptions(parent) { + if (skip("[", true)) { + do { + parseOption(parent, "option"); + } while (skip(",", true)); + skip("]"); + } + return parent; + } + + function parseService(parent, token) { + + /* istanbul ignore if */ + if (!nameRe.test(token = next())) + throw illegal(token, "service name"); + + var service = new Service(token); + ifBlock(service, function parseService_block(token) { + if (parseCommon(service, token)) + return; + + /* istanbul ignore else */ + if (token === "rpc") + parseMethod(service, token); + else + throw illegal(token); + }); + parent.add(service); + } + + function parseMethod(parent, token) { + var type = token; + + /* istanbul ignore if */ + if (!nameRe.test(token = next())) + throw illegal(token, "name"); + + var name = token, + requestType, requestStream, + responseType, responseStream; + + skip("("); + if (skip("stream", true)) + requestStream = true; + + /* istanbul ignore if */ + if (!typeRefRe.test(token = next())) + throw illegal(token); + + requestType = token; + skip(")"); skip("returns"); skip("("); + if (skip("stream", true)) + responseStream = true; + + /* istanbul ignore if */ + if (!typeRefRe.test(token = next())) + throw illegal(token); + + responseType = token; + skip(")"); + + var method = new Method(name, type, requestType, responseType, requestStream, responseStream); + ifBlock(method, function parseMethod_block(token) { + + /* istanbul ignore else */ + if (token === "option") { + parseOption(method, token); + skip(";"); + } else + throw illegal(token); + + }); + parent.add(method); + } + + function parseExtension(parent, token) { + + /* istanbul ignore if */ + if (!typeRefRe.test(token = next())) + throw illegal(token, "reference"); + + var reference = token; + ifBlock(null, function parseExtension_block(token) { + switch (token) { + + case "required": + case "repeated": + case "optional": + parseField(parent, token, reference); + break; + + default: + /* istanbul ignore if */ + if (!isProto3 || !typeRefRe.test(token)) + throw illegal(token); + push(token); + parseField(parent, "optional", reference); + break; + } + }); + } + + var token; + while ((token = next()) !== null) { + switch (token) { + + case "package": + + /* istanbul ignore if */ + if (!head) + throw illegal(token); + + parsePackage(); + break; + + case "import": + + /* istanbul ignore if */ + if (!head) + throw illegal(token); + + parseImport(); + break; + + case "syntax": + + /* istanbul ignore if */ + if (!head) + throw illegal(token); + + parseSyntax(); + break; + + case "option": + + /* istanbul ignore if */ + if (!head) + throw illegal(token); + + parseOption(ptr, token); + skip(";"); + break; + + default: + + /* istanbul ignore else */ + if (parseCommon(ptr, token)) { + head = false; + continue; + } + + /* istanbul ignore next */ + throw illegal(token); + } + } + + parse.filename = null; + return { + "package" : pkg, + "imports" : imports, + weakImports : weakImports, + syntax : syntax, + root : root + }; +} + +/** + * Parses the given .proto source and returns an object with the parsed contents. + * @name parse + * @function + * @param {string} source Source contents + * @param {IParseOptions} [options] Parse options. Defaults to {@link parse.defaults} when omitted. + * @returns {IParserResult} Parser result + * @property {string} filename=null Currently processing file name for error reporting, if known + * @property {IParseOptions} defaults Default {@link IParseOptions} + * @variation 2 + */ + +},{"15":15,"16":16,"20":20,"22":22,"25":25,"29":29,"33":33,"34":34,"35":35,"36":36,"37":37}],27:[function(require,module,exports){ +"use strict"; +module.exports = Reader; + +var util = require(39); + +var BufferReader; // cyclic + +var LongBits = util.LongBits, + utf8 = util.utf8; + +/* istanbul ignore next */ +function indexOutOfRange(reader, writeLength) { + return RangeError("index out of range: " + reader.pos + " + " + (writeLength || 1) + " > " + reader.len); +} + +/** + * Constructs a new reader instance using the specified buffer. + * @classdesc Wire format reader using `Uint8Array` if available, otherwise `Array`. + * @constructor + * @param {Uint8Array} buffer Buffer to read from + */ +function Reader(buffer) { + + /** + * Read buffer. + * @type {Uint8Array} + */ + this.buf = buffer; + + /** + * Read buffer position. + * @type {number} + */ + this.pos = 0; + + /** + * Read buffer length. + * @type {number} + */ + this.len = buffer.length; +} + +var create_array = typeof Uint8Array !== "undefined" + ? function create_typed_array(buffer) { + if (buffer instanceof Uint8Array || Array.isArray(buffer)) + return new Reader(buffer); + throw Error("illegal buffer"); + } + /* istanbul ignore next */ + : function create_array(buffer) { + if (Array.isArray(buffer)) + return new Reader(buffer); + throw Error("illegal buffer"); + }; + +/** + * Creates a new reader using the specified buffer. + * @function + * @param {Uint8Array|Buffer} buffer Buffer to read from + * @returns {Reader|BufferReader} A {@link BufferReader} if `buffer` is a Buffer, otherwise a {@link Reader} + * @throws {Error} If `buffer` is not a valid buffer + */ +Reader.create = util.Buffer + ? function create_buffer_setup(buffer) { + return (Reader.create = function create_buffer(buffer) { + return util.Buffer.isBuffer(buffer) + ? new BufferReader(buffer) + /* istanbul ignore next */ + : create_array(buffer); + })(buffer); + } + /* istanbul ignore next */ + : create_array; + +Reader.prototype._slice = util.Array.prototype.subarray || /* istanbul ignore next */ util.Array.prototype.slice; + +/** + * Reads a varint as an unsigned 32 bit value. + * @function + * @returns {number} Value read + */ +Reader.prototype.uint32 = (function read_uint32_setup() { + var value = 4294967295; // optimizer type-hint, tends to deopt otherwise (?!) + return function read_uint32() { + value = ( this.buf[this.pos] & 127 ) >>> 0; if (this.buf[this.pos++] < 128) return value; + value = (value | (this.buf[this.pos] & 127) << 7) >>> 0; if (this.buf[this.pos++] < 128) return value; + value = (value | (this.buf[this.pos] & 127) << 14) >>> 0; if (this.buf[this.pos++] < 128) return value; + value = (value | (this.buf[this.pos] & 127) << 21) >>> 0; if (this.buf[this.pos++] < 128) return value; + value = (value | (this.buf[this.pos] & 15) << 28) >>> 0; if (this.buf[this.pos++] < 128) return value; + + /* istanbul ignore if */ + if ((this.pos += 5) > this.len) { + this.pos = this.len; + throw indexOutOfRange(this, 10); + } + return value; + }; +})(); + +/** + * Reads a varint as a signed 32 bit value. + * @returns {number} Value read + */ +Reader.prototype.int32 = function read_int32() { + return this.uint32() | 0; +}; + +/** + * Reads a zig-zag encoded varint as a signed 32 bit value. + * @returns {number} Value read + */ +Reader.prototype.sint32 = function read_sint32() { + var value = this.uint32(); + return value >>> 1 ^ -(value & 1) | 0; +}; + +/* eslint-disable no-invalid-this */ + +function readLongVarint() { + // tends to deopt with local vars for octet etc. + var bits = new LongBits(0, 0); + var i = 0; + if (this.len - this.pos > 4) { // fast route (lo) + for (; i < 4; ++i) { + // 1st..4th + bits.lo = (bits.lo | (this.buf[this.pos] & 127) << i * 7) >>> 0; + if (this.buf[this.pos++] < 128) + return bits; + } + // 5th + bits.lo = (bits.lo | (this.buf[this.pos] & 127) << 28) >>> 0; + bits.hi = (bits.hi | (this.buf[this.pos] & 127) >> 4) >>> 0; + if (this.buf[this.pos++] < 128) + return bits; + i = 0; + } else { + for (; i < 3; ++i) { + /* istanbul ignore if */ + if (this.pos >= this.len) + throw indexOutOfRange(this); + // 1st..3th + bits.lo = (bits.lo | (this.buf[this.pos] & 127) << i * 7) >>> 0; + if (this.buf[this.pos++] < 128) + return bits; + } + // 4th + bits.lo = (bits.lo | (this.buf[this.pos++] & 127) << i * 7) >>> 0; + return bits; + } + if (this.len - this.pos > 4) { // fast route (hi) + for (; i < 5; ++i) { + // 6th..10th + bits.hi = (bits.hi | (this.buf[this.pos] & 127) << i * 7 + 3) >>> 0; + if (this.buf[this.pos++] < 128) + return bits; + } + } else { + for (; i < 5; ++i) { + /* istanbul ignore if */ + if (this.pos >= this.len) + throw indexOutOfRange(this); + // 6th..10th + bits.hi = (bits.hi | (this.buf[this.pos] & 127) << i * 7 + 3) >>> 0; + if (this.buf[this.pos++] < 128) + return bits; + } + } + /* istanbul ignore next */ + throw Error("invalid varint encoding"); +} + +/* eslint-enable no-invalid-this */ + +/** + * Reads a varint as a signed 64 bit value. + * @name Reader#int64 + * @function + * @returns {Long} Value read + */ + +/** + * Reads a varint as an unsigned 64 bit value. + * @name Reader#uint64 + * @function + * @returns {Long} Value read + */ + +/** + * Reads a zig-zag encoded varint as a signed 64 bit value. + * @name Reader#sint64 + * @function + * @returns {Long} Value read + */ + +/** + * Reads a varint as a boolean. + * @returns {boolean} Value read + */ +Reader.prototype.bool = function read_bool() { + return this.uint32() !== 0; +}; + +function readFixed32_end(buf, end) { // note that this uses `end`, not `pos` + return (buf[end - 4] + | buf[end - 3] << 8 + | buf[end - 2] << 16 + | buf[end - 1] << 24) >>> 0; +} + +/** + * Reads fixed 32 bits as an unsigned 32 bit integer. + * @returns {number} Value read + */ +Reader.prototype.fixed32 = function read_fixed32() { + + /* istanbul ignore if */ + if (this.pos + 4 > this.len) + throw indexOutOfRange(this, 4); + + return readFixed32_end(this.buf, this.pos += 4); +}; + +/** + * Reads fixed 32 bits as a signed 32 bit integer. + * @returns {number} Value read + */ +Reader.prototype.sfixed32 = function read_sfixed32() { + + /* istanbul ignore if */ + if (this.pos + 4 > this.len) + throw indexOutOfRange(this, 4); + + return readFixed32_end(this.buf, this.pos += 4) | 0; +}; + +/* eslint-disable no-invalid-this */ + +function readFixed64(/* this: Reader */) { + + /* istanbul ignore if */ + if (this.pos + 8 > this.len) + throw indexOutOfRange(this, 8); + + return new LongBits(readFixed32_end(this.buf, this.pos += 4), readFixed32_end(this.buf, this.pos += 4)); +} + +/* eslint-enable no-invalid-this */ + +/** + * Reads fixed 64 bits. + * @name Reader#fixed64 + * @function + * @returns {Long} Value read + */ + +/** + * Reads zig-zag encoded fixed 64 bits. + * @name Reader#sfixed64 + * @function + * @returns {Long} Value read + */ + +/** + * Reads a float (32 bit) as a number. + * @function + * @returns {number} Value read + */ +Reader.prototype.float = function read_float() { + + /* istanbul ignore if */ + if (this.pos + 4 > this.len) + throw indexOutOfRange(this, 4); + + var value = util.float.readFloatLE(this.buf, this.pos); + this.pos += 4; + return value; +}; + +/** + * Reads a double (64 bit float) as a number. + * @function + * @returns {number} Value read + */ +Reader.prototype.double = function read_double() { + + /* istanbul ignore if */ + if (this.pos + 8 > this.len) + throw indexOutOfRange(this, 4); + + var value = util.float.readDoubleLE(this.buf, this.pos); + this.pos += 8; + return value; +}; + +/** + * Reads a sequence of bytes preceeded by its length as a varint. + * @returns {Uint8Array} Value read + */ +Reader.prototype.bytes = function read_bytes() { + var length = this.uint32(), + start = this.pos, + end = this.pos + length; + + /* istanbul ignore if */ + if (end > this.len) + throw indexOutOfRange(this, length); + + this.pos += length; + if (Array.isArray(this.buf)) // plain array + return this.buf.slice(start, end); + return start === end // fix for IE 10/Win8 and others' subarray returning array of size 1 + ? new this.buf.constructor(0) + : this._slice.call(this.buf, start, end); +}; + +/** + * Reads a string preceeded by its byte length as a varint. + * @returns {string} Value read + */ +Reader.prototype.string = function read_string() { + var bytes = this.bytes(); + return utf8.read(bytes, 0, bytes.length); +}; + +/** + * Skips the specified number of bytes if specified, otherwise skips a varint. + * @param {number} [length] Length if known, otherwise a varint is assumed + * @returns {Reader} `this` + */ +Reader.prototype.skip = function skip(length) { + if (typeof length === "number") { + /* istanbul ignore if */ + if (this.pos + length > this.len) + throw indexOutOfRange(this, length); + this.pos += length; + } else { + do { + /* istanbul ignore if */ + if (this.pos >= this.len) + throw indexOutOfRange(this); + } while (this.buf[this.pos++] & 128); + } + return this; +}; + +/** + * Skips the next element of the specified wire type. + * @param {number} wireType Wire type received + * @returns {Reader} `this` + */ +Reader.prototype.skipType = function(wireType) { + switch (wireType) { + case 0: + this.skip(); + break; + case 1: + this.skip(8); + break; + case 2: + this.skip(this.uint32()); + break; + case 3: + while ((wireType = this.uint32() & 7) !== 4) { + this.skipType(wireType); + } + break; + case 5: + this.skip(4); + break; + + /* istanbul ignore next */ + default: + throw Error("invalid wire type " + wireType + " at offset " + this.pos); + } + return this; +}; + +Reader._configure = function(BufferReader_) { + BufferReader = BufferReader_; + + var fn = util.Long ? "toLong" : /* istanbul ignore next */ "toNumber"; + util.merge(Reader.prototype, { + + int64: function read_int64() { + return readLongVarint.call(this)[fn](false); + }, + + uint64: function read_uint64() { + return readLongVarint.call(this)[fn](true); + }, + + sint64: function read_sint64() { + return readLongVarint.call(this).zzDecode()[fn](false); + }, + + fixed64: function read_fixed64() { + return readFixed64.call(this)[fn](true); + }, + + sfixed64: function read_sfixed64() { + return readFixed64.call(this)[fn](false); + } + + }); +}; + +},{"39":39}],28:[function(require,module,exports){ +"use strict"; +module.exports = BufferReader; + +// extends Reader +var Reader = require(27); +(BufferReader.prototype = Object.create(Reader.prototype)).constructor = BufferReader; + +var util = require(39); + +/** + * Constructs a new buffer reader instance. + * @classdesc Wire format reader using node buffers. + * @extends Reader + * @constructor + * @param {Buffer} buffer Buffer to read from + */ +function BufferReader(buffer) { + Reader.call(this, buffer); + + /** + * Read buffer. + * @name BufferReader#buf + * @type {Buffer} + */ +} + +/* istanbul ignore else */ +if (util.Buffer) + BufferReader.prototype._slice = util.Buffer.prototype.slice; + +/** + * @override + */ +BufferReader.prototype.string = function read_string_buffer() { + var len = this.uint32(); // modifies pos + return this.buf.utf8Slice(this.pos, this.pos = Math.min(this.pos + len, this.len)); +}; + +/** + * Reads a sequence of bytes preceeded by its length as a varint. + * @name BufferReader#bytes + * @function + * @returns {Buffer} Value read + */ + +},{"27":27,"39":39}],29:[function(require,module,exports){ +"use strict"; +module.exports = Root; + +// extends Namespace +var Namespace = require(23); +((Root.prototype = Object.create(Namespace.prototype)).constructor = Root).className = "Root"; + +var Field = require(16), + Enum = require(15), + OneOf = require(25), + util = require(37); + +var Type, // cyclic + parse, // might be excluded + common; // " + +/** + * Constructs a new root namespace instance. + * @classdesc Root namespace wrapping all types, enums, services, sub-namespaces etc. that belong together. + * @extends NamespaceBase + * @constructor + * @param {Object.} [options] Top level options + */ +function Root(options) { + Namespace.call(this, "", options); + + /** + * Deferred extension fields. + * @type {Field[]} + */ + this.deferred = []; + + /** + * Resolved file names of loaded files. + * @type {string[]} + */ + this.files = []; +} + +/** + * Loads a namespace descriptor into a root namespace. + * @param {INamespace} json Nameespace descriptor + * @param {Root} [root] Root namespace, defaults to create a new one if omitted + * @returns {Root} Root namespace + */ +Root.fromJSON = function fromJSON(json, root) { + if (!root) + root = new Root(); + if (json.options) + root.setOptions(json.options); + return root.addJSON(json.nested); +}; + +/** + * Resolves the path of an imported file, relative to the importing origin. + * This method exists so you can override it with your own logic in case your imports are scattered over multiple directories. + * @function + * @param {string} origin The file name of the importing file + * @param {string} target The file name being imported + * @returns {string|null} Resolved path to `target` or `null` to skip the file + */ +Root.prototype.resolvePath = util.path.resolve; + +// A symbol-like function to safely signal synchronous loading +/* istanbul ignore next */ +function SYNC() {} // eslint-disable-line no-empty-function + +/** + * Loads one or multiple .proto or preprocessed .json files into this root namespace and calls the callback. + * @param {string|string[]} filename Names of one or multiple files to load + * @param {IParseOptions} options Parse options + * @param {LoadCallback} callback Callback function + * @returns {undefined} + */ +Root.prototype.load = function load(filename, options, callback) { + if (typeof options === "function") { + callback = options; + options = undefined; + } + var self = this; + if (!callback) + return util.asPromise(load, self, filename, options); + + var sync = callback === SYNC; // undocumented + + // Finishes loading by calling the callback (exactly once) + function finish(err, root) { + /* istanbul ignore if */ + if (!callback) + return; + var cb = callback; + callback = null; + if (sync) + throw err; + cb(err, root); + } + + // Processes a single file + function process(filename, source) { + try { + if (util.isString(source) && source.charAt(0) === "{") + source = JSON.parse(source); + if (!util.isString(source)) + self.setOptions(source.options).addJSON(source.nested); + else { + parse.filename = filename; + var parsed = parse(source, self, options), + resolved, + i = 0; + if (parsed.imports) + for (; i < parsed.imports.length; ++i) + if (resolved = self.resolvePath(filename, parsed.imports[i])) + fetch(resolved); + if (parsed.weakImports) + for (i = 0; i < parsed.weakImports.length; ++i) + if (resolved = self.resolvePath(filename, parsed.weakImports[i])) + fetch(resolved, true); + } + } catch (err) { + finish(err); + } + if (!sync && !queued) + finish(null, self); // only once anyway + } + + // Fetches a single file + function fetch(filename, weak) { + + // Strip path if this file references a bundled definition + var idx = filename.lastIndexOf("google/protobuf/"); + if (idx > -1) { + var altname = filename.substring(idx); + if (altname in common) + filename = altname; + } + + // Skip if already loaded / attempted + if (self.files.indexOf(filename) > -1) + return; + self.files.push(filename); + + // Shortcut bundled definitions + if (filename in common) { + if (sync) + process(filename, common[filename]); + else { + ++queued; + setTimeout(function() { + --queued; + process(filename, common[filename]); + }); + } + return; + } + + // Otherwise fetch from disk or network + if (sync) { + var source; + try { + source = util.fs.readFileSync(filename).toString("utf8"); + } catch (err) { + if (!weak) + finish(err); + return; + } + process(filename, source); + } else { + ++queued; + util.fetch(filename, function(err, source) { + --queued; + /* istanbul ignore if */ + if (!callback) + return; // terminated meanwhile + if (err) { + /* istanbul ignore else */ + if (!weak) + finish(err); + else if (!queued) // can't be covered reliably + finish(null, self); + return; + } + process(filename, source); + }); + } + } + var queued = 0; + + // Assembling the root namespace doesn't require working type + // references anymore, so we can load everything in parallel + if (util.isString(filename)) + filename = [ filename ]; + for (var i = 0, resolved; i < filename.length; ++i) + if (resolved = self.resolvePath("", filename[i])) + fetch(resolved); + + if (sync) + return self; + if (!queued) + finish(null, self); + return undefined; +}; +// function load(filename:string, options:IParseOptions, callback:LoadCallback):undefined + +/** + * Loads one or multiple .proto or preprocessed .json files into this root namespace and calls the callback. + * @function Root#load + * @param {string|string[]} filename Names of one or multiple files to load + * @param {LoadCallback} callback Callback function + * @returns {undefined} + * @variation 2 + */ +// function load(filename:string, callback:LoadCallback):undefined + +/** + * Loads one or multiple .proto or preprocessed .json files into this root namespace and returns a promise. + * @function Root#load + * @param {string|string[]} filename Names of one or multiple files to load + * @param {IParseOptions} [options] Parse options. Defaults to {@link parse.defaults} when omitted. + * @returns {Promise} Promise + * @variation 3 + */ +// function load(filename:string, [options:IParseOptions]):Promise + +/** + * Synchronously loads one or multiple .proto or preprocessed .json files into this root namespace (node only). + * @function Root#loadSync + * @param {string|string[]} filename Names of one or multiple files to load + * @param {IParseOptions} [options] Parse options. Defaults to {@link parse.defaults} when omitted. + * @returns {Root} Root namespace + * @throws {Error} If synchronous fetching is not supported (i.e. in browsers) or if a file's syntax is invalid + */ +Root.prototype.loadSync = function loadSync(filename, options) { + if (!util.isNode) + throw Error("not supported"); + return this.load(filename, options, SYNC); +}; + +/** + * @override + */ +Root.prototype.resolveAll = function resolveAll() { + if (this.deferred.length) + throw Error("unresolvable extensions: " + this.deferred.map(function(field) { + return "'extend " + field.extend + "' in " + field.parent.fullName; + }).join(", ")); + return Namespace.prototype.resolveAll.call(this); +}; + +// only uppercased (and thus conflict-free) children are exposed, see below +var exposeRe = /^[A-Z]/; + +/** + * Handles a deferred declaring extension field by creating a sister field to represent it within its extended type. + * @param {Root} root Root instance + * @param {Field} field Declaring extension field witin the declaring type + * @returns {boolean} `true` if successfully added to the extended type, `false` otherwise + * @inner + * @ignore + */ +function tryHandleExtension(root, field) { + var extendedType = field.parent.lookup(field.extend); + if (extendedType) { + var sisterField = new Field(field.fullName, field.id, field.type, field.rule, undefined, field.options); + sisterField.declaringField = field; + field.extensionField = sisterField; + extendedType.add(sisterField); + return true; + } + return false; +} + +/** + * Called when any object is added to this root or its sub-namespaces. + * @param {ReflectionObject} object Object added + * @returns {undefined} + * @private + */ +Root.prototype._handleAdd = function _handleAdd(object) { + if (object instanceof Field) { + + if (/* an extension field (implies not part of a oneof) */ object.extend !== undefined && /* not already handled */ !object.extensionField) + if (!tryHandleExtension(this, object)) + this.deferred.push(object); + + } else if (object instanceof Enum) { + + if (exposeRe.test(object.name)) + object.parent[object.name] = object.values; // expose enum values as property of its parent + + } else if (!(object instanceof OneOf)) /* everything else is a namespace */ { + + if (object instanceof Type) // Try to handle any deferred extensions + for (var i = 0; i < this.deferred.length;) + if (tryHandleExtension(this, this.deferred[i])) + this.deferred.splice(i, 1); + else + ++i; + for (var j = 0; j < /* initializes */ object.nestedArray.length; ++j) // recurse into the namespace + this._handleAdd(object._nestedArray[j]); + if (exposeRe.test(object.name)) + object.parent[object.name] = object; // expose namespace as property of its parent + } + + // The above also adds uppercased (and thus conflict-free) nested types, services and enums as + // properties of namespaces just like static code does. This allows using a .d.ts generated for + // a static module with reflection-based solutions where the condition is met. +}; + +/** + * Called when any object is removed from this root or its sub-namespaces. + * @param {ReflectionObject} object Object removed + * @returns {undefined} + * @private + */ +Root.prototype._handleRemove = function _handleRemove(object) { + if (object instanceof Field) { + + if (/* an extension field */ object.extend !== undefined) { + if (/* already handled */ object.extensionField) { // remove its sister field + object.extensionField.parent.remove(object.extensionField); + object.extensionField = null; + } else { // cancel the extension + var index = this.deferred.indexOf(object); + /* istanbul ignore else */ + if (index > -1) + this.deferred.splice(index, 1); + } + } + + } else if (object instanceof Enum) { + + if (exposeRe.test(object.name)) + delete object.parent[object.name]; // unexpose enum values + + } else if (object instanceof Namespace) { + + for (var i = 0; i < /* initializes */ object.nestedArray.length; ++i) // recurse into the namespace + this._handleRemove(object._nestedArray[i]); + + if (exposeRe.test(object.name)) + delete object.parent[object.name]; // unexpose namespaces + + } +}; + +// Sets up cyclic dependencies (called in index-light) +Root._configure = function(Type_, parse_, common_) { + Type = Type_; + parse = parse_; + common = common_; +}; + +},{"15":15,"16":16,"23":23,"25":25,"37":37}],30:[function(require,module,exports){ +"use strict"; +module.exports = {}; + +/** + * Named roots. + * This is where pbjs stores generated structures (the option `-r, --root` specifies a name). + * Can also be used manually to make roots available accross modules. + * @name roots + * @type {Object.} + * @example + * // pbjs -r myroot -o compiled.js ... + * + * // in another module: + * require("./compiled.js"); + * + * // in any subsequent module: + * var root = protobuf.roots["myroot"]; + */ + +},{}],31:[function(require,module,exports){ +"use strict"; + +/** + * Streaming RPC helpers. + * @namespace + */ +var rpc = exports; + +/** + * RPC implementation passed to {@link Service#create} performing a service request on network level, i.e. by utilizing http requests or websockets. + * @typedef RPCImpl + * @type {function} + * @param {Method|rpc.ServiceMethod,Message<{}>>} method Reflected or static method being called + * @param {Uint8Array} requestData Request data + * @param {RPCImplCallback} callback Callback function + * @returns {undefined} + * @example + * function rpcImpl(method, requestData, callback) { + * if (protobuf.util.lcFirst(method.name) !== "myMethod") // compatible with static code + * throw Error("no such method"); + * asynchronouslyObtainAResponse(requestData, function(err, responseData) { + * callback(err, responseData); + * }); + * } + */ + +/** + * Node-style callback as used by {@link RPCImpl}. + * @typedef RPCImplCallback + * @type {function} + * @param {Error|null} error Error, if any, otherwise `null` + * @param {Uint8Array|null} [response] Response data or `null` to signal end of stream, if there hasn't been an error + * @returns {undefined} + */ + +rpc.Service = require(32); + +},{"32":32}],32:[function(require,module,exports){ +"use strict"; +module.exports = Service; + +var util = require(39); + +// Extends EventEmitter +(Service.prototype = Object.create(util.EventEmitter.prototype)).constructor = Service; + +/** + * A service method callback as used by {@link rpc.ServiceMethod|ServiceMethod}. + * + * Differs from {@link RPCImplCallback} in that it is an actual callback of a service method which may not return `response = null`. + * @typedef rpc.ServiceMethodCallback + * @template TRes extends Message + * @type {function} + * @param {Error|null} error Error, if any + * @param {TRes} [response] Response message + * @returns {undefined} + */ + +/** + * A service method part of a {@link rpc.Service} as created by {@link Service.create}. + * @typedef rpc.ServiceMethod + * @template TReq extends Message + * @template TRes extends Message + * @type {function} + * @param {TReq|Properties} request Request message or plain object + * @param {rpc.ServiceMethodCallback} [callback] Node-style callback called with the error, if any, and the response message + * @returns {Promise>} Promise if `callback` has been omitted, otherwise `undefined` + */ + +/** + * Constructs a new RPC service instance. + * @classdesc An RPC service as returned by {@link Service#create}. + * @exports rpc.Service + * @extends util.EventEmitter + * @constructor + * @param {RPCImpl} rpcImpl RPC implementation + * @param {boolean} [requestDelimited=false] Whether requests are length-delimited + * @param {boolean} [responseDelimited=false] Whether responses are length-delimited + */ +function Service(rpcImpl, requestDelimited, responseDelimited) { + + if (typeof rpcImpl !== "function") + throw TypeError("rpcImpl must be a function"); + + util.EventEmitter.call(this); + + /** + * RPC implementation. Becomes `null` once the service is ended. + * @type {RPCImpl|null} + */ + this.rpcImpl = rpcImpl; + + /** + * Whether requests are length-delimited. + * @type {boolean} + */ + this.requestDelimited = Boolean(requestDelimited); + + /** + * Whether responses are length-delimited. + * @type {boolean} + */ + this.responseDelimited = Boolean(responseDelimited); +} + +/** + * Calls a service method through {@link rpc.Service#rpcImpl|rpcImpl}. + * @param {Method|rpc.ServiceMethod} method Reflected or static method + * @param {Constructor} requestCtor Request constructor + * @param {Constructor} responseCtor Response constructor + * @param {TReq|Properties} request Request message or plain object + * @param {rpc.ServiceMethodCallback} callback Service callback + * @returns {undefined} + * @template TReq extends Message + * @template TRes extends Message + */ +Service.prototype.rpcCall = function rpcCall(method, requestCtor, responseCtor, request, callback) { + + if (!request) + throw TypeError("request must be specified"); + + var self = this; + if (!callback) + return util.asPromise(rpcCall, self, method, requestCtor, responseCtor, request); + + if (!self.rpcImpl) { + setTimeout(function() { callback(Error("already ended")); }, 0); + return undefined; + } + + try { + return self.rpcImpl( + method, + requestCtor[self.requestDelimited ? "encodeDelimited" : "encode"](request).finish(), + function rpcCallback(err, response) { + + if (err) { + self.emit("error", err, method); + return callback(err); + } + + if (response === null) { + self.end(/* endedByRPC */ true); + return undefined; + } + + if (!(response instanceof responseCtor)) { + try { + response = responseCtor[self.responseDelimited ? "decodeDelimited" : "decode"](response); + } catch (err) { + self.emit("error", err, method); + return callback(err); + } + } + + self.emit("data", response, method); + return callback(null, response); + } + ); + } catch (err) { + self.emit("error", err, method); + setTimeout(function() { callback(err); }, 0); + return undefined; + } +}; + +/** + * Ends this service and emits the `end` event. + * @param {boolean} [endedByRPC=false] Whether the service has been ended by the RPC implementation. + * @returns {rpc.Service} `this` + */ +Service.prototype.end = function end(endedByRPC) { + if (this.rpcImpl) { + if (!endedByRPC) // signal end to rpcImpl + this.rpcImpl(null, null, null); + this.rpcImpl = null; + this.emit("end").off(); + } + return this; +}; + +},{"39":39}],33:[function(require,module,exports){ +"use strict"; +module.exports = Service; + +// extends Namespace +var Namespace = require(23); +((Service.prototype = Object.create(Namespace.prototype)).constructor = Service).className = "Service"; + +var Method = require(22), + util = require(37), + rpc = require(31); + +/** + * Constructs a new service instance. + * @classdesc Reflected service. + * @extends NamespaceBase + * @constructor + * @param {string} name Service name + * @param {Object.} [options] Service options + * @throws {TypeError} If arguments are invalid + */ +function Service(name, options) { + Namespace.call(this, name, options); + + /** + * Service methods. + * @type {Object.} + */ + this.methods = {}; // toJSON, marker + + /** + * Cached methods as an array. + * @type {Method[]|null} + * @private + */ + this._methodsArray = null; +} + +/** + * Service descriptor. + * @interface IService + * @extends INamespace + * @property {Object.} methods Method descriptors + */ + +/** + * Constructs a service from a service descriptor. + * @param {string} name Service name + * @param {IService} json Service descriptor + * @returns {Service} Created service + * @throws {TypeError} If arguments are invalid + */ +Service.fromJSON = function fromJSON(name, json) { + var service = new Service(name, json.options); + /* istanbul ignore else */ + if (json.methods) + for (var names = Object.keys(json.methods), i = 0; i < names.length; ++i) + service.add(Method.fromJSON(names[i], json.methods[names[i]])); + if (json.nested) + service.addJSON(json.nested); + service.comment = json.comment; + return service; +}; + +/** + * Converts this service to a service descriptor. + * @param {IToJSONOptions} [toJSONOptions] JSON conversion options + * @returns {IService} Service descriptor + */ +Service.prototype.toJSON = function toJSON(toJSONOptions) { + var inherited = Namespace.prototype.toJSON.call(this, toJSONOptions); + var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false; + return util.toObject([ + "options" , inherited && inherited.options || undefined, + "methods" , Namespace.arrayToJSON(this.methodsArray, toJSONOptions) || /* istanbul ignore next */ {}, + "nested" , inherited && inherited.nested || undefined, + "comment" , keepComments ? this.comment : undefined + ]); +}; + +/** + * Methods of this service as an array for iteration. + * @name Service#methodsArray + * @type {Method[]} + * @readonly + */ +Object.defineProperty(Service.prototype, "methodsArray", { + get: function() { + return this._methodsArray || (this._methodsArray = util.toArray(this.methods)); + } +}); + +function clearCache(service) { + service._methodsArray = null; + return service; +} + +/** + * @override + */ +Service.prototype.get = function get(name) { + return this.methods[name] + || Namespace.prototype.get.call(this, name); +}; + +/** + * @override + */ +Service.prototype.resolveAll = function resolveAll() { + var methods = this.methodsArray; + for (var i = 0; i < methods.length; ++i) + methods[i].resolve(); + return Namespace.prototype.resolve.call(this); +}; + +/** + * @override + */ +Service.prototype.add = function add(object) { + + /* istanbul ignore if */ + if (this.get(object.name)) + throw Error("duplicate name '" + object.name + "' in " + this); + + if (object instanceof Method) { + this.methods[object.name] = object; + object.parent = this; + return clearCache(this); + } + return Namespace.prototype.add.call(this, object); +}; + +/** + * @override + */ +Service.prototype.remove = function remove(object) { + if (object instanceof Method) { + + /* istanbul ignore if */ + if (this.methods[object.name] !== object) + throw Error(object + " is not a member of " + this); + + delete this.methods[object.name]; + object.parent = null; + return clearCache(this); + } + return Namespace.prototype.remove.call(this, object); +}; + +/** + * Creates a runtime service using the specified rpc implementation. + * @param {RPCImpl} rpcImpl RPC implementation + * @param {boolean} [requestDelimited=false] Whether requests are length-delimited + * @param {boolean} [responseDelimited=false] Whether responses are length-delimited + * @returns {rpc.Service} RPC service. Useful where requests and/or responses are streamed. + */ +Service.prototype.create = function create(rpcImpl, requestDelimited, responseDelimited) { + var rpcService = new rpc.Service(rpcImpl, requestDelimited, responseDelimited); + for (var i = 0, method; i < /* initializes */ this.methodsArray.length; ++i) { + var methodName = util.lcFirst((method = this._methodsArray[i]).resolve().name).replace(/[^$\w_]/g, ""); + rpcService[methodName] = util.codegen(["r","c"], util.isReserved(methodName) ? methodName + "_" : methodName)("return this.rpcCall(m,q,s,r,c)")({ + m: method, + q: method.resolvedRequestType.ctor, + s: method.resolvedResponseType.ctor + }); + } + return rpcService; +}; + +},{"22":22,"23":23,"31":31,"37":37}],34:[function(require,module,exports){ +"use strict"; +module.exports = tokenize; + +var delimRe = /[\s{}=;:[\],'"()<>]/g, + stringDoubleRe = /(?:"([^"\\]*(?:\\.[^"\\]*)*)")/g, + stringSingleRe = /(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g; + +var setCommentRe = /^ *[*/]+ */, + setCommentAltRe = /^\s*\*?\/*/, + setCommentSplitRe = /\n/g, + whitespaceRe = /\s/, + unescapeRe = /\\(.?)/g; + +var unescapeMap = { + "0": "\0", + "r": "\r", + "n": "\n", + "t": "\t" +}; + +/** + * Unescapes a string. + * @param {string} str String to unescape + * @returns {string} Unescaped string + * @property {Object.} map Special characters map + * @memberof tokenize + */ +function unescape(str) { + return str.replace(unescapeRe, function($0, $1) { + switch ($1) { + case "\\": + case "": + return $1; + default: + return unescapeMap[$1] || ""; + } + }); +} + +tokenize.unescape = unescape; + +/** + * Gets the next token and advances. + * @typedef TokenizerHandleNext + * @type {function} + * @returns {string|null} Next token or `null` on eof + */ + +/** + * Peeks for the next token. + * @typedef TokenizerHandlePeek + * @type {function} + * @returns {string|null} Next token or `null` on eof + */ + +/** + * Pushes a token back to the stack. + * @typedef TokenizerHandlePush + * @type {function} + * @param {string} token Token + * @returns {undefined} + */ + +/** + * Skips the next token. + * @typedef TokenizerHandleSkip + * @type {function} + * @param {string} expected Expected token + * @param {boolean} [optional=false] If optional + * @returns {boolean} Whether the token matched + * @throws {Error} If the token didn't match and is not optional + */ + +/** + * Gets the comment on the previous line or, alternatively, the line comment on the specified line. + * @typedef TokenizerHandleCmnt + * @type {function} + * @param {number} [line] Line number + * @returns {string|null} Comment text or `null` if none + */ + +/** + * Handle object returned from {@link tokenize}. + * @interface ITokenizerHandle + * @property {TokenizerHandleNext} next Gets the next token and advances (`null` on eof) + * @property {TokenizerHandlePeek} peek Peeks for the next token (`null` on eof) + * @property {TokenizerHandlePush} push Pushes a token back to the stack + * @property {TokenizerHandleSkip} skip Skips a token, returns its presence and advances or, if non-optional and not present, throws + * @property {TokenizerHandleCmnt} cmnt Gets the comment on the previous line or the line comment on the specified line, if any + * @property {number} line Current line number + */ + +/** + * Tokenizes the given .proto source and returns an object with useful utility functions. + * @param {string} source Source contents + * @param {boolean} alternateCommentMode Whether we should activate alternate comment parsing mode. + * @returns {ITokenizerHandle} Tokenizer handle + */ +function tokenize(source, alternateCommentMode) { + /* eslint-disable callback-return */ + source = source.toString(); + + var offset = 0, + length = source.length, + line = 1, + commentType = null, + commentText = null, + commentLine = 0, + commentLineEmpty = false; + + var stack = []; + + var stringDelim = null; + + /* istanbul ignore next */ + /** + * Creates an error for illegal syntax. + * @param {string} subject Subject + * @returns {Error} Error created + * @inner + */ + function illegal(subject) { + return Error("illegal " + subject + " (line " + line + ")"); + } + + /** + * Reads a string till its end. + * @returns {string} String read + * @inner + */ + function readString() { + var re = stringDelim === "'" ? stringSingleRe : stringDoubleRe; + re.lastIndex = offset - 1; + var match = re.exec(source); + if (!match) + throw illegal("string"); + offset = re.lastIndex; + push(stringDelim); + stringDelim = null; + return unescape(match[1]); + } + + /** + * Gets the character at `pos` within the source. + * @param {number} pos Position + * @returns {string} Character + * @inner + */ + function charAt(pos) { + return source.charAt(pos); + } + + /** + * Sets the current comment text. + * @param {number} start Start offset + * @param {number} end End offset + * @returns {undefined} + * @inner + */ + function setComment(start, end) { + commentType = source.charAt(start++); + commentLine = line; + commentLineEmpty = false; + var lookback; + if (alternateCommentMode) { + lookback = 2; // alternate comment parsing: "//" or "/*" + } else { + lookback = 3; // "///" or "/**" + } + var commentOffset = start - lookback, + c; + do { + if (--commentOffset < 0 || + (c = source.charAt(commentOffset)) === "\n") { + commentLineEmpty = true; + break; + } + } while (c === " " || c === "\t"); + var lines = source + .substring(start, end) + .split(setCommentSplitRe); + for (var i = 0; i < lines.length; ++i) + lines[i] = lines[i] + .replace(alternateCommentMode ? setCommentAltRe : setCommentRe, "") + .trim(); + commentText = lines + .join("\n") + .trim(); + } + + function isDoubleSlashCommentLine(startOffset) { + var endOffset = findEndOfLine(startOffset); + + // see if remaining line matches comment pattern + var lineText = source.substring(startOffset, endOffset); + // look for 1 or 2 slashes since startOffset would already point past + // the first slash that started the comment. + var isComment = /^\s*\/{1,2}/.test(lineText); + return isComment; + } + + function findEndOfLine(cursor) { + // find end of cursor's line + var endOffset = cursor; + while (endOffset < length && charAt(endOffset) !== "\n") { + endOffset++; + } + return endOffset; + } + + /** + * Obtains the next token. + * @returns {string|null} Next token or `null` on eof + * @inner + */ + function next() { + if (stack.length > 0) + return stack.shift(); + if (stringDelim) + return readString(); + var repeat, + prev, + curr, + start, + isDoc; + do { + if (offset === length) + return null; + repeat = false; + while (whitespaceRe.test(curr = charAt(offset))) { + if (curr === "\n") + ++line; + if (++offset === length) + return null; + } + + if (charAt(offset) === "/") { + if (++offset === length) { + throw illegal("comment"); + } + if (charAt(offset) === "/") { // Line + if (!alternateCommentMode) { + // check for triple-slash comment + isDoc = charAt(start = offset + 1) === "/"; + + while (charAt(++offset) !== "\n") { + if (offset === length) { + return null; + } + } + ++offset; + if (isDoc) { + setComment(start, offset - 1); + } + ++line; + repeat = true; + } else { + // check for double-slash comments, consolidating consecutive lines + start = offset; + isDoc = false; + if (isDoubleSlashCommentLine(offset)) { + isDoc = true; + do { + offset = findEndOfLine(offset); + if (offset === length) { + break; + } + offset++; + } while (isDoubleSlashCommentLine(offset)); + } else { + offset = Math.min(length, findEndOfLine(offset) + 1); + } + if (isDoc) { + setComment(start, offset); + } + line++; + repeat = true; + } + } else if ((curr = charAt(offset)) === "*") { /* Block */ + // check for /** (regular comment mode) or /* (alternate comment mode) + start = offset + 1; + isDoc = alternateCommentMode || charAt(start) === "*"; + do { + if (curr === "\n") { + ++line; + } + if (++offset === length) { + throw illegal("comment"); + } + prev = curr; + curr = charAt(offset); + } while (prev !== "*" || curr !== "/"); + ++offset; + if (isDoc) { + setComment(start, offset - 2); + } + repeat = true; + } else { + return "/"; + } + } + } while (repeat); + + // offset !== length if we got here + + var end = offset; + delimRe.lastIndex = 0; + var delim = delimRe.test(charAt(end++)); + if (!delim) + while (end < length && !delimRe.test(charAt(end))) + ++end; + var token = source.substring(offset, offset = end); + if (token === "\"" || token === "'") + stringDelim = token; + return token; + } + + /** + * Pushes a token back to the stack. + * @param {string} token Token + * @returns {undefined} + * @inner + */ + function push(token) { + stack.push(token); + } + + /** + * Peeks for the next token. + * @returns {string|null} Token or `null` on eof + * @inner + */ + function peek() { + if (!stack.length) { + var token = next(); + if (token === null) + return null; + push(token); + } + return stack[0]; + } + + /** + * Skips a token. + * @param {string} expected Expected token + * @param {boolean} [optional=false] Whether the token is optional + * @returns {boolean} `true` when skipped, `false` if not + * @throws {Error} When a required token is not present + * @inner + */ + function skip(expected, optional) { + var actual = peek(), + equals = actual === expected; + if (equals) { + next(); + return true; + } + if (!optional) + throw illegal("token '" + actual + "', '" + expected + "' expected"); + return false; + } + + /** + * Gets a comment. + * @param {number} [trailingLine] Line number if looking for a trailing comment + * @returns {string|null} Comment text + * @inner + */ + function cmnt(trailingLine) { + var ret = null; + if (trailingLine === undefined) { + if (commentLine === line - 1 && (alternateCommentMode || commentType === "*" || commentLineEmpty)) { + ret = commentText; + } + } else { + /* istanbul ignore else */ + if (commentLine < trailingLine) { + peek(); + } + if (commentLine === trailingLine && !commentLineEmpty && (alternateCommentMode || commentType === "/")) { + ret = commentText; + } + } + return ret; + } + + return Object.defineProperty({ + next: next, + peek: peek, + push: push, + skip: skip, + cmnt: cmnt + }, "line", { + get: function() { return line; } + }); + /* eslint-enable callback-return */ +} + +},{}],35:[function(require,module,exports){ +"use strict"; +module.exports = Type; + +// extends Namespace +var Namespace = require(23); +((Type.prototype = Object.create(Namespace.prototype)).constructor = Type).className = "Type"; + +var Enum = require(15), + OneOf = require(25), + Field = require(16), + MapField = require(20), + Service = require(33), + Message = require(21), + Reader = require(27), + Writer = require(42), + util = require(37), + encoder = require(14), + decoder = require(13), + verifier = require(40), + converter = require(12), + wrappers = require(41); + +/** + * Constructs a new reflected message type instance. + * @classdesc Reflected message type. + * @extends NamespaceBase + * @constructor + * @param {string} name Message name + * @param {Object.} [options] Declared options + */ +function Type(name, options) { + Namespace.call(this, name, options); + + /** + * Message fields. + * @type {Object.} + */ + this.fields = {}; // toJSON, marker + + /** + * Oneofs declared within this namespace, if any. + * @type {Object.} + */ + this.oneofs = undefined; // toJSON + + /** + * Extension ranges, if any. + * @type {number[][]} + */ + this.extensions = undefined; // toJSON + + /** + * Reserved ranges, if any. + * @type {Array.} + */ + this.reserved = undefined; // toJSON + + /*? + * Whether this type is a legacy group. + * @type {boolean|undefined} + */ + this.group = undefined; // toJSON + + /** + * Cached fields by id. + * @type {Object.|null} + * @private + */ + this._fieldsById = null; + + /** + * Cached fields as an array. + * @type {Field[]|null} + * @private + */ + this._fieldsArray = null; + + /** + * Cached oneofs as an array. + * @type {OneOf[]|null} + * @private + */ + this._oneofsArray = null; + + /** + * Cached constructor. + * @type {Constructor<{}>} + * @private + */ + this._ctor = null; +} + +Object.defineProperties(Type.prototype, { + + /** + * Message fields by id. + * @name Type#fieldsById + * @type {Object.} + * @readonly + */ + fieldsById: { + get: function() { + + /* istanbul ignore if */ + if (this._fieldsById) + return this._fieldsById; + + this._fieldsById = {}; + for (var names = Object.keys(this.fields), i = 0; i < names.length; ++i) { + var field = this.fields[names[i]], + id = field.id; + + /* istanbul ignore if */ + if (this._fieldsById[id]) + throw Error("duplicate id " + id + " in " + this); + + this._fieldsById[id] = field; + } + return this._fieldsById; + } + }, + + /** + * Fields of this message as an array for iteration. + * @name Type#fieldsArray + * @type {Field[]} + * @readonly + */ + fieldsArray: { + get: function() { + return this._fieldsArray || (this._fieldsArray = util.toArray(this.fields)); + } + }, + + /** + * Oneofs of this message as an array for iteration. + * @name Type#oneofsArray + * @type {OneOf[]} + * @readonly + */ + oneofsArray: { + get: function() { + return this._oneofsArray || (this._oneofsArray = util.toArray(this.oneofs)); + } + }, + + /** + * The registered constructor, if any registered, otherwise a generic constructor. + * Assigning a function replaces the internal constructor. If the function does not extend {@link Message} yet, its prototype will be setup accordingly and static methods will be populated. If it already extends {@link Message}, it will just replace the internal constructor. + * @name Type#ctor + * @type {Constructor<{}>} + */ + ctor: { + get: function() { + return this._ctor || (this.ctor = Type.generateConstructor(this)()); + }, + set: function(ctor) { + + // Ensure proper prototype + var prototype = ctor.prototype; + if (!(prototype instanceof Message)) { + (ctor.prototype = new Message()).constructor = ctor; + util.merge(ctor.prototype, prototype); + } + + // Classes and messages reference their reflected type + ctor.$type = ctor.prototype.$type = this; + + // Mix in static methods + util.merge(ctor, Message, true); + + this._ctor = ctor; + + // Messages have non-enumerable default values on their prototype + var i = 0; + for (; i < /* initializes */ this.fieldsArray.length; ++i) + this._fieldsArray[i].resolve(); // ensures a proper value + + // Messages have non-enumerable getters and setters for each virtual oneof field + var ctorProperties = {}; + for (i = 0; i < /* initializes */ this.oneofsArray.length; ++i) + ctorProperties[this._oneofsArray[i].resolve().name] = { + get: util.oneOfGetter(this._oneofsArray[i].oneof), + set: util.oneOfSetter(this._oneofsArray[i].oneof) + }; + if (i) + Object.defineProperties(ctor.prototype, ctorProperties); + } + } +}); + +/** + * Generates a constructor function for the specified type. + * @param {Type} mtype Message type + * @returns {Codegen} Codegen instance + */ +Type.generateConstructor = function generateConstructor(mtype) { + /* eslint-disable no-unexpected-multiline */ + var gen = util.codegen(["p"], mtype.name); + // explicitly initialize mutable object/array fields so that these aren't just inherited from the prototype + for (var i = 0, field; i < mtype.fieldsArray.length; ++i) + if ((field = mtype._fieldsArray[i]).map) gen + ("this%s={}", util.safeProp(field.name)); + else if (field.repeated) gen + ("this%s=[]", util.safeProp(field.name)); + return gen + ("if(p)for(var ks=Object.keys(p),i=0;i} [oneofs] Oneof descriptors + * @property {Object.} fields Field descriptors + * @property {number[][]} [extensions] Extension ranges + * @property {number[][]} [reserved] Reserved ranges + * @property {boolean} [group=false] Whether a legacy group or not + */ + +/** + * Creates a message type from a message type descriptor. + * @param {string} name Message name + * @param {IType} json Message type descriptor + * @returns {Type} Created message type + */ +Type.fromJSON = function fromJSON(name, json) { + var type = new Type(name, json.options); + type.extensions = json.extensions; + type.reserved = json.reserved; + var names = Object.keys(json.fields), + i = 0; + for (; i < names.length; ++i) + type.add( + ( typeof json.fields[names[i]].keyType !== "undefined" + ? MapField.fromJSON + : Field.fromJSON )(names[i], json.fields[names[i]]) + ); + if (json.oneofs) + for (names = Object.keys(json.oneofs), i = 0; i < names.length; ++i) + type.add(OneOf.fromJSON(names[i], json.oneofs[names[i]])); + if (json.nested) + for (names = Object.keys(json.nested), i = 0; i < names.length; ++i) { + var nested = json.nested[names[i]]; + type.add( // most to least likely + ( nested.id !== undefined + ? Field.fromJSON + : nested.fields !== undefined + ? Type.fromJSON + : nested.values !== undefined + ? Enum.fromJSON + : nested.methods !== undefined + ? Service.fromJSON + : Namespace.fromJSON )(names[i], nested) + ); + } + if (json.extensions && json.extensions.length) + type.extensions = json.extensions; + if (json.reserved && json.reserved.length) + type.reserved = json.reserved; + if (json.group) + type.group = true; + if (json.comment) + type.comment = json.comment; + return type; +}; + +/** + * Converts this message type to a message type descriptor. + * @param {IToJSONOptions} [toJSONOptions] JSON conversion options + * @returns {IType} Message type descriptor + */ +Type.prototype.toJSON = function toJSON(toJSONOptions) { + var inherited = Namespace.prototype.toJSON.call(this, toJSONOptions); + var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false; + return util.toObject([ + "options" , inherited && inherited.options || undefined, + "oneofs" , Namespace.arrayToJSON(this.oneofsArray, toJSONOptions), + "fields" , Namespace.arrayToJSON(this.fieldsArray.filter(function(obj) { return !obj.declaringField; }), toJSONOptions) || {}, + "extensions" , this.extensions && this.extensions.length ? this.extensions : undefined, + "reserved" , this.reserved && this.reserved.length ? this.reserved : undefined, + "group" , this.group || undefined, + "nested" , inherited && inherited.nested || undefined, + "comment" , keepComments ? this.comment : undefined + ]); +}; + +/** + * @override + */ +Type.prototype.resolveAll = function resolveAll() { + var fields = this.fieldsArray, i = 0; + while (i < fields.length) + fields[i++].resolve(); + var oneofs = this.oneofsArray; i = 0; + while (i < oneofs.length) + oneofs[i++].resolve(); + return Namespace.prototype.resolveAll.call(this); +}; + +/** + * @override + */ +Type.prototype.get = function get(name) { + return this.fields[name] + || this.oneofs && this.oneofs[name] + || this.nested && this.nested[name] + || null; +}; + +/** + * Adds a nested object to this type. + * @param {ReflectionObject} object Nested object to add + * @returns {Type} `this` + * @throws {TypeError} If arguments are invalid + * @throws {Error} If there is already a nested object with this name or, if a field, when there is already a field with this id + */ +Type.prototype.add = function add(object) { + + if (this.get(object.name)) + throw Error("duplicate name '" + object.name + "' in " + this); + + if (object instanceof Field && object.extend === undefined) { + // NOTE: Extension fields aren't actual fields on the declaring type, but nested objects. + // The root object takes care of adding distinct sister-fields to the respective extended + // type instead. + + // avoids calling the getter if not absolutely necessary because it's called quite frequently + if (this._fieldsById ? /* istanbul ignore next */ this._fieldsById[object.id] : this.fieldsById[object.id]) + throw Error("duplicate id " + object.id + " in " + this); + if (this.isReservedId(object.id)) + throw Error("id " + object.id + " is reserved in " + this); + if (this.isReservedName(object.name)) + throw Error("name '" + object.name + "' is reserved in " + this); + + if (object.parent) + object.parent.remove(object); + this.fields[object.name] = object; + object.message = this; + object.onAdd(this); + return clearCache(this); + } + if (object instanceof OneOf) { + if (!this.oneofs) + this.oneofs = {}; + this.oneofs[object.name] = object; + object.onAdd(this); + return clearCache(this); + } + return Namespace.prototype.add.call(this, object); +}; + +/** + * Removes a nested object from this type. + * @param {ReflectionObject} object Nested object to remove + * @returns {Type} `this` + * @throws {TypeError} If arguments are invalid + * @throws {Error} If `object` is not a member of this type + */ +Type.prototype.remove = function remove(object) { + if (object instanceof Field && object.extend === undefined) { + // See Type#add for the reason why extension fields are excluded here. + + /* istanbul ignore if */ + if (!this.fields || this.fields[object.name] !== object) + throw Error(object + " is not a member of " + this); + + delete this.fields[object.name]; + object.parent = null; + object.onRemove(this); + return clearCache(this); + } + if (object instanceof OneOf) { + + /* istanbul ignore if */ + if (!this.oneofs || this.oneofs[object.name] !== object) + throw Error(object + " is not a member of " + this); + + delete this.oneofs[object.name]; + object.parent = null; + object.onRemove(this); + return clearCache(this); + } + return Namespace.prototype.remove.call(this, object); +}; + +/** + * Tests if the specified id is reserved. + * @param {number} id Id to test + * @returns {boolean} `true` if reserved, otherwise `false` + */ +Type.prototype.isReservedId = function isReservedId(id) { + return Namespace.isReservedId(this.reserved, id); +}; + +/** + * Tests if the specified name is reserved. + * @param {string} name Name to test + * @returns {boolean} `true` if reserved, otherwise `false` + */ +Type.prototype.isReservedName = function isReservedName(name) { + return Namespace.isReservedName(this.reserved, name); +}; + +/** + * Creates a new message of this type using the specified properties. + * @param {Object.} [properties] Properties to set + * @returns {Message<{}>} Message instance + */ +Type.prototype.create = function create(properties) { + return new this.ctor(properties); +}; + +/** + * Sets up {@link Type#encode|encode}, {@link Type#decode|decode} and {@link Type#verify|verify}. + * @returns {Type} `this` + */ +Type.prototype.setup = function setup() { + // Sets up everything at once so that the prototype chain does not have to be re-evaluated + // multiple times (V8, soft-deopt prototype-check). + + var fullName = this.fullName, + types = []; + for (var i = 0; i < /* initializes */ this.fieldsArray.length; ++i) + types.push(this._fieldsArray[i].resolve().resolvedType); + + // Replace setup methods with type-specific generated functions + this.encode = encoder(this)({ + Writer : Writer, + types : types, + util : util + }); + this.decode = decoder(this)({ + Reader : Reader, + types : types, + util : util + }); + this.verify = verifier(this)({ + types : types, + util : util + }); + this.fromObject = converter.fromObject(this)({ + types : types, + util : util + }); + this.toObject = converter.toObject(this)({ + types : types, + util : util + }); + + // Inject custom wrappers for common types + var wrapper = wrappers[fullName]; + if (wrapper) { + var originalThis = Object.create(this); + // if (wrapper.fromObject) { + originalThis.fromObject = this.fromObject; + this.fromObject = wrapper.fromObject.bind(originalThis); + // } + // if (wrapper.toObject) { + originalThis.toObject = this.toObject; + this.toObject = wrapper.toObject.bind(originalThis); + // } + } + + return this; +}; + +/** + * Encodes a message of this type. Does not implicitly {@link Type#verify|verify} messages. + * @param {Message<{}>|Object.} message Message instance or plain object + * @param {Writer} [writer] Writer to encode to + * @returns {Writer} writer + */ +Type.prototype.encode = function encode_setup(message, writer) { + return this.setup().encode(message, writer); // overrides this method +}; + +/** + * Encodes a message of this type preceeded by its byte length as a varint. Does not implicitly {@link Type#verify|verify} messages. + * @param {Message<{}>|Object.} message Message instance or plain object + * @param {Writer} [writer] Writer to encode to + * @returns {Writer} writer + */ +Type.prototype.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer && writer.len ? writer.fork() : writer).ldelim(); +}; + +/** + * Decodes a message of this type. + * @param {Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Length of the message, if known beforehand + * @returns {Message<{}>} Decoded message + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {util.ProtocolError<{}>} If required fields are missing + */ +Type.prototype.decode = function decode_setup(reader, length) { + return this.setup().decode(reader, length); // overrides this method +}; + +/** + * Decodes a message of this type preceeded by its byte length as a varint. + * @param {Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {Message<{}>} Decoded message + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {util.ProtocolError} If required fields are missing + */ +Type.prototype.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof Reader)) + reader = Reader.create(reader); + return this.decode(reader, reader.uint32()); +}; + +/** + * Verifies that field values are valid and that required fields are present. + * @param {Object.} message Plain object to verify + * @returns {null|string} `null` if valid, otherwise the reason why it is not + */ +Type.prototype.verify = function verify_setup(message) { + return this.setup().verify(message); // overrides this method +}; + +/** + * Creates a new message of this type from a plain object. Also converts values to their respective internal types. + * @param {Object.} object Plain object to convert + * @returns {Message<{}>} Message instance + */ +Type.prototype.fromObject = function fromObject(object) { + return this.setup().fromObject(object); +}; + +/** + * Conversion options as used by {@link Type#toObject} and {@link Message.toObject}. + * @interface IConversionOptions + * @property {Function} [longs] Long conversion type. + * Valid values are `String` and `Number` (the global types). + * Defaults to copy the present value, which is a possibly unsafe number without and a {@link Long} with a long library. + * @property {Function} [enums] Enum value conversion type. + * Only valid value is `String` (the global type). + * Defaults to copy the present value, which is the numeric id. + * @property {Function} [bytes] Bytes value conversion type. + * Valid values are `Array` and (a base64 encoded) `String` (the global types). + * Defaults to copy the present value, which usually is a Buffer under node and an Uint8Array in the browser. + * @property {boolean} [defaults=false] Also sets default values on the resulting object + * @property {boolean} [arrays=false] Sets empty arrays for missing repeated fields even if `defaults=false` + * @property {boolean} [objects=false] Sets empty objects for missing map fields even if `defaults=false` + * @property {boolean} [oneofs=false] Includes virtual oneof properties set to the present field's name, if any + * @property {boolean} [json=false] Performs additional JSON compatibility conversions, i.e. NaN and Infinity to strings + */ + +/** + * Creates a plain object from a message of this type. Also converts values to other types if specified. + * @param {Message<{}>} message Message instance + * @param {IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ +Type.prototype.toObject = function toObject(message, options) { + return this.setup().toObject(message, options); +}; + +/** + * Decorator function as returned by {@link Type.d} (TypeScript). + * @typedef TypeDecorator + * @type {function} + * @param {Constructor} target Target constructor + * @returns {undefined} + * @template T extends Message + */ + +/** + * Type decorator (TypeScript). + * @param {string} [typeName] Type name, defaults to the constructor's name + * @returns {TypeDecorator} Decorator function + * @template T extends Message + */ +Type.d = function decorateType(typeName) { + return function typeDecorator(target) { + util.decorateType(target, typeName); + }; +}; + +},{"12":12,"13":13,"14":14,"15":15,"16":16,"20":20,"21":21,"23":23,"25":25,"27":27,"33":33,"37":37,"40":40,"41":41,"42":42}],36:[function(require,module,exports){ +"use strict"; + +/** + * Common type constants. + * @namespace + */ +var types = exports; + +var util = require(37); + +var s = [ + "double", // 0 + "float", // 1 + "int32", // 2 + "uint32", // 3 + "sint32", // 4 + "fixed32", // 5 + "sfixed32", // 6 + "int64", // 7 + "uint64", // 8 + "sint64", // 9 + "fixed64", // 10 + "sfixed64", // 11 + "bool", // 12 + "string", // 13 + "bytes" // 14 +]; + +function bake(values, offset) { + var i = 0, o = {}; + offset |= 0; + while (i < values.length) o[s[i + offset]] = values[i++]; + return o; +} + +/** + * Basic type wire types. + * @type {Object.} + * @const + * @property {number} double=1 Fixed64 wire type + * @property {number} float=5 Fixed32 wire type + * @property {number} int32=0 Varint wire type + * @property {number} uint32=0 Varint wire type + * @property {number} sint32=0 Varint wire type + * @property {number} fixed32=5 Fixed32 wire type + * @property {number} sfixed32=5 Fixed32 wire type + * @property {number} int64=0 Varint wire type + * @property {number} uint64=0 Varint wire type + * @property {number} sint64=0 Varint wire type + * @property {number} fixed64=1 Fixed64 wire type + * @property {number} sfixed64=1 Fixed64 wire type + * @property {number} bool=0 Varint wire type + * @property {number} string=2 Ldelim wire type + * @property {number} bytes=2 Ldelim wire type + */ +types.basic = bake([ + /* double */ 1, + /* float */ 5, + /* int32 */ 0, + /* uint32 */ 0, + /* sint32 */ 0, + /* fixed32 */ 5, + /* sfixed32 */ 5, + /* int64 */ 0, + /* uint64 */ 0, + /* sint64 */ 0, + /* fixed64 */ 1, + /* sfixed64 */ 1, + /* bool */ 0, + /* string */ 2, + /* bytes */ 2 +]); + +/** + * Basic type defaults. + * @type {Object.} + * @const + * @property {number} double=0 Double default + * @property {number} float=0 Float default + * @property {number} int32=0 Int32 default + * @property {number} uint32=0 Uint32 default + * @property {number} sint32=0 Sint32 default + * @property {number} fixed32=0 Fixed32 default + * @property {number} sfixed32=0 Sfixed32 default + * @property {number} int64=0 Int64 default + * @property {number} uint64=0 Uint64 default + * @property {number} sint64=0 Sint32 default + * @property {number} fixed64=0 Fixed64 default + * @property {number} sfixed64=0 Sfixed64 default + * @property {boolean} bool=false Bool default + * @property {string} string="" String default + * @property {Array.} bytes=Array(0) Bytes default + * @property {null} message=null Message default + */ +types.defaults = bake([ + /* double */ 0, + /* float */ 0, + /* int32 */ 0, + /* uint32 */ 0, + /* sint32 */ 0, + /* fixed32 */ 0, + /* sfixed32 */ 0, + /* int64 */ 0, + /* uint64 */ 0, + /* sint64 */ 0, + /* fixed64 */ 0, + /* sfixed64 */ 0, + /* bool */ false, + /* string */ "", + /* bytes */ util.emptyArray, + /* message */ null +]); + +/** + * Basic long type wire types. + * @type {Object.} + * @const + * @property {number} int64=0 Varint wire type + * @property {number} uint64=0 Varint wire type + * @property {number} sint64=0 Varint wire type + * @property {number} fixed64=1 Fixed64 wire type + * @property {number} sfixed64=1 Fixed64 wire type + */ +types.long = bake([ + /* int64 */ 0, + /* uint64 */ 0, + /* sint64 */ 0, + /* fixed64 */ 1, + /* sfixed64 */ 1 +], 7); + +/** + * Allowed types for map keys with their associated wire type. + * @type {Object.} + * @const + * @property {number} int32=0 Varint wire type + * @property {number} uint32=0 Varint wire type + * @property {number} sint32=0 Varint wire type + * @property {number} fixed32=5 Fixed32 wire type + * @property {number} sfixed32=5 Fixed32 wire type + * @property {number} int64=0 Varint wire type + * @property {number} uint64=0 Varint wire type + * @property {number} sint64=0 Varint wire type + * @property {number} fixed64=1 Fixed64 wire type + * @property {number} sfixed64=1 Fixed64 wire type + * @property {number} bool=0 Varint wire type + * @property {number} string=2 Ldelim wire type + */ +types.mapKey = bake([ + /* int32 */ 0, + /* uint32 */ 0, + /* sint32 */ 0, + /* fixed32 */ 5, + /* sfixed32 */ 5, + /* int64 */ 0, + /* uint64 */ 0, + /* sint64 */ 0, + /* fixed64 */ 1, + /* sfixed64 */ 1, + /* bool */ 0, + /* string */ 2 +], 2); + +/** + * Allowed types for packed repeated fields with their associated wire type. + * @type {Object.} + * @const + * @property {number} double=1 Fixed64 wire type + * @property {number} float=5 Fixed32 wire type + * @property {number} int32=0 Varint wire type + * @property {number} uint32=0 Varint wire type + * @property {number} sint32=0 Varint wire type + * @property {number} fixed32=5 Fixed32 wire type + * @property {number} sfixed32=5 Fixed32 wire type + * @property {number} int64=0 Varint wire type + * @property {number} uint64=0 Varint wire type + * @property {number} sint64=0 Varint wire type + * @property {number} fixed64=1 Fixed64 wire type + * @property {number} sfixed64=1 Fixed64 wire type + * @property {number} bool=0 Varint wire type + */ +types.packed = bake([ + /* double */ 1, + /* float */ 5, + /* int32 */ 0, + /* uint32 */ 0, + /* sint32 */ 0, + /* fixed32 */ 5, + /* sfixed32 */ 5, + /* int64 */ 0, + /* uint64 */ 0, + /* sint64 */ 0, + /* fixed64 */ 1, + /* sfixed64 */ 1, + /* bool */ 0 +]); + +},{"37":37}],37:[function(require,module,exports){ +"use strict"; + +/** + * Various utility functions. + * @namespace + */ +var util = module.exports = require(39); + +var roots = require(30); + +var Type, // cyclic + Enum; + +util.codegen = require(3); +util.fetch = require(5); +util.path = require(8); + +/** + * Node's fs module if available. + * @type {Object.} + */ +util.fs = util.inquire("fs"); + +/** + * Converts an object's values to an array. + * @param {Object.} object Object to convert + * @returns {Array.<*>} Converted array + */ +util.toArray = function toArray(object) { + if (object) { + var keys = Object.keys(object), + array = new Array(keys.length), + index = 0; + while (index < keys.length) + array[index] = object[keys[index++]]; + return array; + } + return []; +}; + +/** + * Converts an array of keys immediately followed by their respective value to an object, omitting undefined values. + * @param {Array.<*>} array Array to convert + * @returns {Object.} Converted object + */ +util.toObject = function toObject(array) { + var object = {}, + index = 0; + while (index < array.length) { + var key = array[index++], + val = array[index++]; + if (val !== undefined) + object[key] = val; + } + return object; +}; + +var safePropBackslashRe = /\\/g, + safePropQuoteRe = /"/g; + +/** + * Tests whether the specified name is a reserved word in JS. + * @param {string} name Name to test + * @returns {boolean} `true` if reserved, otherwise `false` + */ +util.isReserved = function isReserved(name) { + return /^(?:do|if|in|for|let|new|try|var|case|else|enum|eval|false|null|this|true|void|with|break|catch|class|const|super|throw|while|yield|delete|export|import|public|return|static|switch|typeof|default|extends|finally|package|private|continue|debugger|function|arguments|interface|protected|implements|instanceof)$/.test(name); +}; + +/** + * Returns a safe property accessor for the specified property name. + * @param {string} prop Property name + * @returns {string} Safe accessor + */ +util.safeProp = function safeProp(prop) { + if (!/^[$\w_]+$/.test(prop) || util.isReserved(prop)) + return "[\"" + prop.replace(safePropBackslashRe, "\\\\").replace(safePropQuoteRe, "\\\"") + "\"]"; + return "." + prop; +}; + +/** + * Converts the first character of a string to upper case. + * @param {string} str String to convert + * @returns {string} Converted string + */ +util.ucFirst = function ucFirst(str) { + return str.charAt(0).toUpperCase() + str.substring(1); +}; + +var camelCaseRe = /_([a-z])/g; + +/** + * Converts a string to camel case. + * @param {string} str String to convert + * @returns {string} Converted string + */ +util.camelCase = function camelCase(str) { + return str.substring(0, 1) + + str.substring(1) + .replace(camelCaseRe, function($0, $1) { return $1.toUpperCase(); }); +}; + +/** + * Compares reflected fields by id. + * @param {Field} a First field + * @param {Field} b Second field + * @returns {number} Comparison value + */ +util.compareFieldsById = function compareFieldsById(a, b) { + return a.id - b.id; +}; + +/** + * Decorator helper for types (TypeScript). + * @param {Constructor} ctor Constructor function + * @param {string} [typeName] Type name, defaults to the constructor's name + * @returns {Type} Reflected type + * @template T extends Message + * @property {Root} root Decorators root + */ +util.decorateType = function decorateType(ctor, typeName) { + + /* istanbul ignore if */ + if (ctor.$type) { + if (typeName && ctor.$type.name !== typeName) { + util.decorateRoot.remove(ctor.$type); + ctor.$type.name = typeName; + util.decorateRoot.add(ctor.$type); + } + return ctor.$type; + } + + /* istanbul ignore next */ + if (!Type) + Type = require(35); + + var type = new Type(typeName || ctor.name); + util.decorateRoot.add(type); + type.ctor = ctor; // sets up .encode, .decode etc. + Object.defineProperty(ctor, "$type", { value: type, enumerable: false }); + Object.defineProperty(ctor.prototype, "$type", { value: type, enumerable: false }); + return type; +}; + +var decorateEnumIndex = 0; + +/** + * Decorator helper for enums (TypeScript). + * @param {Object} object Enum object + * @returns {Enum} Reflected enum + */ +util.decorateEnum = function decorateEnum(object) { + + /* istanbul ignore if */ + if (object.$type) + return object.$type; + + /* istanbul ignore next */ + if (!Enum) + Enum = require(15); + + var enm = new Enum("Enum" + decorateEnumIndex++, object); + util.decorateRoot.add(enm); + Object.defineProperty(object, "$type", { value: enm, enumerable: false }); + return enm; +}; + +/** + * Decorator root (TypeScript). + * @name util.decorateRoot + * @type {Root} + * @readonly + */ +Object.defineProperty(util, "decorateRoot", { + get: function() { + return roots["decorated"] || (roots["decorated"] = new (require(29))()); + } +}); + +},{"15":15,"29":29,"3":3,"30":30,"35":35,"39":39,"5":5,"8":8}],38:[function(require,module,exports){ +"use strict"; +module.exports = LongBits; + +var util = require(39); + +/** + * Constructs new long bits. + * @classdesc Helper class for working with the low and high bits of a 64 bit value. + * @memberof util + * @constructor + * @param {number} lo Low 32 bits, unsigned + * @param {number} hi High 32 bits, unsigned + */ +function LongBits(lo, hi) { + + // note that the casts below are theoretically unnecessary as of today, but older statically + // generated converter code might still call the ctor with signed 32bits. kept for compat. + + /** + * Low bits. + * @type {number} + */ + this.lo = lo >>> 0; + + /** + * High bits. + * @type {number} + */ + this.hi = hi >>> 0; +} + +/** + * Zero bits. + * @memberof util.LongBits + * @type {util.LongBits} + */ +var zero = LongBits.zero = new LongBits(0, 0); + +zero.toNumber = function() { return 0; }; +zero.zzEncode = zero.zzDecode = function() { return this; }; +zero.length = function() { return 1; }; + +/** + * Zero hash. + * @memberof util.LongBits + * @type {string} + */ +var zeroHash = LongBits.zeroHash = "\0\0\0\0\0\0\0\0"; + +/** + * Constructs new long bits from the specified number. + * @param {number} value Value + * @returns {util.LongBits} Instance + */ +LongBits.fromNumber = function fromNumber(value) { + if (value === 0) + return zero; + var sign = value < 0; + if (sign) + value = -value; + var lo = value >>> 0, + hi = (value - lo) / 4294967296 >>> 0; + if (sign) { + hi = ~hi >>> 0; + lo = ~lo >>> 0; + if (++lo > 4294967295) { + lo = 0; + if (++hi > 4294967295) + hi = 0; + } + } + return new LongBits(lo, hi); +}; + +/** + * Constructs new long bits from a number, long or string. + * @param {Long|number|string} value Value + * @returns {util.LongBits} Instance + */ +LongBits.from = function from(value) { + if (typeof value === "number") + return LongBits.fromNumber(value); + if (util.isString(value)) { + /* istanbul ignore else */ + if (util.Long) + value = util.Long.fromString(value); + else + return LongBits.fromNumber(parseInt(value, 10)); + } + return value.low || value.high ? new LongBits(value.low >>> 0, value.high >>> 0) : zero; +}; + +/** + * Converts this long bits to a possibly unsafe JavaScript number. + * @param {boolean} [unsigned=false] Whether unsigned or not + * @returns {number} Possibly unsafe number + */ +LongBits.prototype.toNumber = function toNumber(unsigned) { + if (!unsigned && this.hi >>> 31) { + var lo = ~this.lo + 1 >>> 0, + hi = ~this.hi >>> 0; + if (!lo) + hi = hi + 1 >>> 0; + return -(lo + hi * 4294967296); + } + return this.lo + this.hi * 4294967296; +}; + +/** + * Converts this long bits to a long. + * @param {boolean} [unsigned=false] Whether unsigned or not + * @returns {Long} Long + */ +LongBits.prototype.toLong = function toLong(unsigned) { + return util.Long + ? new util.Long(this.lo | 0, this.hi | 0, Boolean(unsigned)) + /* istanbul ignore next */ + : { low: this.lo | 0, high: this.hi | 0, unsigned: Boolean(unsigned) }; +}; + +var charCodeAt = String.prototype.charCodeAt; + +/** + * Constructs new long bits from the specified 8 characters long hash. + * @param {string} hash Hash + * @returns {util.LongBits} Bits + */ +LongBits.fromHash = function fromHash(hash) { + if (hash === zeroHash) + return zero; + return new LongBits( + ( charCodeAt.call(hash, 0) + | charCodeAt.call(hash, 1) << 8 + | charCodeAt.call(hash, 2) << 16 + | charCodeAt.call(hash, 3) << 24) >>> 0 + , + ( charCodeAt.call(hash, 4) + | charCodeAt.call(hash, 5) << 8 + | charCodeAt.call(hash, 6) << 16 + | charCodeAt.call(hash, 7) << 24) >>> 0 + ); +}; + +/** + * Converts this long bits to a 8 characters long hash. + * @returns {string} Hash + */ +LongBits.prototype.toHash = function toHash() { + return String.fromCharCode( + this.lo & 255, + this.lo >>> 8 & 255, + this.lo >>> 16 & 255, + this.lo >>> 24 , + this.hi & 255, + this.hi >>> 8 & 255, + this.hi >>> 16 & 255, + this.hi >>> 24 + ); +}; + +/** + * Zig-zag encodes this long bits. + * @returns {util.LongBits} `this` + */ +LongBits.prototype.zzEncode = function zzEncode() { + var mask = this.hi >> 31; + this.hi = ((this.hi << 1 | this.lo >>> 31) ^ mask) >>> 0; + this.lo = ( this.lo << 1 ^ mask) >>> 0; + return this; +}; + +/** + * Zig-zag decodes this long bits. + * @returns {util.LongBits} `this` + */ +LongBits.prototype.zzDecode = function zzDecode() { + var mask = -(this.lo & 1); + this.lo = ((this.lo >>> 1 | this.hi << 31) ^ mask) >>> 0; + this.hi = ( this.hi >>> 1 ^ mask) >>> 0; + return this; +}; + +/** + * Calculates the length of this longbits when encoded as a varint. + * @returns {number} Length + */ +LongBits.prototype.length = function length() { + var part0 = this.lo, + part1 = (this.lo >>> 28 | this.hi << 4) >>> 0, + part2 = this.hi >>> 24; + return part2 === 0 + ? part1 === 0 + ? part0 < 16384 + ? part0 < 128 ? 1 : 2 + : part0 < 2097152 ? 3 : 4 + : part1 < 16384 + ? part1 < 128 ? 5 : 6 + : part1 < 2097152 ? 7 : 8 + : part2 < 128 ? 9 : 10; +}; + +},{"39":39}],39:[function(require,module,exports){ +"use strict"; +var util = exports; + +// used to return a Promise where callback is omitted +util.asPromise = require(1); + +// converts to / from base64 encoded strings +util.base64 = require(2); + +// base class of rpc.Service +util.EventEmitter = require(4); + +// float handling accross browsers +util.float = require(6); + +// requires modules optionally and hides the call from bundlers +util.inquire = require(7); + +// converts to / from utf8 encoded strings +util.utf8 = require(10); + +// provides a node-like buffer pool in the browser +util.pool = require(9); + +// utility to work with the low and high bits of a 64 bit value +util.LongBits = require(38); + +// global object reference +util.global = typeof window !== "undefined" && window + || typeof global !== "undefined" && global + || typeof self !== "undefined" && self + || this; // eslint-disable-line no-invalid-this + +/** + * An immuable empty array. + * @memberof util + * @type {Array.<*>} + * @const + */ +util.emptyArray = Object.freeze ? Object.freeze([]) : /* istanbul ignore next */ []; // used on prototypes + +/** + * An immutable empty object. + * @type {Object} + * @const + */ +util.emptyObject = Object.freeze ? Object.freeze({}) : /* istanbul ignore next */ {}; // used on prototypes + +/** + * Whether running within node or not. + * @memberof util + * @type {boolean} + * @const + */ +util.isNode = Boolean(util.global.process && util.global.process.versions && util.global.process.versions.node); + +/** + * Tests if the specified value is an integer. + * @function + * @param {*} value Value to test + * @returns {boolean} `true` if the value is an integer + */ +util.isInteger = Number.isInteger || /* istanbul ignore next */ function isInteger(value) { + return typeof value === "number" && isFinite(value) && Math.floor(value) === value; +}; + +/** + * Tests if the specified value is a string. + * @param {*} value Value to test + * @returns {boolean} `true` if the value is a string + */ +util.isString = function isString(value) { + return typeof value === "string" || value instanceof String; +}; + +/** + * Tests if the specified value is a non-null object. + * @param {*} value Value to test + * @returns {boolean} `true` if the value is a non-null object + */ +util.isObject = function isObject(value) { + return value && typeof value === "object"; +}; + +/** + * Checks if a property on a message is considered to be present. + * This is an alias of {@link util.isSet}. + * @function + * @param {Object} obj Plain object or message instance + * @param {string} prop Property name + * @returns {boolean} `true` if considered to be present, otherwise `false` + */ +util.isset = + +/** + * Checks if a property on a message is considered to be present. + * @param {Object} obj Plain object or message instance + * @param {string} prop Property name + * @returns {boolean} `true` if considered to be present, otherwise `false` + */ +util.isSet = function isSet(obj, prop) { + var value = obj[prop]; + if (value != null && obj.hasOwnProperty(prop)) // eslint-disable-line eqeqeq, no-prototype-builtins + return typeof value !== "object" || (Array.isArray(value) ? value.length : Object.keys(value).length) > 0; + return false; +}; + +/** + * Any compatible Buffer instance. + * This is a minimal stand-alone definition of a Buffer instance. The actual type is that exported by node's typings. + * @interface Buffer + * @extends Uint8Array + */ + +/** + * Node's Buffer class if available. + * @type {Constructor} + */ +util.Buffer = (function() { + try { + var Buffer = util.inquire("buffer").Buffer; + // refuse to use non-node buffers if not explicitly assigned (perf reasons): + return Buffer.prototype.utf8Write ? Buffer : /* istanbul ignore next */ null; + } catch (e) { + /* istanbul ignore next */ + return null; + } +})(); + +// Internal alias of or polyfull for Buffer.from. +util._Buffer_from = null; + +// Internal alias of or polyfill for Buffer.allocUnsafe. +util._Buffer_allocUnsafe = null; + +/** + * Creates a new buffer of whatever type supported by the environment. + * @param {number|number[]} [sizeOrArray=0] Buffer size or number array + * @returns {Uint8Array|Buffer} Buffer + */ +util.newBuffer = function newBuffer(sizeOrArray) { + /* istanbul ignore next */ + return typeof sizeOrArray === "number" + ? util.Buffer + ? util._Buffer_allocUnsafe(sizeOrArray) + : new util.Array(sizeOrArray) + : util.Buffer + ? util._Buffer_from(sizeOrArray) + : typeof Uint8Array === "undefined" + ? sizeOrArray + : new Uint8Array(sizeOrArray); +}; + +/** + * Array implementation used in the browser. `Uint8Array` if supported, otherwise `Array`. + * @type {Constructor} + */ +util.Array = typeof Uint8Array !== "undefined" ? Uint8Array /* istanbul ignore next */ : Array; + +/** + * Any compatible Long instance. + * This is a minimal stand-alone definition of a Long instance. The actual type is that exported by long.js. + * @interface Long + * @property {number} low Low bits + * @property {number} high High bits + * @property {boolean} unsigned Whether unsigned or not + */ + +/** + * Long.js's Long class if available. + * @type {Constructor} + */ +util.Long = /* istanbul ignore next */ util.global.dcodeIO && /* istanbul ignore next */ util.global.dcodeIO.Long + || /* istanbul ignore next */ util.global.Long + || util.inquire("long"); + +/** + * Regular expression used to verify 2 bit (`bool`) map keys. + * @type {RegExp} + * @const + */ +util.key2Re = /^true|false|0|1$/; + +/** + * Regular expression used to verify 32 bit (`int32` etc.) map keys. + * @type {RegExp} + * @const + */ +util.key32Re = /^-?(?:0|[1-9][0-9]*)$/; + +/** + * Regular expression used to verify 64 bit (`int64` etc.) map keys. + * @type {RegExp} + * @const + */ +util.key64Re = /^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/; + +/** + * Converts a number or long to an 8 characters long hash string. + * @param {Long|number} value Value to convert + * @returns {string} Hash + */ +util.longToHash = function longToHash(value) { + return value + ? util.LongBits.from(value).toHash() + : util.LongBits.zeroHash; +}; + +/** + * Converts an 8 characters long hash string to a long or number. + * @param {string} hash Hash + * @param {boolean} [unsigned=false] Whether unsigned or not + * @returns {Long|number} Original value + */ +util.longFromHash = function longFromHash(hash, unsigned) { + var bits = util.LongBits.fromHash(hash); + if (util.Long) + return util.Long.fromBits(bits.lo, bits.hi, unsigned); + return bits.toNumber(Boolean(unsigned)); +}; + +/** + * Merges the properties of the source object into the destination object. + * @memberof util + * @param {Object.} dst Destination object + * @param {Object.} src Source object + * @param {boolean} [ifNotSet=false] Merges only if the key is not already set + * @returns {Object.} Destination object + */ +function merge(dst, src, ifNotSet) { // used by converters + for (var keys = Object.keys(src), i = 0; i < keys.length; ++i) + if (dst[keys[i]] === undefined || !ifNotSet) + dst[keys[i]] = src[keys[i]]; + return dst; +} + +util.merge = merge; + +/** + * Converts the first character of a string to lower case. + * @param {string} str String to convert + * @returns {string} Converted string + */ +util.lcFirst = function lcFirst(str) { + return str.charAt(0).toLowerCase() + str.substring(1); +}; + +/** + * Creates a custom error constructor. + * @memberof util + * @param {string} name Error name + * @returns {Constructor} Custom error constructor + */ +function newError(name) { + + function CustomError(message, properties) { + + if (!(this instanceof CustomError)) + return new CustomError(message, properties); + + // Error.call(this, message); + // ^ just returns a new error instance because the ctor can be called as a function + + Object.defineProperty(this, "message", { get: function() { return message; } }); + + /* istanbul ignore next */ + if (Error.captureStackTrace) // node + Error.captureStackTrace(this, CustomError); + else + Object.defineProperty(this, "stack", { value: (new Error()).stack || "" }); + + if (properties) + merge(this, properties); + } + + (CustomError.prototype = Object.create(Error.prototype)).constructor = CustomError; + + Object.defineProperty(CustomError.prototype, "name", { get: function() { return name; } }); + + CustomError.prototype.toString = function toString() { + return this.name + ": " + this.message; + }; + + return CustomError; +} + +util.newError = newError; + +/** + * Constructs a new protocol error. + * @classdesc Error subclass indicating a protocol specifc error. + * @memberof util + * @extends Error + * @template T extends Message + * @constructor + * @param {string} message Error message + * @param {Object.} [properties] Additional properties + * @example + * try { + * MyMessage.decode(someBuffer); // throws if required fields are missing + * } catch (e) { + * if (e instanceof ProtocolError && e.instance) + * console.log("decoded so far: " + JSON.stringify(e.instance)); + * } + */ +util.ProtocolError = newError("ProtocolError"); + +/** + * So far decoded message instance. + * @name util.ProtocolError#instance + * @type {Message} + */ + +/** + * A OneOf getter as returned by {@link util.oneOfGetter}. + * @typedef OneOfGetter + * @type {function} + * @returns {string|undefined} Set field name, if any + */ + +/** + * Builds a getter for a oneof's present field name. + * @param {string[]} fieldNames Field names + * @returns {OneOfGetter} Unbound getter + */ +util.oneOfGetter = function getOneOf(fieldNames) { + var fieldMap = {}; + for (var i = 0; i < fieldNames.length; ++i) + fieldMap[fieldNames[i]] = 1; + + /** + * @returns {string|undefined} Set field name, if any + * @this Object + * @ignore + */ + return function() { // eslint-disable-line consistent-return + for (var keys = Object.keys(this), i = keys.length - 1; i > -1; --i) + if (fieldMap[keys[i]] === 1 && this[keys[i]] !== undefined && this[keys[i]] !== null) + return keys[i]; + }; +}; + +/** + * A OneOf setter as returned by {@link util.oneOfSetter}. + * @typedef OneOfSetter + * @type {function} + * @param {string|undefined} value Field name + * @returns {undefined} + */ + +/** + * Builds a setter for a oneof's present field name. + * @param {string[]} fieldNames Field names + * @returns {OneOfSetter} Unbound setter + */ +util.oneOfSetter = function setOneOf(fieldNames) { + + /** + * @param {string} name Field name + * @returns {undefined} + * @this Object + * @ignore + */ + return function(name) { + for (var i = 0; i < fieldNames.length; ++i) + if (fieldNames[i] !== name) + delete this[fieldNames[i]]; + }; +}; + +/** + * Default conversion options used for {@link Message#toJSON} implementations. + * + * These options are close to proto3's JSON mapping with the exception that internal types like Any are handled just like messages. More precisely: + * + * - Longs become strings + * - Enums become string keys + * - Bytes become base64 encoded strings + * - (Sub-)Messages become plain objects + * - Maps become plain objects with all string keys + * - Repeated fields become arrays + * - NaN and Infinity for float and double fields become strings + * + * @type {IConversionOptions} + * @see https://developers.google.com/protocol-buffers/docs/proto3?hl=en#json + */ +util.toJSONOptions = { + longs: String, + enums: String, + bytes: String, + json: true +}; + +// Sets up buffer utility according to the environment (called in index-minimal) +util._configure = function() { + var Buffer = util.Buffer; + /* istanbul ignore if */ + if (!Buffer) { + util._Buffer_from = util._Buffer_allocUnsafe = null; + return; + } + // because node 4.x buffers are incompatible & immutable + // see: https://github.com/dcodeIO/protobuf.js/pull/665 + util._Buffer_from = Buffer.from !== Uint8Array.from && Buffer.from || + /* istanbul ignore next */ + function Buffer_from(value, encoding) { + return new Buffer(value, encoding); + }; + util._Buffer_allocUnsafe = Buffer.allocUnsafe || + /* istanbul ignore next */ + function Buffer_allocUnsafe(size) { + return new Buffer(size); + }; +}; + +},{"1":1,"10":10,"2":2,"38":38,"4":4,"6":6,"7":7,"9":9}],40:[function(require,module,exports){ +"use strict"; +module.exports = verifier; + +var Enum = require(15), + util = require(37); + +function invalid(field, expected) { + return field.name + ": " + expected + (field.repeated && expected !== "array" ? "[]" : field.map && expected !== "object" ? "{k:"+field.keyType+"}" : "") + " expected"; +} + +/** + * Generates a partial value verifier. + * @param {Codegen} gen Codegen instance + * @param {Field} field Reflected field + * @param {number} fieldIndex Field index + * @param {string} ref Variable reference + * @returns {Codegen} Codegen instance + * @ignore + */ +function genVerifyValue(gen, field, fieldIndex, ref) { + /* eslint-disable no-unexpected-multiline */ + if (field.resolvedType) { + if (field.resolvedType instanceof Enum) { gen + ("switch(%s){", ref) + ("default:") + ("return%j", invalid(field, "enum value")); + for (var keys = Object.keys(field.resolvedType.values), j = 0; j < keys.length; ++j) gen + ("case %i:", field.resolvedType.values[keys[j]]); + gen + ("break") + ("}"); + } else { + gen + ("{") + ("var e=types[%i].verify(%s);", fieldIndex, ref) + ("if(e)") + ("return%j+e", field.name + ".") + ("}"); + } + } else { + switch (field.type) { + case "int32": + case "uint32": + case "sint32": + case "fixed32": + case "sfixed32": gen + ("if(!util.isInteger(%s))", ref) + ("return%j", invalid(field, "integer")); + break; + case "int64": + case "uint64": + case "sint64": + case "fixed64": + case "sfixed64": gen + ("if(!util.isInteger(%s)&&!(%s&&util.isInteger(%s.low)&&util.isInteger(%s.high)))", ref, ref, ref, ref) + ("return%j", invalid(field, "integer|Long")); + break; + case "float": + case "double": gen + ("if(typeof %s!==\"number\")", ref) + ("return%j", invalid(field, "number")); + break; + case "bool": gen + ("if(typeof %s!==\"boolean\")", ref) + ("return%j", invalid(field, "boolean")); + break; + case "string": gen + ("if(!util.isString(%s))", ref) + ("return%j", invalid(field, "string")); + break; + case "bytes": gen + ("if(!(%s&&typeof %s.length===\"number\"||util.isString(%s)))", ref, ref, ref) + ("return%j", invalid(field, "buffer")); + break; + } + } + return gen; + /* eslint-enable no-unexpected-multiline */ +} + +/** + * Generates a partial key verifier. + * @param {Codegen} gen Codegen instance + * @param {Field} field Reflected field + * @param {string} ref Variable reference + * @returns {Codegen} Codegen instance + * @ignore + */ +function genVerifyKey(gen, field, ref) { + /* eslint-disable no-unexpected-multiline */ + switch (field.keyType) { + case "int32": + case "uint32": + case "sint32": + case "fixed32": + case "sfixed32": gen + ("if(!util.key32Re.test(%s))", ref) + ("return%j", invalid(field, "integer key")); + break; + case "int64": + case "uint64": + case "sint64": + case "fixed64": + case "sfixed64": gen + ("if(!util.key64Re.test(%s))", ref) // see comment above: x is ok, d is not + ("return%j", invalid(field, "integer|Long key")); + break; + case "bool": gen + ("if(!util.key2Re.test(%s))", ref) + ("return%j", invalid(field, "boolean key")); + break; + } + return gen; + /* eslint-enable no-unexpected-multiline */ +} + +/** + * Generates a verifier specific to the specified message type. + * @param {Type} mtype Message type + * @returns {Codegen} Codegen instance + */ +function verifier(mtype) { + /* eslint-disable no-unexpected-multiline */ + + var gen = util.codegen(["m"], mtype.name + "$verify") + ("if(typeof m!==\"object\"||m===null)") + ("return%j", "object expected"); + var oneofs = mtype.oneofsArray, + seenFirstField = {}; + if (oneofs.length) gen + ("var p={}"); + + for (var i = 0; i < /* initializes */ mtype.fieldsArray.length; ++i) { + var field = mtype._fieldsArray[i].resolve(), + ref = "m" + util.safeProp(field.name); + + if (field.optional) gen + ("if(%s!=null&&m.hasOwnProperty(%j)){", ref, field.name); // !== undefined && !== null + + // map fields + if (field.map) { gen + ("if(!util.isObject(%s))", ref) + ("return%j", invalid(field, "object")) + ("var k=Object.keys(%s)", ref) + ("for(var i=0;i} + * @const + */ +var wrappers = exports; + +var Message = require(21); + +/** + * From object converter part of an {@link IWrapper}. + * @typedef WrapperFromObjectConverter + * @type {function} + * @param {Object.} object Plain object + * @returns {Message<{}>} Message instance + * @this Type + */ + +/** + * To object converter part of an {@link IWrapper}. + * @typedef WrapperToObjectConverter + * @type {function} + * @param {Message<{}>} message Message instance + * @param {IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + * @this Type + */ + +/** + * Common type wrapper part of {@link wrappers}. + * @interface IWrapper + * @property {WrapperFromObjectConverter} [fromObject] From object converter + * @property {WrapperToObjectConverter} [toObject] To object converter + */ + +// Custom wrapper for Any +wrappers[".google.protobuf.Any"] = { + + fromObject: function(object) { + + // unwrap value type if mapped + if (object && object["@type"]) { + var type = this.lookup(object["@type"]); + /* istanbul ignore else */ + if (type) { + // type_url does not accept leading "." + var type_url = object["@type"].charAt(0) === "." ? + object["@type"].substr(1) : object["@type"]; + // type_url prefix is optional, but path seperator is required + return this.create({ + type_url: "/" + type_url, + value: type.encode(type.fromObject(object)).finish() + }); + } + } + + return this.fromObject(object); + }, + + toObject: function(message, options) { + + // decode value if requested and unmapped + if (options && options.json && message.type_url && message.value) { + // Only use fully qualified type name after the last '/' + var name = message.type_url.substring(message.type_url.lastIndexOf("/") + 1); + var type = this.lookup(name); + /* istanbul ignore else */ + if (type) + message = type.decode(message.value); + } + + // wrap value if unmapped + if (!(message instanceof this.ctor) && message instanceof Message) { + var object = message.$type.toObject(message, options); + object["@type"] = message.$type.fullName; + return object; + } + + return this.toObject(message, options); + } +}; + +},{"21":21}],42:[function(require,module,exports){ +"use strict"; +module.exports = Writer; + +var util = require(39); + +var BufferWriter; // cyclic + +var LongBits = util.LongBits, + base64 = util.base64, + utf8 = util.utf8; + +/** + * Constructs a new writer operation instance. + * @classdesc Scheduled writer operation. + * @constructor + * @param {function(*, Uint8Array, number)} fn Function to call + * @param {number} len Value byte length + * @param {*} val Value to write + * @ignore + */ +function Op(fn, len, val) { + + /** + * Function to call. + * @type {function(Uint8Array, number, *)} + */ + this.fn = fn; + + /** + * Value byte length. + * @type {number} + */ + this.len = len; + + /** + * Next operation. + * @type {Writer.Op|undefined} + */ + this.next = undefined; + + /** + * Value to write. + * @type {*} + */ + this.val = val; // type varies +} + +/* istanbul ignore next */ +function noop() {} // eslint-disable-line no-empty-function + +/** + * Constructs a new writer state instance. + * @classdesc Copied writer state. + * @memberof Writer + * @constructor + * @param {Writer} writer Writer to copy state from + * @ignore + */ +function State(writer) { + + /** + * Current head. + * @type {Writer.Op} + */ + this.head = writer.head; + + /** + * Current tail. + * @type {Writer.Op} + */ + this.tail = writer.tail; + + /** + * Current buffer length. + * @type {number} + */ + this.len = writer.len; + + /** + * Next state. + * @type {State|null} + */ + this.next = writer.states; +} + +/** + * Constructs a new writer instance. + * @classdesc Wire format writer using `Uint8Array` if available, otherwise `Array`. + * @constructor + */ +function Writer() { + + /** + * Current length. + * @type {number} + */ + this.len = 0; + + /** + * Operations head. + * @type {Object} + */ + this.head = new Op(noop, 0, 0); + + /** + * Operations tail + * @type {Object} + */ + this.tail = this.head; + + /** + * Linked forked states. + * @type {Object|null} + */ + this.states = null; + + // When a value is written, the writer calculates its byte length and puts it into a linked + // list of operations to perform when finish() is called. This both allows us to allocate + // buffers of the exact required size and reduces the amount of work we have to do compared + // to first calculating over objects and then encoding over objects. In our case, the encoding + // part is just a linked list walk calling operations with already prepared values. +} + +/** + * Creates a new writer. + * @function + * @returns {BufferWriter|Writer} A {@link BufferWriter} when Buffers are supported, otherwise a {@link Writer} + */ +Writer.create = util.Buffer + ? function create_buffer_setup() { + return (Writer.create = function create_buffer() { + return new BufferWriter(); + })(); + } + /* istanbul ignore next */ + : function create_array() { + return new Writer(); + }; + +/** + * Allocates a buffer of the specified size. + * @param {number} size Buffer size + * @returns {Uint8Array} Buffer + */ +Writer.alloc = function alloc(size) { + return new util.Array(size); +}; + +// Use Uint8Array buffer pool in the browser, just like node does with buffers +/* istanbul ignore else */ +if (util.Array !== Array) + Writer.alloc = util.pool(Writer.alloc, util.Array.prototype.subarray); + +/** + * Pushes a new operation to the queue. + * @param {function(Uint8Array, number, *)} fn Function to call + * @param {number} len Value byte length + * @param {number} val Value to write + * @returns {Writer} `this` + * @private + */ +Writer.prototype._push = function push(fn, len, val) { + this.tail = this.tail.next = new Op(fn, len, val); + this.len += len; + return this; +}; + +function writeByte(val, buf, pos) { + buf[pos] = val & 255; +} + +function writeVarint32(val, buf, pos) { + while (val > 127) { + buf[pos++] = val & 127 | 128; + val >>>= 7; + } + buf[pos] = val; +} + +/** + * Constructs a new varint writer operation instance. + * @classdesc Scheduled varint writer operation. + * @extends Op + * @constructor + * @param {number} len Value byte length + * @param {number} val Value to write + * @ignore + */ +function VarintOp(len, val) { + this.len = len; + this.next = undefined; + this.val = val; +} + +VarintOp.prototype = Object.create(Op.prototype); +VarintOp.prototype.fn = writeVarint32; + +/** + * Writes an unsigned 32 bit value as a varint. + * @param {number} value Value to write + * @returns {Writer} `this` + */ +Writer.prototype.uint32 = function write_uint32(value) { + // here, the call to this.push has been inlined and a varint specific Op subclass is used. + // uint32 is by far the most frequently used operation and benefits significantly from this. + this.len += (this.tail = this.tail.next = new VarintOp( + (value = value >>> 0) + < 128 ? 1 + : value < 16384 ? 2 + : value < 2097152 ? 3 + : value < 268435456 ? 4 + : 5, + value)).len; + return this; +}; + +/** + * Writes a signed 32 bit value as a varint. + * @function + * @param {number} value Value to write + * @returns {Writer} `this` + */ +Writer.prototype.int32 = function write_int32(value) { + return value < 0 + ? this._push(writeVarint64, 10, LongBits.fromNumber(value)) // 10 bytes per spec + : this.uint32(value); +}; + +/** + * Writes a 32 bit value as a varint, zig-zag encoded. + * @param {number} value Value to write + * @returns {Writer} `this` + */ +Writer.prototype.sint32 = function write_sint32(value) { + return this.uint32((value << 1 ^ value >> 31) >>> 0); +}; + +function writeVarint64(val, buf, pos) { + while (val.hi) { + buf[pos++] = val.lo & 127 | 128; + val.lo = (val.lo >>> 7 | val.hi << 25) >>> 0; + val.hi >>>= 7; + } + while (val.lo > 127) { + buf[pos++] = val.lo & 127 | 128; + val.lo = val.lo >>> 7; + } + buf[pos++] = val.lo; +} + +/** + * Writes an unsigned 64 bit value as a varint. + * @param {Long|number|string} value Value to write + * @returns {Writer} `this` + * @throws {TypeError} If `value` is a string and no long library is present. + */ +Writer.prototype.uint64 = function write_uint64(value) { + var bits = LongBits.from(value); + return this._push(writeVarint64, bits.length(), bits); +}; + +/** + * Writes a signed 64 bit value as a varint. + * @function + * @param {Long|number|string} value Value to write + * @returns {Writer} `this` + * @throws {TypeError} If `value` is a string and no long library is present. + */ +Writer.prototype.int64 = Writer.prototype.uint64; + +/** + * Writes a signed 64 bit value as a varint, zig-zag encoded. + * @param {Long|number|string} value Value to write + * @returns {Writer} `this` + * @throws {TypeError} If `value` is a string and no long library is present. + */ +Writer.prototype.sint64 = function write_sint64(value) { + var bits = LongBits.from(value).zzEncode(); + return this._push(writeVarint64, bits.length(), bits); +}; + +/** + * Writes a boolish value as a varint. + * @param {boolean} value Value to write + * @returns {Writer} `this` + */ +Writer.prototype.bool = function write_bool(value) { + return this._push(writeByte, 1, value ? 1 : 0); +}; + +function writeFixed32(val, buf, pos) { + buf[pos ] = val & 255; + buf[pos + 1] = val >>> 8 & 255; + buf[pos + 2] = val >>> 16 & 255; + buf[pos + 3] = val >>> 24; +} + +/** + * Writes an unsigned 32 bit value as fixed 32 bits. + * @param {number} value Value to write + * @returns {Writer} `this` + */ +Writer.prototype.fixed32 = function write_fixed32(value) { + return this._push(writeFixed32, 4, value >>> 0); +}; + +/** + * Writes a signed 32 bit value as fixed 32 bits. + * @function + * @param {number} value Value to write + * @returns {Writer} `this` + */ +Writer.prototype.sfixed32 = Writer.prototype.fixed32; + +/** + * Writes an unsigned 64 bit value as fixed 64 bits. + * @param {Long|number|string} value Value to write + * @returns {Writer} `this` + * @throws {TypeError} If `value` is a string and no long library is present. + */ +Writer.prototype.fixed64 = function write_fixed64(value) { + var bits = LongBits.from(value); + return this._push(writeFixed32, 4, bits.lo)._push(writeFixed32, 4, bits.hi); +}; + +/** + * Writes a signed 64 bit value as fixed 64 bits. + * @function + * @param {Long|number|string} value Value to write + * @returns {Writer} `this` + * @throws {TypeError} If `value` is a string and no long library is present. + */ +Writer.prototype.sfixed64 = Writer.prototype.fixed64; + +/** + * Writes a float (32 bit). + * @function + * @param {number} value Value to write + * @returns {Writer} `this` + */ +Writer.prototype.float = function write_float(value) { + return this._push(util.float.writeFloatLE, 4, value); +}; + +/** + * Writes a double (64 bit float). + * @function + * @param {number} value Value to write + * @returns {Writer} `this` + */ +Writer.prototype.double = function write_double(value) { + return this._push(util.float.writeDoubleLE, 8, value); +}; + +var writeBytes = util.Array.prototype.set + ? function writeBytes_set(val, buf, pos) { + buf.set(val, pos); // also works for plain array values + } + /* istanbul ignore next */ + : function writeBytes_for(val, buf, pos) { + for (var i = 0; i < val.length; ++i) + buf[pos + i] = val[i]; + }; + +/** + * Writes a sequence of bytes. + * @param {Uint8Array|string} value Buffer or base64 encoded string to write + * @returns {Writer} `this` + */ +Writer.prototype.bytes = function write_bytes(value) { + var len = value.length >>> 0; + if (!len) + return this._push(writeByte, 1, 0); + if (util.isString(value)) { + var buf = Writer.alloc(len = base64.length(value)); + base64.decode(value, buf, 0); + value = buf; + } + return this.uint32(len)._push(writeBytes, len, value); +}; + +/** + * Writes a string. + * @param {string} value Value to write + * @returns {Writer} `this` + */ +Writer.prototype.string = function write_string(value) { + var len = utf8.length(value); + return len + ? this.uint32(len)._push(utf8.write, len, value) + : this._push(writeByte, 1, 0); +}; + +/** + * Forks this writer's state by pushing it to a stack. + * Calling {@link Writer#reset|reset} or {@link Writer#ldelim|ldelim} resets the writer to the previous state. + * @returns {Writer} `this` + */ +Writer.prototype.fork = function fork() { + this.states = new State(this); + this.head = this.tail = new Op(noop, 0, 0); + this.len = 0; + return this; +}; + +/** + * Resets this instance to the last state. + * @returns {Writer} `this` + */ +Writer.prototype.reset = function reset() { + if (this.states) { + this.head = this.states.head; + this.tail = this.states.tail; + this.len = this.states.len; + this.states = this.states.next; + } else { + this.head = this.tail = new Op(noop, 0, 0); + this.len = 0; + } + return this; +}; + +/** + * Resets to the last state and appends the fork state's current write length as a varint followed by its operations. + * @returns {Writer} `this` + */ +Writer.prototype.ldelim = function ldelim() { + var head = this.head, + tail = this.tail, + len = this.len; + this.reset().uint32(len); + if (len) { + this.tail.next = head.next; // skip noop + this.tail = tail; + this.len += len; + } + return this; +}; + +/** + * Finishes the write operation. + * @returns {Uint8Array} Finished buffer + */ +Writer.prototype.finish = function finish() { + var head = this.head.next, // skip noop + buf = this.constructor.alloc(this.len), + pos = 0; + while (head) { + head.fn(head.val, buf, pos); + pos += head.len; + head = head.next; + } + // this.head = this.tail = null; + return buf; +}; + +Writer._configure = function(BufferWriter_) { + BufferWriter = BufferWriter_; +}; + +},{"39":39}],43:[function(require,module,exports){ +"use strict"; +module.exports = BufferWriter; + +// extends Writer +var Writer = require(42); +(BufferWriter.prototype = Object.create(Writer.prototype)).constructor = BufferWriter; + +var util = require(39); + +var Buffer = util.Buffer; + +/** + * Constructs a new buffer writer instance. + * @classdesc Wire format writer using node buffers. + * @extends Writer + * @constructor + */ +function BufferWriter() { + Writer.call(this); +} + +/** + * Allocates a buffer of the specified size. + * @param {number} size Buffer size + * @returns {Buffer} Buffer + */ +BufferWriter.alloc = function alloc_buffer(size) { + return (BufferWriter.alloc = util._Buffer_allocUnsafe)(size); +}; + +var writeBytesBuffer = Buffer && Buffer.prototype instanceof Uint8Array && Buffer.prototype.set.name === "set" + ? function writeBytesBuffer_set(val, buf, pos) { + buf.set(val, pos); // faster than copy (requires node >= 4 where Buffers extend Uint8Array and set is properly inherited) + // also works for plain array values + } + /* istanbul ignore next */ + : function writeBytesBuffer_copy(val, buf, pos) { + if (val.copy) // Buffer values + val.copy(buf, pos, 0, val.length); + else for (var i = 0; i < val.length;) // plain array values + buf[pos++] = val[i++]; + }; + +/** + * @override + */ +BufferWriter.prototype.bytes = function write_bytes_buffer(value) { + if (util.isString(value)) + value = util._Buffer_from(value, "base64"); + var len = value.length >>> 0; + this.uint32(len); + if (len) + this._push(writeBytesBuffer, len, value); + return this; +}; + +function writeStringBuffer(val, buf, pos) { + if (val.length < 40) // plain js is faster for short strings (probably due to redundant assertions) + util.utf8.write(val, buf, pos); + else + buf.utf8Write(val, pos); +} + +/** + * @override + */ +BufferWriter.prototype.string = function write_string_buffer(value) { + var len = Buffer.byteLength(value); + this.uint32(len); + if (len) + this._push(writeStringBuffer, len, value); + return this; +}; + + +/** + * Finishes the write operation. + * @name BufferWriter#finish + * @function + * @returns {Buffer} Finished buffer + */ + +},{"39":39,"42":42}]},{},[19]) + +})(); +//# sourceMappingURL=protobuf.js.map diff --git a/frontend/build-templates/web-mobile/protobuf.js.map b/frontend/build-templates/web-mobile/protobuf.js.map new file mode 100644 index 0000000..d00d017 --- /dev/null +++ b/frontend/build-templates/web-mobile/protobuf.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["lib/prelude.js","../node_modules/@protobufjs/aspromise/index.js","../node_modules/@protobufjs/base64/index.js","../node_modules/@protobufjs/codegen/index.js","../node_modules/@protobufjs/eventemitter/index.js","../node_modules/@protobufjs/fetch/index.js","../node_modules/@protobufjs/float/index.js","../node_modules/@protobufjs/inquire/index.js","../node_modules/@protobufjs/path/index.js","../node_modules/@protobufjs/pool/index.js","../node_modules/@protobufjs/utf8/index.js","../src/common.js","../src/converter.js","../src/decoder.js","../src/encoder.js","../src/enum.js","../src/field.js","../src/index-light.js","../src/index-minimal.js","../src/index","../src/mapfield.js","../src/message.js","../src/method.js","../src/namespace.js","../src/object.js","../src/oneof.js","../src/parse.js","../src/reader.js","../src/reader_buffer.js","../src/root.js","../src/roots.js","../src/rpc.js","../src/rpc/service.js","../src/service.js","../src/tokenize.js","../src/type.js","../src/types.js","../src/util.js","../src/util/longbits.js","../src/util/minimal.js","../src/verifier.js","../src/wrappers.js","../src/writer.js","../src/writer_buffer.js"],"names":[],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;ACjCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACpDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC3IA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACnGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC5EA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACnHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC/UA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACjBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACjEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AChDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACzGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC/YA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACrSA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC1GA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACnGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACrLA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACnXA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACxGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACpCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACZA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC9HA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC1IA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACvJA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACjbA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACxMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC3MA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACtvBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACrZA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC5CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC/VA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AClBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACpCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC9IA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACvKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC7YA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC7kBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACpMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AClLA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACxMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC9ZA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AChLA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACnFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC3cA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"protobuf.js","sourcesContent":["(function prelude(modules, cache, entries) {\r\n\r\n // This is the prelude used to bundle protobuf.js for the browser. Wraps up the CommonJS\r\n // sources through a conflict-free require shim and is again wrapped within an iife that\r\n // provides a minification-friendly `undefined` var plus a global \"use strict\" directive\r\n // so that minification can remove the directives of each module.\r\n\r\n function $require(name) {\r\n var $module = cache[name];\r\n if (!$module)\r\n modules[name][0].call($module = cache[name] = { exports: {} }, $require, $module, $module.exports);\r\n return $module.exports;\r\n }\r\n\r\n var protobuf = $require(entries[0]);\r\n\r\n // Expose globally\r\n protobuf.util.global.protobuf = protobuf;\r\n\r\n // Be nice to AMD\r\n if (typeof define === \"function\" && define.amd)\r\n define([\"long\"], function(Long) {\r\n if (Long && Long.isLong) {\r\n protobuf.util.Long = Long;\r\n protobuf.configure();\r\n }\r\n return protobuf;\r\n });\r\n\r\n // Be nice to CommonJS\r\n if (typeof module === \"object\" && module && module.exports)\r\n module.exports = protobuf;\r\n\r\n})/* end of prelude */","\"use strict\";\r\nmodule.exports = asPromise;\r\n\r\n/**\r\n * Callback as used by {@link util.asPromise}.\r\n * @typedef asPromiseCallback\r\n * @type {function}\r\n * @param {Error|null} error Error, if any\r\n * @param {...*} params Additional arguments\r\n * @returns {undefined}\r\n */\r\n\r\n/**\r\n * Returns a promise from a node-style callback function.\r\n * @memberof util\r\n * @param {asPromiseCallback} fn Function to call\r\n * @param {*} ctx Function context\r\n * @param {...*} params Function arguments\r\n * @returns {Promise<*>} Promisified function\r\n */\r\nfunction asPromise(fn, ctx/*, varargs */) {\r\n var params = new Array(arguments.length - 1),\r\n offset = 0,\r\n index = 2,\r\n pending = true;\r\n while (index < arguments.length)\r\n params[offset++] = arguments[index++];\r\n return new Promise(function executor(resolve, reject) {\r\n params[offset] = function callback(err/*, varargs */) {\r\n if (pending) {\r\n pending = false;\r\n if (err)\r\n reject(err);\r\n else {\r\n var params = new Array(arguments.length - 1),\r\n offset = 0;\r\n while (offset < params.length)\r\n params[offset++] = arguments[offset];\r\n resolve.apply(null, params);\r\n }\r\n }\r\n };\r\n try {\r\n fn.apply(ctx || null, params);\r\n } catch (err) {\r\n if (pending) {\r\n pending = false;\r\n reject(err);\r\n }\r\n }\r\n });\r\n}\r\n","\"use strict\";\r\n\r\n/**\r\n * A minimal base64 implementation for number arrays.\r\n * @memberof util\r\n * @namespace\r\n */\r\nvar base64 = exports;\r\n\r\n/**\r\n * Calculates the byte length of a base64 encoded string.\r\n * @param {string} string Base64 encoded string\r\n * @returns {number} Byte length\r\n */\r\nbase64.length = function length(string) {\r\n var p = string.length;\r\n if (!p)\r\n return 0;\r\n var n = 0;\r\n while (--p % 4 > 1 && string.charAt(p) === \"=\")\r\n ++n;\r\n return Math.ceil(string.length * 3) / 4 - n;\r\n};\r\n\r\n// Base64 encoding table\r\nvar b64 = new Array(64);\r\n\r\n// Base64 decoding table\r\nvar s64 = new Array(123);\r\n\r\n// 65..90, 97..122, 48..57, 43, 47\r\nfor (var i = 0; i < 64;)\r\n s64[b64[i] = i < 26 ? i + 65 : i < 52 ? i + 71 : i < 62 ? i - 4 : i - 59 | 43] = i++;\r\n\r\n/**\r\n * Encodes a buffer to a base64 encoded string.\r\n * @param {Uint8Array} buffer Source buffer\r\n * @param {number} start Source start\r\n * @param {number} end Source end\r\n * @returns {string} Base64 encoded string\r\n */\r\nbase64.encode = function encode(buffer, start, end) {\r\n var parts = null,\r\n chunk = [];\r\n var i = 0, // output index\r\n j = 0, // goto index\r\n t; // temporary\r\n while (start < end) {\r\n var b = buffer[start++];\r\n switch (j) {\r\n case 0:\r\n chunk[i++] = b64[b >> 2];\r\n t = (b & 3) << 4;\r\n j = 1;\r\n break;\r\n case 1:\r\n chunk[i++] = b64[t | b >> 4];\r\n t = (b & 15) << 2;\r\n j = 2;\r\n break;\r\n case 2:\r\n chunk[i++] = b64[t | b >> 6];\r\n chunk[i++] = b64[b & 63];\r\n j = 0;\r\n break;\r\n }\r\n if (i > 8191) {\r\n (parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));\r\n i = 0;\r\n }\r\n }\r\n if (j) {\r\n chunk[i++] = b64[t];\r\n chunk[i++] = 61;\r\n if (j === 1)\r\n chunk[i++] = 61;\r\n }\r\n if (parts) {\r\n if (i)\r\n parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));\r\n return parts.join(\"\");\r\n }\r\n return String.fromCharCode.apply(String, chunk.slice(0, i));\r\n};\r\n\r\nvar invalidEncoding = \"invalid encoding\";\r\n\r\n/**\r\n * Decodes a base64 encoded string to a buffer.\r\n * @param {string} string Source string\r\n * @param {Uint8Array} buffer Destination buffer\r\n * @param {number} offset Destination offset\r\n * @returns {number} Number of bytes written\r\n * @throws {Error} If encoding is invalid\r\n */\r\nbase64.decode = function decode(string, buffer, offset) {\r\n var start = offset;\r\n var j = 0, // goto index\r\n t; // temporary\r\n for (var i = 0; i < string.length;) {\r\n var c = string.charCodeAt(i++);\r\n if (c === 61 && j > 1)\r\n break;\r\n if ((c = s64[c]) === undefined)\r\n throw Error(invalidEncoding);\r\n switch (j) {\r\n case 0:\r\n t = c;\r\n j = 1;\r\n break;\r\n case 1:\r\n buffer[offset++] = t << 2 | (c & 48) >> 4;\r\n t = c;\r\n j = 2;\r\n break;\r\n case 2:\r\n buffer[offset++] = (t & 15) << 4 | (c & 60) >> 2;\r\n t = c;\r\n j = 3;\r\n break;\r\n case 3:\r\n buffer[offset++] = (t & 3) << 6 | c;\r\n j = 0;\r\n break;\r\n }\r\n }\r\n if (j === 1)\r\n throw Error(invalidEncoding);\r\n return offset - start;\r\n};\r\n\r\n/**\r\n * Tests if the specified string appears to be base64 encoded.\r\n * @param {string} string String to test\r\n * @returns {boolean} `true` if probably base64 encoded, otherwise false\r\n */\r\nbase64.test = function test(string) {\r\n return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(string);\r\n};\r\n","\"use strict\";\r\nmodule.exports = codegen;\r\n\r\n/**\r\n * Begins generating a function.\r\n * @memberof util\r\n * @param {string[]} functionParams Function parameter names\r\n * @param {string} [functionName] Function name if not anonymous\r\n * @returns {Codegen} Appender that appends code to the function's body\r\n */\r\nfunction codegen(functionParams, functionName) {\r\n\r\n /* istanbul ignore if */\r\n if (typeof functionParams === \"string\") {\r\n functionName = functionParams;\r\n functionParams = undefined;\r\n }\r\n\r\n var body = [];\r\n\r\n /**\r\n * Appends code to the function's body or finishes generation.\r\n * @typedef Codegen\r\n * @type {function}\r\n * @param {string|Object.} [formatStringOrScope] Format string or, to finish the function, an object of additional scope variables, if any\r\n * @param {...*} [formatParams] Format parameters\r\n * @returns {Codegen|Function} Itself or the generated function if finished\r\n * @throws {Error} If format parameter counts do not match\r\n */\r\n\r\n function Codegen(formatStringOrScope) {\r\n // note that explicit array handling below makes this ~50% faster\r\n\r\n // finish the function\r\n if (typeof formatStringOrScope !== \"string\") {\r\n var source = toString();\r\n if (codegen.verbose)\r\n console.log(\"codegen: \" + source); // eslint-disable-line no-console\r\n source = \"return \" + source;\r\n if (formatStringOrScope) {\r\n var scopeKeys = Object.keys(formatStringOrScope),\r\n scopeParams = new Array(scopeKeys.length + 1),\r\n scopeValues = new Array(scopeKeys.length),\r\n scopeOffset = 0;\r\n while (scopeOffset < scopeKeys.length) {\r\n scopeParams[scopeOffset] = scopeKeys[scopeOffset];\r\n scopeValues[scopeOffset] = formatStringOrScope[scopeKeys[scopeOffset++]];\r\n }\r\n scopeParams[scopeOffset] = source;\r\n return Function.apply(null, scopeParams).apply(null, scopeValues); // eslint-disable-line no-new-func\r\n }\r\n return Function(source)(); // eslint-disable-line no-new-func\r\n }\r\n\r\n // otherwise append to body\r\n var formatParams = new Array(arguments.length - 1),\r\n formatOffset = 0;\r\n while (formatOffset < formatParams.length)\r\n formatParams[formatOffset] = arguments[++formatOffset];\r\n formatOffset = 0;\r\n formatStringOrScope = formatStringOrScope.replace(/%([%dfijs])/g, function replace($0, $1) {\r\n var value = formatParams[formatOffset++];\r\n switch ($1) {\r\n case \"d\": case \"f\": return String(Number(value));\r\n case \"i\": return String(Math.floor(value));\r\n case \"j\": return JSON.stringify(value);\r\n case \"s\": return String(value);\r\n }\r\n return \"%\";\r\n });\r\n if (formatOffset !== formatParams.length)\r\n throw Error(\"parameter count mismatch\");\r\n body.push(formatStringOrScope);\r\n return Codegen;\r\n }\r\n\r\n function toString(functionNameOverride) {\r\n return \"function \" + (functionNameOverride || functionName || \"\") + \"(\" + (functionParams && functionParams.join(\",\") || \"\") + \"){\\n \" + body.join(\"\\n \") + \"\\n}\";\r\n }\r\n\r\n Codegen.toString = toString;\r\n return Codegen;\r\n}\r\n\r\n/**\r\n * Begins generating a function.\r\n * @memberof util\r\n * @function codegen\r\n * @param {string} [functionName] Function name if not anonymous\r\n * @returns {Codegen} Appender that appends code to the function's body\r\n * @variation 2\r\n */\r\n\r\n/**\r\n * When set to `true`, codegen will log generated code to console. Useful for debugging.\r\n * @name util.codegen.verbose\r\n * @type {boolean}\r\n */\r\ncodegen.verbose = false;\r\n","\"use strict\";\r\nmodule.exports = EventEmitter;\r\n\r\n/**\r\n * Constructs a new event emitter instance.\r\n * @classdesc A minimal event emitter.\r\n * @memberof util\r\n * @constructor\r\n */\r\nfunction EventEmitter() {\r\n\r\n /**\r\n * Registered listeners.\r\n * @type {Object.}\r\n * @private\r\n */\r\n this._listeners = {};\r\n}\r\n\r\n/**\r\n * Registers an event listener.\r\n * @param {string} evt Event name\r\n * @param {function} fn Listener\r\n * @param {*} [ctx] Listener context\r\n * @returns {util.EventEmitter} `this`\r\n */\r\nEventEmitter.prototype.on = function on(evt, fn, ctx) {\r\n (this._listeners[evt] || (this._listeners[evt] = [])).push({\r\n fn : fn,\r\n ctx : ctx || this\r\n });\r\n return this;\r\n};\r\n\r\n/**\r\n * Removes an event listener or any matching listeners if arguments are omitted.\r\n * @param {string} [evt] Event name. Removes all listeners if omitted.\r\n * @param {function} [fn] Listener to remove. Removes all listeners of `evt` if omitted.\r\n * @returns {util.EventEmitter} `this`\r\n */\r\nEventEmitter.prototype.off = function off(evt, fn) {\r\n if (evt === undefined)\r\n this._listeners = {};\r\n else {\r\n if (fn === undefined)\r\n this._listeners[evt] = [];\r\n else {\r\n var listeners = this._listeners[evt];\r\n for (var i = 0; i < listeners.length;)\r\n if (listeners[i].fn === fn)\r\n listeners.splice(i, 1);\r\n else\r\n ++i;\r\n }\r\n }\r\n return this;\r\n};\r\n\r\n/**\r\n * Emits an event by calling its listeners with the specified arguments.\r\n * @param {string} evt Event name\r\n * @param {...*} args Arguments\r\n * @returns {util.EventEmitter} `this`\r\n */\r\nEventEmitter.prototype.emit = function emit(evt) {\r\n var listeners = this._listeners[evt];\r\n if (listeners) {\r\n var args = [],\r\n i = 1;\r\n for (; i < arguments.length;)\r\n args.push(arguments[i++]);\r\n for (i = 0; i < listeners.length;)\r\n listeners[i].fn.apply(listeners[i++].ctx, args);\r\n }\r\n return this;\r\n};\r\n","\"use strict\";\r\nmodule.exports = fetch;\r\n\r\nvar asPromise = require(1),\r\n inquire = require(7);\r\n\r\nvar fs = inquire(\"fs\");\r\n\r\n/**\r\n * Node-style callback as used by {@link util.fetch}.\r\n * @typedef FetchCallback\r\n * @type {function}\r\n * @param {?Error} error Error, if any, otherwise `null`\r\n * @param {string} [contents] File contents, if there hasn't been an error\r\n * @returns {undefined}\r\n */\r\n\r\n/**\r\n * Options as used by {@link util.fetch}.\r\n * @typedef FetchOptions\r\n * @type {Object}\r\n * @property {boolean} [binary=false] Whether expecting a binary response\r\n * @property {boolean} [xhr=false] If `true`, forces the use of XMLHttpRequest\r\n */\r\n\r\n/**\r\n * Fetches the contents of a file.\r\n * @memberof util\r\n * @param {string} filename File path or url\r\n * @param {FetchOptions} options Fetch options\r\n * @param {FetchCallback} callback Callback function\r\n * @returns {undefined}\r\n */\r\nfunction fetch(filename, options, callback) {\r\n if (typeof options === \"function\") {\r\n callback = options;\r\n options = {};\r\n } else if (!options)\r\n options = {};\r\n\r\n if (!callback)\r\n return asPromise(fetch, this, filename, options); // eslint-disable-line no-invalid-this\r\n\r\n // if a node-like filesystem is present, try it first but fall back to XHR if nothing is found.\r\n if (!options.xhr && fs && fs.readFile)\r\n return fs.readFile(filename, function fetchReadFileCallback(err, contents) {\r\n return err && typeof XMLHttpRequest !== \"undefined\"\r\n ? fetch.xhr(filename, options, callback)\r\n : err\r\n ? callback(err)\r\n : callback(null, options.binary ? contents : contents.toString(\"utf8\"));\r\n });\r\n\r\n // use the XHR version otherwise.\r\n return fetch.xhr(filename, options, callback);\r\n}\r\n\r\n/**\r\n * Fetches the contents of a file.\r\n * @name util.fetch\r\n * @function\r\n * @param {string} path File path or url\r\n * @param {FetchCallback} callback Callback function\r\n * @returns {undefined}\r\n * @variation 2\r\n */\r\n\r\n/**\r\n * Fetches the contents of a file.\r\n * @name util.fetch\r\n * @function\r\n * @param {string} path File path or url\r\n * @param {FetchOptions} [options] Fetch options\r\n * @returns {Promise} Promise\r\n * @variation 3\r\n */\r\n\r\n/**/\r\nfetch.xhr = function fetch_xhr(filename, options, callback) {\r\n var xhr = new XMLHttpRequest();\r\n xhr.onreadystatechange /* works everywhere */ = function fetchOnReadyStateChange() {\r\n\r\n if (xhr.readyState !== 4)\r\n return undefined;\r\n\r\n // local cors security errors return status 0 / empty string, too. afaik this cannot be\r\n // reliably distinguished from an actually empty file for security reasons. feel free\r\n // to send a pull request if you are aware of a solution.\r\n if (xhr.status !== 0 && xhr.status !== 200)\r\n return callback(Error(\"status \" + xhr.status));\r\n\r\n // if binary data is expected, make sure that some sort of array is returned, even if\r\n // ArrayBuffers are not supported. the binary string fallback, however, is unsafe.\r\n if (options.binary) {\r\n var buffer = xhr.response;\r\n if (!buffer) {\r\n buffer = [];\r\n for (var i = 0; i < xhr.responseText.length; ++i)\r\n buffer.push(xhr.responseText.charCodeAt(i) & 255);\r\n }\r\n return callback(null, typeof Uint8Array !== \"undefined\" ? new Uint8Array(buffer) : buffer);\r\n }\r\n return callback(null, xhr.responseText);\r\n };\r\n\r\n if (options.binary) {\r\n // ref: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Sending_and_Receiving_Binary_Data#Receiving_binary_data_in_older_browsers\r\n if (\"overrideMimeType\" in xhr)\r\n xhr.overrideMimeType(\"text/plain; charset=x-user-defined\");\r\n xhr.responseType = \"arraybuffer\";\r\n }\r\n\r\n xhr.open(\"GET\", filename);\r\n xhr.send();\r\n};\r\n","\"use strict\";\r\n\r\nmodule.exports = factory(factory);\r\n\r\n/**\r\n * Reads / writes floats / doubles from / to buffers.\r\n * @name util.float\r\n * @namespace\r\n */\r\n\r\n/**\r\n * Writes a 32 bit float to a buffer using little endian byte order.\r\n * @name util.float.writeFloatLE\r\n * @function\r\n * @param {number} val Value to write\r\n * @param {Uint8Array} buf Target buffer\r\n * @param {number} pos Target buffer offset\r\n * @returns {undefined}\r\n */\r\n\r\n/**\r\n * Writes a 32 bit float to a buffer using big endian byte order.\r\n * @name util.float.writeFloatBE\r\n * @function\r\n * @param {number} val Value to write\r\n * @param {Uint8Array} buf Target buffer\r\n * @param {number} pos Target buffer offset\r\n * @returns {undefined}\r\n */\r\n\r\n/**\r\n * Reads a 32 bit float from a buffer using little endian byte order.\r\n * @name util.float.readFloatLE\r\n * @function\r\n * @param {Uint8Array} buf Source buffer\r\n * @param {number} pos Source buffer offset\r\n * @returns {number} Value read\r\n */\r\n\r\n/**\r\n * Reads a 32 bit float from a buffer using big endian byte order.\r\n * @name util.float.readFloatBE\r\n * @function\r\n * @param {Uint8Array} buf Source buffer\r\n * @param {number} pos Source buffer offset\r\n * @returns {number} Value read\r\n */\r\n\r\n/**\r\n * Writes a 64 bit double to a buffer using little endian byte order.\r\n * @name util.float.writeDoubleLE\r\n * @function\r\n * @param {number} val Value to write\r\n * @param {Uint8Array} buf Target buffer\r\n * @param {number} pos Target buffer offset\r\n * @returns {undefined}\r\n */\r\n\r\n/**\r\n * Writes a 64 bit double to a buffer using big endian byte order.\r\n * @name util.float.writeDoubleBE\r\n * @function\r\n * @param {number} val Value to write\r\n * @param {Uint8Array} buf Target buffer\r\n * @param {number} pos Target buffer offset\r\n * @returns {undefined}\r\n */\r\n\r\n/**\r\n * Reads a 64 bit double from a buffer using little endian byte order.\r\n * @name util.float.readDoubleLE\r\n * @function\r\n * @param {Uint8Array} buf Source buffer\r\n * @param {number} pos Source buffer offset\r\n * @returns {number} Value read\r\n */\r\n\r\n/**\r\n * Reads a 64 bit double from a buffer using big endian byte order.\r\n * @name util.float.readDoubleBE\r\n * @function\r\n * @param {Uint8Array} buf Source buffer\r\n * @param {number} pos Source buffer offset\r\n * @returns {number} Value read\r\n */\r\n\r\n// Factory function for the purpose of node-based testing in modified global environments\r\nfunction factory(exports) {\r\n\r\n // float: typed array\r\n if (typeof Float32Array !== \"undefined\") (function() {\r\n\r\n var f32 = new Float32Array([ -0 ]),\r\n f8b = new Uint8Array(f32.buffer),\r\n le = f8b[3] === 128;\r\n\r\n function writeFloat_f32_cpy(val, buf, pos) {\r\n f32[0] = val;\r\n buf[pos ] = f8b[0];\r\n buf[pos + 1] = f8b[1];\r\n buf[pos + 2] = f8b[2];\r\n buf[pos + 3] = f8b[3];\r\n }\r\n\r\n function writeFloat_f32_rev(val, buf, pos) {\r\n f32[0] = val;\r\n buf[pos ] = f8b[3];\r\n buf[pos + 1] = f8b[2];\r\n buf[pos + 2] = f8b[1];\r\n buf[pos + 3] = f8b[0];\r\n }\r\n\r\n /* istanbul ignore next */\r\n exports.writeFloatLE = le ? writeFloat_f32_cpy : writeFloat_f32_rev;\r\n /* istanbul ignore next */\r\n exports.writeFloatBE = le ? writeFloat_f32_rev : writeFloat_f32_cpy;\r\n\r\n function readFloat_f32_cpy(buf, pos) {\r\n f8b[0] = buf[pos ];\r\n f8b[1] = buf[pos + 1];\r\n f8b[2] = buf[pos + 2];\r\n f8b[3] = buf[pos + 3];\r\n return f32[0];\r\n }\r\n\r\n function readFloat_f32_rev(buf, pos) {\r\n f8b[3] = buf[pos ];\r\n f8b[2] = buf[pos + 1];\r\n f8b[1] = buf[pos + 2];\r\n f8b[0] = buf[pos + 3];\r\n return f32[0];\r\n }\r\n\r\n /* istanbul ignore next */\r\n exports.readFloatLE = le ? readFloat_f32_cpy : readFloat_f32_rev;\r\n /* istanbul ignore next */\r\n exports.readFloatBE = le ? readFloat_f32_rev : readFloat_f32_cpy;\r\n\r\n // float: ieee754\r\n })(); else (function() {\r\n\r\n function writeFloat_ieee754(writeUint, val, buf, pos) {\r\n var sign = val < 0 ? 1 : 0;\r\n if (sign)\r\n val = -val;\r\n if (val === 0)\r\n writeUint(1 / val > 0 ? /* positive */ 0 : /* negative 0 */ 2147483648, buf, pos);\r\n else if (isNaN(val))\r\n writeUint(2143289344, buf, pos);\r\n else if (val > 3.4028234663852886e+38) // +-Infinity\r\n writeUint((sign << 31 | 2139095040) >>> 0, buf, pos);\r\n else if (val < 1.1754943508222875e-38) // denormal\r\n writeUint((sign << 31 | Math.round(val / 1.401298464324817e-45)) >>> 0, buf, pos);\r\n else {\r\n var exponent = Math.floor(Math.log(val) / Math.LN2),\r\n mantissa = Math.round(val * Math.pow(2, -exponent) * 8388608) & 8388607;\r\n writeUint((sign << 31 | exponent + 127 << 23 | mantissa) >>> 0, buf, pos);\r\n }\r\n }\r\n\r\n exports.writeFloatLE = writeFloat_ieee754.bind(null, writeUintLE);\r\n exports.writeFloatBE = writeFloat_ieee754.bind(null, writeUintBE);\r\n\r\n function readFloat_ieee754(readUint, buf, pos) {\r\n var uint = readUint(buf, pos),\r\n sign = (uint >> 31) * 2 + 1,\r\n exponent = uint >>> 23 & 255,\r\n mantissa = uint & 8388607;\r\n return exponent === 255\r\n ? mantissa\r\n ? NaN\r\n : sign * Infinity\r\n : exponent === 0 // denormal\r\n ? sign * 1.401298464324817e-45 * mantissa\r\n : sign * Math.pow(2, exponent - 150) * (mantissa + 8388608);\r\n }\r\n\r\n exports.readFloatLE = readFloat_ieee754.bind(null, readUintLE);\r\n exports.readFloatBE = readFloat_ieee754.bind(null, readUintBE);\r\n\r\n })();\r\n\r\n // double: typed array\r\n if (typeof Float64Array !== \"undefined\") (function() {\r\n\r\n var f64 = new Float64Array([-0]),\r\n f8b = new Uint8Array(f64.buffer),\r\n le = f8b[7] === 128;\r\n\r\n function writeDouble_f64_cpy(val, buf, pos) {\r\n f64[0] = val;\r\n buf[pos ] = f8b[0];\r\n buf[pos + 1] = f8b[1];\r\n buf[pos + 2] = f8b[2];\r\n buf[pos + 3] = f8b[3];\r\n buf[pos + 4] = f8b[4];\r\n buf[pos + 5] = f8b[5];\r\n buf[pos + 6] = f8b[6];\r\n buf[pos + 7] = f8b[7];\r\n }\r\n\r\n function writeDouble_f64_rev(val, buf, pos) {\r\n f64[0] = val;\r\n buf[pos ] = f8b[7];\r\n buf[pos + 1] = f8b[6];\r\n buf[pos + 2] = f8b[5];\r\n buf[pos + 3] = f8b[4];\r\n buf[pos + 4] = f8b[3];\r\n buf[pos + 5] = f8b[2];\r\n buf[pos + 6] = f8b[1];\r\n buf[pos + 7] = f8b[0];\r\n }\r\n\r\n /* istanbul ignore next */\r\n exports.writeDoubleLE = le ? writeDouble_f64_cpy : writeDouble_f64_rev;\r\n /* istanbul ignore next */\r\n exports.writeDoubleBE = le ? writeDouble_f64_rev : writeDouble_f64_cpy;\r\n\r\n function readDouble_f64_cpy(buf, pos) {\r\n f8b[0] = buf[pos ];\r\n f8b[1] = buf[pos + 1];\r\n f8b[2] = buf[pos + 2];\r\n f8b[3] = buf[pos + 3];\r\n f8b[4] = buf[pos + 4];\r\n f8b[5] = buf[pos + 5];\r\n f8b[6] = buf[pos + 6];\r\n f8b[7] = buf[pos + 7];\r\n return f64[0];\r\n }\r\n\r\n function readDouble_f64_rev(buf, pos) {\r\n f8b[7] = buf[pos ];\r\n f8b[6] = buf[pos + 1];\r\n f8b[5] = buf[pos + 2];\r\n f8b[4] = buf[pos + 3];\r\n f8b[3] = buf[pos + 4];\r\n f8b[2] = buf[pos + 5];\r\n f8b[1] = buf[pos + 6];\r\n f8b[0] = buf[pos + 7];\r\n return f64[0];\r\n }\r\n\r\n /* istanbul ignore next */\r\n exports.readDoubleLE = le ? readDouble_f64_cpy : readDouble_f64_rev;\r\n /* istanbul ignore next */\r\n exports.readDoubleBE = le ? readDouble_f64_rev : readDouble_f64_cpy;\r\n\r\n // double: ieee754\r\n })(); else (function() {\r\n\r\n function writeDouble_ieee754(writeUint, off0, off1, val, buf, pos) {\r\n var sign = val < 0 ? 1 : 0;\r\n if (sign)\r\n val = -val;\r\n if (val === 0) {\r\n writeUint(0, buf, pos + off0);\r\n writeUint(1 / val > 0 ? /* positive */ 0 : /* negative 0 */ 2147483648, buf, pos + off1);\r\n } else if (isNaN(val)) {\r\n writeUint(0, buf, pos + off0);\r\n writeUint(2146959360, buf, pos + off1);\r\n } else if (val > 1.7976931348623157e+308) { // +-Infinity\r\n writeUint(0, buf, pos + off0);\r\n writeUint((sign << 31 | 2146435072) >>> 0, buf, pos + off1);\r\n } else {\r\n var mantissa;\r\n if (val < 2.2250738585072014e-308) { // denormal\r\n mantissa = val / 5e-324;\r\n writeUint(mantissa >>> 0, buf, pos + off0);\r\n writeUint((sign << 31 | mantissa / 4294967296) >>> 0, buf, pos + off1);\r\n } else {\r\n var exponent = Math.floor(Math.log(val) / Math.LN2);\r\n if (exponent === 1024)\r\n exponent = 1023;\r\n mantissa = val * Math.pow(2, -exponent);\r\n writeUint(mantissa * 4503599627370496 >>> 0, buf, pos + off0);\r\n writeUint((sign << 31 | exponent + 1023 << 20 | mantissa * 1048576 & 1048575) >>> 0, buf, pos + off1);\r\n }\r\n }\r\n }\r\n\r\n exports.writeDoubleLE = writeDouble_ieee754.bind(null, writeUintLE, 0, 4);\r\n exports.writeDoubleBE = writeDouble_ieee754.bind(null, writeUintBE, 4, 0);\r\n\r\n function readDouble_ieee754(readUint, off0, off1, buf, pos) {\r\n var lo = readUint(buf, pos + off0),\r\n hi = readUint(buf, pos + off1);\r\n var sign = (hi >> 31) * 2 + 1,\r\n exponent = hi >>> 20 & 2047,\r\n mantissa = 4294967296 * (hi & 1048575) + lo;\r\n return exponent === 2047\r\n ? mantissa\r\n ? NaN\r\n : sign * Infinity\r\n : exponent === 0 // denormal\r\n ? sign * 5e-324 * mantissa\r\n : sign * Math.pow(2, exponent - 1075) * (mantissa + 4503599627370496);\r\n }\r\n\r\n exports.readDoubleLE = readDouble_ieee754.bind(null, readUintLE, 0, 4);\r\n exports.readDoubleBE = readDouble_ieee754.bind(null, readUintBE, 4, 0);\r\n\r\n })();\r\n\r\n return exports;\r\n}\r\n\r\n// uint helpers\r\n\r\nfunction writeUintLE(val, buf, pos) {\r\n buf[pos ] = val & 255;\r\n buf[pos + 1] = val >>> 8 & 255;\r\n buf[pos + 2] = val >>> 16 & 255;\r\n buf[pos + 3] = val >>> 24;\r\n}\r\n\r\nfunction writeUintBE(val, buf, pos) {\r\n buf[pos ] = val >>> 24;\r\n buf[pos + 1] = val >>> 16 & 255;\r\n buf[pos + 2] = val >>> 8 & 255;\r\n buf[pos + 3] = val & 255;\r\n}\r\n\r\nfunction readUintLE(buf, pos) {\r\n return (buf[pos ]\r\n | buf[pos + 1] << 8\r\n | buf[pos + 2] << 16\r\n | buf[pos + 3] << 24) >>> 0;\r\n}\r\n\r\nfunction readUintBE(buf, pos) {\r\n return (buf[pos ] << 24\r\n | buf[pos + 1] << 16\r\n | buf[pos + 2] << 8\r\n | buf[pos + 3]) >>> 0;\r\n}\r\n","\"use strict\";\r\nmodule.exports = inquire;\r\n\r\n/**\r\n * Requires a module only if available.\r\n * @memberof util\r\n * @param {string} moduleName Module to require\r\n * @returns {?Object} Required module if available and not empty, otherwise `null`\r\n */\r\nfunction inquire(moduleName) {\r\n try {\r\n var mod = eval(\"quire\".replace(/^/,\"re\"))(moduleName); // eslint-disable-line no-eval\r\n if (mod && (mod.length || Object.keys(mod).length))\r\n return mod;\r\n } catch (e) {} // eslint-disable-line no-empty\r\n return null;\r\n}\r\n","\"use strict\";\r\n\r\n/**\r\n * A minimal path module to resolve Unix, Windows and URL paths alike.\r\n * @memberof util\r\n * @namespace\r\n */\r\nvar path = exports;\r\n\r\nvar isAbsolute =\r\n/**\r\n * Tests if the specified path is absolute.\r\n * @param {string} path Path to test\r\n * @returns {boolean} `true` if path is absolute\r\n */\r\npath.isAbsolute = function isAbsolute(path) {\r\n return /^(?:\\/|\\w+:)/.test(path);\r\n};\r\n\r\nvar normalize =\r\n/**\r\n * Normalizes the specified path.\r\n * @param {string} path Path to normalize\r\n * @returns {string} Normalized path\r\n */\r\npath.normalize = function normalize(path) {\r\n path = path.replace(/\\\\/g, \"/\")\r\n .replace(/\\/{2,}/g, \"/\");\r\n var parts = path.split(\"/\"),\r\n absolute = isAbsolute(path),\r\n prefix = \"\";\r\n if (absolute)\r\n prefix = parts.shift() + \"/\";\r\n for (var i = 0; i < parts.length;) {\r\n if (parts[i] === \"..\") {\r\n if (i > 0 && parts[i - 1] !== \"..\")\r\n parts.splice(--i, 2);\r\n else if (absolute)\r\n parts.splice(i, 1);\r\n else\r\n ++i;\r\n } else if (parts[i] === \".\")\r\n parts.splice(i, 1);\r\n else\r\n ++i;\r\n }\r\n return prefix + parts.join(\"/\");\r\n};\r\n\r\n/**\r\n * Resolves the specified include path against the specified origin path.\r\n * @param {string} originPath Path to the origin file\r\n * @param {string} includePath Include path relative to origin path\r\n * @param {boolean} [alreadyNormalized=false] `true` if both paths are already known to be normalized\r\n * @returns {string} Path to the include file\r\n */\r\npath.resolve = function resolve(originPath, includePath, alreadyNormalized) {\r\n if (!alreadyNormalized)\r\n includePath = normalize(includePath);\r\n if (isAbsolute(includePath))\r\n return includePath;\r\n if (!alreadyNormalized)\r\n originPath = normalize(originPath);\r\n return (originPath = originPath.replace(/(?:\\/|^)[^/]+$/, \"\")).length ? normalize(originPath + \"/\" + includePath) : includePath;\r\n};\r\n","\"use strict\";\r\nmodule.exports = pool;\r\n\r\n/**\r\n * An allocator as used by {@link util.pool}.\r\n * @typedef PoolAllocator\r\n * @type {function}\r\n * @param {number} size Buffer size\r\n * @returns {Uint8Array} Buffer\r\n */\r\n\r\n/**\r\n * A slicer as used by {@link util.pool}.\r\n * @typedef PoolSlicer\r\n * @type {function}\r\n * @param {number} start Start offset\r\n * @param {number} end End offset\r\n * @returns {Uint8Array} Buffer slice\r\n * @this {Uint8Array}\r\n */\r\n\r\n/**\r\n * A general purpose buffer pool.\r\n * @memberof util\r\n * @function\r\n * @param {PoolAllocator} alloc Allocator\r\n * @param {PoolSlicer} slice Slicer\r\n * @param {number} [size=8192] Slab size\r\n * @returns {PoolAllocator} Pooled allocator\r\n */\r\nfunction pool(alloc, slice, size) {\r\n var SIZE = size || 8192;\r\n var MAX = SIZE >>> 1;\r\n var slab = null;\r\n var offset = SIZE;\r\n return function pool_alloc(size) {\r\n if (size < 1 || size > MAX)\r\n return alloc(size);\r\n if (offset + size > SIZE) {\r\n slab = alloc(SIZE);\r\n offset = 0;\r\n }\r\n var buf = slice.call(slab, offset, offset += size);\r\n if (offset & 7) // align to 32 bit\r\n offset = (offset | 7) + 1;\r\n return buf;\r\n };\r\n}\r\n","\"use strict\";\r\n\r\n/**\r\n * A minimal UTF8 implementation for number arrays.\r\n * @memberof util\r\n * @namespace\r\n */\r\nvar utf8 = exports;\r\n\r\n/**\r\n * Calculates the UTF8 byte length of a string.\r\n * @param {string} string String\r\n * @returns {number} Byte length\r\n */\r\nutf8.length = function utf8_length(string) {\r\n var len = 0,\r\n c = 0;\r\n for (var i = 0; i < string.length; ++i) {\r\n c = string.charCodeAt(i);\r\n if (c < 128)\r\n len += 1;\r\n else if (c < 2048)\r\n len += 2;\r\n else if ((c & 0xFC00) === 0xD800 && (string.charCodeAt(i + 1) & 0xFC00) === 0xDC00) {\r\n ++i;\r\n len += 4;\r\n } else\r\n len += 3;\r\n }\r\n return len;\r\n};\r\n\r\n/**\r\n * Reads UTF8 bytes as a string.\r\n * @param {Uint8Array} buffer Source buffer\r\n * @param {number} start Source start\r\n * @param {number} end Source end\r\n * @returns {string} String read\r\n */\r\nutf8.read = function utf8_read(buffer, start, end) {\r\n var len = end - start;\r\n if (len < 1)\r\n return \"\";\r\n var parts = null,\r\n chunk = [],\r\n i = 0, // char offset\r\n t; // temporary\r\n while (start < end) {\r\n t = buffer[start++];\r\n if (t < 128)\r\n chunk[i++] = t;\r\n else if (t > 191 && t < 224)\r\n chunk[i++] = (t & 31) << 6 | buffer[start++] & 63;\r\n else if (t > 239 && t < 365) {\r\n t = ((t & 7) << 18 | (buffer[start++] & 63) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63) - 0x10000;\r\n chunk[i++] = 0xD800 + (t >> 10);\r\n chunk[i++] = 0xDC00 + (t & 1023);\r\n } else\r\n chunk[i++] = (t & 15) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63;\r\n if (i > 8191) {\r\n (parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));\r\n i = 0;\r\n }\r\n }\r\n if (parts) {\r\n if (i)\r\n parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));\r\n return parts.join(\"\");\r\n }\r\n return String.fromCharCode.apply(String, chunk.slice(0, i));\r\n};\r\n\r\n/**\r\n * Writes a string as UTF8 bytes.\r\n * @param {string} string Source string\r\n * @param {Uint8Array} buffer Destination buffer\r\n * @param {number} offset Destination offset\r\n * @returns {number} Bytes written\r\n */\r\nutf8.write = function utf8_write(string, buffer, offset) {\r\n var start = offset,\r\n c1, // character 1\r\n c2; // character 2\r\n for (var i = 0; i < string.length; ++i) {\r\n c1 = string.charCodeAt(i);\r\n if (c1 < 128) {\r\n buffer[offset++] = c1;\r\n } else if (c1 < 2048) {\r\n buffer[offset++] = c1 >> 6 | 192;\r\n buffer[offset++] = c1 & 63 | 128;\r\n } else if ((c1 & 0xFC00) === 0xD800 && ((c2 = string.charCodeAt(i + 1)) & 0xFC00) === 0xDC00) {\r\n c1 = 0x10000 + ((c1 & 0x03FF) << 10) + (c2 & 0x03FF);\r\n ++i;\r\n buffer[offset++] = c1 >> 18 | 240;\r\n buffer[offset++] = c1 >> 12 & 63 | 128;\r\n buffer[offset++] = c1 >> 6 & 63 | 128;\r\n buffer[offset++] = c1 & 63 | 128;\r\n } else {\r\n buffer[offset++] = c1 >> 12 | 224;\r\n buffer[offset++] = c1 >> 6 & 63 | 128;\r\n buffer[offset++] = c1 & 63 | 128;\r\n }\r\n }\r\n return offset - start;\r\n};\r\n","\"use strict\";\r\nmodule.exports = common;\r\n\r\nvar commonRe = /\\/|\\./;\r\n\r\n/**\r\n * Provides common type definitions.\r\n * Can also be used to provide additional google types or your own custom types.\r\n * @param {string} name Short name as in `google/protobuf/[name].proto` or full file name\r\n * @param {Object.} json JSON definition within `google.protobuf` if a short name, otherwise the file's root definition\r\n * @returns {undefined}\r\n * @property {INamespace} google/protobuf/any.proto Any\r\n * @property {INamespace} google/protobuf/duration.proto Duration\r\n * @property {INamespace} google/protobuf/empty.proto Empty\r\n * @property {INamespace} google/protobuf/field_mask.proto FieldMask\r\n * @property {INamespace} google/protobuf/struct.proto Struct, Value, NullValue and ListValue\r\n * @property {INamespace} google/protobuf/timestamp.proto Timestamp\r\n * @property {INamespace} google/protobuf/wrappers.proto Wrappers\r\n * @example\r\n * // manually provides descriptor.proto (assumes google/protobuf/ namespace and .proto extension)\r\n * protobuf.common(\"descriptor\", descriptorJson);\r\n *\r\n * // manually provides a custom definition (uses my.foo namespace)\r\n * protobuf.common(\"my/foo/bar.proto\", myFooBarJson);\r\n */\r\nfunction common(name, json) {\r\n if (!commonRe.test(name)) {\r\n name = \"google/protobuf/\" + name + \".proto\";\r\n json = { nested: { google: { nested: { protobuf: { nested: json } } } } };\r\n }\r\n common[name] = json;\r\n}\r\n\r\n// Not provided because of limited use (feel free to discuss or to provide yourself):\r\n//\r\n// google/protobuf/descriptor.proto\r\n// google/protobuf/source_context.proto\r\n// google/protobuf/type.proto\r\n//\r\n// Stripped and pre-parsed versions of these non-bundled files are instead available as part of\r\n// the repository or package within the google/protobuf directory.\r\n\r\ncommon(\"any\", {\r\n\r\n /**\r\n * Properties of a google.protobuf.Any message.\r\n * @interface IAny\r\n * @type {Object}\r\n * @property {string} [typeUrl]\r\n * @property {Uint8Array} [bytes]\r\n * @memberof common\r\n */\r\n Any: {\r\n fields: {\r\n type_url: {\r\n type: \"string\",\r\n id: 1\r\n },\r\n value: {\r\n type: \"bytes\",\r\n id: 2\r\n }\r\n }\r\n }\r\n});\r\n\r\nvar timeType;\r\n\r\ncommon(\"duration\", {\r\n\r\n /**\r\n * Properties of a google.protobuf.Duration message.\r\n * @interface IDuration\r\n * @type {Object}\r\n * @property {number|Long} [seconds]\r\n * @property {number} [nanos]\r\n * @memberof common\r\n */\r\n Duration: timeType = {\r\n fields: {\r\n seconds: {\r\n type: \"int64\",\r\n id: 1\r\n },\r\n nanos: {\r\n type: \"int32\",\r\n id: 2\r\n }\r\n }\r\n }\r\n});\r\n\r\ncommon(\"timestamp\", {\r\n\r\n /**\r\n * Properties of a google.protobuf.Timestamp message.\r\n * @interface ITimestamp\r\n * @type {Object}\r\n * @property {number|Long} [seconds]\r\n * @property {number} [nanos]\r\n * @memberof common\r\n */\r\n Timestamp: timeType\r\n});\r\n\r\ncommon(\"empty\", {\r\n\r\n /**\r\n * Properties of a google.protobuf.Empty message.\r\n * @interface IEmpty\r\n * @memberof common\r\n */\r\n Empty: {\r\n fields: {}\r\n }\r\n});\r\n\r\ncommon(\"struct\", {\r\n\r\n /**\r\n * Properties of a google.protobuf.Struct message.\r\n * @interface IStruct\r\n * @type {Object}\r\n * @property {Object.} [fields]\r\n * @memberof common\r\n */\r\n Struct: {\r\n fields: {\r\n fields: {\r\n keyType: \"string\",\r\n type: \"Value\",\r\n id: 1\r\n }\r\n }\r\n },\r\n\r\n /**\r\n * Properties of a google.protobuf.Value message.\r\n * @interface IValue\r\n * @type {Object}\r\n * @property {string} [kind]\r\n * @property {0} [nullValue]\r\n * @property {number} [numberValue]\r\n * @property {string} [stringValue]\r\n * @property {boolean} [boolValue]\r\n * @property {IStruct} [structValue]\r\n * @property {IListValue} [listValue]\r\n * @memberof common\r\n */\r\n Value: {\r\n oneofs: {\r\n kind: {\r\n oneof: [\r\n \"nullValue\",\r\n \"numberValue\",\r\n \"stringValue\",\r\n \"boolValue\",\r\n \"structValue\",\r\n \"listValue\"\r\n ]\r\n }\r\n },\r\n fields: {\r\n nullValue: {\r\n type: \"NullValue\",\r\n id: 1\r\n },\r\n numberValue: {\r\n type: \"double\",\r\n id: 2\r\n },\r\n stringValue: {\r\n type: \"string\",\r\n id: 3\r\n },\r\n boolValue: {\r\n type: \"bool\",\r\n id: 4\r\n },\r\n structValue: {\r\n type: \"Struct\",\r\n id: 5\r\n },\r\n listValue: {\r\n type: \"ListValue\",\r\n id: 6\r\n }\r\n }\r\n },\r\n\r\n NullValue: {\r\n values: {\r\n NULL_VALUE: 0\r\n }\r\n },\r\n\r\n /**\r\n * Properties of a google.protobuf.ListValue message.\r\n * @interface IListValue\r\n * @type {Object}\r\n * @property {Array.} [values]\r\n * @memberof common\r\n */\r\n ListValue: {\r\n fields: {\r\n values: {\r\n rule: \"repeated\",\r\n type: \"Value\",\r\n id: 1\r\n }\r\n }\r\n }\r\n});\r\n\r\ncommon(\"wrappers\", {\r\n\r\n /**\r\n * Properties of a google.protobuf.DoubleValue message.\r\n * @interface IDoubleValue\r\n * @type {Object}\r\n * @property {number} [value]\r\n * @memberof common\r\n */\r\n DoubleValue: {\r\n fields: {\r\n value: {\r\n type: \"double\",\r\n id: 1\r\n }\r\n }\r\n },\r\n\r\n /**\r\n * Properties of a google.protobuf.FloatValue message.\r\n * @interface IFloatValue\r\n * @type {Object}\r\n * @property {number} [value]\r\n * @memberof common\r\n */\r\n FloatValue: {\r\n fields: {\r\n value: {\r\n type: \"float\",\r\n id: 1\r\n }\r\n }\r\n },\r\n\r\n /**\r\n * Properties of a google.protobuf.Int64Value message.\r\n * @interface IInt64Value\r\n * @type {Object}\r\n * @property {number|Long} [value]\r\n * @memberof common\r\n */\r\n Int64Value: {\r\n fields: {\r\n value: {\r\n type: \"int64\",\r\n id: 1\r\n }\r\n }\r\n },\r\n\r\n /**\r\n * Properties of a google.protobuf.UInt64Value message.\r\n * @interface IUInt64Value\r\n * @type {Object}\r\n * @property {number|Long} [value]\r\n * @memberof common\r\n */\r\n UInt64Value: {\r\n fields: {\r\n value: {\r\n type: \"uint64\",\r\n id: 1\r\n }\r\n }\r\n },\r\n\r\n /**\r\n * Properties of a google.protobuf.Int32Value message.\r\n * @interface IInt32Value\r\n * @type {Object}\r\n * @property {number} [value]\r\n * @memberof common\r\n */\r\n Int32Value: {\r\n fields: {\r\n value: {\r\n type: \"int32\",\r\n id: 1\r\n }\r\n }\r\n },\r\n\r\n /**\r\n * Properties of a google.protobuf.UInt32Value message.\r\n * @interface IUInt32Value\r\n * @type {Object}\r\n * @property {number} [value]\r\n * @memberof common\r\n */\r\n UInt32Value: {\r\n fields: {\r\n value: {\r\n type: \"uint32\",\r\n id: 1\r\n }\r\n }\r\n },\r\n\r\n /**\r\n * Properties of a google.protobuf.BoolValue message.\r\n * @interface IBoolValue\r\n * @type {Object}\r\n * @property {boolean} [value]\r\n * @memberof common\r\n */\r\n BoolValue: {\r\n fields: {\r\n value: {\r\n type: \"bool\",\r\n id: 1\r\n }\r\n }\r\n },\r\n\r\n /**\r\n * Properties of a google.protobuf.StringValue message.\r\n * @interface IStringValue\r\n * @type {Object}\r\n * @property {string} [value]\r\n * @memberof common\r\n */\r\n StringValue: {\r\n fields: {\r\n value: {\r\n type: \"string\",\r\n id: 1\r\n }\r\n }\r\n },\r\n\r\n /**\r\n * Properties of a google.protobuf.BytesValue message.\r\n * @interface IBytesValue\r\n * @type {Object}\r\n * @property {Uint8Array} [value]\r\n * @memberof common\r\n */\r\n BytesValue: {\r\n fields: {\r\n value: {\r\n type: \"bytes\",\r\n id: 1\r\n }\r\n }\r\n }\r\n});\r\n\r\ncommon(\"field_mask\", {\r\n\r\n /**\r\n * Properties of a google.protobuf.FieldMask message.\r\n * @interface IDoubleValue\r\n * @type {Object}\r\n * @property {number} [value]\r\n * @memberof common\r\n */\r\n FieldMask: {\r\n fields: {\r\n paths: {\r\n rule: \"repeated\",\r\n type: \"string\",\r\n id: 1\r\n }\r\n }\r\n }\r\n});\r\n\r\n/**\r\n * Gets the root definition of the specified common proto file.\r\n *\r\n * Bundled definitions are:\r\n * - google/protobuf/any.proto\r\n * - google/protobuf/duration.proto\r\n * - google/protobuf/empty.proto\r\n * - google/protobuf/field_mask.proto\r\n * - google/protobuf/struct.proto\r\n * - google/protobuf/timestamp.proto\r\n * - google/protobuf/wrappers.proto\r\n *\r\n * @param {string} file Proto file name\r\n * @returns {INamespace|null} Root definition or `null` if not defined\r\n */\r\ncommon.get = function get(file) {\r\n return common[file] || null;\r\n};\r\n","\"use strict\";\r\n/**\r\n * Runtime message from/to plain object converters.\r\n * @namespace\r\n */\r\nvar converter = exports;\r\n\r\nvar Enum = require(15),\r\n util = require(37);\r\n\r\n/**\r\n * Generates a partial value fromObject conveter.\r\n * @param {Codegen} gen Codegen instance\r\n * @param {Field} field Reflected field\r\n * @param {number} fieldIndex Field index\r\n * @param {string} prop Property reference\r\n * @returns {Codegen} Codegen instance\r\n * @ignore\r\n */\r\nfunction genValuePartial_fromObject(gen, field, fieldIndex, prop) {\r\n /* eslint-disable no-unexpected-multiline, block-scoped-var, no-redeclare */\r\n if (field.resolvedType) {\r\n if (field.resolvedType instanceof Enum) { gen\r\n (\"switch(d%s){\", prop);\r\n for (var values = field.resolvedType.values, keys = Object.keys(values), i = 0; i < keys.length; ++i) {\r\n if (field.repeated && values[keys[i]] === field.typeDefault) gen\r\n (\"default:\");\r\n gen\r\n (\"case%j:\", keys[i])\r\n (\"case %i:\", values[keys[i]])\r\n (\"m%s=%j\", prop, values[keys[i]])\r\n (\"break\");\r\n } gen\r\n (\"}\");\r\n } else gen\r\n (\"if(typeof d%s!==\\\"object\\\")\", prop)\r\n (\"throw TypeError(%j)\", field.fullName + \": object expected\")\r\n (\"m%s=types[%i].fromObject(d%s)\", prop, fieldIndex, prop);\r\n } else {\r\n var isUnsigned = false;\r\n switch (field.type) {\r\n case \"double\":\r\n case \"float\": gen\r\n (\"m%s=Number(d%s)\", prop, prop); // also catches \"NaN\", \"Infinity\"\r\n break;\r\n case \"uint32\":\r\n case \"fixed32\": gen\r\n (\"m%s=d%s>>>0\", prop, prop);\r\n break;\r\n case \"int32\":\r\n case \"sint32\":\r\n case \"sfixed32\": gen\r\n (\"m%s=d%s|0\", prop, prop);\r\n break;\r\n case \"uint64\":\r\n isUnsigned = true;\r\n // eslint-disable-line no-fallthrough\r\n case \"int64\":\r\n case \"sint64\":\r\n case \"fixed64\":\r\n case \"sfixed64\": gen\r\n (\"if(util.Long)\")\r\n (\"(m%s=util.Long.fromValue(d%s)).unsigned=%j\", prop, prop, isUnsigned)\r\n (\"else if(typeof d%s===\\\"string\\\")\", prop)\r\n (\"m%s=parseInt(d%s,10)\", prop, prop)\r\n (\"else if(typeof d%s===\\\"number\\\")\", prop)\r\n (\"m%s=d%s\", prop, prop)\r\n (\"else if(typeof d%s===\\\"object\\\")\", prop)\r\n (\"m%s=new util.LongBits(d%s.low>>>0,d%s.high>>>0).toNumber(%s)\", prop, prop, prop, isUnsigned ? \"true\" : \"\");\r\n break;\r\n case \"bytes\": gen\r\n (\"if(typeof d%s===\\\"string\\\")\", prop)\r\n (\"util.base64.decode(d%s,m%s=util.newBuffer(util.base64.length(d%s)),0)\", prop, prop, prop)\r\n (\"else if(d%s.length)\", prop)\r\n (\"m%s=d%s\", prop, prop);\r\n break;\r\n case \"string\": gen\r\n (\"m%s=String(d%s)\", prop, prop);\r\n break;\r\n case \"bool\": gen\r\n (\"m%s=Boolean(d%s)\", prop, prop);\r\n break;\r\n /* default: gen\r\n (\"m%s=d%s\", prop, prop);\r\n break; */\r\n }\r\n }\r\n return gen;\r\n /* eslint-enable no-unexpected-multiline, block-scoped-var, no-redeclare */\r\n}\r\n\r\n/**\r\n * Generates a plain object to runtime message converter specific to the specified message type.\r\n * @param {Type} mtype Message type\r\n * @returns {Codegen} Codegen instance\r\n */\r\nconverter.fromObject = function fromObject(mtype) {\r\n /* eslint-disable no-unexpected-multiline, block-scoped-var, no-redeclare */\r\n var fields = mtype.fieldsArray;\r\n var gen = util.codegen([\"d\"], mtype.name + \"$fromObject\")\r\n (\"if(d instanceof this.ctor)\")\r\n (\"return d\");\r\n if (!fields.length) return gen\r\n (\"return new this.ctor\");\r\n gen\r\n (\"var m=new this.ctor\");\r\n for (var i = 0; i < fields.length; ++i) {\r\n var field = fields[i].resolve(),\r\n prop = util.safeProp(field.name);\r\n\r\n // Map fields\r\n if (field.map) { gen\r\n (\"if(d%s){\", prop)\r\n (\"if(typeof d%s!==\\\"object\\\")\", prop)\r\n (\"throw TypeError(%j)\", field.fullName + \": object expected\")\r\n (\"m%s={}\", prop)\r\n (\"for(var ks=Object.keys(d%s),i=0;i>>0,m%s.high>>>0).toNumber(%s):m%s\", prop, prop, prop, prop, isUnsigned ? \"true\": \"\", prop);\r\n break;\r\n case \"bytes\": gen\r\n (\"d%s=o.bytes===String?util.base64.encode(m%s,0,m%s.length):o.bytes===Array?Array.prototype.slice.call(m%s):m%s\", prop, prop, prop, prop, prop);\r\n break;\r\n default: gen\r\n (\"d%s=m%s\", prop, prop);\r\n break;\r\n }\r\n }\r\n return gen;\r\n /* eslint-enable no-unexpected-multiline, block-scoped-var, no-redeclare */\r\n}\r\n\r\n/**\r\n * Generates a runtime message to plain object converter specific to the specified message type.\r\n * @param {Type} mtype Message type\r\n * @returns {Codegen} Codegen instance\r\n */\r\nconverter.toObject = function toObject(mtype) {\r\n /* eslint-disable no-unexpected-multiline, block-scoped-var, no-redeclare */\r\n var fields = mtype.fieldsArray.slice().sort(util.compareFieldsById);\r\n if (!fields.length)\r\n return util.codegen()(\"return {}\");\r\n var gen = util.codegen([\"m\", \"o\"], mtype.name + \"$toObject\")\r\n (\"if(!o)\")\r\n (\"o={}\")\r\n (\"var d={}\");\r\n\r\n var repeatedFields = [],\r\n mapFields = [],\r\n normalFields = [],\r\n i = 0;\r\n for (; i < fields.length; ++i)\r\n if (!fields[i].partOf)\r\n ( fields[i].resolve().repeated ? repeatedFields\r\n : fields[i].map ? mapFields\r\n : normalFields).push(fields[i]);\r\n\r\n if (repeatedFields.length) { gen\r\n (\"if(o.arrays||o.defaults){\");\r\n for (i = 0; i < repeatedFields.length; ++i) gen\r\n (\"d%s=[]\", util.safeProp(repeatedFields[i].name));\r\n gen\r\n (\"}\");\r\n }\r\n\r\n if (mapFields.length) { gen\r\n (\"if(o.objects||o.defaults){\");\r\n for (i = 0; i < mapFields.length; ++i) gen\r\n (\"d%s={}\", util.safeProp(mapFields[i].name));\r\n gen\r\n (\"}\");\r\n }\r\n\r\n if (normalFields.length) { gen\r\n (\"if(o.defaults){\");\r\n for (i = 0; i < normalFields.length; ++i) {\r\n var field = normalFields[i],\r\n prop = util.safeProp(field.name);\r\n if (field.resolvedType instanceof Enum) gen\r\n (\"d%s=o.enums===String?%j:%j\", prop, field.resolvedType.valuesById[field.typeDefault], field.typeDefault);\r\n else if (field.long) gen\r\n (\"if(util.Long){\")\r\n (\"var n=new util.Long(%i,%i,%j)\", field.typeDefault.low, field.typeDefault.high, field.typeDefault.unsigned)\r\n (\"d%s=o.longs===String?n.toString():o.longs===Number?n.toNumber():n\", prop)\r\n (\"}else\")\r\n (\"d%s=o.longs===String?%j:%i\", prop, field.typeDefault.toString(), field.typeDefault.toNumber());\r\n else if (field.bytes) {\r\n var arrayDefault = \"[\" + Array.prototype.slice.call(field.typeDefault).join(\",\") + \"]\";\r\n gen\r\n (\"if(o.bytes===String)d%s=%j\", prop, String.fromCharCode.apply(String, field.typeDefault))\r\n (\"else{\")\r\n (\"d%s=%s\", prop, arrayDefault)\r\n (\"if(o.bytes!==Array)d%s=util.newBuffer(d%s)\", prop, prop)\r\n (\"}\");\r\n } else gen\r\n (\"d%s=%j\", prop, field.typeDefault); // also messages (=null)\r\n } gen\r\n (\"}\");\r\n }\r\n var hasKs2 = false;\r\n for (i = 0; i < fields.length; ++i) {\r\n var field = fields[i],\r\n index = mtype._fieldsArray.indexOf(field),\r\n prop = util.safeProp(field.name);\r\n if (field.map) {\r\n if (!hasKs2) { hasKs2 = true; gen\r\n (\"var ks2\");\r\n } gen\r\n (\"if(m%s&&(ks2=Object.keys(m%s)).length){\", prop, prop)\r\n (\"d%s={}\", prop)\r\n (\"for(var j=0;j>>3){\");\r\n\r\n var i = 0;\r\n for (; i < /* initializes */ mtype.fieldsArray.length; ++i) {\r\n var field = mtype._fieldsArray[i].resolve(),\r\n type = field.resolvedType instanceof Enum ? \"int32\" : field.type,\r\n ref = \"m\" + util.safeProp(field.name); gen\r\n (\"case %i:\", field.id);\r\n\r\n // Map fields\r\n if (field.map) { gen\r\n (\"r.skip().pos++\") // assumes id 1 + key wireType\r\n (\"if(%s===util.emptyObject)\", ref)\r\n (\"%s={}\", ref)\r\n (\"k=r.%s()\", field.keyType)\r\n (\"r.pos++\"); // assumes id 2 + value wireType\r\n if (types.long[field.keyType] !== undefined) {\r\n if (types.basic[type] === undefined) gen\r\n (\"%s[typeof k===\\\"object\\\"?util.longToHash(k):k]=types[%i].decode(r,r.uint32())\", ref, i); // can't be groups\r\n else gen\r\n (\"%s[typeof k===\\\"object\\\"?util.longToHash(k):k]=r.%s()\", ref, type);\r\n } else {\r\n if (types.basic[type] === undefined) gen\r\n (\"%s[k]=types[%i].decode(r,r.uint32())\", ref, i); // can't be groups\r\n else gen\r\n (\"%s[k]=r.%s()\", ref, type);\r\n }\r\n\r\n // Repeated fields\r\n } else if (field.repeated) { gen\r\n\r\n (\"if(!(%s&&%s.length))\", ref, ref)\r\n (\"%s=[]\", ref);\r\n\r\n // Packable (always check for forward and backward compatiblity)\r\n if (types.packed[type] !== undefined) gen\r\n (\"if((t&7)===2){\")\r\n (\"var c2=r.uint32()+r.pos\")\r\n (\"while(r.pos>> 0, (field.id << 3 | 4) >>> 0)\r\n : gen(\"types[%i].encode(%s,w.uint32(%i).fork()).ldelim()\", fieldIndex, ref, (field.id << 3 | 2) >>> 0);\r\n}\r\n\r\n/**\r\n * Generates an encoder specific to the specified message type.\r\n * @param {Type} mtype Message type\r\n * @returns {Codegen} Codegen instance\r\n */\r\nfunction encoder(mtype) {\r\n /* eslint-disable no-unexpected-multiline, block-scoped-var, no-redeclare */\r\n var gen = util.codegen([\"m\", \"w\"], mtype.name + \"$encode\")\r\n (\"if(!w)\")\r\n (\"w=Writer.create()\");\r\n\r\n var i, ref;\r\n\r\n // \"when a message is serialized its known fields should be written sequentially by field number\"\r\n var fields = /* initializes */ mtype.fieldsArray.slice().sort(util.compareFieldsById);\r\n\r\n for (var i = 0; i < fields.length; ++i) {\r\n var field = fields[i].resolve(),\r\n index = mtype._fieldsArray.indexOf(field),\r\n type = field.resolvedType instanceof Enum ? \"int32\" : field.type,\r\n wireType = types.basic[type];\r\n ref = \"m\" + util.safeProp(field.name);\r\n\r\n // Map fields\r\n if (field.map) {\r\n gen\r\n (\"if(%s!=null&&m.hasOwnProperty(%j)){\", ref, field.name) // !== undefined && !== null\r\n (\"for(var ks=Object.keys(%s),i=0;i>> 0, 8 | types.mapKey[field.keyType], field.keyType);\r\n if (wireType === undefined) gen\r\n (\"types[%i].encode(%s[ks[i]],w.uint32(18).fork()).ldelim().ldelim()\", index, ref); // can't be groups\r\n else gen\r\n (\".uint32(%i).%s(%s[ks[i]]).ldelim()\", 16 | wireType, type, ref);\r\n gen\r\n (\"}\")\r\n (\"}\");\r\n\r\n // Repeated fields\r\n } else if (field.repeated) { gen\r\n (\"if(%s!=null&&%s.length){\", ref, ref); // !== undefined && !== null\r\n\r\n // Packed repeated\r\n if (field.packed && types.packed[type] !== undefined) { gen\r\n\r\n (\"w.uint32(%i).fork()\", (field.id << 3 | 2) >>> 0)\r\n (\"for(var i=0;i<%s.length;++i)\", ref)\r\n (\"w.%s(%s[i])\", type, ref)\r\n (\"w.ldelim()\");\r\n\r\n // Non-packed\r\n } else { gen\r\n\r\n (\"for(var i=0;i<%s.length;++i)\", ref);\r\n if (wireType === undefined)\r\n genTypePartial(gen, field, index, ref + \"[i]\");\r\n else gen\r\n (\"w.uint32(%i).%s(%s[i])\", (field.id << 3 | wireType) >>> 0, type, ref);\r\n\r\n } gen\r\n (\"}\");\r\n\r\n // Non-repeated\r\n } else {\r\n if (field.optional) gen\r\n (\"if(%s!=null&&m.hasOwnProperty(%j))\", ref, field.name); // !== undefined && !== null\r\n\r\n if (wireType === undefined)\r\n genTypePartial(gen, field, index, ref);\r\n else gen\r\n (\"w.uint32(%i).%s(%s)\", (field.id << 3 | wireType) >>> 0, type, ref);\r\n\r\n }\r\n }\r\n\r\n return gen\r\n (\"return w\");\r\n /* eslint-enable no-unexpected-multiline, block-scoped-var, no-redeclare */\r\n}","\"use strict\";\r\nmodule.exports = Enum;\r\n\r\n// extends ReflectionObject\r\nvar ReflectionObject = require(24);\r\n((Enum.prototype = Object.create(ReflectionObject.prototype)).constructor = Enum).className = \"Enum\";\r\n\r\nvar Namespace = require(23),\r\n util = require(37);\r\n\r\n/**\r\n * Constructs a new enum instance.\r\n * @classdesc Reflected enum.\r\n * @extends ReflectionObject\r\n * @constructor\r\n * @param {string} name Unique name within its namespace\r\n * @param {Object.} [values] Enum values as an object, by name\r\n * @param {Object.} [options] Declared options\r\n * @param {string} [comment] The comment for this enum\r\n * @param {Object.} [comments] The value comments for this enum\r\n */\r\nfunction Enum(name, values, options, comment, comments) {\r\n ReflectionObject.call(this, name, options);\r\n\r\n if (values && typeof values !== \"object\")\r\n throw TypeError(\"values must be an object\");\r\n\r\n /**\r\n * Enum values by id.\r\n * @type {Object.}\r\n */\r\n this.valuesById = {};\r\n\r\n /**\r\n * Enum values by name.\r\n * @type {Object.}\r\n */\r\n this.values = Object.create(this.valuesById); // toJSON, marker\r\n\r\n /**\r\n * Enum comment text.\r\n * @type {string|null}\r\n */\r\n this.comment = comment;\r\n\r\n /**\r\n * Value comment texts, if any.\r\n * @type {Object.}\r\n */\r\n this.comments = comments || {};\r\n\r\n /**\r\n * Reserved ranges, if any.\r\n * @type {Array.}\r\n */\r\n this.reserved = undefined; // toJSON\r\n\r\n // Note that values inherit valuesById on their prototype which makes them a TypeScript-\r\n // compatible enum. This is used by pbts to write actual enum definitions that work for\r\n // static and reflection code alike instead of emitting generic object definitions.\r\n\r\n if (values)\r\n for (var keys = Object.keys(values), i = 0; i < keys.length; ++i)\r\n if (typeof values[keys[i]] === \"number\") // use forward entries only\r\n this.valuesById[ this.values[keys[i]] = values[keys[i]] ] = keys[i];\r\n}\r\n\r\n/**\r\n * Enum descriptor.\r\n * @interface IEnum\r\n * @property {Object.} values Enum values\r\n * @property {Object.} [options] Enum options\r\n */\r\n\r\n/**\r\n * Constructs an enum from an enum descriptor.\r\n * @param {string} name Enum name\r\n * @param {IEnum} json Enum descriptor\r\n * @returns {Enum} Created enum\r\n * @throws {TypeError} If arguments are invalid\r\n */\r\nEnum.fromJSON = function fromJSON(name, json) {\r\n var enm = new Enum(name, json.values, json.options, json.comment, json.comments);\r\n enm.reserved = json.reserved;\r\n return enm;\r\n};\r\n\r\n/**\r\n * Converts this enum to an enum descriptor.\r\n * @param {IToJSONOptions} [toJSONOptions] JSON conversion options\r\n * @returns {IEnum} Enum descriptor\r\n */\r\nEnum.prototype.toJSON = function toJSON(toJSONOptions) {\r\n var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false;\r\n return util.toObject([\r\n \"options\" , this.options,\r\n \"values\" , this.values,\r\n \"reserved\" , this.reserved && this.reserved.length ? this.reserved : undefined,\r\n \"comment\" , keepComments ? this.comment : undefined,\r\n \"comments\" , keepComments ? this.comments : undefined\r\n ]);\r\n};\r\n\r\n/**\r\n * Adds a value to this enum.\r\n * @param {string} name Value name\r\n * @param {number} id Value id\r\n * @param {string} [comment] Comment, if any\r\n * @returns {Enum} `this`\r\n * @throws {TypeError} If arguments are invalid\r\n * @throws {Error} If there is already a value with this name or id\r\n */\r\nEnum.prototype.add = function add(name, id, comment) {\r\n // utilized by the parser but not by .fromJSON\r\n\r\n if (!util.isString(name))\r\n throw TypeError(\"name must be a string\");\r\n\r\n if (!util.isInteger(id))\r\n throw TypeError(\"id must be an integer\");\r\n\r\n if (this.values[name] !== undefined)\r\n throw Error(\"duplicate name '\" + name + \"' in \" + this);\r\n\r\n if (this.isReservedId(id))\r\n throw Error(\"id \" + id + \" is reserved in \" + this);\r\n\r\n if (this.isReservedName(name))\r\n throw Error(\"name '\" + name + \"' is reserved in \" + this);\r\n\r\n if (this.valuesById[id] !== undefined) {\r\n if (!(this.options && this.options.allow_alias))\r\n throw Error(\"duplicate id \" + id + \" in \" + this);\r\n this.values[name] = id;\r\n } else\r\n this.valuesById[this.values[name] = id] = name;\r\n\r\n this.comments[name] = comment || null;\r\n return this;\r\n};\r\n\r\n/**\r\n * Removes a value from this enum\r\n * @param {string} name Value name\r\n * @returns {Enum} `this`\r\n * @throws {TypeError} If arguments are invalid\r\n * @throws {Error} If `name` is not a name of this enum\r\n */\r\nEnum.prototype.remove = function remove(name) {\r\n\r\n if (!util.isString(name))\r\n throw TypeError(\"name must be a string\");\r\n\r\n var val = this.values[name];\r\n if (val == null)\r\n throw Error(\"name '\" + name + \"' does not exist in \" + this);\r\n\r\n delete this.valuesById[val];\r\n delete this.values[name];\r\n delete this.comments[name];\r\n\r\n return this;\r\n};\r\n\r\n/**\r\n * Tests if the specified id is reserved.\r\n * @param {number} id Id to test\r\n * @returns {boolean} `true` if reserved, otherwise `false`\r\n */\r\nEnum.prototype.isReservedId = function isReservedId(id) {\r\n return Namespace.isReservedId(this.reserved, id);\r\n};\r\n\r\n/**\r\n * Tests if the specified name is reserved.\r\n * @param {string} name Name to test\r\n * @returns {boolean} `true` if reserved, otherwise `false`\r\n */\r\nEnum.prototype.isReservedName = function isReservedName(name) {\r\n return Namespace.isReservedName(this.reserved, name);\r\n};\r\n","\"use strict\";\r\nmodule.exports = Field;\r\n\r\n// extends ReflectionObject\r\nvar ReflectionObject = require(24);\r\n((Field.prototype = Object.create(ReflectionObject.prototype)).constructor = Field).className = \"Field\";\r\n\r\nvar Enum = require(15),\r\n types = require(36),\r\n util = require(37);\r\n\r\nvar Type; // cyclic\r\n\r\nvar ruleRe = /^required|optional|repeated$/;\r\n\r\n/**\r\n * Constructs a new message field instance. Note that {@link MapField|map fields} have their own class.\r\n * @name Field\r\n * @classdesc Reflected message field.\r\n * @extends FieldBase\r\n * @constructor\r\n * @param {string} name Unique name within its namespace\r\n * @param {number} id Unique id within its namespace\r\n * @param {string} type Value type\r\n * @param {string|Object.} [rule=\"optional\"] Field rule\r\n * @param {string|Object.} [extend] Extended type if different from parent\r\n * @param {Object.} [options] Declared options\r\n */\r\n\r\n/**\r\n * Constructs a field from a field descriptor.\r\n * @param {string} name Field name\r\n * @param {IField} json Field descriptor\r\n * @returns {Field} Created field\r\n * @throws {TypeError} If arguments are invalid\r\n */\r\nField.fromJSON = function fromJSON(name, json) {\r\n return new Field(name, json.id, json.type, json.rule, json.extend, json.options, json.comment);\r\n};\r\n\r\n/**\r\n * Not an actual constructor. Use {@link Field} instead.\r\n * @classdesc Base class of all reflected message fields. This is not an actual class but here for the sake of having consistent type definitions.\r\n * @exports FieldBase\r\n * @extends ReflectionObject\r\n * @constructor\r\n * @param {string} name Unique name within its namespace\r\n * @param {number} id Unique id within its namespace\r\n * @param {string} type Value type\r\n * @param {string|Object.} [rule=\"optional\"] Field rule\r\n * @param {string|Object.} [extend] Extended type if different from parent\r\n * @param {Object.} [options] Declared options\r\n * @param {string} [comment] Comment associated with this field\r\n */\r\nfunction Field(name, id, type, rule, extend, options, comment) {\r\n\r\n if (util.isObject(rule)) {\r\n comment = extend;\r\n options = rule;\r\n rule = extend = undefined;\r\n } else if (util.isObject(extend)) {\r\n comment = options;\r\n options = extend;\r\n extend = undefined;\r\n }\r\n\r\n ReflectionObject.call(this, name, options);\r\n\r\n if (!util.isInteger(id) || id < 0)\r\n throw TypeError(\"id must be a non-negative integer\");\r\n\r\n if (!util.isString(type))\r\n throw TypeError(\"type must be a string\");\r\n\r\n if (rule !== undefined && !ruleRe.test(rule = rule.toString().toLowerCase()))\r\n throw TypeError(\"rule must be a string rule\");\r\n\r\n if (extend !== undefined && !util.isString(extend))\r\n throw TypeError(\"extend must be a string\");\r\n\r\n /**\r\n * Field rule, if any.\r\n * @type {string|undefined}\r\n */\r\n this.rule = rule && rule !== \"optional\" ? rule : undefined; // toJSON\r\n\r\n /**\r\n * Field type.\r\n * @type {string}\r\n */\r\n this.type = type; // toJSON\r\n\r\n /**\r\n * Unique field id.\r\n * @type {number}\r\n */\r\n this.id = id; // toJSON, marker\r\n\r\n /**\r\n * Extended type if different from parent.\r\n * @type {string|undefined}\r\n */\r\n this.extend = extend || undefined; // toJSON\r\n\r\n /**\r\n * Whether this field is required.\r\n * @type {boolean}\r\n */\r\n this.required = rule === \"required\";\r\n\r\n /**\r\n * Whether this field is optional.\r\n * @type {boolean}\r\n */\r\n this.optional = !this.required;\r\n\r\n /**\r\n * Whether this field is repeated.\r\n * @type {boolean}\r\n */\r\n this.repeated = rule === \"repeated\";\r\n\r\n /**\r\n * Whether this field is a map or not.\r\n * @type {boolean}\r\n */\r\n this.map = false;\r\n\r\n /**\r\n * Message this field belongs to.\r\n * @type {Type|null}\r\n */\r\n this.message = null;\r\n\r\n /**\r\n * OneOf this field belongs to, if any,\r\n * @type {OneOf|null}\r\n */\r\n this.partOf = null;\r\n\r\n /**\r\n * The field type's default value.\r\n * @type {*}\r\n */\r\n this.typeDefault = null;\r\n\r\n /**\r\n * The field's default value on prototypes.\r\n * @type {*}\r\n */\r\n this.defaultValue = null;\r\n\r\n /**\r\n * Whether this field's value should be treated as a long.\r\n * @type {boolean}\r\n */\r\n this.long = util.Long ? types.long[type] !== undefined : /* istanbul ignore next */ false;\r\n\r\n /**\r\n * Whether this field's value is a buffer.\r\n * @type {boolean}\r\n */\r\n this.bytes = type === \"bytes\";\r\n\r\n /**\r\n * Resolved type if not a basic type.\r\n * @type {Type|Enum|null}\r\n */\r\n this.resolvedType = null;\r\n\r\n /**\r\n * Sister-field within the extended type if a declaring extension field.\r\n * @type {Field|null}\r\n */\r\n this.extensionField = null;\r\n\r\n /**\r\n * Sister-field within the declaring namespace if an extended field.\r\n * @type {Field|null}\r\n */\r\n this.declaringField = null;\r\n\r\n /**\r\n * Internally remembers whether this field is packed.\r\n * @type {boolean|null}\r\n * @private\r\n */\r\n this._packed = null;\r\n\r\n /**\r\n * Comment for this field.\r\n * @type {string|null}\r\n */\r\n this.comment = comment;\r\n}\r\n\r\n/**\r\n * Determines whether this field is packed. Only relevant when repeated and working with proto2.\r\n * @name Field#packed\r\n * @type {boolean}\r\n * @readonly\r\n */\r\nObject.defineProperty(Field.prototype, \"packed\", {\r\n get: function() {\r\n // defaults to packed=true if not explicity set to false\r\n if (this._packed === null)\r\n this._packed = this.getOption(\"packed\") !== false;\r\n return this._packed;\r\n }\r\n});\r\n\r\n/**\r\n * @override\r\n */\r\nField.prototype.setOption = function setOption(name, value, ifNotSet) {\r\n if (name === \"packed\") // clear cached before setting\r\n this._packed = null;\r\n return ReflectionObject.prototype.setOption.call(this, name, value, ifNotSet);\r\n};\r\n\r\n/**\r\n * Field descriptor.\r\n * @interface IField\r\n * @property {string} [rule=\"optional\"] Field rule\r\n * @property {string} type Field type\r\n * @property {number} id Field id\r\n * @property {Object.} [options] Field options\r\n */\r\n\r\n/**\r\n * Extension field descriptor.\r\n * @interface IExtensionField\r\n * @extends IField\r\n * @property {string} extend Extended type\r\n */\r\n\r\n/**\r\n * Converts this field to a field descriptor.\r\n * @param {IToJSONOptions} [toJSONOptions] JSON conversion options\r\n * @returns {IField} Field descriptor\r\n */\r\nField.prototype.toJSON = function toJSON(toJSONOptions) {\r\n var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false;\r\n return util.toObject([\r\n \"rule\" , this.rule !== \"optional\" && this.rule || undefined,\r\n \"type\" , this.type,\r\n \"id\" , this.id,\r\n \"extend\" , this.extend,\r\n \"options\" , this.options,\r\n \"comment\" , keepComments ? this.comment : undefined\r\n ]);\r\n};\r\n\r\n/**\r\n * Resolves this field's type references.\r\n * @returns {Field} `this`\r\n * @throws {Error} If any reference cannot be resolved\r\n */\r\nField.prototype.resolve = function resolve() {\r\n\r\n if (this.resolved)\r\n return this;\r\n\r\n if ((this.typeDefault = types.defaults[this.type]) === undefined) { // if not a basic type, resolve it\r\n this.resolvedType = (this.declaringField ? this.declaringField.parent : this.parent).lookupTypeOrEnum(this.type);\r\n if (this.resolvedType instanceof Type)\r\n this.typeDefault = null;\r\n else // instanceof Enum\r\n this.typeDefault = this.resolvedType.values[Object.keys(this.resolvedType.values)[0]]; // first defined\r\n }\r\n\r\n // use explicitly set default value if present\r\n if (this.options && this.options[\"default\"] != null) {\r\n this.typeDefault = this.options[\"default\"];\r\n if (this.resolvedType instanceof Enum && typeof this.typeDefault === \"string\")\r\n this.typeDefault = this.resolvedType.values[this.typeDefault];\r\n }\r\n\r\n // remove unnecessary options\r\n if (this.options) {\r\n if (this.options.packed === true || this.options.packed !== undefined && this.resolvedType && !(this.resolvedType instanceof Enum))\r\n delete this.options.packed;\r\n if (!Object.keys(this.options).length)\r\n this.options = undefined;\r\n }\r\n\r\n // convert to internal data type if necesssary\r\n if (this.long) {\r\n this.typeDefault = util.Long.fromNumber(this.typeDefault, this.type.charAt(0) === \"u\");\r\n\r\n /* istanbul ignore else */\r\n if (Object.freeze)\r\n Object.freeze(this.typeDefault); // long instances are meant to be immutable anyway (i.e. use small int cache that even requires it)\r\n\r\n } else if (this.bytes && typeof this.typeDefault === \"string\") {\r\n var buf;\r\n if (util.base64.test(this.typeDefault))\r\n util.base64.decode(this.typeDefault, buf = util.newBuffer(util.base64.length(this.typeDefault)), 0);\r\n else\r\n util.utf8.write(this.typeDefault, buf = util.newBuffer(util.utf8.length(this.typeDefault)), 0);\r\n this.typeDefault = buf;\r\n }\r\n\r\n // take special care of maps and repeated fields\r\n if (this.map)\r\n this.defaultValue = util.emptyObject;\r\n else if (this.repeated)\r\n this.defaultValue = util.emptyArray;\r\n else\r\n this.defaultValue = this.typeDefault;\r\n\r\n // ensure proper value on prototype\r\n if (this.parent instanceof Type)\r\n this.parent.ctor.prototype[this.name] = this.defaultValue;\r\n\r\n return ReflectionObject.prototype.resolve.call(this);\r\n};\r\n\r\n/**\r\n * Decorator function as returned by {@link Field.d} and {@link MapField.d} (TypeScript).\r\n * @typedef FieldDecorator\r\n * @type {function}\r\n * @param {Object} prototype Target prototype\r\n * @param {string} fieldName Field name\r\n * @returns {undefined}\r\n */\r\n\r\n/**\r\n * Field decorator (TypeScript).\r\n * @name Field.d\r\n * @function\r\n * @param {number} fieldId Field id\r\n * @param {\"double\"|\"float\"|\"int32\"|\"uint32\"|\"sint32\"|\"fixed32\"|\"sfixed32\"|\"int64\"|\"uint64\"|\"sint64\"|\"fixed64\"|\"sfixed64\"|\"string\"|\"bool\"|\"bytes\"|Object} fieldType Field type\r\n * @param {\"optional\"|\"required\"|\"repeated\"} [fieldRule=\"optional\"] Field rule\r\n * @param {T} [defaultValue] Default value\r\n * @returns {FieldDecorator} Decorator function\r\n * @template T extends number | number[] | Long | Long[] | string | string[] | boolean | boolean[] | Uint8Array | Uint8Array[] | Buffer | Buffer[]\r\n */\r\nField.d = function decorateField(fieldId, fieldType, fieldRule, defaultValue) {\r\n\r\n // submessage: decorate the submessage and use its name as the type\r\n if (typeof fieldType === \"function\")\r\n fieldType = util.decorateType(fieldType).name;\r\n\r\n // enum reference: create a reflected copy of the enum and keep reuseing it\r\n else if (fieldType && typeof fieldType === \"object\")\r\n fieldType = util.decorateEnum(fieldType).name;\r\n\r\n return function fieldDecorator(prototype, fieldName) {\r\n util.decorateType(prototype.constructor)\r\n .add(new Field(fieldName, fieldId, fieldType, fieldRule, { \"default\": defaultValue }));\r\n };\r\n};\r\n\r\n/**\r\n * Field decorator (TypeScript).\r\n * @name Field.d\r\n * @function\r\n * @param {number} fieldId Field id\r\n * @param {Constructor|string} fieldType Field type\r\n * @param {\"optional\"|\"required\"|\"repeated\"} [fieldRule=\"optional\"] Field rule\r\n * @returns {FieldDecorator} Decorator function\r\n * @template T extends Message\r\n * @variation 2\r\n */\r\n// like Field.d but without a default value\r\n\r\n// Sets up cyclic dependencies (called in index-light)\r\nField._configure = function configure(Type_) {\r\n Type = Type_;\r\n};\r\n","\"use strict\";\r\nvar protobuf = module.exports = require(18);\r\n\r\nprotobuf.build = \"light\";\r\n\r\n/**\r\n * A node-style callback as used by {@link load} and {@link Root#load}.\r\n * @typedef LoadCallback\r\n * @type {function}\r\n * @param {Error|null} error Error, if any, otherwise `null`\r\n * @param {Root} [root] Root, if there hasn't been an error\r\n * @returns {undefined}\r\n */\r\n\r\n/**\r\n * Loads one or multiple .proto or preprocessed .json files into a common root namespace and calls the callback.\r\n * @param {string|string[]} filename One or multiple files to load\r\n * @param {Root} root Root namespace, defaults to create a new one if omitted.\r\n * @param {LoadCallback} callback Callback function\r\n * @returns {undefined}\r\n * @see {@link Root#load}\r\n */\r\nfunction load(filename, root, callback) {\r\n if (typeof root === \"function\") {\r\n callback = root;\r\n root = new protobuf.Root();\r\n } else if (!root)\r\n root = new protobuf.Root();\r\n return root.load(filename, callback);\r\n}\r\n\r\n/**\r\n * Loads one or multiple .proto or preprocessed .json files into a common root namespace and calls the callback.\r\n * @name load\r\n * @function\r\n * @param {string|string[]} filename One or multiple files to load\r\n * @param {LoadCallback} callback Callback function\r\n * @returns {undefined}\r\n * @see {@link Root#load}\r\n * @variation 2\r\n */\r\n// function load(filename:string, callback:LoadCallback):undefined\r\n\r\n/**\r\n * Loads one or multiple .proto or preprocessed .json files into a common root namespace and returns a promise.\r\n * @name load\r\n * @function\r\n * @param {string|string[]} filename One or multiple files to load\r\n * @param {Root} [root] Root namespace, defaults to create a new one if omitted.\r\n * @returns {Promise} Promise\r\n * @see {@link Root#load}\r\n * @variation 3\r\n */\r\n// function load(filename:string, [root:Root]):Promise\r\n\r\nprotobuf.load = load;\r\n\r\n/**\r\n * Synchronously loads one or multiple .proto or preprocessed .json files into a common root namespace (node only).\r\n * @param {string|string[]} filename One or multiple files to load\r\n * @param {Root} [root] Root namespace, defaults to create a new one if omitted.\r\n * @returns {Root} Root namespace\r\n * @throws {Error} If synchronous fetching is not supported (i.e. in browsers) or if a file's syntax is invalid\r\n * @see {@link Root#loadSync}\r\n */\r\nfunction loadSync(filename, root) {\r\n if (!root)\r\n root = new protobuf.Root();\r\n return root.loadSync(filename);\r\n}\r\n\r\nprotobuf.loadSync = loadSync;\r\n\r\n// Serialization\r\nprotobuf.encoder = require(14);\r\nprotobuf.decoder = require(13);\r\nprotobuf.verifier = require(40);\r\nprotobuf.converter = require(12);\r\n\r\n// Reflection\r\nprotobuf.ReflectionObject = require(24);\r\nprotobuf.Namespace = require(23);\r\nprotobuf.Root = require(29);\r\nprotobuf.Enum = require(15);\r\nprotobuf.Type = require(35);\r\nprotobuf.Field = require(16);\r\nprotobuf.OneOf = require(25);\r\nprotobuf.MapField = require(20);\r\nprotobuf.Service = require(33);\r\nprotobuf.Method = require(22);\r\n\r\n// Runtime\r\nprotobuf.Message = require(21);\r\nprotobuf.wrappers = require(41);\r\n\r\n// Utility\r\nprotobuf.types = require(36);\r\nprotobuf.util = require(37);\r\n\r\n// Set up possibly cyclic reflection dependencies\r\nprotobuf.ReflectionObject._configure(protobuf.Root);\r\nprotobuf.Namespace._configure(protobuf.Type, protobuf.Service, protobuf.Enum);\r\nprotobuf.Root._configure(protobuf.Type);\r\nprotobuf.Field._configure(protobuf.Type);\r\n","\"use strict\";\r\nvar protobuf = exports;\r\n\r\n/**\r\n * Build type, one of `\"full\"`, `\"light\"` or `\"minimal\"`.\r\n * @name build\r\n * @type {string}\r\n * @const\r\n */\r\nprotobuf.build = \"minimal\";\r\n\r\n// Serialization\r\nprotobuf.Writer = require(42);\r\nprotobuf.BufferWriter = require(43);\r\nprotobuf.Reader = require(27);\r\nprotobuf.BufferReader = require(28);\r\n\r\n// Utility\r\nprotobuf.util = require(39);\r\nprotobuf.rpc = require(31);\r\nprotobuf.roots = require(30);\r\nprotobuf.configure = configure;\r\n\r\n/* istanbul ignore next */\r\n/**\r\n * Reconfigures the library according to the environment.\r\n * @returns {undefined}\r\n */\r\nfunction configure() {\r\n protobuf.Reader._configure(protobuf.BufferReader);\r\n protobuf.util._configure();\r\n}\r\n\r\n// Set up buffer utility according to the environment\r\nprotobuf.Writer._configure(protobuf.BufferWriter);\r\nconfigure();\r\n","\"use strict\";\r\nvar protobuf = module.exports = require(17);\r\n\r\nprotobuf.build = \"full\";\r\n\r\n// Parser\r\nprotobuf.tokenize = require(34);\r\nprotobuf.parse = require(26);\r\nprotobuf.common = require(11);\r\n\r\n// Configure parser\r\nprotobuf.Root._configure(protobuf.Type, protobuf.parse, protobuf.common);\r\n","\"use strict\";\r\nmodule.exports = MapField;\r\n\r\n// extends Field\r\nvar Field = require(16);\r\n((MapField.prototype = Object.create(Field.prototype)).constructor = MapField).className = \"MapField\";\r\n\r\nvar types = require(36),\r\n util = require(37);\r\n\r\n/**\r\n * Constructs a new map field instance.\r\n * @classdesc Reflected map field.\r\n * @extends FieldBase\r\n * @constructor\r\n * @param {string} name Unique name within its namespace\r\n * @param {number} id Unique id within its namespace\r\n * @param {string} keyType Key type\r\n * @param {string} type Value type\r\n * @param {Object.} [options] Declared options\r\n * @param {string} [comment] Comment associated with this field\r\n */\r\nfunction MapField(name, id, keyType, type, options, comment) {\r\n Field.call(this, name, id, type, undefined, undefined, options, comment);\r\n\r\n /* istanbul ignore if */\r\n if (!util.isString(keyType))\r\n throw TypeError(\"keyType must be a string\");\r\n\r\n /**\r\n * Key type.\r\n * @type {string}\r\n */\r\n this.keyType = keyType; // toJSON, marker\r\n\r\n /**\r\n * Resolved key type if not a basic type.\r\n * @type {ReflectionObject|null}\r\n */\r\n this.resolvedKeyType = null;\r\n\r\n // Overrides Field#map\r\n this.map = true;\r\n}\r\n\r\n/**\r\n * Map field descriptor.\r\n * @interface IMapField\r\n * @extends {IField}\r\n * @property {string} keyType Key type\r\n */\r\n\r\n/**\r\n * Extension map field descriptor.\r\n * @interface IExtensionMapField\r\n * @extends IMapField\r\n * @property {string} extend Extended type\r\n */\r\n\r\n/**\r\n * Constructs a map field from a map field descriptor.\r\n * @param {string} name Field name\r\n * @param {IMapField} json Map field descriptor\r\n * @returns {MapField} Created map field\r\n * @throws {TypeError} If arguments are invalid\r\n */\r\nMapField.fromJSON = function fromJSON(name, json) {\r\n return new MapField(name, json.id, json.keyType, json.type, json.options, json.comment);\r\n};\r\n\r\n/**\r\n * Converts this map field to a map field descriptor.\r\n * @param {IToJSONOptions} [toJSONOptions] JSON conversion options\r\n * @returns {IMapField} Map field descriptor\r\n */\r\nMapField.prototype.toJSON = function toJSON(toJSONOptions) {\r\n var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false;\r\n return util.toObject([\r\n \"keyType\" , this.keyType,\r\n \"type\" , this.type,\r\n \"id\" , this.id,\r\n \"extend\" , this.extend,\r\n \"options\" , this.options,\r\n \"comment\" , keepComments ? this.comment : undefined\r\n ]);\r\n};\r\n\r\n/**\r\n * @override\r\n */\r\nMapField.prototype.resolve = function resolve() {\r\n if (this.resolved)\r\n return this;\r\n\r\n // Besides a value type, map fields have a key type that may be \"any scalar type except for floating point types and bytes\"\r\n if (types.mapKey[this.keyType] === undefined)\r\n throw Error(\"invalid key type: \" + this.keyType);\r\n\r\n return Field.prototype.resolve.call(this);\r\n};\r\n\r\n/**\r\n * Map field decorator (TypeScript).\r\n * @name MapField.d\r\n * @function\r\n * @param {number} fieldId Field id\r\n * @param {\"int32\"|\"uint32\"|\"sint32\"|\"fixed32\"|\"sfixed32\"|\"int64\"|\"uint64\"|\"sint64\"|\"fixed64\"|\"sfixed64\"|\"bool\"|\"string\"} fieldKeyType Field key type\r\n * @param {\"double\"|\"float\"|\"int32\"|\"uint32\"|\"sint32\"|\"fixed32\"|\"sfixed32\"|\"int64\"|\"uint64\"|\"sint64\"|\"fixed64\"|\"sfixed64\"|\"bool\"|\"string\"|\"bytes\"|Object|Constructor<{}>} fieldValueType Field value type\r\n * @returns {FieldDecorator} Decorator function\r\n * @template T extends { [key: string]: number | Long | string | boolean | Uint8Array | Buffer | number[] | Message<{}> }\r\n */\r\nMapField.d = function decorateMapField(fieldId, fieldKeyType, fieldValueType) {\r\n\r\n // submessage value: decorate the submessage and use its name as the type\r\n if (typeof fieldValueType === \"function\")\r\n fieldValueType = util.decorateType(fieldValueType).name;\r\n\r\n // enum reference value: create a reflected copy of the enum and keep reuseing it\r\n else if (fieldValueType && typeof fieldValueType === \"object\")\r\n fieldValueType = util.decorateEnum(fieldValueType).name;\r\n\r\n return function mapFieldDecorator(prototype, fieldName) {\r\n util.decorateType(prototype.constructor)\r\n .add(new MapField(fieldName, fieldId, fieldKeyType, fieldValueType));\r\n };\r\n};\r\n","\"use strict\";\r\nmodule.exports = Message;\r\n\r\nvar util = require(39);\r\n\r\n/**\r\n * Constructs a new message instance.\r\n * @classdesc Abstract runtime message.\r\n * @constructor\r\n * @param {Properties} [properties] Properties to set\r\n * @template T extends object = object\r\n */\r\nfunction Message(properties) {\r\n // not used internally\r\n if (properties)\r\n for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)\r\n this[keys[i]] = properties[keys[i]];\r\n}\r\n\r\n/**\r\n * Reference to the reflected type.\r\n * @name Message.$type\r\n * @type {Type}\r\n * @readonly\r\n */\r\n\r\n/**\r\n * Reference to the reflected type.\r\n * @name Message#$type\r\n * @type {Type}\r\n * @readonly\r\n */\r\n\r\n/*eslint-disable valid-jsdoc*/\r\n\r\n/**\r\n * Creates a new message of this type using the specified properties.\r\n * @param {Object.} [properties] Properties to set\r\n * @returns {Message} Message instance\r\n * @template T extends Message\r\n * @this Constructor\r\n */\r\nMessage.create = function create(properties) {\r\n return this.$type.create(properties);\r\n};\r\n\r\n/**\r\n * Encodes a message of this type.\r\n * @param {T|Object.} message Message to encode\r\n * @param {Writer} [writer] Writer to use\r\n * @returns {Writer} Writer\r\n * @template T extends Message\r\n * @this Constructor\r\n */\r\nMessage.encode = function encode(message, writer) {\r\n return this.$type.encode(message, writer);\r\n};\r\n\r\n/**\r\n * Encodes a message of this type preceeded by its length as a varint.\r\n * @param {T|Object.} message Message to encode\r\n * @param {Writer} [writer] Writer to use\r\n * @returns {Writer} Writer\r\n * @template T extends Message\r\n * @this Constructor\r\n */\r\nMessage.encodeDelimited = function encodeDelimited(message, writer) {\r\n return this.$type.encodeDelimited(message, writer);\r\n};\r\n\r\n/**\r\n * Decodes a message of this type.\r\n * @name Message.decode\r\n * @function\r\n * @param {Reader|Uint8Array} reader Reader or buffer to decode\r\n * @returns {T} Decoded message\r\n * @template T extends Message\r\n * @this Constructor\r\n */\r\nMessage.decode = function decode(reader) {\r\n return this.$type.decode(reader);\r\n};\r\n\r\n/**\r\n * Decodes a message of this type preceeded by its length as a varint.\r\n * @name Message.decodeDelimited\r\n * @function\r\n * @param {Reader|Uint8Array} reader Reader or buffer to decode\r\n * @returns {T} Decoded message\r\n * @template T extends Message\r\n * @this Constructor\r\n */\r\nMessage.decodeDelimited = function decodeDelimited(reader) {\r\n return this.$type.decodeDelimited(reader);\r\n};\r\n\r\n/**\r\n * Verifies a message of this type.\r\n * @name Message.verify\r\n * @function\r\n * @param {Object.} message Plain object to verify\r\n * @returns {string|null} `null` if valid, otherwise the reason why it is not\r\n */\r\nMessage.verify = function verify(message) {\r\n return this.$type.verify(message);\r\n};\r\n\r\n/**\r\n * Creates a new message of this type from a plain object. Also converts values to their respective internal types.\r\n * @param {Object.} object Plain object\r\n * @returns {T} Message instance\r\n * @template T extends Message\r\n * @this Constructor\r\n */\r\nMessage.fromObject = function fromObject(object) {\r\n return this.$type.fromObject(object);\r\n};\r\n\r\n/**\r\n * Creates a plain object from a message of this type. Also converts values to other types if specified.\r\n * @param {T} message Message instance\r\n * @param {IConversionOptions} [options] Conversion options\r\n * @returns {Object.} Plain object\r\n * @template T extends Message\r\n * @this Constructor\r\n */\r\nMessage.toObject = function toObject(message, options) {\r\n return this.$type.toObject(message, options);\r\n};\r\n\r\n/**\r\n * Converts this message to JSON.\r\n * @returns {Object.} JSON object\r\n */\r\nMessage.prototype.toJSON = function toJSON() {\r\n return this.$type.toObject(this, util.toJSONOptions);\r\n};\r\n\r\n/*eslint-enable valid-jsdoc*/","\"use strict\";\r\nmodule.exports = Method;\r\n\r\n// extends ReflectionObject\r\nvar ReflectionObject = require(24);\r\n((Method.prototype = Object.create(ReflectionObject.prototype)).constructor = Method).className = \"Method\";\r\n\r\nvar util = require(37);\r\n\r\n/**\r\n * Constructs a new service method instance.\r\n * @classdesc Reflected service method.\r\n * @extends ReflectionObject\r\n * @constructor\r\n * @param {string} name Method name\r\n * @param {string|undefined} type Method type, usually `\"rpc\"`\r\n * @param {string} requestType Request message type\r\n * @param {string} responseType Response message type\r\n * @param {boolean|Object.} [requestStream] Whether the request is streamed\r\n * @param {boolean|Object.} [responseStream] Whether the response is streamed\r\n * @param {Object.} [options] Declared options\r\n * @param {string} [comment] The comment for this method\r\n */\r\nfunction Method(name, type, requestType, responseType, requestStream, responseStream, options, comment) {\r\n\r\n /* istanbul ignore next */\r\n if (util.isObject(requestStream)) {\r\n options = requestStream;\r\n requestStream = responseStream = undefined;\r\n } else if (util.isObject(responseStream)) {\r\n options = responseStream;\r\n responseStream = undefined;\r\n }\r\n\r\n /* istanbul ignore if */\r\n if (!(type === undefined || util.isString(type)))\r\n throw TypeError(\"type must be a string\");\r\n\r\n /* istanbul ignore if */\r\n if (!util.isString(requestType))\r\n throw TypeError(\"requestType must be a string\");\r\n\r\n /* istanbul ignore if */\r\n if (!util.isString(responseType))\r\n throw TypeError(\"responseType must be a string\");\r\n\r\n ReflectionObject.call(this, name, options);\r\n\r\n /**\r\n * Method type.\r\n * @type {string}\r\n */\r\n this.type = type || \"rpc\"; // toJSON\r\n\r\n /**\r\n * Request type.\r\n * @type {string}\r\n */\r\n this.requestType = requestType; // toJSON, marker\r\n\r\n /**\r\n * Whether requests are streamed or not.\r\n * @type {boolean|undefined}\r\n */\r\n this.requestStream = requestStream ? true : undefined; // toJSON\r\n\r\n /**\r\n * Response type.\r\n * @type {string}\r\n */\r\n this.responseType = responseType; // toJSON\r\n\r\n /**\r\n * Whether responses are streamed or not.\r\n * @type {boolean|undefined}\r\n */\r\n this.responseStream = responseStream ? true : undefined; // toJSON\r\n\r\n /**\r\n * Resolved request type.\r\n * @type {Type|null}\r\n */\r\n this.resolvedRequestType = null;\r\n\r\n /**\r\n * Resolved response type.\r\n * @type {Type|null}\r\n */\r\n this.resolvedResponseType = null;\r\n\r\n /**\r\n * Comment for this method\r\n * @type {string|null}\r\n */\r\n this.comment = comment;\r\n}\r\n\r\n/**\r\n * Method descriptor.\r\n * @interface IMethod\r\n * @property {string} [type=\"rpc\"] Method type\r\n * @property {string} requestType Request type\r\n * @property {string} responseType Response type\r\n * @property {boolean} [requestStream=false] Whether requests are streamed\r\n * @property {boolean} [responseStream=false] Whether responses are streamed\r\n * @property {Object.} [options] Method options\r\n */\r\n\r\n/**\r\n * Constructs a method from a method descriptor.\r\n * @param {string} name Method name\r\n * @param {IMethod} json Method descriptor\r\n * @returns {Method} Created method\r\n * @throws {TypeError} If arguments are invalid\r\n */\r\nMethod.fromJSON = function fromJSON(name, json) {\r\n return new Method(name, json.type, json.requestType, json.responseType, json.requestStream, json.responseStream, json.options, json.comment);\r\n};\r\n\r\n/**\r\n * Converts this method to a method descriptor.\r\n * @param {IToJSONOptions} [toJSONOptions] JSON conversion options\r\n * @returns {IMethod} Method descriptor\r\n */\r\nMethod.prototype.toJSON = function toJSON(toJSONOptions) {\r\n var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false;\r\n return util.toObject([\r\n \"type\" , this.type !== \"rpc\" && /* istanbul ignore next */ this.type || undefined,\r\n \"requestType\" , this.requestType,\r\n \"requestStream\" , this.requestStream,\r\n \"responseType\" , this.responseType,\r\n \"responseStream\" , this.responseStream,\r\n \"options\" , this.options,\r\n \"comment\" , keepComments ? this.comment : undefined\r\n ]);\r\n};\r\n\r\n/**\r\n * @override\r\n */\r\nMethod.prototype.resolve = function resolve() {\r\n\r\n /* istanbul ignore if */\r\n if (this.resolved)\r\n return this;\r\n\r\n this.resolvedRequestType = this.parent.lookupType(this.requestType);\r\n this.resolvedResponseType = this.parent.lookupType(this.responseType);\r\n\r\n return ReflectionObject.prototype.resolve.call(this);\r\n};\r\n","\"use strict\";\r\nmodule.exports = Namespace;\r\n\r\n// extends ReflectionObject\r\nvar ReflectionObject = require(24);\r\n((Namespace.prototype = Object.create(ReflectionObject.prototype)).constructor = Namespace).className = \"Namespace\";\r\n\r\nvar Field = require(16),\r\n util = require(37);\r\n\r\nvar Type, // cyclic\r\n Service,\r\n Enum;\r\n\r\n/**\r\n * Constructs a new namespace instance.\r\n * @name Namespace\r\n * @classdesc Reflected namespace.\r\n * @extends NamespaceBase\r\n * @constructor\r\n * @param {string} name Namespace name\r\n * @param {Object.} [options] Declared options\r\n */\r\n\r\n/**\r\n * Constructs a namespace from JSON.\r\n * @memberof Namespace\r\n * @function\r\n * @param {string} name Namespace name\r\n * @param {Object.} json JSON object\r\n * @returns {Namespace} Created namespace\r\n * @throws {TypeError} If arguments are invalid\r\n */\r\nNamespace.fromJSON = function fromJSON(name, json) {\r\n return new Namespace(name, json.options).addJSON(json.nested);\r\n};\r\n\r\n/**\r\n * Converts an array of reflection objects to JSON.\r\n * @memberof Namespace\r\n * @param {ReflectionObject[]} array Object array\r\n * @param {IToJSONOptions} [toJSONOptions] JSON conversion options\r\n * @returns {Object.|undefined} JSON object or `undefined` when array is empty\r\n */\r\nfunction arrayToJSON(array, toJSONOptions) {\r\n if (!(array && array.length))\r\n return undefined;\r\n var obj = {};\r\n for (var i = 0; i < array.length; ++i)\r\n obj[array[i].name] = array[i].toJSON(toJSONOptions);\r\n return obj;\r\n}\r\n\r\nNamespace.arrayToJSON = arrayToJSON;\r\n\r\n/**\r\n * Tests if the specified id is reserved.\r\n * @param {Array.|undefined} reserved Array of reserved ranges and names\r\n * @param {number} id Id to test\r\n * @returns {boolean} `true` if reserved, otherwise `false`\r\n */\r\nNamespace.isReservedId = function isReservedId(reserved, id) {\r\n if (reserved)\r\n for (var i = 0; i < reserved.length; ++i)\r\n if (typeof reserved[i] !== \"string\" && reserved[i][0] <= id && reserved[i][1] >= id)\r\n return true;\r\n return false;\r\n};\r\n\r\n/**\r\n * Tests if the specified name is reserved.\r\n * @param {Array.|undefined} reserved Array of reserved ranges and names\r\n * @param {string} name Name to test\r\n * @returns {boolean} `true` if reserved, otherwise `false`\r\n */\r\nNamespace.isReservedName = function isReservedName(reserved, name) {\r\n if (reserved)\r\n for (var i = 0; i < reserved.length; ++i)\r\n if (reserved[i] === name)\r\n return true;\r\n return false;\r\n};\r\n\r\n/**\r\n * Not an actual constructor. Use {@link Namespace} instead.\r\n * @classdesc Base class of all reflection objects containing nested objects. This is not an actual class but here for the sake of having consistent type definitions.\r\n * @exports NamespaceBase\r\n * @extends ReflectionObject\r\n * @abstract\r\n * @constructor\r\n * @param {string} name Namespace name\r\n * @param {Object.} [options] Declared options\r\n * @see {@link Namespace}\r\n */\r\nfunction Namespace(name, options) {\r\n ReflectionObject.call(this, name, options);\r\n\r\n /**\r\n * Nested objects by name.\r\n * @type {Object.|undefined}\r\n */\r\n this.nested = undefined; // toJSON\r\n\r\n /**\r\n * Cached nested objects as an array.\r\n * @type {ReflectionObject[]|null}\r\n * @private\r\n */\r\n this._nestedArray = null;\r\n}\r\n\r\nfunction clearCache(namespace) {\r\n namespace._nestedArray = null;\r\n return namespace;\r\n}\r\n\r\n/**\r\n * Nested objects of this namespace as an array for iteration.\r\n * @name NamespaceBase#nestedArray\r\n * @type {ReflectionObject[]}\r\n * @readonly\r\n */\r\nObject.defineProperty(Namespace.prototype, \"nestedArray\", {\r\n get: function() {\r\n return this._nestedArray || (this._nestedArray = util.toArray(this.nested));\r\n }\r\n});\r\n\r\n/**\r\n * Namespace descriptor.\r\n * @interface INamespace\r\n * @property {Object.} [options] Namespace options\r\n * @property {Object.} [nested] Nested object descriptors\r\n */\r\n\r\n/**\r\n * Any extension field descriptor.\r\n * @typedef AnyExtensionField\r\n * @type {IExtensionField|IExtensionMapField}\r\n */\r\n\r\n/**\r\n * Any nested object descriptor.\r\n * @typedef AnyNestedObject\r\n * @type {IEnum|IType|IService|AnyExtensionField|INamespace}\r\n */\r\n// ^ BEWARE: VSCode hangs forever when using more than 5 types (that's why AnyExtensionField exists in the first place)\r\n\r\n/**\r\n * Converts this namespace to a namespace descriptor.\r\n * @param {IToJSONOptions} [toJSONOptions] JSON conversion options\r\n * @returns {INamespace} Namespace descriptor\r\n */\r\nNamespace.prototype.toJSON = function toJSON(toJSONOptions) {\r\n return util.toObject([\r\n \"options\" , this.options,\r\n \"nested\" , arrayToJSON(this.nestedArray, toJSONOptions)\r\n ]);\r\n};\r\n\r\n/**\r\n * Adds nested objects to this namespace from nested object descriptors.\r\n * @param {Object.} nestedJson Any nested object descriptors\r\n * @returns {Namespace} `this`\r\n */\r\nNamespace.prototype.addJSON = function addJSON(nestedJson) {\r\n var ns = this;\r\n /* istanbul ignore else */\r\n if (nestedJson) {\r\n for (var names = Object.keys(nestedJson), i = 0, nested; i < names.length; ++i) {\r\n nested = nestedJson[names[i]];\r\n ns.add( // most to least likely\r\n ( nested.fields !== undefined\r\n ? Type.fromJSON\r\n : nested.values !== undefined\r\n ? Enum.fromJSON\r\n : nested.methods !== undefined\r\n ? Service.fromJSON\r\n : nested.id !== undefined\r\n ? Field.fromJSON\r\n : Namespace.fromJSON )(names[i], nested)\r\n );\r\n }\r\n }\r\n return this;\r\n};\r\n\r\n/**\r\n * Gets the nested object of the specified name.\r\n * @param {string} name Nested object name\r\n * @returns {ReflectionObject|null} The reflection object or `null` if it doesn't exist\r\n */\r\nNamespace.prototype.get = function get(name) {\r\n return this.nested && this.nested[name]\r\n || null;\r\n};\r\n\r\n/**\r\n * Gets the values of the nested {@link Enum|enum} of the specified name.\r\n * This methods differs from {@link Namespace#get|get} in that it returns an enum's values directly and throws instead of returning `null`.\r\n * @param {string} name Nested enum name\r\n * @returns {Object.} Enum values\r\n * @throws {Error} If there is no such enum\r\n */\r\nNamespace.prototype.getEnum = function getEnum(name) {\r\n if (this.nested && this.nested[name] instanceof Enum)\r\n return this.nested[name].values;\r\n throw Error(\"no such enum: \" + name);\r\n};\r\n\r\n/**\r\n * Adds a nested object to this namespace.\r\n * @param {ReflectionObject} object Nested object to add\r\n * @returns {Namespace} `this`\r\n * @throws {TypeError} If arguments are invalid\r\n * @throws {Error} If there is already a nested object with this name\r\n */\r\nNamespace.prototype.add = function add(object) {\r\n\r\n if (!(object instanceof Field && object.extend !== undefined || object instanceof Type || object instanceof Enum || object instanceof Service || object instanceof Namespace))\r\n throw TypeError(\"object must be a valid nested object\");\r\n\r\n if (!this.nested)\r\n this.nested = {};\r\n else {\r\n var prev = this.get(object.name);\r\n if (prev) {\r\n if (prev instanceof Namespace && object instanceof Namespace && !(prev instanceof Type || prev instanceof Service)) {\r\n // replace plain namespace but keep existing nested elements and options\r\n var nested = prev.nestedArray;\r\n for (var i = 0; i < nested.length; ++i)\r\n object.add(nested[i]);\r\n this.remove(prev);\r\n if (!this.nested)\r\n this.nested = {};\r\n object.setOptions(prev.options, true);\r\n\r\n } else\r\n throw Error(\"duplicate name '\" + object.name + \"' in \" + this);\r\n }\r\n }\r\n this.nested[object.name] = object;\r\n object.onAdd(this);\r\n return clearCache(this);\r\n};\r\n\r\n/**\r\n * Removes a nested object from this namespace.\r\n * @param {ReflectionObject} object Nested object to remove\r\n * @returns {Namespace} `this`\r\n * @throws {TypeError} If arguments are invalid\r\n * @throws {Error} If `object` is not a member of this namespace\r\n */\r\nNamespace.prototype.remove = function remove(object) {\r\n\r\n if (!(object instanceof ReflectionObject))\r\n throw TypeError(\"object must be a ReflectionObject\");\r\n if (object.parent !== this)\r\n throw Error(object + \" is not a member of \" + this);\r\n\r\n delete this.nested[object.name];\r\n if (!Object.keys(this.nested).length)\r\n this.nested = undefined;\r\n\r\n object.onRemove(this);\r\n return clearCache(this);\r\n};\r\n\r\n/**\r\n * Defines additial namespaces within this one if not yet existing.\r\n * @param {string|string[]} path Path to create\r\n * @param {*} [json] Nested types to create from JSON\r\n * @returns {Namespace} Pointer to the last namespace created or `this` if path is empty\r\n */\r\nNamespace.prototype.define = function define(path, json) {\r\n\r\n if (util.isString(path))\r\n path = path.split(\".\");\r\n else if (!Array.isArray(path))\r\n throw TypeError(\"illegal path\");\r\n if (path && path.length && path[0] === \"\")\r\n throw Error(\"path must be relative\");\r\n\r\n var ptr = this;\r\n while (path.length > 0) {\r\n var part = path.shift();\r\n if (ptr.nested && ptr.nested[part]) {\r\n ptr = ptr.nested[part];\r\n if (!(ptr instanceof Namespace))\r\n throw Error(\"path conflicts with non-namespace objects\");\r\n } else\r\n ptr.add(ptr = new Namespace(part));\r\n }\r\n if (json)\r\n ptr.addJSON(json);\r\n return ptr;\r\n};\r\n\r\n/**\r\n * Resolves this namespace's and all its nested objects' type references. Useful to validate a reflection tree, but comes at a cost.\r\n * @returns {Namespace} `this`\r\n */\r\nNamespace.prototype.resolveAll = function resolveAll() {\r\n var nested = this.nestedArray, i = 0;\r\n while (i < nested.length)\r\n if (nested[i] instanceof Namespace)\r\n nested[i++].resolveAll();\r\n else\r\n nested[i++].resolve();\r\n return this.resolve();\r\n};\r\n\r\n/**\r\n * Recursively looks up the reflection object matching the specified path in the scope of this namespace.\r\n * @param {string|string[]} path Path to look up\r\n * @param {*|Array.<*>} filterTypes Filter types, any combination of the constructors of `protobuf.Type`, `protobuf.Enum`, `protobuf.Service` etc.\r\n * @param {boolean} [parentAlreadyChecked=false] If known, whether the parent has already been checked\r\n * @returns {ReflectionObject|null} Looked up object or `null` if none could be found\r\n */\r\nNamespace.prototype.lookup = function lookup(path, filterTypes, parentAlreadyChecked) {\r\n\r\n /* istanbul ignore next */\r\n if (typeof filterTypes === \"boolean\") {\r\n parentAlreadyChecked = filterTypes;\r\n filterTypes = undefined;\r\n } else if (filterTypes && !Array.isArray(filterTypes))\r\n filterTypes = [ filterTypes ];\r\n\r\n if (util.isString(path) && path.length) {\r\n if (path === \".\")\r\n return this.root;\r\n path = path.split(\".\");\r\n } else if (!path.length)\r\n return this;\r\n\r\n // Start at root if path is absolute\r\n if (path[0] === \"\")\r\n return this.root.lookup(path.slice(1), filterTypes);\r\n\r\n // Test if the first part matches any nested object, and if so, traverse if path contains more\r\n var found = this.get(path[0]);\r\n if (found) {\r\n if (path.length === 1) {\r\n if (!filterTypes || filterTypes.indexOf(found.constructor) > -1)\r\n return found;\r\n } else if (found instanceof Namespace && (found = found.lookup(path.slice(1), filterTypes, true)))\r\n return found;\r\n\r\n // Otherwise try each nested namespace\r\n } else\r\n for (var i = 0; i < this.nestedArray.length; ++i)\r\n if (this._nestedArray[i] instanceof Namespace && (found = this._nestedArray[i].lookup(path, filterTypes, true)))\r\n return found;\r\n\r\n // If there hasn't been a match, try again at the parent\r\n if (this.parent === null || parentAlreadyChecked)\r\n return null;\r\n return this.parent.lookup(path, filterTypes);\r\n};\r\n\r\n/**\r\n * Looks up the reflection object at the specified path, relative to this namespace.\r\n * @name NamespaceBase#lookup\r\n * @function\r\n * @param {string|string[]} path Path to look up\r\n * @param {boolean} [parentAlreadyChecked=false] Whether the parent has already been checked\r\n * @returns {ReflectionObject|null} Looked up object or `null` if none could be found\r\n * @variation 2\r\n */\r\n// lookup(path: string, [parentAlreadyChecked: boolean])\r\n\r\n/**\r\n * Looks up the {@link Type|type} at the specified path, relative to this namespace.\r\n * Besides its signature, this methods differs from {@link Namespace#lookup|lookup} in that it throws instead of returning `null`.\r\n * @param {string|string[]} path Path to look up\r\n * @returns {Type} Looked up type\r\n * @throws {Error} If `path` does not point to a type\r\n */\r\nNamespace.prototype.lookupType = function lookupType(path) {\r\n var found = this.lookup(path, [ Type ]);\r\n if (!found)\r\n throw Error(\"no such type: \" + path);\r\n return found;\r\n};\r\n\r\n/**\r\n * Looks up the values of the {@link Enum|enum} at the specified path, relative to this namespace.\r\n * Besides its signature, this methods differs from {@link Namespace#lookup|lookup} in that it throws instead of returning `null`.\r\n * @param {string|string[]} path Path to look up\r\n * @returns {Enum} Looked up enum\r\n * @throws {Error} If `path` does not point to an enum\r\n */\r\nNamespace.prototype.lookupEnum = function lookupEnum(path) {\r\n var found = this.lookup(path, [ Enum ]);\r\n if (!found)\r\n throw Error(\"no such Enum '\" + path + \"' in \" + this);\r\n return found;\r\n};\r\n\r\n/**\r\n * Looks up the {@link Type|type} or {@link Enum|enum} at the specified path, relative to this namespace.\r\n * Besides its signature, this methods differs from {@link Namespace#lookup|lookup} in that it throws instead of returning `null`.\r\n * @param {string|string[]} path Path to look up\r\n * @returns {Type} Looked up type or enum\r\n * @throws {Error} If `path` does not point to a type or enum\r\n */\r\nNamespace.prototype.lookupTypeOrEnum = function lookupTypeOrEnum(path) {\r\n var found = this.lookup(path, [ Type, Enum ]);\r\n if (!found)\r\n throw Error(\"no such Type or Enum '\" + path + \"' in \" + this);\r\n return found;\r\n};\r\n\r\n/**\r\n * Looks up the {@link Service|service} at the specified path, relative to this namespace.\r\n * Besides its signature, this methods differs from {@link Namespace#lookup|lookup} in that it throws instead of returning `null`.\r\n * @param {string|string[]} path Path to look up\r\n * @returns {Service} Looked up service\r\n * @throws {Error} If `path` does not point to a service\r\n */\r\nNamespace.prototype.lookupService = function lookupService(path) {\r\n var found = this.lookup(path, [ Service ]);\r\n if (!found)\r\n throw Error(\"no such Service '\" + path + \"' in \" + this);\r\n return found;\r\n};\r\n\r\n// Sets up cyclic dependencies (called in index-light)\r\nNamespace._configure = function(Type_, Service_, Enum_) {\r\n Type = Type_;\r\n Service = Service_;\r\n Enum = Enum_;\r\n};\r\n","\"use strict\";\r\nmodule.exports = ReflectionObject;\r\n\r\nReflectionObject.className = \"ReflectionObject\";\r\n\r\nvar util = require(37);\r\n\r\nvar Root; // cyclic\r\n\r\n/**\r\n * Constructs a new reflection object instance.\r\n * @classdesc Base class of all reflection objects.\r\n * @constructor\r\n * @param {string} name Object name\r\n * @param {Object.} [options] Declared options\r\n * @abstract\r\n */\r\nfunction ReflectionObject(name, options) {\r\n\r\n if (!util.isString(name))\r\n throw TypeError(\"name must be a string\");\r\n\r\n if (options && !util.isObject(options))\r\n throw TypeError(\"options must be an object\");\r\n\r\n /**\r\n * Options.\r\n * @type {Object.|undefined}\r\n */\r\n this.options = options; // toJSON\r\n\r\n /**\r\n * Unique name within its namespace.\r\n * @type {string}\r\n */\r\n this.name = name;\r\n\r\n /**\r\n * Parent namespace.\r\n * @type {Namespace|null}\r\n */\r\n this.parent = null;\r\n\r\n /**\r\n * Whether already resolved or not.\r\n * @type {boolean}\r\n */\r\n this.resolved = false;\r\n\r\n /**\r\n * Comment text, if any.\r\n * @type {string|null}\r\n */\r\n this.comment = null;\r\n\r\n /**\r\n * Defining file name.\r\n * @type {string|null}\r\n */\r\n this.filename = null;\r\n}\r\n\r\nObject.defineProperties(ReflectionObject.prototype, {\r\n\r\n /**\r\n * Reference to the root namespace.\r\n * @name ReflectionObject#root\r\n * @type {Root}\r\n * @readonly\r\n */\r\n root: {\r\n get: function() {\r\n var ptr = this;\r\n while (ptr.parent !== null)\r\n ptr = ptr.parent;\r\n return ptr;\r\n }\r\n },\r\n\r\n /**\r\n * Full name including leading dot.\r\n * @name ReflectionObject#fullName\r\n * @type {string}\r\n * @readonly\r\n */\r\n fullName: {\r\n get: function() {\r\n var path = [ this.name ],\r\n ptr = this.parent;\r\n while (ptr) {\r\n path.unshift(ptr.name);\r\n ptr = ptr.parent;\r\n }\r\n return path.join(\".\");\r\n }\r\n }\r\n});\r\n\r\n/**\r\n * Converts this reflection object to its descriptor representation.\r\n * @returns {Object.} Descriptor\r\n * @abstract\r\n */\r\nReflectionObject.prototype.toJSON = /* istanbul ignore next */ function toJSON() {\r\n throw Error(); // not implemented, shouldn't happen\r\n};\r\n\r\n/**\r\n * Called when this object is added to a parent.\r\n * @param {ReflectionObject} parent Parent added to\r\n * @returns {undefined}\r\n */\r\nReflectionObject.prototype.onAdd = function onAdd(parent) {\r\n if (this.parent && this.parent !== parent)\r\n this.parent.remove(this);\r\n this.parent = parent;\r\n this.resolved = false;\r\n var root = parent.root;\r\n if (root instanceof Root)\r\n root._handleAdd(this);\r\n};\r\n\r\n/**\r\n * Called when this object is removed from a parent.\r\n * @param {ReflectionObject} parent Parent removed from\r\n * @returns {undefined}\r\n */\r\nReflectionObject.prototype.onRemove = function onRemove(parent) {\r\n var root = parent.root;\r\n if (root instanceof Root)\r\n root._handleRemove(this);\r\n this.parent = null;\r\n this.resolved = false;\r\n};\r\n\r\n/**\r\n * Resolves this objects type references.\r\n * @returns {ReflectionObject} `this`\r\n */\r\nReflectionObject.prototype.resolve = function resolve() {\r\n if (this.resolved)\r\n return this;\r\n if (this.root instanceof Root)\r\n this.resolved = true; // only if part of a root\r\n return this;\r\n};\r\n\r\n/**\r\n * Gets an option value.\r\n * @param {string} name Option name\r\n * @returns {*} Option value or `undefined` if not set\r\n */\r\nReflectionObject.prototype.getOption = function getOption(name) {\r\n if (this.options)\r\n return this.options[name];\r\n return undefined;\r\n};\r\n\r\n/**\r\n * Sets an option.\r\n * @param {string} name Option name\r\n * @param {*} value Option value\r\n * @param {boolean} [ifNotSet] Sets the option only if it isn't currently set\r\n * @returns {ReflectionObject} `this`\r\n */\r\nReflectionObject.prototype.setOption = function setOption(name, value, ifNotSet) {\r\n if (!ifNotSet || !this.options || this.options[name] === undefined)\r\n (this.options || (this.options = {}))[name] = value;\r\n return this;\r\n};\r\n\r\n/**\r\n * Sets multiple options.\r\n * @param {Object.} options Options to set\r\n * @param {boolean} [ifNotSet] Sets an option only if it isn't currently set\r\n * @returns {ReflectionObject} `this`\r\n */\r\nReflectionObject.prototype.setOptions = function setOptions(options, ifNotSet) {\r\n if (options)\r\n for (var keys = Object.keys(options), i = 0; i < keys.length; ++i)\r\n this.setOption(keys[i], options[keys[i]], ifNotSet);\r\n return this;\r\n};\r\n\r\n/**\r\n * Converts this instance to its string representation.\r\n * @returns {string} Class name[, space, full name]\r\n */\r\nReflectionObject.prototype.toString = function toString() {\r\n var className = this.constructor.className,\r\n fullName = this.fullName;\r\n if (fullName.length)\r\n return className + \" \" + fullName;\r\n return className;\r\n};\r\n\r\n// Sets up cyclic dependencies (called in index-light)\r\nReflectionObject._configure = function(Root_) {\r\n Root = Root_;\r\n};\r\n","\"use strict\";\r\nmodule.exports = OneOf;\r\n\r\n// extends ReflectionObject\r\nvar ReflectionObject = require(24);\r\n((OneOf.prototype = Object.create(ReflectionObject.prototype)).constructor = OneOf).className = \"OneOf\";\r\n\r\nvar Field = require(16),\r\n util = require(37);\r\n\r\n/**\r\n * Constructs a new oneof instance.\r\n * @classdesc Reflected oneof.\r\n * @extends ReflectionObject\r\n * @constructor\r\n * @param {string} name Oneof name\r\n * @param {string[]|Object.} [fieldNames] Field names\r\n * @param {Object.} [options] Declared options\r\n * @param {string} [comment] Comment associated with this field\r\n */\r\nfunction OneOf(name, fieldNames, options, comment) {\r\n if (!Array.isArray(fieldNames)) {\r\n options = fieldNames;\r\n fieldNames = undefined;\r\n }\r\n ReflectionObject.call(this, name, options);\r\n\r\n /* istanbul ignore if */\r\n if (!(fieldNames === undefined || Array.isArray(fieldNames)))\r\n throw TypeError(\"fieldNames must be an Array\");\r\n\r\n /**\r\n * Field names that belong to this oneof.\r\n * @type {string[]}\r\n */\r\n this.oneof = fieldNames || []; // toJSON, marker\r\n\r\n /**\r\n * Fields that belong to this oneof as an array for iteration.\r\n * @type {Field[]}\r\n * @readonly\r\n */\r\n this.fieldsArray = []; // declared readonly for conformance, possibly not yet added to parent\r\n\r\n /**\r\n * Comment for this field.\r\n * @type {string|null}\r\n */\r\n this.comment = comment;\r\n}\r\n\r\n/**\r\n * Oneof descriptor.\r\n * @interface IOneOf\r\n * @property {Array.} oneof Oneof field names\r\n * @property {Object.} [options] Oneof options\r\n */\r\n\r\n/**\r\n * Constructs a oneof from a oneof descriptor.\r\n * @param {string} name Oneof name\r\n * @param {IOneOf} json Oneof descriptor\r\n * @returns {OneOf} Created oneof\r\n * @throws {TypeError} If arguments are invalid\r\n */\r\nOneOf.fromJSON = function fromJSON(name, json) {\r\n return new OneOf(name, json.oneof, json.options, json.comment);\r\n};\r\n\r\n/**\r\n * Converts this oneof to a oneof descriptor.\r\n * @param {IToJSONOptions} [toJSONOptions] JSON conversion options\r\n * @returns {IOneOf} Oneof descriptor\r\n */\r\nOneOf.prototype.toJSON = function toJSON(toJSONOptions) {\r\n var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false;\r\n return util.toObject([\r\n \"options\" , this.options,\r\n \"oneof\" , this.oneof,\r\n \"comment\" , keepComments ? this.comment : undefined\r\n ]);\r\n};\r\n\r\n/**\r\n * Adds the fields of the specified oneof to the parent if not already done so.\r\n * @param {OneOf} oneof The oneof\r\n * @returns {undefined}\r\n * @inner\r\n * @ignore\r\n */\r\nfunction addFieldsToParent(oneof) {\r\n if (oneof.parent)\r\n for (var i = 0; i < oneof.fieldsArray.length; ++i)\r\n if (!oneof.fieldsArray[i].parent)\r\n oneof.parent.add(oneof.fieldsArray[i]);\r\n}\r\n\r\n/**\r\n * Adds a field to this oneof and removes it from its current parent, if any.\r\n * @param {Field} field Field to add\r\n * @returns {OneOf} `this`\r\n */\r\nOneOf.prototype.add = function add(field) {\r\n\r\n /* istanbul ignore if */\r\n if (!(field instanceof Field))\r\n throw TypeError(\"field must be a Field\");\r\n\r\n if (field.parent && field.parent !== this.parent)\r\n field.parent.remove(field);\r\n this.oneof.push(field.name);\r\n this.fieldsArray.push(field);\r\n field.partOf = this; // field.parent remains null\r\n addFieldsToParent(this);\r\n return this;\r\n};\r\n\r\n/**\r\n * Removes a field from this oneof and puts it back to the oneof's parent.\r\n * @param {Field} field Field to remove\r\n * @returns {OneOf} `this`\r\n */\r\nOneOf.prototype.remove = function remove(field) {\r\n\r\n /* istanbul ignore if */\r\n if (!(field instanceof Field))\r\n throw TypeError(\"field must be a Field\");\r\n\r\n var index = this.fieldsArray.indexOf(field);\r\n\r\n /* istanbul ignore if */\r\n if (index < 0)\r\n throw Error(field + \" is not a member of \" + this);\r\n\r\n this.fieldsArray.splice(index, 1);\r\n index = this.oneof.indexOf(field.name);\r\n\r\n /* istanbul ignore else */\r\n if (index > -1) // theoretical\r\n this.oneof.splice(index, 1);\r\n\r\n field.partOf = null;\r\n return this;\r\n};\r\n\r\n/**\r\n * @override\r\n */\r\nOneOf.prototype.onAdd = function onAdd(parent) {\r\n ReflectionObject.prototype.onAdd.call(this, parent);\r\n var self = this;\r\n // Collect present fields\r\n for (var i = 0; i < this.oneof.length; ++i) {\r\n var field = parent.get(this.oneof[i]);\r\n if (field && !field.partOf) {\r\n field.partOf = self;\r\n self.fieldsArray.push(field);\r\n }\r\n }\r\n // Add not yet present fields\r\n addFieldsToParent(this);\r\n};\r\n\r\n/**\r\n * @override\r\n */\r\nOneOf.prototype.onRemove = function onRemove(parent) {\r\n for (var i = 0, field; i < this.fieldsArray.length; ++i)\r\n if ((field = this.fieldsArray[i]).parent)\r\n field.parent.remove(field);\r\n ReflectionObject.prototype.onRemove.call(this, parent);\r\n};\r\n\r\n/**\r\n * Decorator function as returned by {@link OneOf.d} (TypeScript).\r\n * @typedef OneOfDecorator\r\n * @type {function}\r\n * @param {Object} prototype Target prototype\r\n * @param {string} oneofName OneOf name\r\n * @returns {undefined}\r\n */\r\n\r\n/**\r\n * OneOf decorator (TypeScript).\r\n * @function\r\n * @param {...string} fieldNames Field names\r\n * @returns {OneOfDecorator} Decorator function\r\n * @template T extends string\r\n */\r\nOneOf.d = function decorateOneOf() {\r\n var fieldNames = new Array(arguments.length),\r\n index = 0;\r\n while (index < arguments.length)\r\n fieldNames[index] = arguments[index++];\r\n return function oneOfDecorator(prototype, oneofName) {\r\n util.decorateType(prototype.constructor)\r\n .add(new OneOf(oneofName, fieldNames));\r\n Object.defineProperty(prototype, oneofName, {\r\n get: util.oneOfGetter(fieldNames),\r\n set: util.oneOfSetter(fieldNames)\r\n });\r\n };\r\n};\r\n","\"use strict\";\r\nmodule.exports = parse;\r\n\r\nparse.filename = null;\r\nparse.defaults = { keepCase: false };\r\n\r\nvar tokenize = require(34),\r\n Root = require(29),\r\n Type = require(35),\r\n Field = require(16),\r\n MapField = require(20),\r\n OneOf = require(25),\r\n Enum = require(15),\r\n Service = require(33),\r\n Method = require(22),\r\n types = require(36),\r\n util = require(37);\r\n\r\nvar base10Re = /^[1-9][0-9]*$/,\r\n base10NegRe = /^-?[1-9][0-9]*$/,\r\n base16Re = /^0[x][0-9a-fA-F]+$/,\r\n base16NegRe = /^-?0[x][0-9a-fA-F]+$/,\r\n base8Re = /^0[0-7]+$/,\r\n base8NegRe = /^-?0[0-7]+$/,\r\n numberRe = /^(?![eE])[0-9]*(?:\\.[0-9]*)?(?:[eE][+-]?[0-9]+)?$/,\r\n nameRe = /^[a-zA-Z_][a-zA-Z_0-9]*$/,\r\n typeRefRe = /^(?:\\.?[a-zA-Z_][a-zA-Z_0-9]*)(?:\\.[a-zA-Z_][a-zA-Z_0-9]*)*$/,\r\n fqTypeRefRe = /^(?:\\.[a-zA-Z_][a-zA-Z_0-9]*)+$/;\r\n\r\n/**\r\n * Result object returned from {@link parse}.\r\n * @interface IParserResult\r\n * @property {string|undefined} package Package name, if declared\r\n * @property {string[]|undefined} imports Imports, if any\r\n * @property {string[]|undefined} weakImports Weak imports, if any\r\n * @property {string|undefined} syntax Syntax, if specified (either `\"proto2\"` or `\"proto3\"`)\r\n * @property {Root} root Populated root instance\r\n */\r\n\r\n/**\r\n * Options modifying the behavior of {@link parse}.\r\n * @interface IParseOptions\r\n * @property {boolean} [keepCase=false] Keeps field casing instead of converting to camel case\r\n * @property {boolean} [alternateCommentMode=false] Recognize double-slash comments in addition to doc-block comments.\r\n */\r\n\r\n/**\r\n * Options modifying the behavior of JSON serialization.\r\n * @interface IToJSONOptions\r\n * @property {boolean} [keepComments=false] Serializes comments.\r\n */\r\n\r\n/**\r\n * Parses the given .proto source and returns an object with the parsed contents.\r\n * @param {string} source Source contents\r\n * @param {Root} root Root to populate\r\n * @param {IParseOptions} [options] Parse options. Defaults to {@link parse.defaults} when omitted.\r\n * @returns {IParserResult} Parser result\r\n * @property {string} filename=null Currently processing file name for error reporting, if known\r\n * @property {IParseOptions} defaults Default {@link IParseOptions}\r\n */\r\nfunction parse(source, root, options) {\r\n /* eslint-disable callback-return */\r\n if (!(root instanceof Root)) {\r\n options = root;\r\n root = new Root();\r\n }\r\n if (!options)\r\n options = parse.defaults;\r\n\r\n var tn = tokenize(source, options.alternateCommentMode || false),\r\n next = tn.next,\r\n push = tn.push,\r\n peek = tn.peek,\r\n skip = tn.skip,\r\n cmnt = tn.cmnt;\r\n\r\n var head = true,\r\n pkg,\r\n imports,\r\n weakImports,\r\n syntax,\r\n isProto3 = false;\r\n\r\n var ptr = root;\r\n\r\n var applyCase = options.keepCase ? function(name) { return name; } : util.camelCase;\r\n\r\n /* istanbul ignore next */\r\n function illegal(token, name, insideTryCatch) {\r\n var filename = parse.filename;\r\n if (!insideTryCatch)\r\n parse.filename = null;\r\n return Error(\"illegal \" + (name || \"token\") + \" '\" + token + \"' (\" + (filename ? filename + \", \" : \"\") + \"line \" + tn.line + \")\");\r\n }\r\n\r\n function readString() {\r\n var values = [],\r\n token;\r\n do {\r\n /* istanbul ignore if */\r\n if ((token = next()) !== \"\\\"\" && token !== \"'\")\r\n throw illegal(token);\r\n\r\n values.push(next());\r\n skip(token);\r\n token = peek();\r\n } while (token === \"\\\"\" || token === \"'\");\r\n return values.join(\"\");\r\n }\r\n\r\n function readValue(acceptTypeRef) {\r\n var token = next();\r\n switch (token) {\r\n case \"'\":\r\n case \"\\\"\":\r\n push(token);\r\n return readString();\r\n case \"true\": case \"TRUE\":\r\n return true;\r\n case \"false\": case \"FALSE\":\r\n return false;\r\n }\r\n try {\r\n return parseNumber(token, /* insideTryCatch */ true);\r\n } catch (e) {\r\n\r\n /* istanbul ignore else */\r\n if (acceptTypeRef && typeRefRe.test(token))\r\n return token;\r\n\r\n /* istanbul ignore next */\r\n throw illegal(token, \"value\");\r\n }\r\n }\r\n\r\n function readRanges(target, acceptStrings) {\r\n var token, start;\r\n do {\r\n if (acceptStrings && ((token = peek()) === \"\\\"\" || token === \"'\"))\r\n target.push(readString());\r\n else\r\n target.push([ start = parseId(next()), skip(\"to\", true) ? parseId(next()) : start ]);\r\n } while (skip(\",\", true));\r\n skip(\";\");\r\n }\r\n\r\n function parseNumber(token, insideTryCatch) {\r\n var sign = 1;\r\n if (token.charAt(0) === \"-\") {\r\n sign = -1;\r\n token = token.substring(1);\r\n }\r\n switch (token) {\r\n case \"inf\": case \"INF\": case \"Inf\":\r\n return sign * Infinity;\r\n case \"nan\": case \"NAN\": case \"Nan\": case \"NaN\":\r\n return NaN;\r\n case \"0\":\r\n return 0;\r\n }\r\n if (base10Re.test(token))\r\n return sign * parseInt(token, 10);\r\n if (base16Re.test(token))\r\n return sign * parseInt(token, 16);\r\n if (base8Re.test(token))\r\n return sign * parseInt(token, 8);\r\n\r\n /* istanbul ignore else */\r\n if (numberRe.test(token))\r\n return sign * parseFloat(token);\r\n\r\n /* istanbul ignore next */\r\n throw illegal(token, \"number\", insideTryCatch);\r\n }\r\n\r\n function parseId(token, acceptNegative) {\r\n switch (token) {\r\n case \"max\": case \"MAX\": case \"Max\":\r\n return 536870911;\r\n case \"0\":\r\n return 0;\r\n }\r\n\r\n /* istanbul ignore if */\r\n if (!acceptNegative && token.charAt(0) === \"-\")\r\n throw illegal(token, \"id\");\r\n\r\n if (base10NegRe.test(token))\r\n return parseInt(token, 10);\r\n if (base16NegRe.test(token))\r\n return parseInt(token, 16);\r\n\r\n /* istanbul ignore else */\r\n if (base8NegRe.test(token))\r\n return parseInt(token, 8);\r\n\r\n /* istanbul ignore next */\r\n throw illegal(token, \"id\");\r\n }\r\n\r\n function parsePackage() {\r\n\r\n /* istanbul ignore if */\r\n if (pkg !== undefined)\r\n throw illegal(\"package\");\r\n\r\n pkg = next();\r\n\r\n /* istanbul ignore if */\r\n if (!typeRefRe.test(pkg))\r\n throw illegal(pkg, \"name\");\r\n\r\n ptr = ptr.define(pkg);\r\n skip(\";\");\r\n }\r\n\r\n function parseImport() {\r\n var token = peek();\r\n var whichImports;\r\n switch (token) {\r\n case \"weak\":\r\n whichImports = weakImports || (weakImports = []);\r\n next();\r\n break;\r\n case \"public\":\r\n next();\r\n // eslint-disable-line no-fallthrough\r\n default:\r\n whichImports = imports || (imports = []);\r\n break;\r\n }\r\n token = readString();\r\n skip(\";\");\r\n whichImports.push(token);\r\n }\r\n\r\n function parseSyntax() {\r\n skip(\"=\");\r\n syntax = readString();\r\n isProto3 = syntax === \"proto3\";\r\n\r\n /* istanbul ignore if */\r\n if (!isProto3 && syntax !== \"proto2\")\r\n throw illegal(syntax, \"syntax\");\r\n\r\n skip(\";\");\r\n }\r\n\r\n function parseCommon(parent, token) {\r\n switch (token) {\r\n\r\n case \"option\":\r\n parseOption(parent, token);\r\n skip(\";\");\r\n return true;\r\n\r\n case \"message\":\r\n parseType(parent, token);\r\n return true;\r\n\r\n case \"enum\":\r\n parseEnum(parent, token);\r\n return true;\r\n\r\n case \"service\":\r\n parseService(parent, token);\r\n return true;\r\n\r\n case \"extend\":\r\n parseExtension(parent, token);\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n function ifBlock(obj, fnIf, fnElse) {\r\n var trailingLine = tn.line;\r\n if (obj) {\r\n obj.comment = cmnt(); // try block-type comment\r\n obj.filename = parse.filename;\r\n }\r\n if (skip(\"{\", true)) {\r\n var token;\r\n while ((token = next()) !== \"}\")\r\n fnIf(token);\r\n skip(\";\", true);\r\n } else {\r\n if (fnElse)\r\n fnElse();\r\n skip(\";\");\r\n if (obj && typeof obj.comment !== \"string\")\r\n obj.comment = cmnt(trailingLine); // try line-type comment if no block\r\n }\r\n }\r\n\r\n function parseType(parent, token) {\r\n\r\n /* istanbul ignore if */\r\n if (!nameRe.test(token = next()))\r\n throw illegal(token, \"type name\");\r\n\r\n var type = new Type(token);\r\n ifBlock(type, function parseType_block(token) {\r\n if (parseCommon(type, token))\r\n return;\r\n\r\n switch (token) {\r\n\r\n case \"map\":\r\n parseMapField(type, token);\r\n break;\r\n\r\n case \"required\":\r\n case \"optional\":\r\n case \"repeated\":\r\n parseField(type, token);\r\n break;\r\n\r\n case \"oneof\":\r\n parseOneOf(type, token);\r\n break;\r\n\r\n case \"extensions\":\r\n readRanges(type.extensions || (type.extensions = []));\r\n break;\r\n\r\n case \"reserved\":\r\n readRanges(type.reserved || (type.reserved = []), true);\r\n break;\r\n\r\n default:\r\n /* istanbul ignore if */\r\n if (!isProto3 || !typeRefRe.test(token))\r\n throw illegal(token);\r\n\r\n push(token);\r\n parseField(type, \"optional\");\r\n break;\r\n }\r\n });\r\n parent.add(type);\r\n }\r\n\r\n function parseField(parent, rule, extend) {\r\n var type = next();\r\n if (type === \"group\") {\r\n parseGroup(parent, rule);\r\n return;\r\n }\r\n\r\n /* istanbul ignore if */\r\n if (!typeRefRe.test(type))\r\n throw illegal(type, \"type\");\r\n\r\n var name = next();\r\n\r\n /* istanbul ignore if */\r\n if (!nameRe.test(name))\r\n throw illegal(name, \"name\");\r\n\r\n name = applyCase(name);\r\n skip(\"=\");\r\n\r\n var field = new Field(name, parseId(next()), type, rule, extend);\r\n ifBlock(field, function parseField_block(token) {\r\n\r\n /* istanbul ignore else */\r\n if (token === \"option\") {\r\n parseOption(field, token);\r\n skip(\";\");\r\n } else\r\n throw illegal(token);\r\n\r\n }, function parseField_line() {\r\n parseInlineOptions(field);\r\n });\r\n parent.add(field);\r\n\r\n // JSON defaults to packed=true if not set so we have to set packed=false explicity when\r\n // parsing proto2 descriptors without the option, where applicable. This must be done for\r\n // all known packable types and anything that could be an enum (= is not a basic type).\r\n if (!isProto3 && field.repeated && (types.packed[type] !== undefined || types.basic[type] === undefined))\r\n field.setOption(\"packed\", false, /* ifNotSet */ true);\r\n }\r\n\r\n function parseGroup(parent, rule) {\r\n var name = next();\r\n\r\n /* istanbul ignore if */\r\n if (!nameRe.test(name))\r\n throw illegal(name, \"name\");\r\n\r\n var fieldName = util.lcFirst(name);\r\n if (name === fieldName)\r\n name = util.ucFirst(name);\r\n skip(\"=\");\r\n var id = parseId(next());\r\n var type = new Type(name);\r\n type.group = true;\r\n var field = new Field(fieldName, id, name, rule);\r\n field.filename = parse.filename;\r\n ifBlock(type, function parseGroup_block(token) {\r\n switch (token) {\r\n\r\n case \"option\":\r\n parseOption(type, token);\r\n skip(\";\");\r\n break;\r\n\r\n case \"required\":\r\n case \"optional\":\r\n case \"repeated\":\r\n parseField(type, token);\r\n break;\r\n\r\n /* istanbul ignore next */\r\n default:\r\n throw illegal(token); // there are no groups with proto3 semantics\r\n }\r\n });\r\n parent.add(type)\r\n .add(field);\r\n }\r\n\r\n function parseMapField(parent) {\r\n skip(\"<\");\r\n var keyType = next();\r\n\r\n /* istanbul ignore if */\r\n if (types.mapKey[keyType] === undefined)\r\n throw illegal(keyType, \"type\");\r\n\r\n skip(\",\");\r\n var valueType = next();\r\n\r\n /* istanbul ignore if */\r\n if (!typeRefRe.test(valueType))\r\n throw illegal(valueType, \"type\");\r\n\r\n skip(\">\");\r\n var name = next();\r\n\r\n /* istanbul ignore if */\r\n if (!nameRe.test(name))\r\n throw illegal(name, \"name\");\r\n\r\n skip(\"=\");\r\n var field = new MapField(applyCase(name), parseId(next()), keyType, valueType);\r\n ifBlock(field, function parseMapField_block(token) {\r\n\r\n /* istanbul ignore else */\r\n if (token === \"option\") {\r\n parseOption(field, token);\r\n skip(\";\");\r\n } else\r\n throw illegal(token);\r\n\r\n }, function parseMapField_line() {\r\n parseInlineOptions(field);\r\n });\r\n parent.add(field);\r\n }\r\n\r\n function parseOneOf(parent, token) {\r\n\r\n /* istanbul ignore if */\r\n if (!nameRe.test(token = next()))\r\n throw illegal(token, \"name\");\r\n\r\n var oneof = new OneOf(applyCase(token));\r\n ifBlock(oneof, function parseOneOf_block(token) {\r\n if (token === \"option\") {\r\n parseOption(oneof, token);\r\n skip(\";\");\r\n } else {\r\n push(token);\r\n parseField(oneof, \"optional\");\r\n }\r\n });\r\n parent.add(oneof);\r\n }\r\n\r\n function parseEnum(parent, token) {\r\n\r\n /* istanbul ignore if */\r\n if (!nameRe.test(token = next()))\r\n throw illegal(token, \"name\");\r\n\r\n var enm = new Enum(token);\r\n ifBlock(enm, function parseEnum_block(token) {\r\n switch(token) {\r\n case \"option\":\r\n parseOption(enm, token);\r\n skip(\";\");\r\n break;\r\n\r\n case \"reserved\":\r\n readRanges(enm.reserved || (enm.reserved = []), true);\r\n break;\r\n\r\n default:\r\n parseEnumValue(enm, token);\r\n }\r\n });\r\n parent.add(enm);\r\n }\r\n\r\n function parseEnumValue(parent, token) {\r\n\r\n /* istanbul ignore if */\r\n if (!nameRe.test(token))\r\n throw illegal(token, \"name\");\r\n\r\n skip(\"=\");\r\n var value = parseId(next(), true),\r\n dummy = {};\r\n ifBlock(dummy, function parseEnumValue_block(token) {\r\n\r\n /* istanbul ignore else */\r\n if (token === \"option\") {\r\n parseOption(dummy, token); // skip\r\n skip(\";\");\r\n } else\r\n throw illegal(token);\r\n\r\n }, function parseEnumValue_line() {\r\n parseInlineOptions(dummy); // skip\r\n });\r\n parent.add(token, value, dummy.comment);\r\n }\r\n\r\n function parseOption(parent, token) {\r\n var isCustom = skip(\"(\", true);\r\n\r\n /* istanbul ignore if */\r\n if (!typeRefRe.test(token = next()))\r\n throw illegal(token, \"name\");\r\n\r\n var name = token;\r\n if (isCustom) {\r\n skip(\")\");\r\n name = \"(\" + name + \")\";\r\n token = peek();\r\n if (fqTypeRefRe.test(token)) {\r\n name += token;\r\n next();\r\n }\r\n }\r\n skip(\"=\");\r\n parseOptionValue(parent, name);\r\n }\r\n\r\n function parseOptionValue(parent, name) {\r\n if (skip(\"{\", true)) { // { a: \"foo\" b { c: \"bar\" } }\r\n do {\r\n /* istanbul ignore if */\r\n if (!nameRe.test(token = next()))\r\n throw illegal(token, \"name\");\r\n\r\n if (peek() === \"{\")\r\n parseOptionValue(parent, name + \".\" + token);\r\n else {\r\n skip(\":\");\r\n if (peek() === \"{\")\r\n parseOptionValue(parent, name + \".\" + token);\r\n else\r\n setOption(parent, name + \".\" + token, readValue(true));\r\n }\r\n skip(\",\", true);\r\n } while (!skip(\"}\", true));\r\n } else\r\n setOption(parent, name, readValue(true));\r\n // Does not enforce a delimiter to be universal\r\n }\r\n\r\n function setOption(parent, name, value) {\r\n if (parent.setOption)\r\n parent.setOption(name, value);\r\n }\r\n\r\n function parseInlineOptions(parent) {\r\n if (skip(\"[\", true)) {\r\n do {\r\n parseOption(parent, \"option\");\r\n } while (skip(\",\", true));\r\n skip(\"]\");\r\n }\r\n return parent;\r\n }\r\n\r\n function parseService(parent, token) {\r\n\r\n /* istanbul ignore if */\r\n if (!nameRe.test(token = next()))\r\n throw illegal(token, \"service name\");\r\n\r\n var service = new Service(token);\r\n ifBlock(service, function parseService_block(token) {\r\n if (parseCommon(service, token))\r\n return;\r\n\r\n /* istanbul ignore else */\r\n if (token === \"rpc\")\r\n parseMethod(service, token);\r\n else\r\n throw illegal(token);\r\n });\r\n parent.add(service);\r\n }\r\n\r\n function parseMethod(parent, token) {\r\n var type = token;\r\n\r\n /* istanbul ignore if */\r\n if (!nameRe.test(token = next()))\r\n throw illegal(token, \"name\");\r\n\r\n var name = token,\r\n requestType, requestStream,\r\n responseType, responseStream;\r\n\r\n skip(\"(\");\r\n if (skip(\"stream\", true))\r\n requestStream = true;\r\n\r\n /* istanbul ignore if */\r\n if (!typeRefRe.test(token = next()))\r\n throw illegal(token);\r\n\r\n requestType = token;\r\n skip(\")\"); skip(\"returns\"); skip(\"(\");\r\n if (skip(\"stream\", true))\r\n responseStream = true;\r\n\r\n /* istanbul ignore if */\r\n if (!typeRefRe.test(token = next()))\r\n throw illegal(token);\r\n\r\n responseType = token;\r\n skip(\")\");\r\n\r\n var method = new Method(name, type, requestType, responseType, requestStream, responseStream);\r\n ifBlock(method, function parseMethod_block(token) {\r\n\r\n /* istanbul ignore else */\r\n if (token === \"option\") {\r\n parseOption(method, token);\r\n skip(\";\");\r\n } else\r\n throw illegal(token);\r\n\r\n });\r\n parent.add(method);\r\n }\r\n\r\n function parseExtension(parent, token) {\r\n\r\n /* istanbul ignore if */\r\n if (!typeRefRe.test(token = next()))\r\n throw illegal(token, \"reference\");\r\n\r\n var reference = token;\r\n ifBlock(null, function parseExtension_block(token) {\r\n switch (token) {\r\n\r\n case \"required\":\r\n case \"repeated\":\r\n case \"optional\":\r\n parseField(parent, token, reference);\r\n break;\r\n\r\n default:\r\n /* istanbul ignore if */\r\n if (!isProto3 || !typeRefRe.test(token))\r\n throw illegal(token);\r\n push(token);\r\n parseField(parent, \"optional\", reference);\r\n break;\r\n }\r\n });\r\n }\r\n\r\n var token;\r\n while ((token = next()) !== null) {\r\n switch (token) {\r\n\r\n case \"package\":\r\n\r\n /* istanbul ignore if */\r\n if (!head)\r\n throw illegal(token);\r\n\r\n parsePackage();\r\n break;\r\n\r\n case \"import\":\r\n\r\n /* istanbul ignore if */\r\n if (!head)\r\n throw illegal(token);\r\n\r\n parseImport();\r\n break;\r\n\r\n case \"syntax\":\r\n\r\n /* istanbul ignore if */\r\n if (!head)\r\n throw illegal(token);\r\n\r\n parseSyntax();\r\n break;\r\n\r\n case \"option\":\r\n\r\n /* istanbul ignore if */\r\n if (!head)\r\n throw illegal(token);\r\n\r\n parseOption(ptr, token);\r\n skip(\";\");\r\n break;\r\n\r\n default:\r\n\r\n /* istanbul ignore else */\r\n if (parseCommon(ptr, token)) {\r\n head = false;\r\n continue;\r\n }\r\n\r\n /* istanbul ignore next */\r\n throw illegal(token);\r\n }\r\n }\r\n\r\n parse.filename = null;\r\n return {\r\n \"package\" : pkg,\r\n \"imports\" : imports,\r\n weakImports : weakImports,\r\n syntax : syntax,\r\n root : root\r\n };\r\n}\r\n\r\n/**\r\n * Parses the given .proto source and returns an object with the parsed contents.\r\n * @name parse\r\n * @function\r\n * @param {string} source Source contents\r\n * @param {IParseOptions} [options] Parse options. Defaults to {@link parse.defaults} when omitted.\r\n * @returns {IParserResult} Parser result\r\n * @property {string} filename=null Currently processing file name for error reporting, if known\r\n * @property {IParseOptions} defaults Default {@link IParseOptions}\r\n * @variation 2\r\n */\r\n","\"use strict\";\r\nmodule.exports = Reader;\r\n\r\nvar util = require(39);\r\n\r\nvar BufferReader; // cyclic\r\n\r\nvar LongBits = util.LongBits,\r\n utf8 = util.utf8;\r\n\r\n/* istanbul ignore next */\r\nfunction indexOutOfRange(reader, writeLength) {\r\n return RangeError(\"index out of range: \" + reader.pos + \" + \" + (writeLength || 1) + \" > \" + reader.len);\r\n}\r\n\r\n/**\r\n * Constructs a new reader instance using the specified buffer.\r\n * @classdesc Wire format reader using `Uint8Array` if available, otherwise `Array`.\r\n * @constructor\r\n * @param {Uint8Array} buffer Buffer to read from\r\n */\r\nfunction Reader(buffer) {\r\n\r\n /**\r\n * Read buffer.\r\n * @type {Uint8Array}\r\n */\r\n this.buf = buffer;\r\n\r\n /**\r\n * Read buffer position.\r\n * @type {number}\r\n */\r\n this.pos = 0;\r\n\r\n /**\r\n * Read buffer length.\r\n * @type {number}\r\n */\r\n this.len = buffer.length;\r\n}\r\n\r\nvar create_array = typeof Uint8Array !== \"undefined\"\r\n ? function create_typed_array(buffer) {\r\n if (buffer instanceof Uint8Array || Array.isArray(buffer))\r\n return new Reader(buffer);\r\n throw Error(\"illegal buffer\");\r\n }\r\n /* istanbul ignore next */\r\n : function create_array(buffer) {\r\n if (Array.isArray(buffer))\r\n return new Reader(buffer);\r\n throw Error(\"illegal buffer\");\r\n };\r\n\r\n/**\r\n * Creates a new reader using the specified buffer.\r\n * @function\r\n * @param {Uint8Array|Buffer} buffer Buffer to read from\r\n * @returns {Reader|BufferReader} A {@link BufferReader} if `buffer` is a Buffer, otherwise a {@link Reader}\r\n * @throws {Error} If `buffer` is not a valid buffer\r\n */\r\nReader.create = util.Buffer\r\n ? function create_buffer_setup(buffer) {\r\n return (Reader.create = function create_buffer(buffer) {\r\n return util.Buffer.isBuffer(buffer)\r\n ? new BufferReader(buffer)\r\n /* istanbul ignore next */\r\n : create_array(buffer);\r\n })(buffer);\r\n }\r\n /* istanbul ignore next */\r\n : create_array;\r\n\r\nReader.prototype._slice = util.Array.prototype.subarray || /* istanbul ignore next */ util.Array.prototype.slice;\r\n\r\n/**\r\n * Reads a varint as an unsigned 32 bit value.\r\n * @function\r\n * @returns {number} Value read\r\n */\r\nReader.prototype.uint32 = (function read_uint32_setup() {\r\n var value = 4294967295; // optimizer type-hint, tends to deopt otherwise (?!)\r\n return function read_uint32() {\r\n value = ( this.buf[this.pos] & 127 ) >>> 0; if (this.buf[this.pos++] < 128) return value;\r\n value = (value | (this.buf[this.pos] & 127) << 7) >>> 0; if (this.buf[this.pos++] < 128) return value;\r\n value = (value | (this.buf[this.pos] & 127) << 14) >>> 0; if (this.buf[this.pos++] < 128) return value;\r\n value = (value | (this.buf[this.pos] & 127) << 21) >>> 0; if (this.buf[this.pos++] < 128) return value;\r\n value = (value | (this.buf[this.pos] & 15) << 28) >>> 0; if (this.buf[this.pos++] < 128) return value;\r\n\r\n /* istanbul ignore if */\r\n if ((this.pos += 5) > this.len) {\r\n this.pos = this.len;\r\n throw indexOutOfRange(this, 10);\r\n }\r\n return value;\r\n };\r\n})();\r\n\r\n/**\r\n * Reads a varint as a signed 32 bit value.\r\n * @returns {number} Value read\r\n */\r\nReader.prototype.int32 = function read_int32() {\r\n return this.uint32() | 0;\r\n};\r\n\r\n/**\r\n * Reads a zig-zag encoded varint as a signed 32 bit value.\r\n * @returns {number} Value read\r\n */\r\nReader.prototype.sint32 = function read_sint32() {\r\n var value = this.uint32();\r\n return value >>> 1 ^ -(value & 1) | 0;\r\n};\r\n\r\n/* eslint-disable no-invalid-this */\r\n\r\nfunction readLongVarint() {\r\n // tends to deopt with local vars for octet etc.\r\n var bits = new LongBits(0, 0);\r\n var i = 0;\r\n if (this.len - this.pos > 4) { // fast route (lo)\r\n for (; i < 4; ++i) {\r\n // 1st..4th\r\n bits.lo = (bits.lo | (this.buf[this.pos] & 127) << i * 7) >>> 0;\r\n if (this.buf[this.pos++] < 128)\r\n return bits;\r\n }\r\n // 5th\r\n bits.lo = (bits.lo | (this.buf[this.pos] & 127) << 28) >>> 0;\r\n bits.hi = (bits.hi | (this.buf[this.pos] & 127) >> 4) >>> 0;\r\n if (this.buf[this.pos++] < 128)\r\n return bits;\r\n i = 0;\r\n } else {\r\n for (; i < 3; ++i) {\r\n /* istanbul ignore if */\r\n if (this.pos >= this.len)\r\n throw indexOutOfRange(this);\r\n // 1st..3th\r\n bits.lo = (bits.lo | (this.buf[this.pos] & 127) << i * 7) >>> 0;\r\n if (this.buf[this.pos++] < 128)\r\n return bits;\r\n }\r\n // 4th\r\n bits.lo = (bits.lo | (this.buf[this.pos++] & 127) << i * 7) >>> 0;\r\n return bits;\r\n }\r\n if (this.len - this.pos > 4) { // fast route (hi)\r\n for (; i < 5; ++i) {\r\n // 6th..10th\r\n bits.hi = (bits.hi | (this.buf[this.pos] & 127) << i * 7 + 3) >>> 0;\r\n if (this.buf[this.pos++] < 128)\r\n return bits;\r\n }\r\n } else {\r\n for (; i < 5; ++i) {\r\n /* istanbul ignore if */\r\n if (this.pos >= this.len)\r\n throw indexOutOfRange(this);\r\n // 6th..10th\r\n bits.hi = (bits.hi | (this.buf[this.pos] & 127) << i * 7 + 3) >>> 0;\r\n if (this.buf[this.pos++] < 128)\r\n return bits;\r\n }\r\n }\r\n /* istanbul ignore next */\r\n throw Error(\"invalid varint encoding\");\r\n}\r\n\r\n/* eslint-enable no-invalid-this */\r\n\r\n/**\r\n * Reads a varint as a signed 64 bit value.\r\n * @name Reader#int64\r\n * @function\r\n * @returns {Long} Value read\r\n */\r\n\r\n/**\r\n * Reads a varint as an unsigned 64 bit value.\r\n * @name Reader#uint64\r\n * @function\r\n * @returns {Long} Value read\r\n */\r\n\r\n/**\r\n * Reads a zig-zag encoded varint as a signed 64 bit value.\r\n * @name Reader#sint64\r\n * @function\r\n * @returns {Long} Value read\r\n */\r\n\r\n/**\r\n * Reads a varint as a boolean.\r\n * @returns {boolean} Value read\r\n */\r\nReader.prototype.bool = function read_bool() {\r\n return this.uint32() !== 0;\r\n};\r\n\r\nfunction readFixed32_end(buf, end) { // note that this uses `end`, not `pos`\r\n return (buf[end - 4]\r\n | buf[end - 3] << 8\r\n | buf[end - 2] << 16\r\n | buf[end - 1] << 24) >>> 0;\r\n}\r\n\r\n/**\r\n * Reads fixed 32 bits as an unsigned 32 bit integer.\r\n * @returns {number} Value read\r\n */\r\nReader.prototype.fixed32 = function read_fixed32() {\r\n\r\n /* istanbul ignore if */\r\n if (this.pos + 4 > this.len)\r\n throw indexOutOfRange(this, 4);\r\n\r\n return readFixed32_end(this.buf, this.pos += 4);\r\n};\r\n\r\n/**\r\n * Reads fixed 32 bits as a signed 32 bit integer.\r\n * @returns {number} Value read\r\n */\r\nReader.prototype.sfixed32 = function read_sfixed32() {\r\n\r\n /* istanbul ignore if */\r\n if (this.pos + 4 > this.len)\r\n throw indexOutOfRange(this, 4);\r\n\r\n return readFixed32_end(this.buf, this.pos += 4) | 0;\r\n};\r\n\r\n/* eslint-disable no-invalid-this */\r\n\r\nfunction readFixed64(/* this: Reader */) {\r\n\r\n /* istanbul ignore if */\r\n if (this.pos + 8 > this.len)\r\n throw indexOutOfRange(this, 8);\r\n\r\n return new LongBits(readFixed32_end(this.buf, this.pos += 4), readFixed32_end(this.buf, this.pos += 4));\r\n}\r\n\r\n/* eslint-enable no-invalid-this */\r\n\r\n/**\r\n * Reads fixed 64 bits.\r\n * @name Reader#fixed64\r\n * @function\r\n * @returns {Long} Value read\r\n */\r\n\r\n/**\r\n * Reads zig-zag encoded fixed 64 bits.\r\n * @name Reader#sfixed64\r\n * @function\r\n * @returns {Long} Value read\r\n */\r\n\r\n/**\r\n * Reads a float (32 bit) as a number.\r\n * @function\r\n * @returns {number} Value read\r\n */\r\nReader.prototype.float = function read_float() {\r\n\r\n /* istanbul ignore if */\r\n if (this.pos + 4 > this.len)\r\n throw indexOutOfRange(this, 4);\r\n\r\n var value = util.float.readFloatLE(this.buf, this.pos);\r\n this.pos += 4;\r\n return value;\r\n};\r\n\r\n/**\r\n * Reads a double (64 bit float) as a number.\r\n * @function\r\n * @returns {number} Value read\r\n */\r\nReader.prototype.double = function read_double() {\r\n\r\n /* istanbul ignore if */\r\n if (this.pos + 8 > this.len)\r\n throw indexOutOfRange(this, 4);\r\n\r\n var value = util.float.readDoubleLE(this.buf, this.pos);\r\n this.pos += 8;\r\n return value;\r\n};\r\n\r\n/**\r\n * Reads a sequence of bytes preceeded by its length as a varint.\r\n * @returns {Uint8Array} Value read\r\n */\r\nReader.prototype.bytes = function read_bytes() {\r\n var length = this.uint32(),\r\n start = this.pos,\r\n end = this.pos + length;\r\n\r\n /* istanbul ignore if */\r\n if (end > this.len)\r\n throw indexOutOfRange(this, length);\r\n\r\n this.pos += length;\r\n if (Array.isArray(this.buf)) // plain array\r\n return this.buf.slice(start, end);\r\n return start === end // fix for IE 10/Win8 and others' subarray returning array of size 1\r\n ? new this.buf.constructor(0)\r\n : this._slice.call(this.buf, start, end);\r\n};\r\n\r\n/**\r\n * Reads a string preceeded by its byte length as a varint.\r\n * @returns {string} Value read\r\n */\r\nReader.prototype.string = function read_string() {\r\n var bytes = this.bytes();\r\n return utf8.read(bytes, 0, bytes.length);\r\n};\r\n\r\n/**\r\n * Skips the specified number of bytes if specified, otherwise skips a varint.\r\n * @param {number} [length] Length if known, otherwise a varint is assumed\r\n * @returns {Reader} `this`\r\n */\r\nReader.prototype.skip = function skip(length) {\r\n if (typeof length === \"number\") {\r\n /* istanbul ignore if */\r\n if (this.pos + length > this.len)\r\n throw indexOutOfRange(this, length);\r\n this.pos += length;\r\n } else {\r\n do {\r\n /* istanbul ignore if */\r\n if (this.pos >= this.len)\r\n throw indexOutOfRange(this);\r\n } while (this.buf[this.pos++] & 128);\r\n }\r\n return this;\r\n};\r\n\r\n/**\r\n * Skips the next element of the specified wire type.\r\n * @param {number} wireType Wire type received\r\n * @returns {Reader} `this`\r\n */\r\nReader.prototype.skipType = function(wireType) {\r\n switch (wireType) {\r\n case 0:\r\n this.skip();\r\n break;\r\n case 1:\r\n this.skip(8);\r\n break;\r\n case 2:\r\n this.skip(this.uint32());\r\n break;\r\n case 3:\r\n while ((wireType = this.uint32() & 7) !== 4) {\r\n this.skipType(wireType);\r\n }\r\n break;\r\n case 5:\r\n this.skip(4);\r\n break;\r\n\r\n /* istanbul ignore next */\r\n default:\r\n throw Error(\"invalid wire type \" + wireType + \" at offset \" + this.pos);\r\n }\r\n return this;\r\n};\r\n\r\nReader._configure = function(BufferReader_) {\r\n BufferReader = BufferReader_;\r\n\r\n var fn = util.Long ? \"toLong\" : /* istanbul ignore next */ \"toNumber\";\r\n util.merge(Reader.prototype, {\r\n\r\n int64: function read_int64() {\r\n return readLongVarint.call(this)[fn](false);\r\n },\r\n\r\n uint64: function read_uint64() {\r\n return readLongVarint.call(this)[fn](true);\r\n },\r\n\r\n sint64: function read_sint64() {\r\n return readLongVarint.call(this).zzDecode()[fn](false);\r\n },\r\n\r\n fixed64: function read_fixed64() {\r\n return readFixed64.call(this)[fn](true);\r\n },\r\n\r\n sfixed64: function read_sfixed64() {\r\n return readFixed64.call(this)[fn](false);\r\n }\r\n\r\n });\r\n};\r\n","\"use strict\";\r\nmodule.exports = BufferReader;\r\n\r\n// extends Reader\r\nvar Reader = require(27);\r\n(BufferReader.prototype = Object.create(Reader.prototype)).constructor = BufferReader;\r\n\r\nvar util = require(39);\r\n\r\n/**\r\n * Constructs a new buffer reader instance.\r\n * @classdesc Wire format reader using node buffers.\r\n * @extends Reader\r\n * @constructor\r\n * @param {Buffer} buffer Buffer to read from\r\n */\r\nfunction BufferReader(buffer) {\r\n Reader.call(this, buffer);\r\n\r\n /**\r\n * Read buffer.\r\n * @name BufferReader#buf\r\n * @type {Buffer}\r\n */\r\n}\r\n\r\n/* istanbul ignore else */\r\nif (util.Buffer)\r\n BufferReader.prototype._slice = util.Buffer.prototype.slice;\r\n\r\n/**\r\n * @override\r\n */\r\nBufferReader.prototype.string = function read_string_buffer() {\r\n var len = this.uint32(); // modifies pos\r\n return this.buf.utf8Slice(this.pos, this.pos = Math.min(this.pos + len, this.len));\r\n};\r\n\r\n/**\r\n * Reads a sequence of bytes preceeded by its length as a varint.\r\n * @name BufferReader#bytes\r\n * @function\r\n * @returns {Buffer} Value read\r\n */\r\n","\"use strict\";\r\nmodule.exports = Root;\r\n\r\n// extends Namespace\r\nvar Namespace = require(23);\r\n((Root.prototype = Object.create(Namespace.prototype)).constructor = Root).className = \"Root\";\r\n\r\nvar Field = require(16),\r\n Enum = require(15),\r\n OneOf = require(25),\r\n util = require(37);\r\n\r\nvar Type, // cyclic\r\n parse, // might be excluded\r\n common; // \"\r\n\r\n/**\r\n * Constructs a new root namespace instance.\r\n * @classdesc Root namespace wrapping all types, enums, services, sub-namespaces etc. that belong together.\r\n * @extends NamespaceBase\r\n * @constructor\r\n * @param {Object.} [options] Top level options\r\n */\r\nfunction Root(options) {\r\n Namespace.call(this, \"\", options);\r\n\r\n /**\r\n * Deferred extension fields.\r\n * @type {Field[]}\r\n */\r\n this.deferred = [];\r\n\r\n /**\r\n * Resolved file names of loaded files.\r\n * @type {string[]}\r\n */\r\n this.files = [];\r\n}\r\n\r\n/**\r\n * Loads a namespace descriptor into a root namespace.\r\n * @param {INamespace} json Nameespace descriptor\r\n * @param {Root} [root] Root namespace, defaults to create a new one if omitted\r\n * @returns {Root} Root namespace\r\n */\r\nRoot.fromJSON = function fromJSON(json, root) {\r\n if (!root)\r\n root = new Root();\r\n if (json.options)\r\n root.setOptions(json.options);\r\n return root.addJSON(json.nested);\r\n};\r\n\r\n/**\r\n * Resolves the path of an imported file, relative to the importing origin.\r\n * This method exists so you can override it with your own logic in case your imports are scattered over multiple directories.\r\n * @function\r\n * @param {string} origin The file name of the importing file\r\n * @param {string} target The file name being imported\r\n * @returns {string|null} Resolved path to `target` or `null` to skip the file\r\n */\r\nRoot.prototype.resolvePath = util.path.resolve;\r\n\r\n// A symbol-like function to safely signal synchronous loading\r\n/* istanbul ignore next */\r\nfunction SYNC() {} // eslint-disable-line no-empty-function\r\n\r\n/**\r\n * Loads one or multiple .proto or preprocessed .json files into this root namespace and calls the callback.\r\n * @param {string|string[]} filename Names of one or multiple files to load\r\n * @param {IParseOptions} options Parse options\r\n * @param {LoadCallback} callback Callback function\r\n * @returns {undefined}\r\n */\r\nRoot.prototype.load = function load(filename, options, callback) {\r\n if (typeof options === \"function\") {\r\n callback = options;\r\n options = undefined;\r\n }\r\n var self = this;\r\n if (!callback)\r\n return util.asPromise(load, self, filename, options);\r\n\r\n var sync = callback === SYNC; // undocumented\r\n\r\n // Finishes loading by calling the callback (exactly once)\r\n function finish(err, root) {\r\n /* istanbul ignore if */\r\n if (!callback)\r\n return;\r\n var cb = callback;\r\n callback = null;\r\n if (sync)\r\n throw err;\r\n cb(err, root);\r\n }\r\n\r\n // Processes a single file\r\n function process(filename, source) {\r\n try {\r\n if (util.isString(source) && source.charAt(0) === \"{\")\r\n source = JSON.parse(source);\r\n if (!util.isString(source))\r\n self.setOptions(source.options).addJSON(source.nested);\r\n else {\r\n parse.filename = filename;\r\n var parsed = parse(source, self, options),\r\n resolved,\r\n i = 0;\r\n if (parsed.imports)\r\n for (; i < parsed.imports.length; ++i)\r\n if (resolved = self.resolvePath(filename, parsed.imports[i]))\r\n fetch(resolved);\r\n if (parsed.weakImports)\r\n for (i = 0; i < parsed.weakImports.length; ++i)\r\n if (resolved = self.resolvePath(filename, parsed.weakImports[i]))\r\n fetch(resolved, true);\r\n }\r\n } catch (err) {\r\n finish(err);\r\n }\r\n if (!sync && !queued)\r\n finish(null, self); // only once anyway\r\n }\r\n\r\n // Fetches a single file\r\n function fetch(filename, weak) {\r\n\r\n // Strip path if this file references a bundled definition\r\n var idx = filename.lastIndexOf(\"google/protobuf/\");\r\n if (idx > -1) {\r\n var altname = filename.substring(idx);\r\n if (altname in common)\r\n filename = altname;\r\n }\r\n\r\n // Skip if already loaded / attempted\r\n if (self.files.indexOf(filename) > -1)\r\n return;\r\n self.files.push(filename);\r\n\r\n // Shortcut bundled definitions\r\n if (filename in common) {\r\n if (sync)\r\n process(filename, common[filename]);\r\n else {\r\n ++queued;\r\n setTimeout(function() {\r\n --queued;\r\n process(filename, common[filename]);\r\n });\r\n }\r\n return;\r\n }\r\n\r\n // Otherwise fetch from disk or network\r\n if (sync) {\r\n var source;\r\n try {\r\n source = util.fs.readFileSync(filename).toString(\"utf8\");\r\n } catch (err) {\r\n if (!weak)\r\n finish(err);\r\n return;\r\n }\r\n process(filename, source);\r\n } else {\r\n ++queued;\r\n util.fetch(filename, function(err, source) {\r\n --queued;\r\n /* istanbul ignore if */\r\n if (!callback)\r\n return; // terminated meanwhile\r\n if (err) {\r\n /* istanbul ignore else */\r\n if (!weak)\r\n finish(err);\r\n else if (!queued) // can't be covered reliably\r\n finish(null, self);\r\n return;\r\n }\r\n process(filename, source);\r\n });\r\n }\r\n }\r\n var queued = 0;\r\n\r\n // Assembling the root namespace doesn't require working type\r\n // references anymore, so we can load everything in parallel\r\n if (util.isString(filename))\r\n filename = [ filename ];\r\n for (var i = 0, resolved; i < filename.length; ++i)\r\n if (resolved = self.resolvePath(\"\", filename[i]))\r\n fetch(resolved);\r\n\r\n if (sync)\r\n return self;\r\n if (!queued)\r\n finish(null, self);\r\n return undefined;\r\n};\r\n// function load(filename:string, options:IParseOptions, callback:LoadCallback):undefined\r\n\r\n/**\r\n * Loads one or multiple .proto or preprocessed .json files into this root namespace and calls the callback.\r\n * @function Root#load\r\n * @param {string|string[]} filename Names of one or multiple files to load\r\n * @param {LoadCallback} callback Callback function\r\n * @returns {undefined}\r\n * @variation 2\r\n */\r\n// function load(filename:string, callback:LoadCallback):undefined\r\n\r\n/**\r\n * Loads one or multiple .proto or preprocessed .json files into this root namespace and returns a promise.\r\n * @function Root#load\r\n * @param {string|string[]} filename Names of one or multiple files to load\r\n * @param {IParseOptions} [options] Parse options. Defaults to {@link parse.defaults} when omitted.\r\n * @returns {Promise} Promise\r\n * @variation 3\r\n */\r\n// function load(filename:string, [options:IParseOptions]):Promise\r\n\r\n/**\r\n * Synchronously loads one or multiple .proto or preprocessed .json files into this root namespace (node only).\r\n * @function Root#loadSync\r\n * @param {string|string[]} filename Names of one or multiple files to load\r\n * @param {IParseOptions} [options] Parse options. Defaults to {@link parse.defaults} when omitted.\r\n * @returns {Root} Root namespace\r\n * @throws {Error} If synchronous fetching is not supported (i.e. in browsers) or if a file's syntax is invalid\r\n */\r\nRoot.prototype.loadSync = function loadSync(filename, options) {\r\n if (!util.isNode)\r\n throw Error(\"not supported\");\r\n return this.load(filename, options, SYNC);\r\n};\r\n\r\n/**\r\n * @override\r\n */\r\nRoot.prototype.resolveAll = function resolveAll() {\r\n if (this.deferred.length)\r\n throw Error(\"unresolvable extensions: \" + this.deferred.map(function(field) {\r\n return \"'extend \" + field.extend + \"' in \" + field.parent.fullName;\r\n }).join(\", \"));\r\n return Namespace.prototype.resolveAll.call(this);\r\n};\r\n\r\n// only uppercased (and thus conflict-free) children are exposed, see below\r\nvar exposeRe = /^[A-Z]/;\r\n\r\n/**\r\n * Handles a deferred declaring extension field by creating a sister field to represent it within its extended type.\r\n * @param {Root} root Root instance\r\n * @param {Field} field Declaring extension field witin the declaring type\r\n * @returns {boolean} `true` if successfully added to the extended type, `false` otherwise\r\n * @inner\r\n * @ignore\r\n */\r\nfunction tryHandleExtension(root, field) {\r\n var extendedType = field.parent.lookup(field.extend);\r\n if (extendedType) {\r\n var sisterField = new Field(field.fullName, field.id, field.type, field.rule, undefined, field.options);\r\n sisterField.declaringField = field;\r\n field.extensionField = sisterField;\r\n extendedType.add(sisterField);\r\n return true;\r\n }\r\n return false;\r\n}\r\n\r\n/**\r\n * Called when any object is added to this root or its sub-namespaces.\r\n * @param {ReflectionObject} object Object added\r\n * @returns {undefined}\r\n * @private\r\n */\r\nRoot.prototype._handleAdd = function _handleAdd(object) {\r\n if (object instanceof Field) {\r\n\r\n if (/* an extension field (implies not part of a oneof) */ object.extend !== undefined && /* not already handled */ !object.extensionField)\r\n if (!tryHandleExtension(this, object))\r\n this.deferred.push(object);\r\n\r\n } else if (object instanceof Enum) {\r\n\r\n if (exposeRe.test(object.name))\r\n object.parent[object.name] = object.values; // expose enum values as property of its parent\r\n\r\n } else if (!(object instanceof OneOf)) /* everything else is a namespace */ {\r\n\r\n if (object instanceof Type) // Try to handle any deferred extensions\r\n for (var i = 0; i < this.deferred.length;)\r\n if (tryHandleExtension(this, this.deferred[i]))\r\n this.deferred.splice(i, 1);\r\n else\r\n ++i;\r\n for (var j = 0; j < /* initializes */ object.nestedArray.length; ++j) // recurse into the namespace\r\n this._handleAdd(object._nestedArray[j]);\r\n if (exposeRe.test(object.name))\r\n object.parent[object.name] = object; // expose namespace as property of its parent\r\n }\r\n\r\n // The above also adds uppercased (and thus conflict-free) nested types, services and enums as\r\n // properties of namespaces just like static code does. This allows using a .d.ts generated for\r\n // a static module with reflection-based solutions where the condition is met.\r\n};\r\n\r\n/**\r\n * Called when any object is removed from this root or its sub-namespaces.\r\n * @param {ReflectionObject} object Object removed\r\n * @returns {undefined}\r\n * @private\r\n */\r\nRoot.prototype._handleRemove = function _handleRemove(object) {\r\n if (object instanceof Field) {\r\n\r\n if (/* an extension field */ object.extend !== undefined) {\r\n if (/* already handled */ object.extensionField) { // remove its sister field\r\n object.extensionField.parent.remove(object.extensionField);\r\n object.extensionField = null;\r\n } else { // cancel the extension\r\n var index = this.deferred.indexOf(object);\r\n /* istanbul ignore else */\r\n if (index > -1)\r\n this.deferred.splice(index, 1);\r\n }\r\n }\r\n\r\n } else if (object instanceof Enum) {\r\n\r\n if (exposeRe.test(object.name))\r\n delete object.parent[object.name]; // unexpose enum values\r\n\r\n } else if (object instanceof Namespace) {\r\n\r\n for (var i = 0; i < /* initializes */ object.nestedArray.length; ++i) // recurse into the namespace\r\n this._handleRemove(object._nestedArray[i]);\r\n\r\n if (exposeRe.test(object.name))\r\n delete object.parent[object.name]; // unexpose namespaces\r\n\r\n }\r\n};\r\n\r\n// Sets up cyclic dependencies (called in index-light)\r\nRoot._configure = function(Type_, parse_, common_) {\r\n Type = Type_;\r\n parse = parse_;\r\n common = common_;\r\n};\r\n","\"use strict\";\r\nmodule.exports = {};\r\n\r\n/**\r\n * Named roots.\r\n * This is where pbjs stores generated structures (the option `-r, --root` specifies a name).\r\n * Can also be used manually to make roots available accross modules.\r\n * @name roots\r\n * @type {Object.}\r\n * @example\r\n * // pbjs -r myroot -o compiled.js ...\r\n *\r\n * // in another module:\r\n * require(\"./compiled.js\");\r\n *\r\n * // in any subsequent module:\r\n * var root = protobuf.roots[\"myroot\"];\r\n */\r\n","\"use strict\";\r\n\r\n/**\r\n * Streaming RPC helpers.\r\n * @namespace\r\n */\r\nvar rpc = exports;\r\n\r\n/**\r\n * RPC implementation passed to {@link Service#create} performing a service request on network level, i.e. by utilizing http requests or websockets.\r\n * @typedef RPCImpl\r\n * @type {function}\r\n * @param {Method|rpc.ServiceMethod,Message<{}>>} method Reflected or static method being called\r\n * @param {Uint8Array} requestData Request data\r\n * @param {RPCImplCallback} callback Callback function\r\n * @returns {undefined}\r\n * @example\r\n * function rpcImpl(method, requestData, callback) {\r\n * if (protobuf.util.lcFirst(method.name) !== \"myMethod\") // compatible with static code\r\n * throw Error(\"no such method\");\r\n * asynchronouslyObtainAResponse(requestData, function(err, responseData) {\r\n * callback(err, responseData);\r\n * });\r\n * }\r\n */\r\n\r\n/**\r\n * Node-style callback as used by {@link RPCImpl}.\r\n * @typedef RPCImplCallback\r\n * @type {function}\r\n * @param {Error|null} error Error, if any, otherwise `null`\r\n * @param {Uint8Array|null} [response] Response data or `null` to signal end of stream, if there hasn't been an error\r\n * @returns {undefined}\r\n */\r\n\r\nrpc.Service = require(32);\r\n","\"use strict\";\r\nmodule.exports = Service;\r\n\r\nvar util = require(39);\r\n\r\n// Extends EventEmitter\r\n(Service.prototype = Object.create(util.EventEmitter.prototype)).constructor = Service;\r\n\r\n/**\r\n * A service method callback as used by {@link rpc.ServiceMethod|ServiceMethod}.\r\n *\r\n * Differs from {@link RPCImplCallback} in that it is an actual callback of a service method which may not return `response = null`.\r\n * @typedef rpc.ServiceMethodCallback\r\n * @template TRes extends Message\r\n * @type {function}\r\n * @param {Error|null} error Error, if any\r\n * @param {TRes} [response] Response message\r\n * @returns {undefined}\r\n */\r\n\r\n/**\r\n * A service method part of a {@link rpc.Service} as created by {@link Service.create}.\r\n * @typedef rpc.ServiceMethod\r\n * @template TReq extends Message\r\n * @template TRes extends Message\r\n * @type {function}\r\n * @param {TReq|Properties} request Request message or plain object\r\n * @param {rpc.ServiceMethodCallback} [callback] Node-style callback called with the error, if any, and the response message\r\n * @returns {Promise>} Promise if `callback` has been omitted, otherwise `undefined`\r\n */\r\n\r\n/**\r\n * Constructs a new RPC service instance.\r\n * @classdesc An RPC service as returned by {@link Service#create}.\r\n * @exports rpc.Service\r\n * @extends util.EventEmitter\r\n * @constructor\r\n * @param {RPCImpl} rpcImpl RPC implementation\r\n * @param {boolean} [requestDelimited=false] Whether requests are length-delimited\r\n * @param {boolean} [responseDelimited=false] Whether responses are length-delimited\r\n */\r\nfunction Service(rpcImpl, requestDelimited, responseDelimited) {\r\n\r\n if (typeof rpcImpl !== \"function\")\r\n throw TypeError(\"rpcImpl must be a function\");\r\n\r\n util.EventEmitter.call(this);\r\n\r\n /**\r\n * RPC implementation. Becomes `null` once the service is ended.\r\n * @type {RPCImpl|null}\r\n */\r\n this.rpcImpl = rpcImpl;\r\n\r\n /**\r\n * Whether requests are length-delimited.\r\n * @type {boolean}\r\n */\r\n this.requestDelimited = Boolean(requestDelimited);\r\n\r\n /**\r\n * Whether responses are length-delimited.\r\n * @type {boolean}\r\n */\r\n this.responseDelimited = Boolean(responseDelimited);\r\n}\r\n\r\n/**\r\n * Calls a service method through {@link rpc.Service#rpcImpl|rpcImpl}.\r\n * @param {Method|rpc.ServiceMethod} method Reflected or static method\r\n * @param {Constructor} requestCtor Request constructor\r\n * @param {Constructor} responseCtor Response constructor\r\n * @param {TReq|Properties} request Request message or plain object\r\n * @param {rpc.ServiceMethodCallback} callback Service callback\r\n * @returns {undefined}\r\n * @template TReq extends Message\r\n * @template TRes extends Message\r\n */\r\nService.prototype.rpcCall = function rpcCall(method, requestCtor, responseCtor, request, callback) {\r\n\r\n if (!request)\r\n throw TypeError(\"request must be specified\");\r\n\r\n var self = this;\r\n if (!callback)\r\n return util.asPromise(rpcCall, self, method, requestCtor, responseCtor, request);\r\n\r\n if (!self.rpcImpl) {\r\n setTimeout(function() { callback(Error(\"already ended\")); }, 0);\r\n return undefined;\r\n }\r\n\r\n try {\r\n return self.rpcImpl(\r\n method,\r\n requestCtor[self.requestDelimited ? \"encodeDelimited\" : \"encode\"](request).finish(),\r\n function rpcCallback(err, response) {\r\n\r\n if (err) {\r\n self.emit(\"error\", err, method);\r\n return callback(err);\r\n }\r\n\r\n if (response === null) {\r\n self.end(/* endedByRPC */ true);\r\n return undefined;\r\n }\r\n\r\n if (!(response instanceof responseCtor)) {\r\n try {\r\n response = responseCtor[self.responseDelimited ? \"decodeDelimited\" : \"decode\"](response);\r\n } catch (err) {\r\n self.emit(\"error\", err, method);\r\n return callback(err);\r\n }\r\n }\r\n\r\n self.emit(\"data\", response, method);\r\n return callback(null, response);\r\n }\r\n );\r\n } catch (err) {\r\n self.emit(\"error\", err, method);\r\n setTimeout(function() { callback(err); }, 0);\r\n return undefined;\r\n }\r\n};\r\n\r\n/**\r\n * Ends this service and emits the `end` event.\r\n * @param {boolean} [endedByRPC=false] Whether the service has been ended by the RPC implementation.\r\n * @returns {rpc.Service} `this`\r\n */\r\nService.prototype.end = function end(endedByRPC) {\r\n if (this.rpcImpl) {\r\n if (!endedByRPC) // signal end to rpcImpl\r\n this.rpcImpl(null, null, null);\r\n this.rpcImpl = null;\r\n this.emit(\"end\").off();\r\n }\r\n return this;\r\n};\r\n","\"use strict\";\r\nmodule.exports = Service;\r\n\r\n// extends Namespace\r\nvar Namespace = require(23);\r\n((Service.prototype = Object.create(Namespace.prototype)).constructor = Service).className = \"Service\";\r\n\r\nvar Method = require(22),\r\n util = require(37),\r\n rpc = require(31);\r\n\r\n/**\r\n * Constructs a new service instance.\r\n * @classdesc Reflected service.\r\n * @extends NamespaceBase\r\n * @constructor\r\n * @param {string} name Service name\r\n * @param {Object.} [options] Service options\r\n * @throws {TypeError} If arguments are invalid\r\n */\r\nfunction Service(name, options) {\r\n Namespace.call(this, name, options);\r\n\r\n /**\r\n * Service methods.\r\n * @type {Object.}\r\n */\r\n this.methods = {}; // toJSON, marker\r\n\r\n /**\r\n * Cached methods as an array.\r\n * @type {Method[]|null}\r\n * @private\r\n */\r\n this._methodsArray = null;\r\n}\r\n\r\n/**\r\n * Service descriptor.\r\n * @interface IService\r\n * @extends INamespace\r\n * @property {Object.} methods Method descriptors\r\n */\r\n\r\n/**\r\n * Constructs a service from a service descriptor.\r\n * @param {string} name Service name\r\n * @param {IService} json Service descriptor\r\n * @returns {Service} Created service\r\n * @throws {TypeError} If arguments are invalid\r\n */\r\nService.fromJSON = function fromJSON(name, json) {\r\n var service = new Service(name, json.options);\r\n /* istanbul ignore else */\r\n if (json.methods)\r\n for (var names = Object.keys(json.methods), i = 0; i < names.length; ++i)\r\n service.add(Method.fromJSON(names[i], json.methods[names[i]]));\r\n if (json.nested)\r\n service.addJSON(json.nested);\r\n service.comment = json.comment;\r\n return service;\r\n};\r\n\r\n/**\r\n * Converts this service to a service descriptor.\r\n * @param {IToJSONOptions} [toJSONOptions] JSON conversion options\r\n * @returns {IService} Service descriptor\r\n */\r\nService.prototype.toJSON = function toJSON(toJSONOptions) {\r\n var inherited = Namespace.prototype.toJSON.call(this, toJSONOptions);\r\n var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false;\r\n return util.toObject([\r\n \"options\" , inherited && inherited.options || undefined,\r\n \"methods\" , Namespace.arrayToJSON(this.methodsArray, toJSONOptions) || /* istanbul ignore next */ {},\r\n \"nested\" , inherited && inherited.nested || undefined,\r\n \"comment\" , keepComments ? this.comment : undefined\r\n ]);\r\n};\r\n\r\n/**\r\n * Methods of this service as an array for iteration.\r\n * @name Service#methodsArray\r\n * @type {Method[]}\r\n * @readonly\r\n */\r\nObject.defineProperty(Service.prototype, \"methodsArray\", {\r\n get: function() {\r\n return this._methodsArray || (this._methodsArray = util.toArray(this.methods));\r\n }\r\n});\r\n\r\nfunction clearCache(service) {\r\n service._methodsArray = null;\r\n return service;\r\n}\r\n\r\n/**\r\n * @override\r\n */\r\nService.prototype.get = function get(name) {\r\n return this.methods[name]\r\n || Namespace.prototype.get.call(this, name);\r\n};\r\n\r\n/**\r\n * @override\r\n */\r\nService.prototype.resolveAll = function resolveAll() {\r\n var methods = this.methodsArray;\r\n for (var i = 0; i < methods.length; ++i)\r\n methods[i].resolve();\r\n return Namespace.prototype.resolve.call(this);\r\n};\r\n\r\n/**\r\n * @override\r\n */\r\nService.prototype.add = function add(object) {\r\n\r\n /* istanbul ignore if */\r\n if (this.get(object.name))\r\n throw Error(\"duplicate name '\" + object.name + \"' in \" + this);\r\n\r\n if (object instanceof Method) {\r\n this.methods[object.name] = object;\r\n object.parent = this;\r\n return clearCache(this);\r\n }\r\n return Namespace.prototype.add.call(this, object);\r\n};\r\n\r\n/**\r\n * @override\r\n */\r\nService.prototype.remove = function remove(object) {\r\n if (object instanceof Method) {\r\n\r\n /* istanbul ignore if */\r\n if (this.methods[object.name] !== object)\r\n throw Error(object + \" is not a member of \" + this);\r\n\r\n delete this.methods[object.name];\r\n object.parent = null;\r\n return clearCache(this);\r\n }\r\n return Namespace.prototype.remove.call(this, object);\r\n};\r\n\r\n/**\r\n * Creates a runtime service using the specified rpc implementation.\r\n * @param {RPCImpl} rpcImpl RPC implementation\r\n * @param {boolean} [requestDelimited=false] Whether requests are length-delimited\r\n * @param {boolean} [responseDelimited=false] Whether responses are length-delimited\r\n * @returns {rpc.Service} RPC service. Useful where requests and/or responses are streamed.\r\n */\r\nService.prototype.create = function create(rpcImpl, requestDelimited, responseDelimited) {\r\n var rpcService = new rpc.Service(rpcImpl, requestDelimited, responseDelimited);\r\n for (var i = 0, method; i < /* initializes */ this.methodsArray.length; ++i) {\r\n var methodName = util.lcFirst((method = this._methodsArray[i]).resolve().name).replace(/[^$\\w_]/g, \"\");\r\n rpcService[methodName] = util.codegen([\"r\",\"c\"], util.isReserved(methodName) ? methodName + \"_\" : methodName)(\"return this.rpcCall(m,q,s,r,c)\")({\r\n m: method,\r\n q: method.resolvedRequestType.ctor,\r\n s: method.resolvedResponseType.ctor\r\n });\r\n }\r\n return rpcService;\r\n};\r\n","\"use strict\";\r\nmodule.exports = tokenize;\r\n\r\nvar delimRe = /[\\s{}=;:[\\],'\"()<>]/g,\r\n stringDoubleRe = /(?:\"([^\"\\\\]*(?:\\\\.[^\"\\\\]*)*)\")/g,\r\n stringSingleRe = /(?:'([^'\\\\]*(?:\\\\.[^'\\\\]*)*)')/g;\r\n\r\nvar setCommentRe = /^ *[*/]+ */,\r\n setCommentAltRe = /^\\s*\\*?\\/*/,\r\n setCommentSplitRe = /\\n/g,\r\n whitespaceRe = /\\s/,\r\n unescapeRe = /\\\\(.?)/g;\r\n\r\nvar unescapeMap = {\r\n \"0\": \"\\0\",\r\n \"r\": \"\\r\",\r\n \"n\": \"\\n\",\r\n \"t\": \"\\t\"\r\n};\r\n\r\n/**\r\n * Unescapes a string.\r\n * @param {string} str String to unescape\r\n * @returns {string} Unescaped string\r\n * @property {Object.} map Special characters map\r\n * @memberof tokenize\r\n */\r\nfunction unescape(str) {\r\n return str.replace(unescapeRe, function($0, $1) {\r\n switch ($1) {\r\n case \"\\\\\":\r\n case \"\":\r\n return $1;\r\n default:\r\n return unescapeMap[$1] || \"\";\r\n }\r\n });\r\n}\r\n\r\ntokenize.unescape = unescape;\r\n\r\n/**\r\n * Gets the next token and advances.\r\n * @typedef TokenizerHandleNext\r\n * @type {function}\r\n * @returns {string|null} Next token or `null` on eof\r\n */\r\n\r\n/**\r\n * Peeks for the next token.\r\n * @typedef TokenizerHandlePeek\r\n * @type {function}\r\n * @returns {string|null} Next token or `null` on eof\r\n */\r\n\r\n/**\r\n * Pushes a token back to the stack.\r\n * @typedef TokenizerHandlePush\r\n * @type {function}\r\n * @param {string} token Token\r\n * @returns {undefined}\r\n */\r\n\r\n/**\r\n * Skips the next token.\r\n * @typedef TokenizerHandleSkip\r\n * @type {function}\r\n * @param {string} expected Expected token\r\n * @param {boolean} [optional=false] If optional\r\n * @returns {boolean} Whether the token matched\r\n * @throws {Error} If the token didn't match and is not optional\r\n */\r\n\r\n/**\r\n * Gets the comment on the previous line or, alternatively, the line comment on the specified line.\r\n * @typedef TokenizerHandleCmnt\r\n * @type {function}\r\n * @param {number} [line] Line number\r\n * @returns {string|null} Comment text or `null` if none\r\n */\r\n\r\n/**\r\n * Handle object returned from {@link tokenize}.\r\n * @interface ITokenizerHandle\r\n * @property {TokenizerHandleNext} next Gets the next token and advances (`null` on eof)\r\n * @property {TokenizerHandlePeek} peek Peeks for the next token (`null` on eof)\r\n * @property {TokenizerHandlePush} push Pushes a token back to the stack\r\n * @property {TokenizerHandleSkip} skip Skips a token, returns its presence and advances or, if non-optional and not present, throws\r\n * @property {TokenizerHandleCmnt} cmnt Gets the comment on the previous line or the line comment on the specified line, if any\r\n * @property {number} line Current line number\r\n */\r\n\r\n/**\r\n * Tokenizes the given .proto source and returns an object with useful utility functions.\r\n * @param {string} source Source contents\r\n * @param {boolean} alternateCommentMode Whether we should activate alternate comment parsing mode.\r\n * @returns {ITokenizerHandle} Tokenizer handle\r\n */\r\nfunction tokenize(source, alternateCommentMode) {\r\n /* eslint-disable callback-return */\r\n source = source.toString();\r\n\r\n var offset = 0,\r\n length = source.length,\r\n line = 1,\r\n commentType = null,\r\n commentText = null,\r\n commentLine = 0,\r\n commentLineEmpty = false;\r\n\r\n var stack = [];\r\n\r\n var stringDelim = null;\r\n\r\n /* istanbul ignore next */\r\n /**\r\n * Creates an error for illegal syntax.\r\n * @param {string} subject Subject\r\n * @returns {Error} Error created\r\n * @inner\r\n */\r\n function illegal(subject) {\r\n return Error(\"illegal \" + subject + \" (line \" + line + \")\");\r\n }\r\n\r\n /**\r\n * Reads a string till its end.\r\n * @returns {string} String read\r\n * @inner\r\n */\r\n function readString() {\r\n var re = stringDelim === \"'\" ? stringSingleRe : stringDoubleRe;\r\n re.lastIndex = offset - 1;\r\n var match = re.exec(source);\r\n if (!match)\r\n throw illegal(\"string\");\r\n offset = re.lastIndex;\r\n push(stringDelim);\r\n stringDelim = null;\r\n return unescape(match[1]);\r\n }\r\n\r\n /**\r\n * Gets the character at `pos` within the source.\r\n * @param {number} pos Position\r\n * @returns {string} Character\r\n * @inner\r\n */\r\n function charAt(pos) {\r\n return source.charAt(pos);\r\n }\r\n\r\n /**\r\n * Sets the current comment text.\r\n * @param {number} start Start offset\r\n * @param {number} end End offset\r\n * @returns {undefined}\r\n * @inner\r\n */\r\n function setComment(start, end) {\r\n commentType = source.charAt(start++);\r\n commentLine = line;\r\n commentLineEmpty = false;\r\n var lookback;\r\n if (alternateCommentMode) {\r\n lookback = 2; // alternate comment parsing: \"//\" or \"/*\"\r\n } else {\r\n lookback = 3; // \"///\" or \"/**\"\r\n }\r\n var commentOffset = start - lookback,\r\n c;\r\n do {\r\n if (--commentOffset < 0 ||\r\n (c = source.charAt(commentOffset)) === \"\\n\") {\r\n commentLineEmpty = true;\r\n break;\r\n }\r\n } while (c === \" \" || c === \"\\t\");\r\n var lines = source\r\n .substring(start, end)\r\n .split(setCommentSplitRe);\r\n for (var i = 0; i < lines.length; ++i)\r\n lines[i] = lines[i]\r\n .replace(alternateCommentMode ? setCommentAltRe : setCommentRe, \"\")\r\n .trim();\r\n commentText = lines\r\n .join(\"\\n\")\r\n .trim();\r\n }\r\n\r\n function isDoubleSlashCommentLine(startOffset) {\r\n var endOffset = findEndOfLine(startOffset);\r\n\r\n // see if remaining line matches comment pattern\r\n var lineText = source.substring(startOffset, endOffset);\r\n // look for 1 or 2 slashes since startOffset would already point past\r\n // the first slash that started the comment.\r\n var isComment = /^\\s*\\/{1,2}/.test(lineText);\r\n return isComment;\r\n }\r\n\r\n function findEndOfLine(cursor) {\r\n // find end of cursor's line\r\n var endOffset = cursor;\r\n while (endOffset < length && charAt(endOffset) !== \"\\n\") {\r\n endOffset++;\r\n }\r\n return endOffset;\r\n }\r\n\r\n /**\r\n * Obtains the next token.\r\n * @returns {string|null} Next token or `null` on eof\r\n * @inner\r\n */\r\n function next() {\r\n if (stack.length > 0)\r\n return stack.shift();\r\n if (stringDelim)\r\n return readString();\r\n var repeat,\r\n prev,\r\n curr,\r\n start,\r\n isDoc;\r\n do {\r\n if (offset === length)\r\n return null;\r\n repeat = false;\r\n while (whitespaceRe.test(curr = charAt(offset))) {\r\n if (curr === \"\\n\")\r\n ++line;\r\n if (++offset === length)\r\n return null;\r\n }\r\n\r\n if (charAt(offset) === \"/\") {\r\n if (++offset === length) {\r\n throw illegal(\"comment\");\r\n }\r\n if (charAt(offset) === \"/\") { // Line\r\n if (!alternateCommentMode) {\r\n // check for triple-slash comment\r\n isDoc = charAt(start = offset + 1) === \"/\";\r\n\r\n while (charAt(++offset) !== \"\\n\") {\r\n if (offset === length) {\r\n return null;\r\n }\r\n }\r\n ++offset;\r\n if (isDoc) {\r\n setComment(start, offset - 1);\r\n }\r\n ++line;\r\n repeat = true;\r\n } else {\r\n // check for double-slash comments, consolidating consecutive lines\r\n start = offset;\r\n isDoc = false;\r\n if (isDoubleSlashCommentLine(offset)) {\r\n isDoc = true;\r\n do {\r\n offset = findEndOfLine(offset);\r\n if (offset === length) {\r\n break;\r\n }\r\n offset++;\r\n } while (isDoubleSlashCommentLine(offset));\r\n } else {\r\n offset = Math.min(length, findEndOfLine(offset) + 1);\r\n }\r\n if (isDoc) {\r\n setComment(start, offset);\r\n }\r\n line++;\r\n repeat = true;\r\n }\r\n } else if ((curr = charAt(offset)) === \"*\") { /* Block */\r\n // check for /** (regular comment mode) or /* (alternate comment mode)\r\n start = offset + 1;\r\n isDoc = alternateCommentMode || charAt(start) === \"*\";\r\n do {\r\n if (curr === \"\\n\") {\r\n ++line;\r\n }\r\n if (++offset === length) {\r\n throw illegal(\"comment\");\r\n }\r\n prev = curr;\r\n curr = charAt(offset);\r\n } while (prev !== \"*\" || curr !== \"/\");\r\n ++offset;\r\n if (isDoc) {\r\n setComment(start, offset - 2);\r\n }\r\n repeat = true;\r\n } else {\r\n return \"/\";\r\n }\r\n }\r\n } while (repeat);\r\n\r\n // offset !== length if we got here\r\n\r\n var end = offset;\r\n delimRe.lastIndex = 0;\r\n var delim = delimRe.test(charAt(end++));\r\n if (!delim)\r\n while (end < length && !delimRe.test(charAt(end)))\r\n ++end;\r\n var token = source.substring(offset, offset = end);\r\n if (token === \"\\\"\" || token === \"'\")\r\n stringDelim = token;\r\n return token;\r\n }\r\n\r\n /**\r\n * Pushes a token back to the stack.\r\n * @param {string} token Token\r\n * @returns {undefined}\r\n * @inner\r\n */\r\n function push(token) {\r\n stack.push(token);\r\n }\r\n\r\n /**\r\n * Peeks for the next token.\r\n * @returns {string|null} Token or `null` on eof\r\n * @inner\r\n */\r\n function peek() {\r\n if (!stack.length) {\r\n var token = next();\r\n if (token === null)\r\n return null;\r\n push(token);\r\n }\r\n return stack[0];\r\n }\r\n\r\n /**\r\n * Skips a token.\r\n * @param {string} expected Expected token\r\n * @param {boolean} [optional=false] Whether the token is optional\r\n * @returns {boolean} `true` when skipped, `false` if not\r\n * @throws {Error} When a required token is not present\r\n * @inner\r\n */\r\n function skip(expected, optional) {\r\n var actual = peek(),\r\n equals = actual === expected;\r\n if (equals) {\r\n next();\r\n return true;\r\n }\r\n if (!optional)\r\n throw illegal(\"token '\" + actual + \"', '\" + expected + \"' expected\");\r\n return false;\r\n }\r\n\r\n /**\r\n * Gets a comment.\r\n * @param {number} [trailingLine] Line number if looking for a trailing comment\r\n * @returns {string|null} Comment text\r\n * @inner\r\n */\r\n function cmnt(trailingLine) {\r\n var ret = null;\r\n if (trailingLine === undefined) {\r\n if (commentLine === line - 1 && (alternateCommentMode || commentType === \"*\" || commentLineEmpty)) {\r\n ret = commentText;\r\n }\r\n } else {\r\n /* istanbul ignore else */\r\n if (commentLine < trailingLine) {\r\n peek();\r\n }\r\n if (commentLine === trailingLine && !commentLineEmpty && (alternateCommentMode || commentType === \"/\")) {\r\n ret = commentText;\r\n }\r\n }\r\n return ret;\r\n }\r\n\r\n return Object.defineProperty({\r\n next: next,\r\n peek: peek,\r\n push: push,\r\n skip: skip,\r\n cmnt: cmnt\r\n }, \"line\", {\r\n get: function() { return line; }\r\n });\r\n /* eslint-enable callback-return */\r\n}\r\n","\"use strict\";\r\nmodule.exports = Type;\r\n\r\n// extends Namespace\r\nvar Namespace = require(23);\r\n((Type.prototype = Object.create(Namespace.prototype)).constructor = Type).className = \"Type\";\r\n\r\nvar Enum = require(15),\r\n OneOf = require(25),\r\n Field = require(16),\r\n MapField = require(20),\r\n Service = require(33),\r\n Message = require(21),\r\n Reader = require(27),\r\n Writer = require(42),\r\n util = require(37),\r\n encoder = require(14),\r\n decoder = require(13),\r\n verifier = require(40),\r\n converter = require(12),\r\n wrappers = require(41);\r\n\r\n/**\r\n * Constructs a new reflected message type instance.\r\n * @classdesc Reflected message type.\r\n * @extends NamespaceBase\r\n * @constructor\r\n * @param {string} name Message name\r\n * @param {Object.} [options] Declared options\r\n */\r\nfunction Type(name, options) {\r\n Namespace.call(this, name, options);\r\n\r\n /**\r\n * Message fields.\r\n * @type {Object.}\r\n */\r\n this.fields = {}; // toJSON, marker\r\n\r\n /**\r\n * Oneofs declared within this namespace, if any.\r\n * @type {Object.}\r\n */\r\n this.oneofs = undefined; // toJSON\r\n\r\n /**\r\n * Extension ranges, if any.\r\n * @type {number[][]}\r\n */\r\n this.extensions = undefined; // toJSON\r\n\r\n /**\r\n * Reserved ranges, if any.\r\n * @type {Array.}\r\n */\r\n this.reserved = undefined; // toJSON\r\n\r\n /*?\r\n * Whether this type is a legacy group.\r\n * @type {boolean|undefined}\r\n */\r\n this.group = undefined; // toJSON\r\n\r\n /**\r\n * Cached fields by id.\r\n * @type {Object.|null}\r\n * @private\r\n */\r\n this._fieldsById = null;\r\n\r\n /**\r\n * Cached fields as an array.\r\n * @type {Field[]|null}\r\n * @private\r\n */\r\n this._fieldsArray = null;\r\n\r\n /**\r\n * Cached oneofs as an array.\r\n * @type {OneOf[]|null}\r\n * @private\r\n */\r\n this._oneofsArray = null;\r\n\r\n /**\r\n * Cached constructor.\r\n * @type {Constructor<{}>}\r\n * @private\r\n */\r\n this._ctor = null;\r\n}\r\n\r\nObject.defineProperties(Type.prototype, {\r\n\r\n /**\r\n * Message fields by id.\r\n * @name Type#fieldsById\r\n * @type {Object.}\r\n * @readonly\r\n */\r\n fieldsById: {\r\n get: function() {\r\n\r\n /* istanbul ignore if */\r\n if (this._fieldsById)\r\n return this._fieldsById;\r\n\r\n this._fieldsById = {};\r\n for (var names = Object.keys(this.fields), i = 0; i < names.length; ++i) {\r\n var field = this.fields[names[i]],\r\n id = field.id;\r\n\r\n /* istanbul ignore if */\r\n if (this._fieldsById[id])\r\n throw Error(\"duplicate id \" + id + \" in \" + this);\r\n\r\n this._fieldsById[id] = field;\r\n }\r\n return this._fieldsById;\r\n }\r\n },\r\n\r\n /**\r\n * Fields of this message as an array for iteration.\r\n * @name Type#fieldsArray\r\n * @type {Field[]}\r\n * @readonly\r\n */\r\n fieldsArray: {\r\n get: function() {\r\n return this._fieldsArray || (this._fieldsArray = util.toArray(this.fields));\r\n }\r\n },\r\n\r\n /**\r\n * Oneofs of this message as an array for iteration.\r\n * @name Type#oneofsArray\r\n * @type {OneOf[]}\r\n * @readonly\r\n */\r\n oneofsArray: {\r\n get: function() {\r\n return this._oneofsArray || (this._oneofsArray = util.toArray(this.oneofs));\r\n }\r\n },\r\n\r\n /**\r\n * The registered constructor, if any registered, otherwise a generic constructor.\r\n * Assigning a function replaces the internal constructor. If the function does not extend {@link Message} yet, its prototype will be setup accordingly and static methods will be populated. If it already extends {@link Message}, it will just replace the internal constructor.\r\n * @name Type#ctor\r\n * @type {Constructor<{}>}\r\n */\r\n ctor: {\r\n get: function() {\r\n return this._ctor || (this.ctor = Type.generateConstructor(this)());\r\n },\r\n set: function(ctor) {\r\n\r\n // Ensure proper prototype\r\n var prototype = ctor.prototype;\r\n if (!(prototype instanceof Message)) {\r\n (ctor.prototype = new Message()).constructor = ctor;\r\n util.merge(ctor.prototype, prototype);\r\n }\r\n\r\n // Classes and messages reference their reflected type\r\n ctor.$type = ctor.prototype.$type = this;\r\n\r\n // Mix in static methods\r\n util.merge(ctor, Message, true);\r\n\r\n this._ctor = ctor;\r\n\r\n // Messages have non-enumerable default values on their prototype\r\n var i = 0;\r\n for (; i < /* initializes */ this.fieldsArray.length; ++i)\r\n this._fieldsArray[i].resolve(); // ensures a proper value\r\n\r\n // Messages have non-enumerable getters and setters for each virtual oneof field\r\n var ctorProperties = {};\r\n for (i = 0; i < /* initializes */ this.oneofsArray.length; ++i)\r\n ctorProperties[this._oneofsArray[i].resolve().name] = {\r\n get: util.oneOfGetter(this._oneofsArray[i].oneof),\r\n set: util.oneOfSetter(this._oneofsArray[i].oneof)\r\n };\r\n if (i)\r\n Object.defineProperties(ctor.prototype, ctorProperties);\r\n }\r\n }\r\n});\r\n\r\n/**\r\n * Generates a constructor function for the specified type.\r\n * @param {Type} mtype Message type\r\n * @returns {Codegen} Codegen instance\r\n */\r\nType.generateConstructor = function generateConstructor(mtype) {\r\n /* eslint-disable no-unexpected-multiline */\r\n var gen = util.codegen([\"p\"], mtype.name);\r\n // explicitly initialize mutable object/array fields so that these aren't just inherited from the prototype\r\n for (var i = 0, field; i < mtype.fieldsArray.length; ++i)\r\n if ((field = mtype._fieldsArray[i]).map) gen\r\n (\"this%s={}\", util.safeProp(field.name));\r\n else if (field.repeated) gen\r\n (\"this%s=[]\", util.safeProp(field.name));\r\n return gen\r\n (\"if(p)for(var ks=Object.keys(p),i=0;i} [oneofs] Oneof descriptors\r\n * @property {Object.} fields Field descriptors\r\n * @property {number[][]} [extensions] Extension ranges\r\n * @property {number[][]} [reserved] Reserved ranges\r\n * @property {boolean} [group=false] Whether a legacy group or not\r\n */\r\n\r\n/**\r\n * Creates a message type from a message type descriptor.\r\n * @param {string} name Message name\r\n * @param {IType} json Message type descriptor\r\n * @returns {Type} Created message type\r\n */\r\nType.fromJSON = function fromJSON(name, json) {\r\n var type = new Type(name, json.options);\r\n type.extensions = json.extensions;\r\n type.reserved = json.reserved;\r\n var names = Object.keys(json.fields),\r\n i = 0;\r\n for (; i < names.length; ++i)\r\n type.add(\r\n ( typeof json.fields[names[i]].keyType !== \"undefined\"\r\n ? MapField.fromJSON\r\n : Field.fromJSON )(names[i], json.fields[names[i]])\r\n );\r\n if (json.oneofs)\r\n for (names = Object.keys(json.oneofs), i = 0; i < names.length; ++i)\r\n type.add(OneOf.fromJSON(names[i], json.oneofs[names[i]]));\r\n if (json.nested)\r\n for (names = Object.keys(json.nested), i = 0; i < names.length; ++i) {\r\n var nested = json.nested[names[i]];\r\n type.add( // most to least likely\r\n ( nested.id !== undefined\r\n ? Field.fromJSON\r\n : nested.fields !== undefined\r\n ? Type.fromJSON\r\n : nested.values !== undefined\r\n ? Enum.fromJSON\r\n : nested.methods !== undefined\r\n ? Service.fromJSON\r\n : Namespace.fromJSON )(names[i], nested)\r\n );\r\n }\r\n if (json.extensions && json.extensions.length)\r\n type.extensions = json.extensions;\r\n if (json.reserved && json.reserved.length)\r\n type.reserved = json.reserved;\r\n if (json.group)\r\n type.group = true;\r\n if (json.comment)\r\n type.comment = json.comment;\r\n return type;\r\n};\r\n\r\n/**\r\n * Converts this message type to a message type descriptor.\r\n * @param {IToJSONOptions} [toJSONOptions] JSON conversion options\r\n * @returns {IType} Message type descriptor\r\n */\r\nType.prototype.toJSON = function toJSON(toJSONOptions) {\r\n var inherited = Namespace.prototype.toJSON.call(this, toJSONOptions);\r\n var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false;\r\n return util.toObject([\r\n \"options\" , inherited && inherited.options || undefined,\r\n \"oneofs\" , Namespace.arrayToJSON(this.oneofsArray, toJSONOptions),\r\n \"fields\" , Namespace.arrayToJSON(this.fieldsArray.filter(function(obj) { return !obj.declaringField; }), toJSONOptions) || {},\r\n \"extensions\" , this.extensions && this.extensions.length ? this.extensions : undefined,\r\n \"reserved\" , this.reserved && this.reserved.length ? this.reserved : undefined,\r\n \"group\" , this.group || undefined,\r\n \"nested\" , inherited && inherited.nested || undefined,\r\n \"comment\" , keepComments ? this.comment : undefined\r\n ]);\r\n};\r\n\r\n/**\r\n * @override\r\n */\r\nType.prototype.resolveAll = function resolveAll() {\r\n var fields = this.fieldsArray, i = 0;\r\n while (i < fields.length)\r\n fields[i++].resolve();\r\n var oneofs = this.oneofsArray; i = 0;\r\n while (i < oneofs.length)\r\n oneofs[i++].resolve();\r\n return Namespace.prototype.resolveAll.call(this);\r\n};\r\n\r\n/**\r\n * @override\r\n */\r\nType.prototype.get = function get(name) {\r\n return this.fields[name]\r\n || this.oneofs && this.oneofs[name]\r\n || this.nested && this.nested[name]\r\n || null;\r\n};\r\n\r\n/**\r\n * Adds a nested object to this type.\r\n * @param {ReflectionObject} object Nested object to add\r\n * @returns {Type} `this`\r\n * @throws {TypeError} If arguments are invalid\r\n * @throws {Error} If there is already a nested object with this name or, if a field, when there is already a field with this id\r\n */\r\nType.prototype.add = function add(object) {\r\n\r\n if (this.get(object.name))\r\n throw Error(\"duplicate name '\" + object.name + \"' in \" + this);\r\n\r\n if (object instanceof Field && object.extend === undefined) {\r\n // NOTE: Extension fields aren't actual fields on the declaring type, but nested objects.\r\n // The root object takes care of adding distinct sister-fields to the respective extended\r\n // type instead.\r\n\r\n // avoids calling the getter if not absolutely necessary because it's called quite frequently\r\n if (this._fieldsById ? /* istanbul ignore next */ this._fieldsById[object.id] : this.fieldsById[object.id])\r\n throw Error(\"duplicate id \" + object.id + \" in \" + this);\r\n if (this.isReservedId(object.id))\r\n throw Error(\"id \" + object.id + \" is reserved in \" + this);\r\n if (this.isReservedName(object.name))\r\n throw Error(\"name '\" + object.name + \"' is reserved in \" + this);\r\n\r\n if (object.parent)\r\n object.parent.remove(object);\r\n this.fields[object.name] = object;\r\n object.message = this;\r\n object.onAdd(this);\r\n return clearCache(this);\r\n }\r\n if (object instanceof OneOf) {\r\n if (!this.oneofs)\r\n this.oneofs = {};\r\n this.oneofs[object.name] = object;\r\n object.onAdd(this);\r\n return clearCache(this);\r\n }\r\n return Namespace.prototype.add.call(this, object);\r\n};\r\n\r\n/**\r\n * Removes a nested object from this type.\r\n * @param {ReflectionObject} object Nested object to remove\r\n * @returns {Type} `this`\r\n * @throws {TypeError} If arguments are invalid\r\n * @throws {Error} If `object` is not a member of this type\r\n */\r\nType.prototype.remove = function remove(object) {\r\n if (object instanceof Field && object.extend === undefined) {\r\n // See Type#add for the reason why extension fields are excluded here.\r\n\r\n /* istanbul ignore if */\r\n if (!this.fields || this.fields[object.name] !== object)\r\n throw Error(object + \" is not a member of \" + this);\r\n\r\n delete this.fields[object.name];\r\n object.parent = null;\r\n object.onRemove(this);\r\n return clearCache(this);\r\n }\r\n if (object instanceof OneOf) {\r\n\r\n /* istanbul ignore if */\r\n if (!this.oneofs || this.oneofs[object.name] !== object)\r\n throw Error(object + \" is not a member of \" + this);\r\n\r\n delete this.oneofs[object.name];\r\n object.parent = null;\r\n object.onRemove(this);\r\n return clearCache(this);\r\n }\r\n return Namespace.prototype.remove.call(this, object);\r\n};\r\n\r\n/**\r\n * Tests if the specified id is reserved.\r\n * @param {number} id Id to test\r\n * @returns {boolean} `true` if reserved, otherwise `false`\r\n */\r\nType.prototype.isReservedId = function isReservedId(id) {\r\n return Namespace.isReservedId(this.reserved, id);\r\n};\r\n\r\n/**\r\n * Tests if the specified name is reserved.\r\n * @param {string} name Name to test\r\n * @returns {boolean} `true` if reserved, otherwise `false`\r\n */\r\nType.prototype.isReservedName = function isReservedName(name) {\r\n return Namespace.isReservedName(this.reserved, name);\r\n};\r\n\r\n/**\r\n * Creates a new message of this type using the specified properties.\r\n * @param {Object.} [properties] Properties to set\r\n * @returns {Message<{}>} Message instance\r\n */\r\nType.prototype.create = function create(properties) {\r\n return new this.ctor(properties);\r\n};\r\n\r\n/**\r\n * Sets up {@link Type#encode|encode}, {@link Type#decode|decode} and {@link Type#verify|verify}.\r\n * @returns {Type} `this`\r\n */\r\nType.prototype.setup = function setup() {\r\n // Sets up everything at once so that the prototype chain does not have to be re-evaluated\r\n // multiple times (V8, soft-deopt prototype-check).\r\n\r\n var fullName = this.fullName,\r\n types = [];\r\n for (var i = 0; i < /* initializes */ this.fieldsArray.length; ++i)\r\n types.push(this._fieldsArray[i].resolve().resolvedType);\r\n\r\n // Replace setup methods with type-specific generated functions\r\n this.encode = encoder(this)({\r\n Writer : Writer,\r\n types : types,\r\n util : util\r\n });\r\n this.decode = decoder(this)({\r\n Reader : Reader,\r\n types : types,\r\n util : util\r\n });\r\n this.verify = verifier(this)({\r\n types : types,\r\n util : util\r\n });\r\n this.fromObject = converter.fromObject(this)({\r\n types : types,\r\n util : util\r\n });\r\n this.toObject = converter.toObject(this)({\r\n types : types,\r\n util : util\r\n });\r\n\r\n // Inject custom wrappers for common types\r\n var wrapper = wrappers[fullName];\r\n if (wrapper) {\r\n var originalThis = Object.create(this);\r\n // if (wrapper.fromObject) {\r\n originalThis.fromObject = this.fromObject;\r\n this.fromObject = wrapper.fromObject.bind(originalThis);\r\n // }\r\n // if (wrapper.toObject) {\r\n originalThis.toObject = this.toObject;\r\n this.toObject = wrapper.toObject.bind(originalThis);\r\n // }\r\n }\r\n\r\n return this;\r\n};\r\n\r\n/**\r\n * Encodes a message of this type. Does not implicitly {@link Type#verify|verify} messages.\r\n * @param {Message<{}>|Object.} message Message instance or plain object\r\n * @param {Writer} [writer] Writer to encode to\r\n * @returns {Writer} writer\r\n */\r\nType.prototype.encode = function encode_setup(message, writer) {\r\n return this.setup().encode(message, writer); // overrides this method\r\n};\r\n\r\n/**\r\n * Encodes a message of this type preceeded by its byte length as a varint. Does not implicitly {@link Type#verify|verify} messages.\r\n * @param {Message<{}>|Object.} message Message instance or plain object\r\n * @param {Writer} [writer] Writer to encode to\r\n * @returns {Writer} writer\r\n */\r\nType.prototype.encodeDelimited = function encodeDelimited(message, writer) {\r\n return this.encode(message, writer && writer.len ? writer.fork() : writer).ldelim();\r\n};\r\n\r\n/**\r\n * Decodes a message of this type.\r\n * @param {Reader|Uint8Array} reader Reader or buffer to decode from\r\n * @param {number} [length] Length of the message, if known beforehand\r\n * @returns {Message<{}>} Decoded message\r\n * @throws {Error} If the payload is not a reader or valid buffer\r\n * @throws {util.ProtocolError<{}>} If required fields are missing\r\n */\r\nType.prototype.decode = function decode_setup(reader, length) {\r\n return this.setup().decode(reader, length); // overrides this method\r\n};\r\n\r\n/**\r\n * Decodes a message of this type preceeded by its byte length as a varint.\r\n * @param {Reader|Uint8Array} reader Reader or buffer to decode from\r\n * @returns {Message<{}>} Decoded message\r\n * @throws {Error} If the payload is not a reader or valid buffer\r\n * @throws {util.ProtocolError} If required fields are missing\r\n */\r\nType.prototype.decodeDelimited = function decodeDelimited(reader) {\r\n if (!(reader instanceof Reader))\r\n reader = Reader.create(reader);\r\n return this.decode(reader, reader.uint32());\r\n};\r\n\r\n/**\r\n * Verifies that field values are valid and that required fields are present.\r\n * @param {Object.} message Plain object to verify\r\n * @returns {null|string} `null` if valid, otherwise the reason why it is not\r\n */\r\nType.prototype.verify = function verify_setup(message) {\r\n return this.setup().verify(message); // overrides this method\r\n};\r\n\r\n/**\r\n * Creates a new message of this type from a plain object. Also converts values to their respective internal types.\r\n * @param {Object.} object Plain object to convert\r\n * @returns {Message<{}>} Message instance\r\n */\r\nType.prototype.fromObject = function fromObject(object) {\r\n return this.setup().fromObject(object);\r\n};\r\n\r\n/**\r\n * Conversion options as used by {@link Type#toObject} and {@link Message.toObject}.\r\n * @interface IConversionOptions\r\n * @property {Function} [longs] Long conversion type.\r\n * Valid values are `String` and `Number` (the global types).\r\n * Defaults to copy the present value, which is a possibly unsafe number without and a {@link Long} with a long library.\r\n * @property {Function} [enums] Enum value conversion type.\r\n * Only valid value is `String` (the global type).\r\n * Defaults to copy the present value, which is the numeric id.\r\n * @property {Function} [bytes] Bytes value conversion type.\r\n * Valid values are `Array` and (a base64 encoded) `String` (the global types).\r\n * Defaults to copy the present value, which usually is a Buffer under node and an Uint8Array in the browser.\r\n * @property {boolean} [defaults=false] Also sets default values on the resulting object\r\n * @property {boolean} [arrays=false] Sets empty arrays for missing repeated fields even if `defaults=false`\r\n * @property {boolean} [objects=false] Sets empty objects for missing map fields even if `defaults=false`\r\n * @property {boolean} [oneofs=false] Includes virtual oneof properties set to the present field's name, if any\r\n * @property {boolean} [json=false] Performs additional JSON compatibility conversions, i.e. NaN and Infinity to strings\r\n */\r\n\r\n/**\r\n * Creates a plain object from a message of this type. Also converts values to other types if specified.\r\n * @param {Message<{}>} message Message instance\r\n * @param {IConversionOptions} [options] Conversion options\r\n * @returns {Object.} Plain object\r\n */\r\nType.prototype.toObject = function toObject(message, options) {\r\n return this.setup().toObject(message, options);\r\n};\r\n\r\n/**\r\n * Decorator function as returned by {@link Type.d} (TypeScript).\r\n * @typedef TypeDecorator\r\n * @type {function}\r\n * @param {Constructor} target Target constructor\r\n * @returns {undefined}\r\n * @template T extends Message\r\n */\r\n\r\n/**\r\n * Type decorator (TypeScript).\r\n * @param {string} [typeName] Type name, defaults to the constructor's name\r\n * @returns {TypeDecorator} Decorator function\r\n * @template T extends Message\r\n */\r\nType.d = function decorateType(typeName) {\r\n return function typeDecorator(target) {\r\n util.decorateType(target, typeName);\r\n };\r\n};\r\n","\"use strict\";\r\n\r\n/**\r\n * Common type constants.\r\n * @namespace\r\n */\r\nvar types = exports;\r\n\r\nvar util = require(37);\r\n\r\nvar s = [\r\n \"double\", // 0\r\n \"float\", // 1\r\n \"int32\", // 2\r\n \"uint32\", // 3\r\n \"sint32\", // 4\r\n \"fixed32\", // 5\r\n \"sfixed32\", // 6\r\n \"int64\", // 7\r\n \"uint64\", // 8\r\n \"sint64\", // 9\r\n \"fixed64\", // 10\r\n \"sfixed64\", // 11\r\n \"bool\", // 12\r\n \"string\", // 13\r\n \"bytes\" // 14\r\n];\r\n\r\nfunction bake(values, offset) {\r\n var i = 0, o = {};\r\n offset |= 0;\r\n while (i < values.length) o[s[i + offset]] = values[i++];\r\n return o;\r\n}\r\n\r\n/**\r\n * Basic type wire types.\r\n * @type {Object.}\r\n * @const\r\n * @property {number} double=1 Fixed64 wire type\r\n * @property {number} float=5 Fixed32 wire type\r\n * @property {number} int32=0 Varint wire type\r\n * @property {number} uint32=0 Varint wire type\r\n * @property {number} sint32=0 Varint wire type\r\n * @property {number} fixed32=5 Fixed32 wire type\r\n * @property {number} sfixed32=5 Fixed32 wire type\r\n * @property {number} int64=0 Varint wire type\r\n * @property {number} uint64=0 Varint wire type\r\n * @property {number} sint64=0 Varint wire type\r\n * @property {number} fixed64=1 Fixed64 wire type\r\n * @property {number} sfixed64=1 Fixed64 wire type\r\n * @property {number} bool=0 Varint wire type\r\n * @property {number} string=2 Ldelim wire type\r\n * @property {number} bytes=2 Ldelim wire type\r\n */\r\ntypes.basic = bake([\r\n /* double */ 1,\r\n /* float */ 5,\r\n /* int32 */ 0,\r\n /* uint32 */ 0,\r\n /* sint32 */ 0,\r\n /* fixed32 */ 5,\r\n /* sfixed32 */ 5,\r\n /* int64 */ 0,\r\n /* uint64 */ 0,\r\n /* sint64 */ 0,\r\n /* fixed64 */ 1,\r\n /* sfixed64 */ 1,\r\n /* bool */ 0,\r\n /* string */ 2,\r\n /* bytes */ 2\r\n]);\r\n\r\n/**\r\n * Basic type defaults.\r\n * @type {Object.}\r\n * @const\r\n * @property {number} double=0 Double default\r\n * @property {number} float=0 Float default\r\n * @property {number} int32=0 Int32 default\r\n * @property {number} uint32=0 Uint32 default\r\n * @property {number} sint32=0 Sint32 default\r\n * @property {number} fixed32=0 Fixed32 default\r\n * @property {number} sfixed32=0 Sfixed32 default\r\n * @property {number} int64=0 Int64 default\r\n * @property {number} uint64=0 Uint64 default\r\n * @property {number} sint64=0 Sint32 default\r\n * @property {number} fixed64=0 Fixed64 default\r\n * @property {number} sfixed64=0 Sfixed64 default\r\n * @property {boolean} bool=false Bool default\r\n * @property {string} string=\"\" String default\r\n * @property {Array.} bytes=Array(0) Bytes default\r\n * @property {null} message=null Message default\r\n */\r\ntypes.defaults = bake([\r\n /* double */ 0,\r\n /* float */ 0,\r\n /* int32 */ 0,\r\n /* uint32 */ 0,\r\n /* sint32 */ 0,\r\n /* fixed32 */ 0,\r\n /* sfixed32 */ 0,\r\n /* int64 */ 0,\r\n /* uint64 */ 0,\r\n /* sint64 */ 0,\r\n /* fixed64 */ 0,\r\n /* sfixed64 */ 0,\r\n /* bool */ false,\r\n /* string */ \"\",\r\n /* bytes */ util.emptyArray,\r\n /* message */ null\r\n]);\r\n\r\n/**\r\n * Basic long type wire types.\r\n * @type {Object.}\r\n * @const\r\n * @property {number} int64=0 Varint wire type\r\n * @property {number} uint64=0 Varint wire type\r\n * @property {number} sint64=0 Varint wire type\r\n * @property {number} fixed64=1 Fixed64 wire type\r\n * @property {number} sfixed64=1 Fixed64 wire type\r\n */\r\ntypes.long = bake([\r\n /* int64 */ 0,\r\n /* uint64 */ 0,\r\n /* sint64 */ 0,\r\n /* fixed64 */ 1,\r\n /* sfixed64 */ 1\r\n], 7);\r\n\r\n/**\r\n * Allowed types for map keys with their associated wire type.\r\n * @type {Object.}\r\n * @const\r\n * @property {number} int32=0 Varint wire type\r\n * @property {number} uint32=0 Varint wire type\r\n * @property {number} sint32=0 Varint wire type\r\n * @property {number} fixed32=5 Fixed32 wire type\r\n * @property {number} sfixed32=5 Fixed32 wire type\r\n * @property {number} int64=0 Varint wire type\r\n * @property {number} uint64=0 Varint wire type\r\n * @property {number} sint64=0 Varint wire type\r\n * @property {number} fixed64=1 Fixed64 wire type\r\n * @property {number} sfixed64=1 Fixed64 wire type\r\n * @property {number} bool=0 Varint wire type\r\n * @property {number} string=2 Ldelim wire type\r\n */\r\ntypes.mapKey = bake([\r\n /* int32 */ 0,\r\n /* uint32 */ 0,\r\n /* sint32 */ 0,\r\n /* fixed32 */ 5,\r\n /* sfixed32 */ 5,\r\n /* int64 */ 0,\r\n /* uint64 */ 0,\r\n /* sint64 */ 0,\r\n /* fixed64 */ 1,\r\n /* sfixed64 */ 1,\r\n /* bool */ 0,\r\n /* string */ 2\r\n], 2);\r\n\r\n/**\r\n * Allowed types for packed repeated fields with their associated wire type.\r\n * @type {Object.}\r\n * @const\r\n * @property {number} double=1 Fixed64 wire type\r\n * @property {number} float=5 Fixed32 wire type\r\n * @property {number} int32=0 Varint wire type\r\n * @property {number} uint32=0 Varint wire type\r\n * @property {number} sint32=0 Varint wire type\r\n * @property {number} fixed32=5 Fixed32 wire type\r\n * @property {number} sfixed32=5 Fixed32 wire type\r\n * @property {number} int64=0 Varint wire type\r\n * @property {number} uint64=0 Varint wire type\r\n * @property {number} sint64=0 Varint wire type\r\n * @property {number} fixed64=1 Fixed64 wire type\r\n * @property {number} sfixed64=1 Fixed64 wire type\r\n * @property {number} bool=0 Varint wire type\r\n */\r\ntypes.packed = bake([\r\n /* double */ 1,\r\n /* float */ 5,\r\n /* int32 */ 0,\r\n /* uint32 */ 0,\r\n /* sint32 */ 0,\r\n /* fixed32 */ 5,\r\n /* sfixed32 */ 5,\r\n /* int64 */ 0,\r\n /* uint64 */ 0,\r\n /* sint64 */ 0,\r\n /* fixed64 */ 1,\r\n /* sfixed64 */ 1,\r\n /* bool */ 0\r\n]);\r\n","\"use strict\";\r\n\r\n/**\r\n * Various utility functions.\r\n * @namespace\r\n */\r\nvar util = module.exports = require(39);\r\n\r\nvar roots = require(30);\r\n\r\nvar Type, // cyclic\r\n Enum;\r\n\r\nutil.codegen = require(3);\r\nutil.fetch = require(5);\r\nutil.path = require(8);\r\n\r\n/**\r\n * Node's fs module if available.\r\n * @type {Object.}\r\n */\r\nutil.fs = util.inquire(\"fs\");\r\n\r\n/**\r\n * Converts an object's values to an array.\r\n * @param {Object.} object Object to convert\r\n * @returns {Array.<*>} Converted array\r\n */\r\nutil.toArray = function toArray(object) {\r\n if (object) {\r\n var keys = Object.keys(object),\r\n array = new Array(keys.length),\r\n index = 0;\r\n while (index < keys.length)\r\n array[index] = object[keys[index++]];\r\n return array;\r\n }\r\n return [];\r\n};\r\n\r\n/**\r\n * Converts an array of keys immediately followed by their respective value to an object, omitting undefined values.\r\n * @param {Array.<*>} array Array to convert\r\n * @returns {Object.} Converted object\r\n */\r\nutil.toObject = function toObject(array) {\r\n var object = {},\r\n index = 0;\r\n while (index < array.length) {\r\n var key = array[index++],\r\n val = array[index++];\r\n if (val !== undefined)\r\n object[key] = val;\r\n }\r\n return object;\r\n};\r\n\r\nvar safePropBackslashRe = /\\\\/g,\r\n safePropQuoteRe = /\"/g;\r\n\r\n/**\r\n * Tests whether the specified name is a reserved word in JS.\r\n * @param {string} name Name to test\r\n * @returns {boolean} `true` if reserved, otherwise `false`\r\n */\r\nutil.isReserved = function isReserved(name) {\r\n return /^(?:do|if|in|for|let|new|try|var|case|else|enum|eval|false|null|this|true|void|with|break|catch|class|const|super|throw|while|yield|delete|export|import|public|return|static|switch|typeof|default|extends|finally|package|private|continue|debugger|function|arguments|interface|protected|implements|instanceof)$/.test(name);\r\n};\r\n\r\n/**\r\n * Returns a safe property accessor for the specified property name.\r\n * @param {string} prop Property name\r\n * @returns {string} Safe accessor\r\n */\r\nutil.safeProp = function safeProp(prop) {\r\n if (!/^[$\\w_]+$/.test(prop) || util.isReserved(prop))\r\n return \"[\\\"\" + prop.replace(safePropBackslashRe, \"\\\\\\\\\").replace(safePropQuoteRe, \"\\\\\\\"\") + \"\\\"]\";\r\n return \".\" + prop;\r\n};\r\n\r\n/**\r\n * Converts the first character of a string to upper case.\r\n * @param {string} str String to convert\r\n * @returns {string} Converted string\r\n */\r\nutil.ucFirst = function ucFirst(str) {\r\n return str.charAt(0).toUpperCase() + str.substring(1);\r\n};\r\n\r\nvar camelCaseRe = /_([a-z])/g;\r\n\r\n/**\r\n * Converts a string to camel case.\r\n * @param {string} str String to convert\r\n * @returns {string} Converted string\r\n */\r\nutil.camelCase = function camelCase(str) {\r\n return str.substring(0, 1)\r\n + str.substring(1)\r\n .replace(camelCaseRe, function($0, $1) { return $1.toUpperCase(); });\r\n};\r\n\r\n/**\r\n * Compares reflected fields by id.\r\n * @param {Field} a First field\r\n * @param {Field} b Second field\r\n * @returns {number} Comparison value\r\n */\r\nutil.compareFieldsById = function compareFieldsById(a, b) {\r\n return a.id - b.id;\r\n};\r\n\r\n/**\r\n * Decorator helper for types (TypeScript).\r\n * @param {Constructor} ctor Constructor function\r\n * @param {string} [typeName] Type name, defaults to the constructor's name\r\n * @returns {Type} Reflected type\r\n * @template T extends Message\r\n * @property {Root} root Decorators root\r\n */\r\nutil.decorateType = function decorateType(ctor, typeName) {\r\n\r\n /* istanbul ignore if */\r\n if (ctor.$type) {\r\n if (typeName && ctor.$type.name !== typeName) {\r\n util.decorateRoot.remove(ctor.$type);\r\n ctor.$type.name = typeName;\r\n util.decorateRoot.add(ctor.$type);\r\n }\r\n return ctor.$type;\r\n }\r\n\r\n /* istanbul ignore next */\r\n if (!Type)\r\n Type = require(35);\r\n\r\n var type = new Type(typeName || ctor.name);\r\n util.decorateRoot.add(type);\r\n type.ctor = ctor; // sets up .encode, .decode etc.\r\n Object.defineProperty(ctor, \"$type\", { value: type, enumerable: false });\r\n Object.defineProperty(ctor.prototype, \"$type\", { value: type, enumerable: false });\r\n return type;\r\n};\r\n\r\nvar decorateEnumIndex = 0;\r\n\r\n/**\r\n * Decorator helper for enums (TypeScript).\r\n * @param {Object} object Enum object\r\n * @returns {Enum} Reflected enum\r\n */\r\nutil.decorateEnum = function decorateEnum(object) {\r\n\r\n /* istanbul ignore if */\r\n if (object.$type)\r\n return object.$type;\r\n\r\n /* istanbul ignore next */\r\n if (!Enum)\r\n Enum = require(15);\r\n\r\n var enm = new Enum(\"Enum\" + decorateEnumIndex++, object);\r\n util.decorateRoot.add(enm);\r\n Object.defineProperty(object, \"$type\", { value: enm, enumerable: false });\r\n return enm;\r\n};\r\n\r\n/**\r\n * Decorator root (TypeScript).\r\n * @name util.decorateRoot\r\n * @type {Root}\r\n * @readonly\r\n */\r\nObject.defineProperty(util, \"decorateRoot\", {\r\n get: function() {\r\n return roots[\"decorated\"] || (roots[\"decorated\"] = new (require(29))());\r\n }\r\n});\r\n","\"use strict\";\r\nmodule.exports = LongBits;\r\n\r\nvar util = require(39);\r\n\r\n/**\r\n * Constructs new long bits.\r\n * @classdesc Helper class for working with the low and high bits of a 64 bit value.\r\n * @memberof util\r\n * @constructor\r\n * @param {number} lo Low 32 bits, unsigned\r\n * @param {number} hi High 32 bits, unsigned\r\n */\r\nfunction LongBits(lo, hi) {\r\n\r\n // note that the casts below are theoretically unnecessary as of today, but older statically\r\n // generated converter code might still call the ctor with signed 32bits. kept for compat.\r\n\r\n /**\r\n * Low bits.\r\n * @type {number}\r\n */\r\n this.lo = lo >>> 0;\r\n\r\n /**\r\n * High bits.\r\n * @type {number}\r\n */\r\n this.hi = hi >>> 0;\r\n}\r\n\r\n/**\r\n * Zero bits.\r\n * @memberof util.LongBits\r\n * @type {util.LongBits}\r\n */\r\nvar zero = LongBits.zero = new LongBits(0, 0);\r\n\r\nzero.toNumber = function() { return 0; };\r\nzero.zzEncode = zero.zzDecode = function() { return this; };\r\nzero.length = function() { return 1; };\r\n\r\n/**\r\n * Zero hash.\r\n * @memberof util.LongBits\r\n * @type {string}\r\n */\r\nvar zeroHash = LongBits.zeroHash = \"\\0\\0\\0\\0\\0\\0\\0\\0\";\r\n\r\n/**\r\n * Constructs new long bits from the specified number.\r\n * @param {number} value Value\r\n * @returns {util.LongBits} Instance\r\n */\r\nLongBits.fromNumber = function fromNumber(value) {\r\n if (value === 0)\r\n return zero;\r\n var sign = value < 0;\r\n if (sign)\r\n value = -value;\r\n var lo = value >>> 0,\r\n hi = (value - lo) / 4294967296 >>> 0;\r\n if (sign) {\r\n hi = ~hi >>> 0;\r\n lo = ~lo >>> 0;\r\n if (++lo > 4294967295) {\r\n lo = 0;\r\n if (++hi > 4294967295)\r\n hi = 0;\r\n }\r\n }\r\n return new LongBits(lo, hi);\r\n};\r\n\r\n/**\r\n * Constructs new long bits from a number, long or string.\r\n * @param {Long|number|string} value Value\r\n * @returns {util.LongBits} Instance\r\n */\r\nLongBits.from = function from(value) {\r\n if (typeof value === \"number\")\r\n return LongBits.fromNumber(value);\r\n if (util.isString(value)) {\r\n /* istanbul ignore else */\r\n if (util.Long)\r\n value = util.Long.fromString(value);\r\n else\r\n return LongBits.fromNumber(parseInt(value, 10));\r\n }\r\n return value.low || value.high ? new LongBits(value.low >>> 0, value.high >>> 0) : zero;\r\n};\r\n\r\n/**\r\n * Converts this long bits to a possibly unsafe JavaScript number.\r\n * @param {boolean} [unsigned=false] Whether unsigned or not\r\n * @returns {number} Possibly unsafe number\r\n */\r\nLongBits.prototype.toNumber = function toNumber(unsigned) {\r\n if (!unsigned && this.hi >>> 31) {\r\n var lo = ~this.lo + 1 >>> 0,\r\n hi = ~this.hi >>> 0;\r\n if (!lo)\r\n hi = hi + 1 >>> 0;\r\n return -(lo + hi * 4294967296);\r\n }\r\n return this.lo + this.hi * 4294967296;\r\n};\r\n\r\n/**\r\n * Converts this long bits to a long.\r\n * @param {boolean} [unsigned=false] Whether unsigned or not\r\n * @returns {Long} Long\r\n */\r\nLongBits.prototype.toLong = function toLong(unsigned) {\r\n return util.Long\r\n ? new util.Long(this.lo | 0, this.hi | 0, Boolean(unsigned))\r\n /* istanbul ignore next */\r\n : { low: this.lo | 0, high: this.hi | 0, unsigned: Boolean(unsigned) };\r\n};\r\n\r\nvar charCodeAt = String.prototype.charCodeAt;\r\n\r\n/**\r\n * Constructs new long bits from the specified 8 characters long hash.\r\n * @param {string} hash Hash\r\n * @returns {util.LongBits} Bits\r\n */\r\nLongBits.fromHash = function fromHash(hash) {\r\n if (hash === zeroHash)\r\n return zero;\r\n return new LongBits(\r\n ( charCodeAt.call(hash, 0)\r\n | charCodeAt.call(hash, 1) << 8\r\n | charCodeAt.call(hash, 2) << 16\r\n | charCodeAt.call(hash, 3) << 24) >>> 0\r\n ,\r\n ( charCodeAt.call(hash, 4)\r\n | charCodeAt.call(hash, 5) << 8\r\n | charCodeAt.call(hash, 6) << 16\r\n | charCodeAt.call(hash, 7) << 24) >>> 0\r\n );\r\n};\r\n\r\n/**\r\n * Converts this long bits to a 8 characters long hash.\r\n * @returns {string} Hash\r\n */\r\nLongBits.prototype.toHash = function toHash() {\r\n return String.fromCharCode(\r\n this.lo & 255,\r\n this.lo >>> 8 & 255,\r\n this.lo >>> 16 & 255,\r\n this.lo >>> 24 ,\r\n this.hi & 255,\r\n this.hi >>> 8 & 255,\r\n this.hi >>> 16 & 255,\r\n this.hi >>> 24\r\n );\r\n};\r\n\r\n/**\r\n * Zig-zag encodes this long bits.\r\n * @returns {util.LongBits} `this`\r\n */\r\nLongBits.prototype.zzEncode = function zzEncode() {\r\n var mask = this.hi >> 31;\r\n this.hi = ((this.hi << 1 | this.lo >>> 31) ^ mask) >>> 0;\r\n this.lo = ( this.lo << 1 ^ mask) >>> 0;\r\n return this;\r\n};\r\n\r\n/**\r\n * Zig-zag decodes this long bits.\r\n * @returns {util.LongBits} `this`\r\n */\r\nLongBits.prototype.zzDecode = function zzDecode() {\r\n var mask = -(this.lo & 1);\r\n this.lo = ((this.lo >>> 1 | this.hi << 31) ^ mask) >>> 0;\r\n this.hi = ( this.hi >>> 1 ^ mask) >>> 0;\r\n return this;\r\n};\r\n\r\n/**\r\n * Calculates the length of this longbits when encoded as a varint.\r\n * @returns {number} Length\r\n */\r\nLongBits.prototype.length = function length() {\r\n var part0 = this.lo,\r\n part1 = (this.lo >>> 28 | this.hi << 4) >>> 0,\r\n part2 = this.hi >>> 24;\r\n return part2 === 0\r\n ? part1 === 0\r\n ? part0 < 16384\r\n ? part0 < 128 ? 1 : 2\r\n : part0 < 2097152 ? 3 : 4\r\n : part1 < 16384\r\n ? part1 < 128 ? 5 : 6\r\n : part1 < 2097152 ? 7 : 8\r\n : part2 < 128 ? 9 : 10;\r\n};\r\n","\"use strict\";\r\nvar util = exports;\r\n\r\n// used to return a Promise where callback is omitted\r\nutil.asPromise = require(1);\r\n\r\n// converts to / from base64 encoded strings\r\nutil.base64 = require(2);\r\n\r\n// base class of rpc.Service\r\nutil.EventEmitter = require(4);\r\n\r\n// float handling accross browsers\r\nutil.float = require(6);\r\n\r\n// requires modules optionally and hides the call from bundlers\r\nutil.inquire = require(7);\r\n\r\n// converts to / from utf8 encoded strings\r\nutil.utf8 = require(10);\r\n\r\n// provides a node-like buffer pool in the browser\r\nutil.pool = require(9);\r\n\r\n// utility to work with the low and high bits of a 64 bit value\r\nutil.LongBits = require(38);\r\n\r\n// global object reference\r\nutil.global = typeof window !== \"undefined\" && window\r\n || typeof global !== \"undefined\" && global\r\n || typeof self !== \"undefined\" && self\r\n || this; // eslint-disable-line no-invalid-this\r\n\r\n/**\r\n * An immuable empty array.\r\n * @memberof util\r\n * @type {Array.<*>}\r\n * @const\r\n */\r\nutil.emptyArray = Object.freeze ? Object.freeze([]) : /* istanbul ignore next */ []; // used on prototypes\r\n\r\n/**\r\n * An immutable empty object.\r\n * @type {Object}\r\n * @const\r\n */\r\nutil.emptyObject = Object.freeze ? Object.freeze({}) : /* istanbul ignore next */ {}; // used on prototypes\r\n\r\n/**\r\n * Whether running within node or not.\r\n * @memberof util\r\n * @type {boolean}\r\n * @const\r\n */\r\nutil.isNode = Boolean(util.global.process && util.global.process.versions && util.global.process.versions.node);\r\n\r\n/**\r\n * Tests if the specified value is an integer.\r\n * @function\r\n * @param {*} value Value to test\r\n * @returns {boolean} `true` if the value is an integer\r\n */\r\nutil.isInteger = Number.isInteger || /* istanbul ignore next */ function isInteger(value) {\r\n return typeof value === \"number\" && isFinite(value) && Math.floor(value) === value;\r\n};\r\n\r\n/**\r\n * Tests if the specified value is a string.\r\n * @param {*} value Value to test\r\n * @returns {boolean} `true` if the value is a string\r\n */\r\nutil.isString = function isString(value) {\r\n return typeof value === \"string\" || value instanceof String;\r\n};\r\n\r\n/**\r\n * Tests if the specified value is a non-null object.\r\n * @param {*} value Value to test\r\n * @returns {boolean} `true` if the value is a non-null object\r\n */\r\nutil.isObject = function isObject(value) {\r\n return value && typeof value === \"object\";\r\n};\r\n\r\n/**\r\n * Checks if a property on a message is considered to be present.\r\n * This is an alias of {@link util.isSet}.\r\n * @function\r\n * @param {Object} obj Plain object or message instance\r\n * @param {string} prop Property name\r\n * @returns {boolean} `true` if considered to be present, otherwise `false`\r\n */\r\nutil.isset =\r\n\r\n/**\r\n * Checks if a property on a message is considered to be present.\r\n * @param {Object} obj Plain object or message instance\r\n * @param {string} prop Property name\r\n * @returns {boolean} `true` if considered to be present, otherwise `false`\r\n */\r\nutil.isSet = function isSet(obj, prop) {\r\n var value = obj[prop];\r\n if (value != null && obj.hasOwnProperty(prop)) // eslint-disable-line eqeqeq, no-prototype-builtins\r\n return typeof value !== \"object\" || (Array.isArray(value) ? value.length : Object.keys(value).length) > 0;\r\n return false;\r\n};\r\n\r\n/**\r\n * Any compatible Buffer instance.\r\n * This is a minimal stand-alone definition of a Buffer instance. The actual type is that exported by node's typings.\r\n * @interface Buffer\r\n * @extends Uint8Array\r\n */\r\n\r\n/**\r\n * Node's Buffer class if available.\r\n * @type {Constructor}\r\n */\r\nutil.Buffer = (function() {\r\n try {\r\n var Buffer = util.inquire(\"buffer\").Buffer;\r\n // refuse to use non-node buffers if not explicitly assigned (perf reasons):\r\n return Buffer.prototype.utf8Write ? Buffer : /* istanbul ignore next */ null;\r\n } catch (e) {\r\n /* istanbul ignore next */\r\n return null;\r\n }\r\n})();\r\n\r\n// Internal alias of or polyfull for Buffer.from.\r\nutil._Buffer_from = null;\r\n\r\n// Internal alias of or polyfill for Buffer.allocUnsafe.\r\nutil._Buffer_allocUnsafe = null;\r\n\r\n/**\r\n * Creates a new buffer of whatever type supported by the environment.\r\n * @param {number|number[]} [sizeOrArray=0] Buffer size or number array\r\n * @returns {Uint8Array|Buffer} Buffer\r\n */\r\nutil.newBuffer = function newBuffer(sizeOrArray) {\r\n /* istanbul ignore next */\r\n return typeof sizeOrArray === \"number\"\r\n ? util.Buffer\r\n ? util._Buffer_allocUnsafe(sizeOrArray)\r\n : new util.Array(sizeOrArray)\r\n : util.Buffer\r\n ? util._Buffer_from(sizeOrArray)\r\n : typeof Uint8Array === \"undefined\"\r\n ? sizeOrArray\r\n : new Uint8Array(sizeOrArray);\r\n};\r\n\r\n/**\r\n * Array implementation used in the browser. `Uint8Array` if supported, otherwise `Array`.\r\n * @type {Constructor}\r\n */\r\nutil.Array = typeof Uint8Array !== \"undefined\" ? Uint8Array /* istanbul ignore next */ : Array;\r\n\r\n/**\r\n * Any compatible Long instance.\r\n * This is a minimal stand-alone definition of a Long instance. The actual type is that exported by long.js.\r\n * @interface Long\r\n * @property {number} low Low bits\r\n * @property {number} high High bits\r\n * @property {boolean} unsigned Whether unsigned or not\r\n */\r\n\r\n/**\r\n * Long.js's Long class if available.\r\n * @type {Constructor}\r\n */\r\nutil.Long = /* istanbul ignore next */ util.global.dcodeIO && /* istanbul ignore next */ util.global.dcodeIO.Long\r\n || /* istanbul ignore next */ util.global.Long\r\n || util.inquire(\"long\");\r\n\r\n/**\r\n * Regular expression used to verify 2 bit (`bool`) map keys.\r\n * @type {RegExp}\r\n * @const\r\n */\r\nutil.key2Re = /^true|false|0|1$/;\r\n\r\n/**\r\n * Regular expression used to verify 32 bit (`int32` etc.) map keys.\r\n * @type {RegExp}\r\n * @const\r\n */\r\nutil.key32Re = /^-?(?:0|[1-9][0-9]*)$/;\r\n\r\n/**\r\n * Regular expression used to verify 64 bit (`int64` etc.) map keys.\r\n * @type {RegExp}\r\n * @const\r\n */\r\nutil.key64Re = /^(?:[\\\\x00-\\\\xff]{8}|-?(?:0|[1-9][0-9]*))$/;\r\n\r\n/**\r\n * Converts a number or long to an 8 characters long hash string.\r\n * @param {Long|number} value Value to convert\r\n * @returns {string} Hash\r\n */\r\nutil.longToHash = function longToHash(value) {\r\n return value\r\n ? util.LongBits.from(value).toHash()\r\n : util.LongBits.zeroHash;\r\n};\r\n\r\n/**\r\n * Converts an 8 characters long hash string to a long or number.\r\n * @param {string} hash Hash\r\n * @param {boolean} [unsigned=false] Whether unsigned or not\r\n * @returns {Long|number} Original value\r\n */\r\nutil.longFromHash = function longFromHash(hash, unsigned) {\r\n var bits = util.LongBits.fromHash(hash);\r\n if (util.Long)\r\n return util.Long.fromBits(bits.lo, bits.hi, unsigned);\r\n return bits.toNumber(Boolean(unsigned));\r\n};\r\n\r\n/**\r\n * Merges the properties of the source object into the destination object.\r\n * @memberof util\r\n * @param {Object.} dst Destination object\r\n * @param {Object.} src Source object\r\n * @param {boolean} [ifNotSet=false] Merges only if the key is not already set\r\n * @returns {Object.} Destination object\r\n */\r\nfunction merge(dst, src, ifNotSet) { // used by converters\r\n for (var keys = Object.keys(src), i = 0; i < keys.length; ++i)\r\n if (dst[keys[i]] === undefined || !ifNotSet)\r\n dst[keys[i]] = src[keys[i]];\r\n return dst;\r\n}\r\n\r\nutil.merge = merge;\r\n\r\n/**\r\n * Converts the first character of a string to lower case.\r\n * @param {string} str String to convert\r\n * @returns {string} Converted string\r\n */\r\nutil.lcFirst = function lcFirst(str) {\r\n return str.charAt(0).toLowerCase() + str.substring(1);\r\n};\r\n\r\n/**\r\n * Creates a custom error constructor.\r\n * @memberof util\r\n * @param {string} name Error name\r\n * @returns {Constructor} Custom error constructor\r\n */\r\nfunction newError(name) {\r\n\r\n function CustomError(message, properties) {\r\n\r\n if (!(this instanceof CustomError))\r\n return new CustomError(message, properties);\r\n\r\n // Error.call(this, message);\r\n // ^ just returns a new error instance because the ctor can be called as a function\r\n\r\n Object.defineProperty(this, \"message\", { get: function() { return message; } });\r\n\r\n /* istanbul ignore next */\r\n if (Error.captureStackTrace) // node\r\n Error.captureStackTrace(this, CustomError);\r\n else\r\n Object.defineProperty(this, \"stack\", { value: (new Error()).stack || \"\" });\r\n\r\n if (properties)\r\n merge(this, properties);\r\n }\r\n\r\n (CustomError.prototype = Object.create(Error.prototype)).constructor = CustomError;\r\n\r\n Object.defineProperty(CustomError.prototype, \"name\", { get: function() { return name; } });\r\n\r\n CustomError.prototype.toString = function toString() {\r\n return this.name + \": \" + this.message;\r\n };\r\n\r\n return CustomError;\r\n}\r\n\r\nutil.newError = newError;\r\n\r\n/**\r\n * Constructs a new protocol error.\r\n * @classdesc Error subclass indicating a protocol specifc error.\r\n * @memberof util\r\n * @extends Error\r\n * @template T extends Message\r\n * @constructor\r\n * @param {string} message Error message\r\n * @param {Object.} [properties] Additional properties\r\n * @example\r\n * try {\r\n * MyMessage.decode(someBuffer); // throws if required fields are missing\r\n * } catch (e) {\r\n * if (e instanceof ProtocolError && e.instance)\r\n * console.log(\"decoded so far: \" + JSON.stringify(e.instance));\r\n * }\r\n */\r\nutil.ProtocolError = newError(\"ProtocolError\");\r\n\r\n/**\r\n * So far decoded message instance.\r\n * @name util.ProtocolError#instance\r\n * @type {Message}\r\n */\r\n\r\n/**\r\n * A OneOf getter as returned by {@link util.oneOfGetter}.\r\n * @typedef OneOfGetter\r\n * @type {function}\r\n * @returns {string|undefined} Set field name, if any\r\n */\r\n\r\n/**\r\n * Builds a getter for a oneof's present field name.\r\n * @param {string[]} fieldNames Field names\r\n * @returns {OneOfGetter} Unbound getter\r\n */\r\nutil.oneOfGetter = function getOneOf(fieldNames) {\r\n var fieldMap = {};\r\n for (var i = 0; i < fieldNames.length; ++i)\r\n fieldMap[fieldNames[i]] = 1;\r\n\r\n /**\r\n * @returns {string|undefined} Set field name, if any\r\n * @this Object\r\n * @ignore\r\n */\r\n return function() { // eslint-disable-line consistent-return\r\n for (var keys = Object.keys(this), i = keys.length - 1; i > -1; --i)\r\n if (fieldMap[keys[i]] === 1 && this[keys[i]] !== undefined && this[keys[i]] !== null)\r\n return keys[i];\r\n };\r\n};\r\n\r\n/**\r\n * A OneOf setter as returned by {@link util.oneOfSetter}.\r\n * @typedef OneOfSetter\r\n * @type {function}\r\n * @param {string|undefined} value Field name\r\n * @returns {undefined}\r\n */\r\n\r\n/**\r\n * Builds a setter for a oneof's present field name.\r\n * @param {string[]} fieldNames Field names\r\n * @returns {OneOfSetter} Unbound setter\r\n */\r\nutil.oneOfSetter = function setOneOf(fieldNames) {\r\n\r\n /**\r\n * @param {string} name Field name\r\n * @returns {undefined}\r\n * @this Object\r\n * @ignore\r\n */\r\n return function(name) {\r\n for (var i = 0; i < fieldNames.length; ++i)\r\n if (fieldNames[i] !== name)\r\n delete this[fieldNames[i]];\r\n };\r\n};\r\n\r\n/**\r\n * Default conversion options used for {@link Message#toJSON} implementations.\r\n *\r\n * These options are close to proto3's JSON mapping with the exception that internal types like Any are handled just like messages. More precisely:\r\n *\r\n * - Longs become strings\r\n * - Enums become string keys\r\n * - Bytes become base64 encoded strings\r\n * - (Sub-)Messages become plain objects\r\n * - Maps become plain objects with all string keys\r\n * - Repeated fields become arrays\r\n * - NaN and Infinity for float and double fields become strings\r\n *\r\n * @type {IConversionOptions}\r\n * @see https://developers.google.com/protocol-buffers/docs/proto3?hl=en#json\r\n */\r\nutil.toJSONOptions = {\r\n longs: String,\r\n enums: String,\r\n bytes: String,\r\n json: true\r\n};\r\n\r\n// Sets up buffer utility according to the environment (called in index-minimal)\r\nutil._configure = function() {\r\n var Buffer = util.Buffer;\r\n /* istanbul ignore if */\r\n if (!Buffer) {\r\n util._Buffer_from = util._Buffer_allocUnsafe = null;\r\n return;\r\n }\r\n // because node 4.x buffers are incompatible & immutable\r\n // see: https://github.com/dcodeIO/protobuf.js/pull/665\r\n util._Buffer_from = Buffer.from !== Uint8Array.from && Buffer.from ||\r\n /* istanbul ignore next */\r\n function Buffer_from(value, encoding) {\r\n return new Buffer(value, encoding);\r\n };\r\n util._Buffer_allocUnsafe = Buffer.allocUnsafe ||\r\n /* istanbul ignore next */\r\n function Buffer_allocUnsafe(size) {\r\n return new Buffer(size);\r\n };\r\n};\r\n","\"use strict\";\r\nmodule.exports = verifier;\r\n\r\nvar Enum = require(15),\r\n util = require(37);\r\n\r\nfunction invalid(field, expected) {\r\n return field.name + \": \" + expected + (field.repeated && expected !== \"array\" ? \"[]\" : field.map && expected !== \"object\" ? \"{k:\"+field.keyType+\"}\" : \"\") + \" expected\";\r\n}\r\n\r\n/**\r\n * Generates a partial value verifier.\r\n * @param {Codegen} gen Codegen instance\r\n * @param {Field} field Reflected field\r\n * @param {number} fieldIndex Field index\r\n * @param {string} ref Variable reference\r\n * @returns {Codegen} Codegen instance\r\n * @ignore\r\n */\r\nfunction genVerifyValue(gen, field, fieldIndex, ref) {\r\n /* eslint-disable no-unexpected-multiline */\r\n if (field.resolvedType) {\r\n if (field.resolvedType instanceof Enum) { gen\r\n (\"switch(%s){\", ref)\r\n (\"default:\")\r\n (\"return%j\", invalid(field, \"enum value\"));\r\n for (var keys = Object.keys(field.resolvedType.values), j = 0; j < keys.length; ++j) gen\r\n (\"case %i:\", field.resolvedType.values[keys[j]]);\r\n gen\r\n (\"break\")\r\n (\"}\");\r\n } else {\r\n gen\r\n (\"{\")\r\n (\"var e=types[%i].verify(%s);\", fieldIndex, ref)\r\n (\"if(e)\")\r\n (\"return%j+e\", field.name + \".\")\r\n (\"}\");\r\n }\r\n } else {\r\n switch (field.type) {\r\n case \"int32\":\r\n case \"uint32\":\r\n case \"sint32\":\r\n case \"fixed32\":\r\n case \"sfixed32\": gen\r\n (\"if(!util.isInteger(%s))\", ref)\r\n (\"return%j\", invalid(field, \"integer\"));\r\n break;\r\n case \"int64\":\r\n case \"uint64\":\r\n case \"sint64\":\r\n case \"fixed64\":\r\n case \"sfixed64\": gen\r\n (\"if(!util.isInteger(%s)&&!(%s&&util.isInteger(%s.low)&&util.isInteger(%s.high)))\", ref, ref, ref, ref)\r\n (\"return%j\", invalid(field, \"integer|Long\"));\r\n break;\r\n case \"float\":\r\n case \"double\": gen\r\n (\"if(typeof %s!==\\\"number\\\")\", ref)\r\n (\"return%j\", invalid(field, \"number\"));\r\n break;\r\n case \"bool\": gen\r\n (\"if(typeof %s!==\\\"boolean\\\")\", ref)\r\n (\"return%j\", invalid(field, \"boolean\"));\r\n break;\r\n case \"string\": gen\r\n (\"if(!util.isString(%s))\", ref)\r\n (\"return%j\", invalid(field, \"string\"));\r\n break;\r\n case \"bytes\": gen\r\n (\"if(!(%s&&typeof %s.length===\\\"number\\\"||util.isString(%s)))\", ref, ref, ref)\r\n (\"return%j\", invalid(field, \"buffer\"));\r\n break;\r\n }\r\n }\r\n return gen;\r\n /* eslint-enable no-unexpected-multiline */\r\n}\r\n\r\n/**\r\n * Generates a partial key verifier.\r\n * @param {Codegen} gen Codegen instance\r\n * @param {Field} field Reflected field\r\n * @param {string} ref Variable reference\r\n * @returns {Codegen} Codegen instance\r\n * @ignore\r\n */\r\nfunction genVerifyKey(gen, field, ref) {\r\n /* eslint-disable no-unexpected-multiline */\r\n switch (field.keyType) {\r\n case \"int32\":\r\n case \"uint32\":\r\n case \"sint32\":\r\n case \"fixed32\":\r\n case \"sfixed32\": gen\r\n (\"if(!util.key32Re.test(%s))\", ref)\r\n (\"return%j\", invalid(field, \"integer key\"));\r\n break;\r\n case \"int64\":\r\n case \"uint64\":\r\n case \"sint64\":\r\n case \"fixed64\":\r\n case \"sfixed64\": gen\r\n (\"if(!util.key64Re.test(%s))\", ref) // see comment above: x is ok, d is not\r\n (\"return%j\", invalid(field, \"integer|Long key\"));\r\n break;\r\n case \"bool\": gen\r\n (\"if(!util.key2Re.test(%s))\", ref)\r\n (\"return%j\", invalid(field, \"boolean key\"));\r\n break;\r\n }\r\n return gen;\r\n /* eslint-enable no-unexpected-multiline */\r\n}\r\n\r\n/**\r\n * Generates a verifier specific to the specified message type.\r\n * @param {Type} mtype Message type\r\n * @returns {Codegen} Codegen instance\r\n */\r\nfunction verifier(mtype) {\r\n /* eslint-disable no-unexpected-multiline */\r\n\r\n var gen = util.codegen([\"m\"], mtype.name + \"$verify\")\r\n (\"if(typeof m!==\\\"object\\\"||m===null)\")\r\n (\"return%j\", \"object expected\");\r\n var oneofs = mtype.oneofsArray,\r\n seenFirstField = {};\r\n if (oneofs.length) gen\r\n (\"var p={}\");\r\n\r\n for (var i = 0; i < /* initializes */ mtype.fieldsArray.length; ++i) {\r\n var field = mtype._fieldsArray[i].resolve(),\r\n ref = \"m\" + util.safeProp(field.name);\r\n\r\n if (field.optional) gen\r\n (\"if(%s!=null&&m.hasOwnProperty(%j)){\", ref, field.name); // !== undefined && !== null\r\n\r\n // map fields\r\n if (field.map) { gen\r\n (\"if(!util.isObject(%s))\", ref)\r\n (\"return%j\", invalid(field, \"object\"))\r\n (\"var k=Object.keys(%s)\", ref)\r\n (\"for(var i=0;i}\r\n * @const\r\n */\r\nvar wrappers = exports;\r\n\r\nvar Message = require(21);\r\n\r\n/**\r\n * From object converter part of an {@link IWrapper}.\r\n * @typedef WrapperFromObjectConverter\r\n * @type {function}\r\n * @param {Object.} object Plain object\r\n * @returns {Message<{}>} Message instance\r\n * @this Type\r\n */\r\n\r\n/**\r\n * To object converter part of an {@link IWrapper}.\r\n * @typedef WrapperToObjectConverter\r\n * @type {function}\r\n * @param {Message<{}>} message Message instance\r\n * @param {IConversionOptions} [options] Conversion options\r\n * @returns {Object.} Plain object\r\n * @this Type\r\n */\r\n\r\n/**\r\n * Common type wrapper part of {@link wrappers}.\r\n * @interface IWrapper\r\n * @property {WrapperFromObjectConverter} [fromObject] From object converter\r\n * @property {WrapperToObjectConverter} [toObject] To object converter\r\n */\r\n\r\n// Custom wrapper for Any\r\nwrappers[\".google.protobuf.Any\"] = {\r\n\r\n fromObject: function(object) {\r\n\r\n // unwrap value type if mapped\r\n if (object && object[\"@type\"]) {\r\n var type = this.lookup(object[\"@type\"]);\r\n /* istanbul ignore else */\r\n if (type) {\r\n // type_url does not accept leading \".\"\r\n var type_url = object[\"@type\"].charAt(0) === \".\" ?\r\n object[\"@type\"].substr(1) : object[\"@type\"];\r\n // type_url prefix is optional, but path seperator is required\r\n return this.create({\r\n type_url: \"/\" + type_url,\r\n value: type.encode(type.fromObject(object)).finish()\r\n });\r\n }\r\n }\r\n\r\n return this.fromObject(object);\r\n },\r\n\r\n toObject: function(message, options) {\r\n\r\n // decode value if requested and unmapped\r\n if (options && options.json && message.type_url && message.value) {\r\n // Only use fully qualified type name after the last '/'\r\n var name = message.type_url.substring(message.type_url.lastIndexOf(\"/\") + 1);\r\n var type = this.lookup(name);\r\n /* istanbul ignore else */\r\n if (type)\r\n message = type.decode(message.value);\r\n }\r\n\r\n // wrap value if unmapped\r\n if (!(message instanceof this.ctor) && message instanceof Message) {\r\n var object = message.$type.toObject(message, options);\r\n object[\"@type\"] = message.$type.fullName;\r\n return object;\r\n }\r\n\r\n return this.toObject(message, options);\r\n }\r\n};\r\n","\"use strict\";\r\nmodule.exports = Writer;\r\n\r\nvar util = require(39);\r\n\r\nvar BufferWriter; // cyclic\r\n\r\nvar LongBits = util.LongBits,\r\n base64 = util.base64,\r\n utf8 = util.utf8;\r\n\r\n/**\r\n * Constructs a new writer operation instance.\r\n * @classdesc Scheduled writer operation.\r\n * @constructor\r\n * @param {function(*, Uint8Array, number)} fn Function to call\r\n * @param {number} len Value byte length\r\n * @param {*} val Value to write\r\n * @ignore\r\n */\r\nfunction Op(fn, len, val) {\r\n\r\n /**\r\n * Function to call.\r\n * @type {function(Uint8Array, number, *)}\r\n */\r\n this.fn = fn;\r\n\r\n /**\r\n * Value byte length.\r\n * @type {number}\r\n */\r\n this.len = len;\r\n\r\n /**\r\n * Next operation.\r\n * @type {Writer.Op|undefined}\r\n */\r\n this.next = undefined;\r\n\r\n /**\r\n * Value to write.\r\n * @type {*}\r\n */\r\n this.val = val; // type varies\r\n}\r\n\r\n/* istanbul ignore next */\r\nfunction noop() {} // eslint-disable-line no-empty-function\r\n\r\n/**\r\n * Constructs a new writer state instance.\r\n * @classdesc Copied writer state.\r\n * @memberof Writer\r\n * @constructor\r\n * @param {Writer} writer Writer to copy state from\r\n * @ignore\r\n */\r\nfunction State(writer) {\r\n\r\n /**\r\n * Current head.\r\n * @type {Writer.Op}\r\n */\r\n this.head = writer.head;\r\n\r\n /**\r\n * Current tail.\r\n * @type {Writer.Op}\r\n */\r\n this.tail = writer.tail;\r\n\r\n /**\r\n * Current buffer length.\r\n * @type {number}\r\n */\r\n this.len = writer.len;\r\n\r\n /**\r\n * Next state.\r\n * @type {State|null}\r\n */\r\n this.next = writer.states;\r\n}\r\n\r\n/**\r\n * Constructs a new writer instance.\r\n * @classdesc Wire format writer using `Uint8Array` if available, otherwise `Array`.\r\n * @constructor\r\n */\r\nfunction Writer() {\r\n\r\n /**\r\n * Current length.\r\n * @type {number}\r\n */\r\n this.len = 0;\r\n\r\n /**\r\n * Operations head.\r\n * @type {Object}\r\n */\r\n this.head = new Op(noop, 0, 0);\r\n\r\n /**\r\n * Operations tail\r\n * @type {Object}\r\n */\r\n this.tail = this.head;\r\n\r\n /**\r\n * Linked forked states.\r\n * @type {Object|null}\r\n */\r\n this.states = null;\r\n\r\n // When a value is written, the writer calculates its byte length and puts it into a linked\r\n // list of operations to perform when finish() is called. This both allows us to allocate\r\n // buffers of the exact required size and reduces the amount of work we have to do compared\r\n // to first calculating over objects and then encoding over objects. In our case, the encoding\r\n // part is just a linked list walk calling operations with already prepared values.\r\n}\r\n\r\n/**\r\n * Creates a new writer.\r\n * @function\r\n * @returns {BufferWriter|Writer} A {@link BufferWriter} when Buffers are supported, otherwise a {@link Writer}\r\n */\r\nWriter.create = util.Buffer\r\n ? function create_buffer_setup() {\r\n return (Writer.create = function create_buffer() {\r\n return new BufferWriter();\r\n })();\r\n }\r\n /* istanbul ignore next */\r\n : function create_array() {\r\n return new Writer();\r\n };\r\n\r\n/**\r\n * Allocates a buffer of the specified size.\r\n * @param {number} size Buffer size\r\n * @returns {Uint8Array} Buffer\r\n */\r\nWriter.alloc = function alloc(size) {\r\n return new util.Array(size);\r\n};\r\n\r\n// Use Uint8Array buffer pool in the browser, just like node does with buffers\r\n/* istanbul ignore else */\r\nif (util.Array !== Array)\r\n Writer.alloc = util.pool(Writer.alloc, util.Array.prototype.subarray);\r\n\r\n/**\r\n * Pushes a new operation to the queue.\r\n * @param {function(Uint8Array, number, *)} fn Function to call\r\n * @param {number} len Value byte length\r\n * @param {number} val Value to write\r\n * @returns {Writer} `this`\r\n * @private\r\n */\r\nWriter.prototype._push = function push(fn, len, val) {\r\n this.tail = this.tail.next = new Op(fn, len, val);\r\n this.len += len;\r\n return this;\r\n};\r\n\r\nfunction writeByte(val, buf, pos) {\r\n buf[pos] = val & 255;\r\n}\r\n\r\nfunction writeVarint32(val, buf, pos) {\r\n while (val > 127) {\r\n buf[pos++] = val & 127 | 128;\r\n val >>>= 7;\r\n }\r\n buf[pos] = val;\r\n}\r\n\r\n/**\r\n * Constructs a new varint writer operation instance.\r\n * @classdesc Scheduled varint writer operation.\r\n * @extends Op\r\n * @constructor\r\n * @param {number} len Value byte length\r\n * @param {number} val Value to write\r\n * @ignore\r\n */\r\nfunction VarintOp(len, val) {\r\n this.len = len;\r\n this.next = undefined;\r\n this.val = val;\r\n}\r\n\r\nVarintOp.prototype = Object.create(Op.prototype);\r\nVarintOp.prototype.fn = writeVarint32;\r\n\r\n/**\r\n * Writes an unsigned 32 bit value as a varint.\r\n * @param {number} value Value to write\r\n * @returns {Writer} `this`\r\n */\r\nWriter.prototype.uint32 = function write_uint32(value) {\r\n // here, the call to this.push has been inlined and a varint specific Op subclass is used.\r\n // uint32 is by far the most frequently used operation and benefits significantly from this.\r\n this.len += (this.tail = this.tail.next = new VarintOp(\r\n (value = value >>> 0)\r\n < 128 ? 1\r\n : value < 16384 ? 2\r\n : value < 2097152 ? 3\r\n : value < 268435456 ? 4\r\n : 5,\r\n value)).len;\r\n return this;\r\n};\r\n\r\n/**\r\n * Writes a signed 32 bit value as a varint.\r\n * @function\r\n * @param {number} value Value to write\r\n * @returns {Writer} `this`\r\n */\r\nWriter.prototype.int32 = function write_int32(value) {\r\n return value < 0\r\n ? this._push(writeVarint64, 10, LongBits.fromNumber(value)) // 10 bytes per spec\r\n : this.uint32(value);\r\n};\r\n\r\n/**\r\n * Writes a 32 bit value as a varint, zig-zag encoded.\r\n * @param {number} value Value to write\r\n * @returns {Writer} `this`\r\n */\r\nWriter.prototype.sint32 = function write_sint32(value) {\r\n return this.uint32((value << 1 ^ value >> 31) >>> 0);\r\n};\r\n\r\nfunction writeVarint64(val, buf, pos) {\r\n while (val.hi) {\r\n buf[pos++] = val.lo & 127 | 128;\r\n val.lo = (val.lo >>> 7 | val.hi << 25) >>> 0;\r\n val.hi >>>= 7;\r\n }\r\n while (val.lo > 127) {\r\n buf[pos++] = val.lo & 127 | 128;\r\n val.lo = val.lo >>> 7;\r\n }\r\n buf[pos++] = val.lo;\r\n}\r\n\r\n/**\r\n * Writes an unsigned 64 bit value as a varint.\r\n * @param {Long|number|string} value Value to write\r\n * @returns {Writer} `this`\r\n * @throws {TypeError} If `value` is a string and no long library is present.\r\n */\r\nWriter.prototype.uint64 = function write_uint64(value) {\r\n var bits = LongBits.from(value);\r\n return this._push(writeVarint64, bits.length(), bits);\r\n};\r\n\r\n/**\r\n * Writes a signed 64 bit value as a varint.\r\n * @function\r\n * @param {Long|number|string} value Value to write\r\n * @returns {Writer} `this`\r\n * @throws {TypeError} If `value` is a string and no long library is present.\r\n */\r\nWriter.prototype.int64 = Writer.prototype.uint64;\r\n\r\n/**\r\n * Writes a signed 64 bit value as a varint, zig-zag encoded.\r\n * @param {Long|number|string} value Value to write\r\n * @returns {Writer} `this`\r\n * @throws {TypeError} If `value` is a string and no long library is present.\r\n */\r\nWriter.prototype.sint64 = function write_sint64(value) {\r\n var bits = LongBits.from(value).zzEncode();\r\n return this._push(writeVarint64, bits.length(), bits);\r\n};\r\n\r\n/**\r\n * Writes a boolish value as a varint.\r\n * @param {boolean} value Value to write\r\n * @returns {Writer} `this`\r\n */\r\nWriter.prototype.bool = function write_bool(value) {\r\n return this._push(writeByte, 1, value ? 1 : 0);\r\n};\r\n\r\nfunction writeFixed32(val, buf, pos) {\r\n buf[pos ] = val & 255;\r\n buf[pos + 1] = val >>> 8 & 255;\r\n buf[pos + 2] = val >>> 16 & 255;\r\n buf[pos + 3] = val >>> 24;\r\n}\r\n\r\n/**\r\n * Writes an unsigned 32 bit value as fixed 32 bits.\r\n * @param {number} value Value to write\r\n * @returns {Writer} `this`\r\n */\r\nWriter.prototype.fixed32 = function write_fixed32(value) {\r\n return this._push(writeFixed32, 4, value >>> 0);\r\n};\r\n\r\n/**\r\n * Writes a signed 32 bit value as fixed 32 bits.\r\n * @function\r\n * @param {number} value Value to write\r\n * @returns {Writer} `this`\r\n */\r\nWriter.prototype.sfixed32 = Writer.prototype.fixed32;\r\n\r\n/**\r\n * Writes an unsigned 64 bit value as fixed 64 bits.\r\n * @param {Long|number|string} value Value to write\r\n * @returns {Writer} `this`\r\n * @throws {TypeError} If `value` is a string and no long library is present.\r\n */\r\nWriter.prototype.fixed64 = function write_fixed64(value) {\r\n var bits = LongBits.from(value);\r\n return this._push(writeFixed32, 4, bits.lo)._push(writeFixed32, 4, bits.hi);\r\n};\r\n\r\n/**\r\n * Writes a signed 64 bit value as fixed 64 bits.\r\n * @function\r\n * @param {Long|number|string} value Value to write\r\n * @returns {Writer} `this`\r\n * @throws {TypeError} If `value` is a string and no long library is present.\r\n */\r\nWriter.prototype.sfixed64 = Writer.prototype.fixed64;\r\n\r\n/**\r\n * Writes a float (32 bit).\r\n * @function\r\n * @param {number} value Value to write\r\n * @returns {Writer} `this`\r\n */\r\nWriter.prototype.float = function write_float(value) {\r\n return this._push(util.float.writeFloatLE, 4, value);\r\n};\r\n\r\n/**\r\n * Writes a double (64 bit float).\r\n * @function\r\n * @param {number} value Value to write\r\n * @returns {Writer} `this`\r\n */\r\nWriter.prototype.double = function write_double(value) {\r\n return this._push(util.float.writeDoubleLE, 8, value);\r\n};\r\n\r\nvar writeBytes = util.Array.prototype.set\r\n ? function writeBytes_set(val, buf, pos) {\r\n buf.set(val, pos); // also works for plain array values\r\n }\r\n /* istanbul ignore next */\r\n : function writeBytes_for(val, buf, pos) {\r\n for (var i = 0; i < val.length; ++i)\r\n buf[pos + i] = val[i];\r\n };\r\n\r\n/**\r\n * Writes a sequence of bytes.\r\n * @param {Uint8Array|string} value Buffer or base64 encoded string to write\r\n * @returns {Writer} `this`\r\n */\r\nWriter.prototype.bytes = function write_bytes(value) {\r\n var len = value.length >>> 0;\r\n if (!len)\r\n return this._push(writeByte, 1, 0);\r\n if (util.isString(value)) {\r\n var buf = Writer.alloc(len = base64.length(value));\r\n base64.decode(value, buf, 0);\r\n value = buf;\r\n }\r\n return this.uint32(len)._push(writeBytes, len, value);\r\n};\r\n\r\n/**\r\n * Writes a string.\r\n * @param {string} value Value to write\r\n * @returns {Writer} `this`\r\n */\r\nWriter.prototype.string = function write_string(value) {\r\n var len = utf8.length(value);\r\n return len\r\n ? this.uint32(len)._push(utf8.write, len, value)\r\n : this._push(writeByte, 1, 0);\r\n};\r\n\r\n/**\r\n * Forks this writer's state by pushing it to a stack.\r\n * Calling {@link Writer#reset|reset} or {@link Writer#ldelim|ldelim} resets the writer to the previous state.\r\n * @returns {Writer} `this`\r\n */\r\nWriter.prototype.fork = function fork() {\r\n this.states = new State(this);\r\n this.head = this.tail = new Op(noop, 0, 0);\r\n this.len = 0;\r\n return this;\r\n};\r\n\r\n/**\r\n * Resets this instance to the last state.\r\n * @returns {Writer} `this`\r\n */\r\nWriter.prototype.reset = function reset() {\r\n if (this.states) {\r\n this.head = this.states.head;\r\n this.tail = this.states.tail;\r\n this.len = this.states.len;\r\n this.states = this.states.next;\r\n } else {\r\n this.head = this.tail = new Op(noop, 0, 0);\r\n this.len = 0;\r\n }\r\n return this;\r\n};\r\n\r\n/**\r\n * Resets to the last state and appends the fork state's current write length as a varint followed by its operations.\r\n * @returns {Writer} `this`\r\n */\r\nWriter.prototype.ldelim = function ldelim() {\r\n var head = this.head,\r\n tail = this.tail,\r\n len = this.len;\r\n this.reset().uint32(len);\r\n if (len) {\r\n this.tail.next = head.next; // skip noop\r\n this.tail = tail;\r\n this.len += len;\r\n }\r\n return this;\r\n};\r\n\r\n/**\r\n * Finishes the write operation.\r\n * @returns {Uint8Array} Finished buffer\r\n */\r\nWriter.prototype.finish = function finish() {\r\n var head = this.head.next, // skip noop\r\n buf = this.constructor.alloc(this.len),\r\n pos = 0;\r\n while (head) {\r\n head.fn(head.val, buf, pos);\r\n pos += head.len;\r\n head = head.next;\r\n }\r\n // this.head = this.tail = null;\r\n return buf;\r\n};\r\n\r\nWriter._configure = function(BufferWriter_) {\r\n BufferWriter = BufferWriter_;\r\n};\r\n","\"use strict\";\r\nmodule.exports = BufferWriter;\r\n\r\n// extends Writer\r\nvar Writer = require(42);\r\n(BufferWriter.prototype = Object.create(Writer.prototype)).constructor = BufferWriter;\r\n\r\nvar util = require(39);\r\n\r\nvar Buffer = util.Buffer;\r\n\r\n/**\r\n * Constructs a new buffer writer instance.\r\n * @classdesc Wire format writer using node buffers.\r\n * @extends Writer\r\n * @constructor\r\n */\r\nfunction BufferWriter() {\r\n Writer.call(this);\r\n}\r\n\r\n/**\r\n * Allocates a buffer of the specified size.\r\n * @param {number} size Buffer size\r\n * @returns {Buffer} Buffer\r\n */\r\nBufferWriter.alloc = function alloc_buffer(size) {\r\n return (BufferWriter.alloc = util._Buffer_allocUnsafe)(size);\r\n};\r\n\r\nvar writeBytesBuffer = Buffer && Buffer.prototype instanceof Uint8Array && Buffer.prototype.set.name === \"set\"\r\n ? function writeBytesBuffer_set(val, buf, pos) {\r\n buf.set(val, pos); // faster than copy (requires node >= 4 where Buffers extend Uint8Array and set is properly inherited)\r\n // also works for plain array values\r\n }\r\n /* istanbul ignore next */\r\n : function writeBytesBuffer_copy(val, buf, pos) {\r\n if (val.copy) // Buffer values\r\n val.copy(buf, pos, 0, val.length);\r\n else for (var i = 0; i < val.length;) // plain array values\r\n buf[pos++] = val[i++];\r\n };\r\n\r\n/**\r\n * @override\r\n */\r\nBufferWriter.prototype.bytes = function write_bytes_buffer(value) {\r\n if (util.isString(value))\r\n value = util._Buffer_from(value, \"base64\");\r\n var len = value.length >>> 0;\r\n this.uint32(len);\r\n if (len)\r\n this._push(writeBytesBuffer, len, value);\r\n return this;\r\n};\r\n\r\nfunction writeStringBuffer(val, buf, pos) {\r\n if (val.length < 40) // plain js is faster for short strings (probably due to redundant assertions)\r\n util.utf8.write(val, buf, pos);\r\n else\r\n buf.utf8Write(val, pos);\r\n}\r\n\r\n/**\r\n * @override\r\n */\r\nBufferWriter.prototype.string = function write_string_buffer(value) {\r\n var len = Buffer.byteLength(value);\r\n this.uint32(len);\r\n if (len)\r\n this._push(writeStringBuffer, len, value);\r\n return this;\r\n};\r\n\r\n\r\n/**\r\n * Finishes the write operation.\r\n * @name BufferWriter#finish\r\n * @function\r\n * @returns {Buffer} Finished buffer\r\n */\r\n"],"sourceRoot":"."} \ No newline at end of file diff --git a/frontend/build-templates/wechatgame/libs/engine/Audio.js b/frontend/build-templates/wechatgame/libs/engine/Audio.js new file mode 100644 index 0000000..432e50b --- /dev/null +++ b/frontend/build-templates/wechatgame/libs/engine/Audio.js @@ -0,0 +1,13 @@ +(function () { + if (!(cc && cc.Audio)) { + return; + } + cc.Audio.prototype.stop = function () { + if (!this._element) return; + this._element.stop(); + this._element.currentTime = 0; + this._unbindEnded(); + this.emit('stop'); + this._state = cc.Audio.State.STOPPED; + }; +})(); \ No newline at end of file diff --git a/frontend/build-templates/wechatgame/libs/engine/DeviceMotionEvent.js b/frontend/build-templates/wechatgame/libs/engine/DeviceMotionEvent.js new file mode 100644 index 0000000..ecaccca --- /dev/null +++ b/frontend/build-templates/wechatgame/libs/engine/DeviceMotionEvent.js @@ -0,0 +1,79 @@ + +const inputManager = _cc.inputManager; +let isInit = false; + +Object.assign(inputManager, { + setAccelerometerEnabled (isEnable) { + let scheduler = cc.director.getScheduler(); + scheduler.enableForTarget(this); + if (isEnable) { + this._registerAccelerometerEvent(); + scheduler.scheduleUpdate(this); + } + else { + this._unregisterAccelerometerEvent(); + scheduler.unscheduleUpdate(this); + } + }, + + // No need to adapt + // setAccelerometerInterval (interval) { }, + + _registerAccelerometerEvent () { + this._accelCurTime = 0; + if (!isInit) { + isInit = true; + let self = this; + this._acceleration = new cc.Acceleration(); + + wx.onAccelerometerChange && wx.onAccelerometerChange(function (res) { + let x = res.x; + let y = res.y; + + let systemInfo = wx.getSystemInfoSync(); + let windowWidth = systemInfo.windowWidth; + let windowHeight = systemInfo.windowHeight; + if (windowHeight < windowWidth) { + // Landscape orientation + + // For left landscape + // x = y; + // y = -x; + + // For right landscape + // x = -y; + // y = x; + + // We suggest to use right landscape by default + let tmp = x; + x = -y; + y = tmp; + } + + self._acceleration.x = x; + self._acceleration.y = y; + self._acceleration.z = res.z; + }); + } + else { + wx.startAccelerometer && wx.startAccelerometer({ + fail: function (err) { + cc.error('register Accelerometer failed ! err: ' + err); + }, + success: function () {}, + complete: function () {}, + }); + } + }, + + _unregisterAccelerometerEvent () { + this._accelCurTime = 0; + wx.stopAccelerometer && wx.stopAccelerometer({ + fail: function (err) { + cc.error('unregister Accelerometer failed ! err: ' + err); + }, + success: function () {}, + complete: function () {}, + }); + }, +}); diff --git a/frontend/build-templates/wechatgame/libs/engine/Editbox.js b/frontend/build-templates/wechatgame/libs/engine/Editbox.js new file mode 100644 index 0000000..c98da67 --- /dev/null +++ b/frontend/build-templates/wechatgame/libs/engine/Editbox.js @@ -0,0 +1,140 @@ +(function () { + if (!(cc && cc.EditBox)) { + return; + } + + var KeyboardReturnType = cc.EditBox.KeyboardReturnType; + var _p = cc.EditBox._EditBoxImpl.prototype; + var _currentEditBoxImpl = null; + + function getKeyboardReturnType (type) { + switch (type) { + case KeyboardReturnType.DEFAULT: + case KeyboardReturnType.DONE: + return 'done'; + case KeyboardReturnType.SEND: + return 'send'; + case KeyboardReturnType.SEARCH: + return 'search'; + case KeyboardReturnType.GO: + return 'go'; + case KeyboardReturnType.NEXT: + return 'next'; + } + return 'done'; + } + + function updateLabelsVisibility(editBox) { + var placeholderLabel = editBox._placeholderLabel; + var textLabel = editBox._textLabel; + var displayText = editBox._impl._text; + + placeholderLabel.node.active = displayText === ''; + textLabel.node.active = displayText !== ''; + } + + cc.EditBox.prototype.editBoxEditingDidBegan = function () { + cc.Component.EventHandler.emitEvents(this.editingDidBegan, this); + this.node.emit('editing-did-began', this); + }; + + cc.EditBox.prototype.editBoxEditingDidEnded = function () { + cc.Component.EventHandler.emitEvents(this.editingDidEnded, this); + this.node.emit('editing-did-ended', this); + }; + + cc.EditBox.prototype._updateStayOnTop = function () { + // wx not support + }; + + _p.setFocus = function () { + this._beginEditing(); + }; + + _p.isFocused = function () { + return this._editing; + }; + + _p.setInputMode = function (inputMode) { + this._inputMode = inputMode; + }; + + _p._beginEditing = function () { + this.createInput(); + }; + + _p._endEditing = function () { + this._delegate && this._delegate.editBoxEditingDidEnded(); + this._editing = false; + }; + + _p.createInput = function () { + // Unregister keyboard event listener in old editBoxImpl if keyboard haven't hidden. + if (_currentEditBoxImpl !== this) { + if (_currentEditBoxImpl) { + _currentEditBoxImpl._endEditing(); + wx.offKeyboardConfirm(_currentEditBoxImpl.onKeyboardConfirmCallback); + wx.offKeyboardInput(_currentEditBoxImpl.onKeyboardInputCallback); + wx.offKeyboardComplete(_currentEditBoxImpl.onKeyboardCompleteCallback); + } + _currentEditBoxImpl = this; + } + + var multiline = this._inputMode === cc.EditBox.InputMode.ANY; + var editBoxImpl = this; + this._editing = true; + + function onKeyboardConfirmCallback (res) { + editBoxImpl._text = res.value; + editBoxImpl._delegate && editBoxImpl._delegate.editBoxEditingReturn && editBoxImpl._delegate.editBoxEditingReturn(); + wx.hideKeyboard({ + success: function (res) { + + }, + fail: function (res) { + cc.warn(res.errMsg); + } + }); + } + + function onKeyboardInputCallback (res) { + if (res.value.length > editBoxImpl._maxLength) { + res.value = res.value.slice(0, editBoxImpl._maxLength); + } + if (editBoxImpl._delegate && editBoxImpl._delegate.editBoxTextChanged) { + if (editBoxImpl._text !== res.value) { + editBoxImpl._text = res.value; + editBoxImpl._delegate.editBoxTextChanged(editBoxImpl._text); + updateLabelsVisibility(editBoxImpl._delegate); + } + } + } + + function onKeyboardCompleteCallback () { + editBoxImpl._endEditing(); + wx.offKeyboardConfirm(onKeyboardConfirmCallback); + wx.offKeyboardInput(onKeyboardInputCallback); + wx.offKeyboardComplete(onKeyboardCompleteCallback); + _currentEditBoxImpl = null; + } + + wx.showKeyboard({ + defaultValue: editBoxImpl._text, + maxLength: editBoxImpl._maxLength, + multiple: multiline, + confirmHold: false, // hide keyboard mannually by wx.onKeyboardConfirm + confirmType: getKeyboardReturnType(editBoxImpl._returnType), + success: function (res) { + editBoxImpl._delegate && editBoxImpl._delegate.editBoxEditingDidBegan && editBoxImpl._delegate.editBoxEditingDidBegan(); + }, + fail: function (res) { + cc.warn(res.errMsg); + editBoxImpl._endEditing(); + } + }); + wx.onKeyboardConfirm(onKeyboardConfirmCallback); + wx.onKeyboardInput(onKeyboardInputCallback); + wx.onKeyboardComplete(onKeyboardCompleteCallback); + }; +})(); + diff --git a/frontend/build-templates/wechatgame/libs/engine/Game.js b/frontend/build-templates/wechatgame/libs/engine/Game.js new file mode 100644 index 0000000..7ab9d02 --- /dev/null +++ b/frontend/build-templates/wechatgame/libs/engine/Game.js @@ -0,0 +1,59 @@ +var _frameRate = 60; +cc.game.setFrameRate = function (frameRate) { + _frameRate = frameRate; + if (wx.setPreferredFramesPerSecond) { + wx.setPreferredFramesPerSecond(frameRate); + } + else { + if (this._intervalId) { + window.cancelAnimFrame(this._intervalId); + } + this._intervalId = 0; + this._paused = true; + this._setAnimFrame(); + this._runMainLoop(); + } +}; + +cc.game._setAnimFrame = function () { + this._lastTime = performance.now(); + this._frameTime = 1000 / _frameRate; + + if (_frameRate !== 60 && _frameRate !== 30) { + window.requestAnimFrame = this._stTime; + window.cancelAnimFrame = this._ctTime; + } + else { + window.requestAnimFrame = window.requestAnimationFrame || this._stTime; + window.cancelAnimFrame = window.cancelAnimationFrame || this._ctTime; + } +}; + +cc.game.getFrameRate = function () { + return _frameRate; +}; + +cc.game._runMainLoop = function () { + var self = this, callback, config = self.config, + director = cc.director, + skip = true, frameRate = config.frameRate; + + cc.debug.setDisplayStats(config.showFPS); + + callback = function () { + if (!self._paused) { + self._intervalId = window.requestAnimFrame(callback); + if (frameRate === 30) { + if (skip = !skip) { + return; + } + } + director.mainLoop(); + } + }; + + self._intervalId = window.requestAnimFrame(callback); + self._paused = false; +}; +// wechat game platform not support this api +cc.game.end = function () {}; \ No newline at end of file diff --git a/frontend/build-templates/wechatgame/libs/engine/downloader.js b/frontend/build-templates/wechatgame/libs/engine/downloader.js new file mode 100644 index 0000000..411c631 --- /dev/null +++ b/frontend/build-templates/wechatgame/libs/engine/downloader.js @@ -0,0 +1,37 @@ +cc.loader.downloader.loadSubpackage = function (name, completeCallback) { + wx.loadSubpackage({ + name: name, + success: function () { + if (completeCallback) completeCallback(); + }, + fail: function () { + if (completeCallback) completeCallback(new Error(`Failed to load subpackage ${name}`)); + } + }) +}; + +function downloadScript (item, callback, isAsync) { + var url = '../../' + item.url; + require(url); + callback(null, item.url); +} + +function loadFont (item) { + var url = item.url; + var fontFamily = wx.loadFont(url); + return fontFamily || 'Arial'; +} + +cc.loader.downloader.addHandlers({ + js : downloadScript +}); + +cc.loader.loader.addHandlers({ + // Font + font: loadFont, + eot: loadFont, + ttf: loadFont, + woff: loadFont, + svg: loadFont, + ttc: loadFont, +}); diff --git a/frontend/build-templates/wechatgame/libs/engine/index.js b/frontend/build-templates/wechatgame/libs/engine/index.js new file mode 100644 index 0000000..1c876be --- /dev/null +++ b/frontend/build-templates/wechatgame/libs/engine/index.js @@ -0,0 +1,6 @@ +require('./Game'); +require('./Audio'); +require('./Editbox'); +require('./DeviceMotionEvent'); +require('./downloader'); +require('./misc'); \ No newline at end of file diff --git a/frontend/build-templates/wechatgame/libs/engine/misc.js b/frontend/build-templates/wechatgame/libs/engine/misc.js new file mode 100644 index 0000000..cf16e41 --- /dev/null +++ b/frontend/build-templates/wechatgame/libs/engine/misc.js @@ -0,0 +1,7 @@ +// cc.AuidioEngine +if (cc && cc.audioEngine) { + cc.audioEngine._maxAudioInstance = 10; +} + +// cc.Macro +cc.macro.DOWNLOAD_MAX_CONCURRENT = 10; diff --git a/frontend/build-templates/wechatgame/libs/weapp-adapter/Audio.js b/frontend/build-templates/wechatgame/libs/weapp-adapter/Audio.js new file mode 100644 index 0000000..12bd6a4 --- /dev/null +++ b/frontend/build-templates/wechatgame/libs/weapp-adapter/Audio.js @@ -0,0 +1,246 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = undefined; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; + +var _HTMLAudioElement2 = require('./HTMLAudioElement'); + +var _HTMLAudioElement3 = _interopRequireDefault(_HTMLAudioElement2); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var HAVE_NOTHING = 0; +var HAVE_METADATA = 1; +var HAVE_CURRENT_DATA = 2; +var HAVE_FUTURE_DATA = 3; +var HAVE_ENOUGH_DATA = 4; + +var SN_SEED = 1; + +var _innerAudioContextMap = {}; + +var Audio = function (_HTMLAudioElement) { + _inherits(Audio, _HTMLAudioElement); + + function Audio(url) { + _classCallCheck(this, Audio); + + var _this = _possibleConstructorReturn(this, (Audio.__proto__ || Object.getPrototypeOf(Audio)).call(this)); + + _this._$sn = SN_SEED++; + + _this.HAVE_NOTHING = HAVE_NOTHING; + _this.HAVE_METADATA = HAVE_METADATA; + _this.HAVE_CURRENT_DATA = HAVE_CURRENT_DATA; + _this.HAVE_FUTURE_DATA = HAVE_FUTURE_DATA; + _this.HAVE_ENOUGH_DATA = HAVE_ENOUGH_DATA; + + _this.readyState = HAVE_NOTHING; + + var innerAudioContext = wx.createInnerAudioContext(); + + _innerAudioContextMap[_this._$sn] = innerAudioContext; + + _this._canplayEvents = ['load', 'loadend', 'canplay', 'canplaythrough', 'loadedmetadata']; + + innerAudioContext.onCanplay(function () { + _this._loaded = true; + _this.readyState = _this.HAVE_CURRENT_DATA; + _this._canplayEvents.forEach(function (type) { + _this.dispatchEvent({ type: type }); + }); + }); + innerAudioContext.onPlay(function () { + _this._paused = _innerAudioContextMap[_this._$sn].paused; + _this.dispatchEvent({ type: 'play' }); + }); + innerAudioContext.onPause(function () { + _this._paused = _innerAudioContextMap[_this._$sn].paused; + _this.dispatchEvent({ type: 'pause' }); + }); + innerAudioContext.onEnded(function () { + _this._paused = _innerAudioContextMap[_this._$sn].paused; + if (_innerAudioContextMap[_this._$sn].loop === false) { + _this.dispatchEvent({ type: 'ended' }); + } + _this.readyState = HAVE_ENOUGH_DATA; + }); + innerAudioContext.onError(function () { + _this._paused = _innerAudioContextMap[_this._$sn].paused; + _this.dispatchEvent({ type: 'error' }); + }); + + if (url) { + _this.src = url; + } else { + _this._src = ''; + } + + _this._loop = innerAudioContext.loop; + _this._autoplay = innerAudioContext.autoplay; + _this._paused = innerAudioContext.paused; + _this._volume = innerAudioContext.volume; + _this._muted = false; + return _this; + } + + _createClass(Audio, [{ + key: 'addEventListener', + value: function addEventListener(type, listener) { + var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; + + _get(Audio.prototype.__proto__ || Object.getPrototypeOf(Audio.prototype), 'addEventListener', this).call(this, type, listener, options); + + type = String(type).toLowerCase(); + + if (this._loaded && this._canplayEvents.indexOf(type) !== -1) { + this.dispatchEvent({ type: type }); + } + } + }, { + key: 'load', + value: function load() { + // console.warn('HTMLAudioElement.load() is not implemented.') + // weixin doesn't need call load() manually + } + }, { + key: 'play', + value: function play() { + _innerAudioContextMap[this._$sn].play(); + } + }, { + key: 'resume', + value: function resume() { + _innerAudioContextMap[this._$sn].resume(); + } + }, { + key: 'pause', + value: function pause() { + _innerAudioContextMap[this._$sn].pause(); + } + }, { + key: 'stop', + value: function stop() { + _innerAudioContextMap[this._$sn].stop(); + } + }, { + key: 'destroy', + value: function destroy() { + _innerAudioContextMap[this._$sn].destroy(); + } + }, { + key: 'canPlayType', + value: function canPlayType() { + var mediaType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; + + if (typeof mediaType !== 'string') { + return ''; + } + + if (mediaType.indexOf('audio/mpeg') > -1 || mediaType.indexOf('audio/mp4')) { + return 'probably'; + } + return ''; + } + }, { + key: 'cloneNode', + value: function cloneNode() { + var newAudio = new Audio(); + newAudio.loop = this.loop; + newAudio.autoplay = this.autoplay; + newAudio.src = this.src; + return newAudio; + } + }, { + key: 'currentTime', + get: function get() { + return _innerAudioContextMap[this._$sn].currentTime; + }, + set: function set(value) { + _innerAudioContextMap[this._$sn].seek(value); + } + }, { + key: 'duration', + get: function get() { + return _innerAudioContextMap[this._$sn].duration; + } + }, { + key: 'src', + get: function get() { + return this._src; + }, + set: function set(value) { + this._src = value; + this._loaded = false; + this.readyState = this.HAVE_NOTHING; + + var innerAudioContext = _innerAudioContextMap[this._$sn]; + + innerAudioContext.src = value; + } + }, { + key: 'loop', + get: function get() { + return this._loop; + }, + set: function set(value) { + this._loop = value; + _innerAudioContextMap[this._$sn].loop = value; + } + }, { + key: 'autoplay', + get: function get() { + return this.autoplay; + }, + set: function set(value) { + this._autoplay = value; + _innerAudioContextMap[this._$sn].autoplay = value; + } + }, { + key: 'paused', + get: function get() { + return this._paused; + } + }, { + key: 'volume', + get: function get() { + return this._volume; + }, + set: function set(value) { + this._volume = value; + if (!this._muted) { + _innerAudioContextMap[this._$sn].volume = value; + } + } + }, { + key: 'muted', + get: function get() { + return this._muted; + }, + set: function set(value) { + this._muted = value; + if (value) { + _innerAudioContextMap[this._$sn].volume = 0; + } else { + _innerAudioContextMap[this._$sn].volume = this._volume; + } + } + }]); + + return Audio; +}(_HTMLAudioElement3.default); + +exports.default = Audio; +module.exports = exports['default']; \ No newline at end of file diff --git a/frontend/build-templates/wechatgame/libs/weapp-adapter/Canvas.js b/frontend/build-templates/wechatgame/libs/weapp-adapter/Canvas.js new file mode 100644 index 0000000..50d6a06 --- /dev/null +++ b/frontend/build-templates/wechatgame/libs/weapp-adapter/Canvas.js @@ -0,0 +1,76 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = Canvas; + +var _WindowProperties = require('./WindowProperties'); + +var hasModifiedCanvasPrototype = false; // import HTMLCanvasElement from './HTMLCanvasElement' + +var hasInit2DContextConstructor = false; +var hasInitWebGLContextConstructor = false; + +function Canvas() { + var canvas = wx.createCanvas(); + + canvas.type = 'canvas'; + + // canvas.__proto__.__proto__.__proto__ = new HTMLCanvasElement() + + var _getContext = canvas.getContext; + + canvas.getBoundingClientRect = function () { + var ret = { + top: 0, + left: 0, + width: window.innerWidth, + height: window.innerHeight + }; + return ret; + }; + + canvas.style = { + top: '0px', + left: '0px', + width: _WindowProperties.innerWidth + 'px', + height: _WindowProperties.innerHeight + 'px' + }; + + canvas.addEventListener = function (type, listener) { + var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; + + // console.log('canvas.addEventListener', type); + document.addEventListener(type, listener, options); + }; + + canvas.removeEventListener = function (type, listener) { + // console.log('canvas.removeEventListener', type); + document.removeEventListener(type, listener); + }; + + canvas.dispatchEvent = function () { + var event = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + + console.log('canvas.dispatchEvent', event.type, event); + // nothing to do + }; + + Object.defineProperty(canvas, 'clientWidth', { + enumerable: true, + get: function get() { + return _WindowProperties.innerWidth; + } + }); + + Object.defineProperty(canvas, 'clientHeight', { + enumerable: true, + get: function get() { + return _WindowProperties.innerHeight; + } + }); + + return canvas; +} +module.exports = exports['default']; \ No newline at end of file diff --git a/frontend/build-templates/wechatgame/libs/weapp-adapter/Element.js b/frontend/build-templates/wechatgame/libs/weapp-adapter/Element.js new file mode 100644 index 0000000..f432349 --- /dev/null +++ b/frontend/build-templates/wechatgame/libs/weapp-adapter/Element.js @@ -0,0 +1,37 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = undefined; + +var _Node2 = require('./Node'); + +var _Node3 = _interopRequireDefault(_Node2); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var Element = function (_Node) { + _inherits(Element, _Node); + + function Element() { + _classCallCheck(this, Element); + + var _this = _possibleConstructorReturn(this, (Element.__proto__ || Object.getPrototypeOf(Element)).call(this)); + + _this.className = ''; + _this.children = []; + return _this; + } + + return Element; +}(_Node3.default); + +exports.default = Element; +module.exports = exports['default']; \ No newline at end of file diff --git a/frontend/build-templates/wechatgame/libs/weapp-adapter/Event.js b/frontend/build-templates/wechatgame/libs/weapp-adapter/Event.js new file mode 100644 index 0000000..9ed90b2 --- /dev/null +++ b/frontend/build-templates/wechatgame/libs/weapp-adapter/Event.js @@ -0,0 +1,26 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = undefined; + +var _util = require('./util'); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var Event = function Event(type) { + _classCallCheck(this, Event); + + this.cancelBubble = false; + this.cancelable = false; + this.target = null; + this.timestampe = Date.now(); + this.preventDefault = _util.noop; + this.stopPropagation = _util.noop; + + this.type = type; +}; + +exports.default = Event; +module.exports = exports['default']; \ No newline at end of file diff --git a/frontend/build-templates/wechatgame/libs/weapp-adapter/EventIniter/MouseEvent.js b/frontend/build-templates/wechatgame/libs/weapp-adapter/EventIniter/MouseEvent.js new file mode 100644 index 0000000..c65f381 --- /dev/null +++ b/frontend/build-templates/wechatgame/libs/weapp-adapter/EventIniter/MouseEvent.js @@ -0,0 +1,14 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var MouseEvent = function MouseEvent() { + _classCallCheck(this, MouseEvent); +}; + +exports.default = MouseEvent; +module.exports = exports["default"]; \ No newline at end of file diff --git a/frontend/build-templates/wechatgame/libs/weapp-adapter/EventIniter/TouchEvent.js b/frontend/build-templates/wechatgame/libs/weapp-adapter/EventIniter/TouchEvent.js new file mode 100644 index 0000000..7c0f4b1 --- /dev/null +++ b/frontend/build-templates/wechatgame/libs/weapp-adapter/EventIniter/TouchEvent.js @@ -0,0 +1,45 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = undefined; + +var _index = require('../util/index.js'); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var TouchEvent = function TouchEvent(type) { + _classCallCheck(this, TouchEvent); + + this.touches = []; + this.targetTouches = []; + this.changedTouches = []; + this.preventDefault = _index.noop; + this.stopPropagation = _index.noop; + + this.type = type; + this.target = window.canvas; + this.currentTarget = window.canvas; +}; + +exports.default = TouchEvent; + + +function touchEventHandlerFactory(type) { + return function (event) { + var touchEvent = new TouchEvent(type); + + touchEvent.touches = event.touches; + touchEvent.targetTouches = Array.prototype.slice.call(event.touches); + touchEvent.changedTouches = event.changedTouches; + touchEvent.timeStamp = event.timeStamp; + document.dispatchEvent(touchEvent); + }; +} + +wx.onTouchStart(touchEventHandlerFactory('touchstart')); +wx.onTouchMove(touchEventHandlerFactory('touchmove')); +wx.onTouchEnd(touchEventHandlerFactory('touchend')); +wx.onTouchCancel(touchEventHandlerFactory('touchcancel')); +module.exports = exports['default']; \ No newline at end of file diff --git a/frontend/build-templates/wechatgame/libs/weapp-adapter/EventIniter/index.js b/frontend/build-templates/wechatgame/libs/weapp-adapter/EventIniter/index.js new file mode 100644 index 0000000..07dd12a --- /dev/null +++ b/frontend/build-templates/wechatgame/libs/weapp-adapter/EventIniter/index.js @@ -0,0 +1,19 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.MouseEvent = exports.TouchEvent = undefined; + +var _TouchEvent2 = require('./TouchEvent'); + +var _TouchEvent3 = _interopRequireDefault(_TouchEvent2); + +var _MouseEvent2 = require('./MouseEvent'); + +var _MouseEvent3 = _interopRequireDefault(_MouseEvent2); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +exports.TouchEvent = _TouchEvent3.default; +exports.MouseEvent = _MouseEvent3.default; \ No newline at end of file diff --git a/frontend/build-templates/wechatgame/libs/weapp-adapter/EventTarget.js b/frontend/build-templates/wechatgame/libs/weapp-adapter/EventTarget.js new file mode 100644 index 0000000..f9d31be --- /dev/null +++ b/frontend/build-templates/wechatgame/libs/weapp-adapter/EventTarget.js @@ -0,0 +1,83 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var _events = new WeakMap(); + +var EventTarget = function () { + function EventTarget() { + _classCallCheck(this, EventTarget); + + _events.set(this, {}); + } + + _createClass(EventTarget, [{ + key: "addEventListener", + value: function addEventListener(type, listener) { + var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; + + var events = _events.get(this); + + if (!events) { + events = {}; + _events.set(this, events); + } + if (!events[type]) { + events[type] = []; + } + events[type].push(listener); + + if (options.capture) { + // console.warn('EventTarget.addEventListener: options.capture is not implemented.') + } + if (options.once) { + // console.warn('EventTarget.addEventListener: options.once is not implemented.') + } + if (options.passive) { + // console.warn('EventTarget.addEventListener: options.passive is not implemented.') + } + } + }, { + key: "removeEventListener", + value: function removeEventListener(type, listener) { + var events = _events.get(this); + + if (events) { + var listeners = events[type]; + + if (listeners && listeners.length > 0) { + for (var i = listeners.length; i--; i > 0) { + if (listeners[i] === listener) { + listeners.splice(i, 1); + break; + } + } + } + } + } + }, { + key: "dispatchEvent", + value: function dispatchEvent() { + var event = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + + var listeners = _events.get(this)[event.type]; + + if (listeners) { + for (var i = 0; i < listeners.length; i++) { + listeners[i](event); + } + } + } + }]); + + return EventTarget; +}(); + +exports.default = EventTarget; +module.exports = exports["default"]; \ No newline at end of file diff --git a/frontend/build-templates/wechatgame/libs/weapp-adapter/FileReader.js b/frontend/build-templates/wechatgame/libs/weapp-adapter/FileReader.js new file mode 100644 index 0000000..7ba9335 --- /dev/null +++ b/frontend/build-templates/wechatgame/libs/weapp-adapter/FileReader.js @@ -0,0 +1,28 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +/* + * TODO 使用 wx.readFile 来封装 FileReader + */ +var FileReader = function () { + function FileReader() { + _classCallCheck(this, FileReader); + } + + _createClass(FileReader, [{ + key: "construct", + value: function construct() {} + }]); + + return FileReader; +}(); + +exports.default = FileReader; +module.exports = exports["default"]; \ No newline at end of file diff --git a/frontend/build-templates/wechatgame/libs/weapp-adapter/HTMLAudioElement.js b/frontend/build-templates/wechatgame/libs/weapp-adapter/HTMLAudioElement.js new file mode 100644 index 0000000..19a7b3b --- /dev/null +++ b/frontend/build-templates/wechatgame/libs/weapp-adapter/HTMLAudioElement.js @@ -0,0 +1,33 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = undefined; + +var _HTMLMediaElement2 = require('./HTMLMediaElement'); + +var _HTMLMediaElement3 = _interopRequireDefault(_HTMLMediaElement2); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var HTMLAudioElement = function (_HTMLMediaElement) { + _inherits(HTMLAudioElement, _HTMLMediaElement); + + function HTMLAudioElement() { + _classCallCheck(this, HTMLAudioElement); + + return _possibleConstructorReturn(this, (HTMLAudioElement.__proto__ || Object.getPrototypeOf(HTMLAudioElement)).call(this, 'audio')); + } + + return HTMLAudioElement; +}(_HTMLMediaElement3.default); + +exports.default = HTMLAudioElement; +module.exports = exports['default']; \ No newline at end of file diff --git a/frontend/build-templates/wechatgame/libs/weapp-adapter/HTMLCanvasElement.js b/frontend/build-templates/wechatgame/libs/weapp-adapter/HTMLCanvasElement.js new file mode 100644 index 0000000..0b8c9cc --- /dev/null +++ b/frontend/build-templates/wechatgame/libs/weapp-adapter/HTMLCanvasElement.js @@ -0,0 +1,34 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _Canvas = require('./Canvas'); + +var _Canvas2 = _interopRequireDefault(_Canvas); + +var _HTMLElement = require('./HTMLElement'); + +var _HTMLElement2 = _interopRequireDefault(_HTMLElement); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// import HTMLElement from './HTMLElement'; + +// export default class HTMLCanvasElement extends HTMLElement +// { +// constructor(){ +// super('canvas') +// } +// }; + +GameGlobal.screencanvas = GameGlobal.screencanvas || new _Canvas2.default(); +var canvas = GameGlobal.screencanvas; + +var canvasConstructor = canvas.constructor; + +// canvasConstructor.__proto__.__proto__ = new HTMLElement(); + +exports.default = canvasConstructor; +module.exports = exports['default']; \ No newline at end of file diff --git a/frontend/build-templates/wechatgame/libs/weapp-adapter/HTMLElement.js b/frontend/build-templates/wechatgame/libs/weapp-adapter/HTMLElement.js new file mode 100644 index 0000000..8607c91 --- /dev/null +++ b/frontend/build-templates/wechatgame/libs/weapp-adapter/HTMLElement.js @@ -0,0 +1,92 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = undefined; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _Element2 = require('./Element'); + +var _Element3 = _interopRequireDefault(_Element2); + +var _index = require('./util/index.js'); + +var _WindowProperties = require('./WindowProperties'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var HTMLElement = function (_Element) { + _inherits(HTMLElement, _Element); + + function HTMLElement() { + var tagName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; + + _classCallCheck(this, HTMLElement); + + var _this = _possibleConstructorReturn(this, (HTMLElement.__proto__ || Object.getPrototypeOf(HTMLElement)).call(this)); + + _this.className = ''; + _this.childern = []; + _this.style = { + width: _WindowProperties.innerWidth + 'px', + height: _WindowProperties.innerHeight + 'px' + }; + _this.insertBefore = _index.noop; + _this.innerHTML = ''; + + _this.tagName = tagName.toUpperCase(); + return _this; + } + + _createClass(HTMLElement, [{ + key: 'setAttribute', + value: function setAttribute(name, value) { + this[name] = value; + } + }, { + key: 'getAttribute', + value: function getAttribute(name) { + return this[name]; + } + }, { + key: 'getBoundingClientRect', + value: function getBoundingClientRect() { + return { + top: 0, + left: 0, + width: _WindowProperties.innerWidth, + height: _WindowProperties.innerHeight + }; + } + }, { + key: 'focus', + value: function focus() {} + }, { + key: 'clientWidth', + get: function get() { + var ret = parseInt(this.style.fontSize, 10) * this.innerHTML.length; + + return Number.isNaN(ret) ? 0 : ret; + } + }, { + key: 'clientHeight', + get: function get() { + var ret = parseInt(this.style.fontSize, 10); + + return Number.isNaN(ret) ? 0 : ret; + } + }]); + + return HTMLElement; +}(_Element3.default); + +exports.default = HTMLElement; +module.exports = exports['default']; \ No newline at end of file diff --git a/frontend/build-templates/wechatgame/libs/weapp-adapter/HTMLImageElement.js b/frontend/build-templates/wechatgame/libs/weapp-adapter/HTMLImageElement.js new file mode 100644 index 0000000..420bfa5 --- /dev/null +++ b/frontend/build-templates/wechatgame/libs/weapp-adapter/HTMLImageElement.js @@ -0,0 +1,27 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _HTMLElement = require('./HTMLElement'); + +var _HTMLElement2 = _interopRequireDefault(_HTMLElement); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var imageConstructor = wx.createImage().constructor; + +// imageConstructor.__proto__.__proto__ = new HTMLElement(); + +// import HTMLElement from './HTMLElement'; + +// export default class HTMLImageElement extends HTMLElement +// { +// constructor(){ +// super('img') +// } +// }; + +exports.default = imageConstructor; +module.exports = exports['default']; \ No newline at end of file diff --git a/frontend/build-templates/wechatgame/libs/weapp-adapter/HTMLMediaElement.js b/frontend/build-templates/wechatgame/libs/weapp-adapter/HTMLMediaElement.js new file mode 100644 index 0000000..346e760 --- /dev/null +++ b/frontend/build-templates/wechatgame/libs/weapp-adapter/HTMLMediaElement.js @@ -0,0 +1,55 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = undefined; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _HTMLElement2 = require('./HTMLElement'); + +var _HTMLElement3 = _interopRequireDefault(_HTMLElement2); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var HTMLMediaElement = function (_HTMLElement) { + _inherits(HTMLMediaElement, _HTMLElement); + + function HTMLMediaElement(type) { + _classCallCheck(this, HTMLMediaElement); + + return _possibleConstructorReturn(this, (HTMLMediaElement.__proto__ || Object.getPrototypeOf(HTMLMediaElement)).call(this, type)); + } + + _createClass(HTMLMediaElement, [{ + key: 'addTextTrack', + value: function addTextTrack() {} + }, { + key: 'captureStream', + value: function captureStream() {} + }, { + key: 'fastSeek', + value: function fastSeek() {} + }, { + key: 'load', + value: function load() {} + }, { + key: 'pause', + value: function pause() {} + }, { + key: 'play', + value: function play() {} + }]); + + return HTMLMediaElement; +}(_HTMLElement3.default); + +exports.default = HTMLMediaElement; +module.exports = exports['default']; \ No newline at end of file diff --git a/frontend/build-templates/wechatgame/libs/weapp-adapter/HTMLVideoElement.js b/frontend/build-templates/wechatgame/libs/weapp-adapter/HTMLVideoElement.js new file mode 100644 index 0000000..456a7b3 --- /dev/null +++ b/frontend/build-templates/wechatgame/libs/weapp-adapter/HTMLVideoElement.js @@ -0,0 +1,34 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = undefined; + +var _HTMLMediaElement2 = require('./HTMLMediaElement'); + +var _HTMLMediaElement3 = _interopRequireDefault(_HTMLMediaElement2); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var HTMLVideoElement = function (_HTMLMediaElement) { + _inherits(HTMLVideoElement, _HTMLMediaElement); + + function HTMLVideoElement() { + _classCallCheck(this, HTMLVideoElement); + + return _possibleConstructorReturn(this, (HTMLVideoElement.__proto__ || Object.getPrototypeOf(HTMLVideoElement)).call(this, 'video')); + } + + return HTMLVideoElement; +}(_HTMLMediaElement3.default); + +exports.default = HTMLVideoElement; +; +module.exports = exports['default']; \ No newline at end of file diff --git a/frontend/build-templates/wechatgame/libs/weapp-adapter/Image.js b/frontend/build-templates/wechatgame/libs/weapp-adapter/Image.js new file mode 100644 index 0000000..5135d85 --- /dev/null +++ b/frontend/build-templates/wechatgame/libs/weapp-adapter/Image.js @@ -0,0 +1,22 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +exports.default = function () { + var image = wx.createImage(); + + // image.__proto__.__proto__.__proto__ = new HTMLImageElement(); + + return image; +}; + +var _HTMLImageElement = require('./HTMLImageElement'); + +var _HTMLImageElement2 = _interopRequireDefault(_HTMLImageElement); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +; +module.exports = exports['default']; \ No newline at end of file diff --git a/frontend/build-templates/wechatgame/libs/weapp-adapter/ImageBitmap.js b/frontend/build-templates/wechatgame/libs/weapp-adapter/ImageBitmap.js new file mode 100644 index 0000000..d9bd8bd --- /dev/null +++ b/frontend/build-templates/wechatgame/libs/weapp-adapter/ImageBitmap.js @@ -0,0 +1,16 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var ImageBitmap = function ImageBitmap() { + // TODO + + _classCallCheck(this, ImageBitmap); +}; + +exports.default = ImageBitmap; +module.exports = exports["default"]; \ No newline at end of file diff --git a/frontend/build-templates/wechatgame/libs/weapp-adapter/Node.js b/frontend/build-templates/wechatgame/libs/weapp-adapter/Node.js new file mode 100644 index 0000000..5bd01f2 --- /dev/null +++ b/frontend/build-templates/wechatgame/libs/weapp-adapter/Node.js @@ -0,0 +1,70 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = undefined; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _EventTarget2 = require('./EventTarget.js'); + +var _EventTarget3 = _interopRequireDefault(_EventTarget2); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var Node = function (_EventTarget) { + _inherits(Node, _EventTarget); + + function Node() { + _classCallCheck(this, Node); + + var _this = _possibleConstructorReturn(this, (Node.__proto__ || Object.getPrototypeOf(Node)).call(this)); + + _this.childNodes = []; + return _this; + } + + _createClass(Node, [{ + key: 'appendChild', + value: function appendChild(node) { + this.childNodes.push(node); + // if (node instanceof Node) { + // this.childNodes.push(node) + // } else { + // throw new TypeError('Failed to executed \'appendChild\' on \'Node\': parameter 1 is not of type \'Node\'.') + // } + } + }, { + key: 'cloneNode', + value: function cloneNode() { + var copyNode = Object.create(this); + + Object.assign(copyNode, this); + return copyNode; + } + }, { + key: 'removeChild', + value: function removeChild(node) { + var index = this.childNodes.findIndex(function (child) { + return child === node; + }); + + if (index > -1) { + return this.childNodes.splice(index, 1); + } + return null; + } + }]); + + return Node; +}(_EventTarget3.default); + +exports.default = Node; +module.exports = exports['default']; \ No newline at end of file diff --git a/frontend/build-templates/wechatgame/libs/weapp-adapter/WebGLRenderingContext.js b/frontend/build-templates/wechatgame/libs/weapp-adapter/WebGLRenderingContext.js new file mode 100644 index 0000000..6cf87c9 --- /dev/null +++ b/frontend/build-templates/wechatgame/libs/weapp-adapter/WebGLRenderingContext.js @@ -0,0 +1,16 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var WebGLRenderingContext = function WebGLRenderingContext() { + // TODO + + _classCallCheck(this, WebGLRenderingContext); +}; + +exports.default = WebGLRenderingContext; +module.exports = exports["default"]; \ No newline at end of file diff --git a/frontend/build-templates/wechatgame/libs/weapp-adapter/WebSocket.js b/frontend/build-templates/wechatgame/libs/weapp-adapter/WebSocket.js new file mode 100644 index 0000000..85e0a54 --- /dev/null +++ b/frontend/build-templates/wechatgame/libs/weapp-adapter/WebSocket.js @@ -0,0 +1,114 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _class, _temp; + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var _socketTask = new WeakMap(); + +var WebSocket = (_temp = _class = function () { + // TODO 更新 binaryType + // The connection is in the process of closing. + // The connection is not yet open. + function WebSocket(url) { + var _this = this; + + var protocols = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; + + _classCallCheck(this, WebSocket); + + this.binaryType = ''; + this.bufferedAmount = 0; + this.extensions = ''; + this.onclose = null; + this.onerror = null; + this.onmessage = null; + this.onopen = null; + this.protocol = ''; + this.readyState = 3; + + if (typeof url !== 'string' || !/(^ws:\/\/)|(^wss:\/\/)/.test(url)) { + throw new TypeError('Failed to construct \'WebSocket\': The URL \'' + url + '\' is invalid'); + } + + this.url = url; + this.readyState = WebSocket.CONNECTING; + + var socketTask = wx.connectSocket({ + url: url, + protocols: Array.isArray(protocols) ? protocols : [protocols], + tcpNoDelay: true + }); + + _socketTask.set(this, socketTask); + + socketTask.onClose(function (res) { + _this.readyState = WebSocket.CLOSED; + if (typeof _this.onclose === 'function') { + _this.onclose(res); + } + }); + + socketTask.onMessage(function (res) { + if (typeof _this.onmessage === 'function') { + _this.onmessage(res); + } + }); + + socketTask.onOpen(function () { + _this.readyState = WebSocket.OPEN; + if (typeof _this.onopen === 'function') { + _this.onopen(); + } + }); + + socketTask.onError(function (res) { + if (typeof _this.onerror === 'function') { + _this.onerror(new Error(res.errMsg)); + } + }); + + return this; + } // TODO 小程序内目前获取不到,实际上需要根据服务器选择的 sub-protocol 返回 + // TODO 更新 bufferedAmount + // The connection is closed or couldn't be opened. + + // The connection is open and ready to communicate. + + + _createClass(WebSocket, [{ + key: 'close', + value: function close(code, reason) { + this.readyState = WebSocket.CLOSING; + var socketTask = _socketTask.get(this); + + socketTask.close({ + code: code, + reason: reason + }); + } + }, { + key: 'send', + value: function send(data) { + if (typeof data !== 'string' && !(data instanceof ArrayBuffer)) { + throw new TypeError('Failed to send message: The data ' + data + ' is invalid'); + } + + var socketTask = _socketTask.get(this); + + socketTask.send({ + data: data + }); + } + }]); + + return WebSocket; +}(), _class.CONNECTING = 0, _class.OPEN = 1, _class.CLOSING = 2, _class.CLOSED = 3, _temp); +exports.default = WebSocket; +module.exports = exports['default']; \ No newline at end of file diff --git a/frontend/build-templates/wechatgame/libs/weapp-adapter/WindowProperties.js b/frontend/build-templates/wechatgame/libs/weapp-adapter/WindowProperties.js new file mode 100644 index 0000000..7add922 --- /dev/null +++ b/frontend/build-templates/wechatgame/libs/weapp-adapter/WindowProperties.js @@ -0,0 +1,30 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _wx$getSystemInfoSync = wx.getSystemInfoSync(), + screenWidth = _wx$getSystemInfoSync.screenWidth, + screenHeight = _wx$getSystemInfoSync.screenHeight, + devicePixelRatio = _wx$getSystemInfoSync.devicePixelRatio; + +var innerWidth = exports.innerWidth = screenWidth; +var innerHeight = exports.innerHeight = screenHeight; +exports.devicePixelRatio = devicePixelRatio; +var screen = exports.screen = { + width: screenWidth, + height: screenHeight, + availWidth: innerWidth, + availHeight: innerHeight, + availLeft: 0, + availTop: 0 +}; + +var performance = exports.performance = { + now: Date.now +}; + +var ontouchstart = exports.ontouchstart = null; +var ontouchmove = exports.ontouchmove = null; +var ontouchend = exports.ontouchend = null; \ No newline at end of file diff --git a/frontend/build-templates/wechatgame/libs/weapp-adapter/Worker.js b/frontend/build-templates/wechatgame/libs/weapp-adapter/Worker.js new file mode 100644 index 0000000..adb522a --- /dev/null +++ b/frontend/build-templates/wechatgame/libs/weapp-adapter/Worker.js @@ -0,0 +1,14 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +exports.default = function (file) { + var worker = wx.createWorker(file); + + return worker; +}; + +; +module.exports = exports["default"]; \ No newline at end of file diff --git a/frontend/build-templates/wechatgame/libs/weapp-adapter/XMLHttpRequest.js b/frontend/build-templates/wechatgame/libs/weapp-adapter/XMLHttpRequest.js new file mode 100644 index 0000000..da9686f --- /dev/null +++ b/frontend/build-templates/wechatgame/libs/weapp-adapter/XMLHttpRequest.js @@ -0,0 +1,210 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = undefined; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _class, _temp; + +var _EventTarget2 = require('./EventTarget.js'); + +var _EventTarget3 = _interopRequireDefault(_EventTarget2); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var _url = new WeakMap(); +var _method = new WeakMap(); +var _requestHeader = new WeakMap(); +var _responseHeader = new WeakMap(); +var _requestTask = new WeakMap(); + +function _triggerEvent(type) { + if (typeof this['on' + type] === 'function') { + for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + + this['on' + type].apply(this, args); + } +} + +function _changeReadyState(readyState) { + this.readyState = readyState; + _triggerEvent.call(this, 'readystatechange'); +} + +var XMLHttpRequest = (_temp = _class = function (_EventTarget) { + _inherits(XMLHttpRequest, _EventTarget); + + // TODO 没法模拟 HEADERS_RECEIVED 和 LOADING 两个状态 + function XMLHttpRequest() { + _classCallCheck(this, XMLHttpRequest); + + var _this2 = _possibleConstructorReturn(this, (XMLHttpRequest.__proto__ || Object.getPrototypeOf(XMLHttpRequest)).call(this)); + + _this2.onabort = null; + _this2.onerror = null; + _this2.onload = null; + _this2.onloadstart = null; + _this2.onprogress = null; + _this2.ontimeout = null; + _this2.onloadend = null; + _this2.onreadystatechange = null; + _this2.readyState = 0; + _this2.response = null; + _this2.responseText = null; + _this2.responseType = ''; + _this2.responseXML = null; + _this2.status = 0; + _this2.statusText = ''; + _this2.upload = {}; + _this2.withCredentials = false; + + + _requestHeader.set(_this2, { + 'content-type': 'application/x-www-form-urlencoded' + }); + _responseHeader.set(_this2, {}); + return _this2; + } + + /* + * TODO 这一批事件应该是在 XMLHttpRequestEventTarget.prototype 上面的 + */ + + + _createClass(XMLHttpRequest, [{ + key: 'abort', + value: function abort() { + var myRequestTask = _requestTask.get(this); + + if (myRequestTask) { + myRequestTask.abort(); + } + } + }, { + key: 'getAllResponseHeaders', + value: function getAllResponseHeaders() { + var responseHeader = _responseHeader.get(this); + + return Object.keys(responseHeader).map(function (header) { + return header + ': ' + responseHeader[header]; + }).join('\n'); + } + }, { + key: 'getResponseHeader', + value: function getResponseHeader(header) { + return _responseHeader.get(this)[header]; + } + }, { + key: 'open', + value: function open(method, url /* async, user, password 这几个参数在小程序内不支持*/) { + _method.set(this, method); + _url.set(this, url); + _changeReadyState.call(this, XMLHttpRequest.OPENED); + } + }, { + key: 'overrideMimeType', + value: function overrideMimeType() {} + }, { + key: 'send', + value: function send() { + var _this3 = this; + + var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; + + if (this.readyState !== XMLHttpRequest.OPENED) { + throw new Error("Failed to execute 'send' on 'XMLHttpRequest': The object's state must be OPENED."); + } else { + wx.request({ + data: data, + url: _url.get(this), + method: _method.get(this), + header: _requestHeader.get(this), + responseType: this.responseType, + success: function success(_ref) { + var data = _ref.data, + statusCode = _ref.statusCode, + header = _ref.header; + + if (typeof data !== 'string' && !(data instanceof ArrayBuffer)) { + try { + data = JSON.stringify(data); + } catch (e) { + data = data; + } + } + + _this3.status = statusCode; + _responseHeader.set(_this3, header); + _triggerEvent.call(_this3, 'loadstart'); + _changeReadyState.call(_this3, XMLHttpRequest.HEADERS_RECEIVED); + _changeReadyState.call(_this3, XMLHttpRequest.LOADING); + + _this3.response = data; + + if (data instanceof ArrayBuffer) { + _this3.responseText = ''; + var bytes = new Uint8Array(data); + var len = bytes.byteLength; + + for (var i = 0; i < len; i++) { + _this3.responseText += String.fromCharCode(bytes[i]); + } + } else { + _this3.responseText = data; + } + _changeReadyState.call(_this3, XMLHttpRequest.DONE); + _triggerEvent.call(_this3, 'load'); + _triggerEvent.call(_this3, 'loadend'); + }, + fail: function fail(_ref2) { + var errMsg = _ref2.errMsg; + + // TODO 规范错误 + if (errMsg.indexOf('abort') !== -1) { + _triggerEvent.call(_this3, 'abort'); + } else if (errMsg.indexOf('timeout') !== -1) { + _triggerEvent.call(_this3, 'timeout'); + } else { + _triggerEvent.call(_this3, 'error', errMsg); + } + _triggerEvent.call(_this3, 'loadend'); + } + }); + } + } + }, { + key: 'setRequestHeader', + value: function setRequestHeader(header, value) { + var myHeader = _requestHeader.get(this); + + myHeader[header] = value; + _requestHeader.set(this, myHeader); + } + }, { + key: 'addEventListener', + value: function addEventListener(type, listener) { + if (typeof listener === 'function') { + var _this = this; + var event = { target: _this }; + this['on' + type] = function (event) { + listener.call(_this, event); + }; + } + } + }]); + + return XMLHttpRequest; +}(_EventTarget3.default), _class.UNSEND = 0, _class.OPENED = 1, _class.HEADERS_RECEIVED = 2, _class.LOADING = 3, _class.DONE = 4, _temp); +exports.default = XMLHttpRequest; +module.exports = exports['default']; \ No newline at end of file diff --git a/frontend/build-templates/wechatgame/libs/weapp-adapter/document.js b/frontend/build-templates/wechatgame/libs/weapp-adapter/document.js new file mode 100644 index 0000000..3a71707 --- /dev/null +++ b/frontend/build-templates/wechatgame/libs/weapp-adapter/document.js @@ -0,0 +1,147 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _window = require('./window'); + +var window = _interopRequireWildcard(_window); + +var _HTMLElement = require('./HTMLElement'); + +var _HTMLElement2 = _interopRequireDefault(_HTMLElement); + +var _HTMLVideoElement = require('./HTMLVideoElement'); + +var _HTMLVideoElement2 = _interopRequireDefault(_HTMLVideoElement); + +var _Image = require('./Image'); + +var _Image2 = _interopRequireDefault(_Image); + +var _Audio = require('./Audio'); + +var _Audio2 = _interopRequireDefault(_Audio); + +var _Canvas = require('./Canvas'); + +var _Canvas2 = _interopRequireDefault(_Canvas); + +require('./EventIniter/index.js'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +var events = {}; + +var document = { + readyState: 'complete', + visibilityState: 'visible', + documentElement: window, + hidden: false, + style: {}, + location: window.location, + ontouchstart: null, + ontouchmove: null, + ontouchend: null, + + head: new _HTMLElement2.default('head'), + body: new _HTMLElement2.default('body'), + + createElement: function createElement(tagName) { + if (tagName === 'canvas') { + return new _Canvas2.default(); + } else if (tagName === 'audio') { + return new _Audio2.default(); + } else if (tagName === 'img') { + return new _Image2.default(); + } else if (tagName === 'video') { + return new _HTMLVideoElement2.default(); + } + + return new _HTMLElement2.default(tagName); + }, + createElementNS: function createElementNS(nameSpace, tagName) { + return this.createElement(tagName); + }, + getElementById: function getElementById(id) { + if (id === window.canvas.id) { + return window.canvas; + } + return null; + }, + getElementsByTagName: function getElementsByTagName(tagName) { + if (tagName === 'head') { + return [document.head]; + } else if (tagName === 'body') { + return [document.body]; + } else if (tagName === 'canvas') { + return [window.canvas]; + } + return []; + }, + getElementsByName: function getElementsByName(tagName) { + if (tagName === 'head') { + return [document.head]; + } else if (tagName === 'body') { + return [document.body]; + } else if (tagName === 'canvas') { + return [window.canvas]; + } + return []; + }, + querySelector: function querySelector(query) { + if (query === 'head') { + return document.head; + } else if (query === 'body') { + return document.body; + } else if (query === 'canvas') { + return window.canvas; + } else if (query === '#' + window.canvas.id) { + return window.canvas; + } + return null; + }, + querySelectorAll: function querySelectorAll(query) { + if (query === 'head') { + return [document.head]; + } else if (query === 'body') { + return [document.body]; + } else if (query === 'canvas') { + return [window.canvas]; + } + return []; + }, + addEventListener: function addEventListener(type, listener) { + if (!events[type]) { + events[type] = []; + } + events[type].push(listener); + }, + removeEventListener: function removeEventListener(type, listener) { + var listeners = events[type]; + + if (listeners && listeners.length > 0) { + for (var i = listeners.length; i--; i > 0) { + if (listeners[i] === listener) { + listeners.splice(i, 1); + break; + } + } + } + }, + dispatchEvent: function dispatchEvent(event) { + var listeners = events[event.type]; + + if (listeners) { + for (var i = 0; i < listeners.length; i++) { + listeners[i](event); + } + } + } +}; + +exports.default = document; +module.exports = exports['default']; \ No newline at end of file diff --git a/frontend/build-templates/wechatgame/libs/weapp-adapter/index.js b/frontend/build-templates/wechatgame/libs/weapp-adapter/index.js new file mode 100644 index 0000000..fb31883 --- /dev/null +++ b/frontend/build-templates/wechatgame/libs/weapp-adapter/index.js @@ -0,0 +1,77 @@ +'use strict'; + +var _window2 = require('./window'); + +var _window = _interopRequireWildcard(_window2); + +var _document = require('./document'); + +var _document2 = _interopRequireDefault(_document); + +var _HTMLElement = require('./HTMLElement'); + +var _HTMLElement2 = _interopRequireDefault(_HTMLElement); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +var global = GameGlobal; + +function inject() { + _window.document = _document2.default; + + _window.addEventListener = function (type, listener) { + _window.document.addEventListener(type, listener); + }; + _window.removeEventListener = function (type, listener) { + _window.document.removeEventListener(type, listener); + }; + _window.dispatchEvent = function () { + var event = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + + console.log('window.dispatchEvent', event.type, event); + // nothing to do + }; + + var _wx$getSystemInfoSync = wx.getSystemInfoSync(), + platform = _wx$getSystemInfoSync.platform; + + // 开发者工具无法重定义 window + + + if (typeof __devtoolssubcontext === 'undefined' && platform === 'devtools') { + for (var key in _window) { + var descriptor = Object.getOwnPropertyDescriptor(global, key); + + if (!descriptor || descriptor.configurable === true) { + Object.defineProperty(window, key, { + value: _window[key] + }); + } + } + + for (var _key in _window.document) { + var _descriptor = Object.getOwnPropertyDescriptor(global.document, _key); + + if (!_descriptor || _descriptor.configurable === true) { + Object.defineProperty(global.document, _key, { + value: _window.document[_key] + }); + } + } + window.parent = window; + } else { + for (var _key2 in _window) { + global[_key2] = _window[_key2]; + } + global.window = _window; + window = global; + window.top = window.parent = window; + } +} + +if (!GameGlobal.__isAdapterInjected) { + GameGlobal.__isAdapterInjected = true; + inject(); +} \ No newline at end of file diff --git a/frontend/build-templates/wechatgame/libs/weapp-adapter/localStorage.js b/frontend/build-templates/wechatgame/libs/weapp-adapter/localStorage.js new file mode 100644 index 0000000..c290e1a --- /dev/null +++ b/frontend/build-templates/wechatgame/libs/weapp-adapter/localStorage.js @@ -0,0 +1,35 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +var localStorage = { + get length() { + var _wx$getStorageInfoSyn = wx.getStorageInfoSync(), + keys = _wx$getStorageInfoSyn.keys; + + return keys.length; + }, + + key: function key(n) { + var _wx$getStorageInfoSyn2 = wx.getStorageInfoSync(), + keys = _wx$getStorageInfoSyn2.keys; + + return keys[n]; + }, + getItem: function getItem(key) { + return wx.getStorageSync(key); + }, + setItem: function setItem(key, value) { + return wx.setStorageSync(key, value); + }, + removeItem: function removeItem(key) { + wx.removeStorageSync(key); + }, + clear: function clear() { + wx.clearStorageSync(); + } +}; + +exports.default = localStorage; +module.exports = exports["default"]; \ No newline at end of file diff --git a/frontend/build-templates/wechatgame/libs/weapp-adapter/location.js b/frontend/build-templates/wechatgame/libs/weapp-adapter/location.js new file mode 100644 index 0000000..1e51699 --- /dev/null +++ b/frontend/build-templates/wechatgame/libs/weapp-adapter/location.js @@ -0,0 +1,12 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +var location = { + href: 'game.js', + reload: function reload() {} +}; + +exports.default = location; +module.exports = exports['default']; \ No newline at end of file diff --git a/frontend/build-templates/wechatgame/libs/weapp-adapter/navigator.js b/frontend/build-templates/wechatgame/libs/weapp-adapter/navigator.js new file mode 100644 index 0000000..3c125e8 --- /dev/null +++ b/frontend/build-templates/wechatgame/libs/weapp-adapter/navigator.js @@ -0,0 +1,45 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _index = require('./util/index.js'); + +// TODO 需要 wx.getSystemInfo 获取更详细信息 +var systemInfo = wx.getSystemInfoSync(); +console.log(systemInfo); + +var system = systemInfo.system; +var platform = systemInfo.platform; +var language = systemInfo.language; +var wechatVersioin = systemInfo.version; + +var android = system.toLowerCase().indexOf('android') !== -1; + +var uaDesc = android ? 'Android; CPU ' + system : 'iPhone; CPU iPhone OS ' + system + ' like Mac OS X'; +var ua = 'Mozilla/5.0 (' + uaDesc + ') AppleWebKit/603.1.30 (KHTML, like Gecko) Mobile/14E8301 MicroMessenger/' + wechatVersioin + ' MiniGame NetType/WIFI Language/' + language; + +var navigator = { + platform: platform, + language: language, + appVersion: '5.0 (' + uaDesc + ') AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1', + userAgent: ua, + onLine: true, // TODO 用 wx.getNetworkStateChange 和 wx.onNetworkStateChange 来返回真实的状态 + + // TODO 用 wx.getLocation 来封装 geolocation + geolocation: { + getCurrentPosition: _index.noop, + watchPosition: _index.noop, + clearWatch: _index.noop + } +}; + +if (wx.onNetworkStatusChange) { + wx.onNetworkStatusChange(function (event) { + navigator.onLine = event.isConnected; + }); +} + +exports.default = navigator; +module.exports = exports['default']; \ No newline at end of file diff --git a/frontend/build-templates/wechatgame/libs/weapp-adapter/util/index.js b/frontend/build-templates/wechatgame/libs/weapp-adapter/util/index.js new file mode 100644 index 0000000..2d9eb32 --- /dev/null +++ b/frontend/build-templates/wechatgame/libs/weapp-adapter/util/index.js @@ -0,0 +1,7 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.noop = noop; +function noop() {} \ No newline at end of file diff --git a/frontend/build-templates/wechatgame/libs/weapp-adapter/window.js b/frontend/build-templates/wechatgame/libs/weapp-adapter/window.js new file mode 100644 index 0000000..480cf77 --- /dev/null +++ b/frontend/build-templates/wechatgame/libs/weapp-adapter/window.js @@ -0,0 +1,139 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.cancelAnimationFrame = exports.requestAnimationFrame = exports.clearInterval = exports.clearTimeout = exports.setInterval = exports.setTimeout = exports.canvas = exports.location = exports.localStorage = exports.DeviceMotionEvent = exports.MouseEvent = exports.TouchEvent = exports.WebGLRenderingContext = exports.HTMLVideoElement = exports.HTMLAudioElement = exports.HTMLMediaElement = exports.HTMLCanvasElement = exports.HTMLImageElement = exports.HTMLElement = exports.FileReader = exports.Audio = exports.ImageBitmap = exports.Image = exports.WebSocket = exports.XMLHttpRequest = exports.navigator = undefined; + +var _index = require('./EventIniter/index.js'); + +Object.defineProperty(exports, 'TouchEvent', { + enumerable: true, + get: function get() { + return _index.TouchEvent; + } +}); +Object.defineProperty(exports, 'MouseEvent', { + enumerable: true, + get: function get() { + return _index.MouseEvent; + } +}); +Object.defineProperty(exports, 'DeviceMotionEvent', { + enumerable: true, + get: function get() { + return _index.DeviceMotionEvent; + } +}); + +var _WindowProperties = require('./WindowProperties'); + +Object.keys(_WindowProperties).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _WindowProperties[key]; + } + }); +}); + +var _Canvas = require('./Canvas'); + +var _Canvas2 = _interopRequireDefault(_Canvas); + +var _navigator2 = require('./navigator'); + +var _navigator3 = _interopRequireDefault(_navigator2); + +var _XMLHttpRequest2 = require('./XMLHttpRequest'); + +var _XMLHttpRequest3 = _interopRequireDefault(_XMLHttpRequest2); + +var _WebSocket2 = require('./WebSocket'); + +var _WebSocket3 = _interopRequireDefault(_WebSocket2); + +var _Image2 = require('./Image'); + +var _Image3 = _interopRequireDefault(_Image2); + +var _ImageBitmap2 = require('./ImageBitmap'); + +var _ImageBitmap3 = _interopRequireDefault(_ImageBitmap2); + +var _Audio2 = require('./Audio'); + +var _Audio3 = _interopRequireDefault(_Audio2); + +var _FileReader2 = require('./FileReader'); + +var _FileReader3 = _interopRequireDefault(_FileReader2); + +var _HTMLElement2 = require('./HTMLElement'); + +var _HTMLElement3 = _interopRequireDefault(_HTMLElement2); + +var _HTMLImageElement2 = require('./HTMLImageElement'); + +var _HTMLImageElement3 = _interopRequireDefault(_HTMLImageElement2); + +var _HTMLCanvasElement2 = require('./HTMLCanvasElement'); + +var _HTMLCanvasElement3 = _interopRequireDefault(_HTMLCanvasElement2); + +var _HTMLMediaElement2 = require('./HTMLMediaElement'); + +var _HTMLMediaElement3 = _interopRequireDefault(_HTMLMediaElement2); + +var _HTMLAudioElement2 = require('./HTMLAudioElement'); + +var _HTMLAudioElement3 = _interopRequireDefault(_HTMLAudioElement2); + +var _HTMLVideoElement2 = require('./HTMLVideoElement'); + +var _HTMLVideoElement3 = _interopRequireDefault(_HTMLVideoElement2); + +var _WebGLRenderingContext2 = require('./WebGLRenderingContext'); + +var _WebGLRenderingContext3 = _interopRequireDefault(_WebGLRenderingContext2); + +var _localStorage2 = require('./localStorage'); + +var _localStorage3 = _interopRequireDefault(_localStorage2); + +var _location2 = require('./location'); + +var _location3 = _interopRequireDefault(_location2); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +exports.navigator = _navigator3.default; +exports.XMLHttpRequest = _XMLHttpRequest3.default; +exports.WebSocket = _WebSocket3.default; +exports.Image = _Image3.default; +exports.ImageBitmap = _ImageBitmap3.default; +exports.Audio = _Audio3.default; +exports.FileReader = _FileReader3.default; +exports.HTMLElement = _HTMLElement3.default; +exports.HTMLImageElement = _HTMLImageElement3.default; +exports.HTMLCanvasElement = _HTMLCanvasElement3.default; +exports.HTMLMediaElement = _HTMLMediaElement3.default; +exports.HTMLAudioElement = _HTMLAudioElement3.default; +exports.HTMLVideoElement = _HTMLVideoElement3.default; +exports.WebGLRenderingContext = _WebGLRenderingContext3.default; +exports.localStorage = _localStorage3.default; +exports.location = _location3.default; + + +// 暴露全局的 canvas +GameGlobal.screencanvas = GameGlobal.screencanvas || new _Canvas2.default(); +var canvas = GameGlobal.screencanvas; + +exports.canvas = canvas; +exports.setTimeout = setTimeout; +exports.setInterval = setInterval; +exports.clearTimeout = clearTimeout; +exports.clearInterval = clearInterval; +exports.requestAnimationFrame = requestAnimationFrame; +exports.cancelAnimationFrame = cancelAnimationFrame; \ No newline at end of file diff --git a/frontend/build-templates/wechatgame/libs/wx-downloader.js b/frontend/build-templates/wechatgame/libs/wx-downloader.js new file mode 100644 index 0000000..a4ad97e --- /dev/null +++ b/frontend/build-templates/wechatgame/libs/wx-downloader.js @@ -0,0 +1,508 @@ +/**************************************************************************** + Copyright (c) 2017 Chukong Technologies Inc. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Chukong Aipu reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ +var ID = 'WXDownloader'; +const wxFsUtils = require('./wx-fs-utils'); + +const REGEX = /^\w+:\/\/.*/; + +var packageFiles = null; +var cachedFiles = null; +var writeCacheFileList = null; +var cacheQueue = null; +var checkNextPeriod = false; +var errTest = /the maximum size of the file storage/; + +var _newAssets = {}; +var WXDownloader = window.WXDownloader = function () { + this.id = ID; + this.async = true; + this.pipeline = null; + this.REMOTE_SERVER_ROOT = ''; + this.SUBCONTEXT_ROOT = ''; + + this.totalBytesExpectedToWriteAlreadyCounted = new Map(); // Keyed by "remoteUrl". + this.totalBytesExpectedToWriteForAllTasks = 0; + this.totalBytesWrittenForAllTasks = 0; + + this.immediateHandleItemCount = 0; + this.immediateHandleItemCompleteCount = 0; + + this.immediateReadFromLocalCount = 0; + this.immediateReadFromLocalCompleteCount = 0; + + this.immediatePackDownloaderCount = 0; + this.immediatePackDownloaderCompleteCount = 0; +}; +WXDownloader.ID = ID; + +WXDownloader.prototype.init = function () { + if (!CC_WECHATGAMESUB) { + this.cacheDir = wx.env.USER_DATA_PATH + '/gamecaches'; + this.cachedFileName = 'cacheList.json'; + // whether or not cache asset into user's storage space + this.cacheAsset = true; + // cache one per cycle + this.cachePeriod = 100; + // whether or not storage space is run out of + this.outOfStorage = false; + + this.writeFilePeriod = 1000; + + cacheQueue = {}; + packageFiles = {}; + + var cacheFilePath = this.cacheDir + '/' + this.cachedFileName; + cachedFiles = wxFsUtils.readJsonSync(cacheFilePath); + if (cachedFiles instanceof Error) { + cachedFiles = {}; + wxFsUtils.makeDirSync(this.cacheDir, true); + wxFsUtils.writeFileSync(cacheFilePath, JSON.stringify(cachedFiles), 'utf8'); + } + } +}; + +WXDownloader.prototype.handle = function (item, callback) { + if (item.type === 'js') { + return null; + } + var immediateHandleItemCompleteCallback = (errors, results) => { + wxDownloader.immediateHandleItemCompleteCount += 1; + callback(errors, results); + }; + var immediateReadFromLocalCompleteCallback = (errors, results) => { + wxDownloader.immediateReadFromLocalCompleteCount += 1; + callback(errors, results); + }; + var immediatePackerDownloaderCompleteCallback = (errors, results) => { + wxDownloader.immediatePackDownloaderCompleteCount += 1; + callback(errors, results); + }; + if (item.type === 'uuid') { + wxDownloader.immediatePackDownloaderCount += 1; + var result = cc.Pipeline.Downloader.PackDownloader.load(item, immediatePackerDownloaderCompleteCallback); + if (undefined === result) { + // When "undefined" is returned, the above "PackDownloader.load(...)" has finished running synchronously and won't trigger "theWrappedCompleteCallback". + wxDownloader.immediatePackDownloaderCompleteCount += 1; + return; + } else if (null === result) { + // When "null" is returned, the above "PackDownloader.load(...)" has been running asynchronously and will trigger "theWrappedCompleteCallback". + return; + } else { + // When "non-empty" is returned, the above "PackDownloader.load(...)" has finished running synchronously and won't trigger "theWrappedCompleteCallback". + wxDownloader.immediatePackDownloaderCompleteCount += 1; + return result; + } + } + + if (CC_WECHATGAMESUB) { + // if wx.getFileSystemManager is undefined, need to skip + if (REGEX.test(item.url)) { + return null; + } + + item.url = this.SUBCONTEXT_ROOT + '/' + item.url; + if (wxFsUtils.checkFsValid()) return null; + wxDownloader.immediateHandleItemCount += 1; + + handleItem(item, immediateHandleItemCompleteCallback); + return; + } + + function seek (inPackage) { + if (inPackage) { + wxDownloader.immediateHandleItemCount += 1; + handleItem(item, immediateHandleItemCompleteCallback); + } + else { + wxDownloader.immediateReadFromLocalCount += 1; + readFromLocal(item, immediateReadFromLocalCompleteCallback); + } + } + + if (item.url in packageFiles) { + seek(packageFiles[item.url]); + } + else { + wxFsUtils.exists(item.url, function (existance) { + packageFiles[item.url] = existance; + seek(existance); + }); + } +}; + +WXDownloader.prototype.cleanOldAssets = function () { + cc.warn('wxDownloader.cleanOldAssets has been deprecated, please use wxDownloader.cleanOldCaches instead!'); + return this.cleanOldCaches(); +}; + +WXDownloader.prototype.cleanOldCaches = function () { + this.cleanAllCaches(_newAssets, function (err) { + if (err) { + cc.warn(err); + } + else { + for (var path in _newAssets) { + cc.log('reserve local file: ' + path); + } + cc.log('Clean old Assets successfully!'); + } + }); +}; + +function handleItem (item, callback) { + if (item.type && !shouldReadFile(item.type)) { + callback(null, null); + } + else { + readFile(item, callback); + } +} + +WXDownloader.prototype.getCacheName = function (filePath) { + var cacheUrlReg = /\//g; + return filePath.replace(cacheUrlReg, '-'); +}; + +WXDownloader.prototype.getCachedFileList = function () { + return cachedFiles; +}; + +WXDownloader.prototype.cleanCache = function (filePath) { + if (filePath in cachedFiles) { + var self = this; + delete cachedFiles[filePath]; + wxFsUtils.writeFileSync(this.cacheDir + '/' + this.cachedFileName, JSON.stringify(cachedFiles), 'utf8'); + wxFsUtils.deleteFile(this.cacheDir + '/' + filePath, function (err) { + if (!err) self.outOfStorage = false; + }); + } +}; + +WXDownloader.prototype.cleanAllAssets = function () { + cc.warn('wxDownloader.cleanAllAssets has been deprecated, please use cleanAllCaches instead!'); + this.cleanAllCaches(null, function (err) { + if (err) cc.error(err.message); + }); +}; + +WXDownloader.prototype.cleanAllCaches = function (exclude, callback) { + exclude = exclude || {}; + var self = this; + var result = wxFsUtils.readDir(self.cacheDir, function (err, list) { + if (err) { + callback && callback(err); + return; + } + var toDelete = []; + for (var i = 0, l = list.length; i < l; i ++) { + var path = list[i]; + if (path === self.cachedFileName) continue; + if (path in exclude) continue; + if (path in cacheQueue) { + delete cacheQueue[path]; + continue; + } + delete cachedFiles[path]; + toDelete.push(path); + } + wxFsUtils.writeFileSync(self.cacheDir + '/' + self.cachedFileName, JSON.stringify(cachedFiles), 'utf8'); + var count = 0; + for (var i = 0, l = toDelete.length; i < l; i ++) { + wxFsUtils.deleteFile(self.cacheDir + '/' + toDelete[i], function (err) { + if (!err) self.outOfStorage = false; + count++; + if (count === l) callback && callback(null); + }) + } + }); + if (result) callback(result); +}; + +var wxDownloader = window.wxDownloader = new WXDownloader(); + +function registerFailHandler (item, cachePath) { + var queue = cc.LoadingItems.getQueue(item); + queue.addListener(item.id, function (item) { + if (item.error) { + if (item.url in cacheQueue) { + delete cacheQueue[item.url]; + } + else { + wxDownloader.cleanCache(cachePath); + } + } + }); +} + +function readFile (item, callback) { + var url = item.url; + var func = wxFsUtils.readText; + if (getFileType(item.type) === FileType.BIN) func = wxFsUtils.readArrayBuffer; + var result = func(url, function (err, data) { + if (err) { + callback(err); + return; + } + if (data) { + item.states[cc.loader.downloader.id] = cc.Pipeline.ItemState.COMPLETE; + callback(null, data); + } + else { + callback(new Error("Empty file: " + url)); + } + }); + if (result) callback(result); +} + +function readFromLocal (item, callback) { + var result = wxFsUtils.checkFsValid(); + if (result) { + callback(result); + return; + } + + var cachedPath = wxDownloader.getCacheName(item.url); + var localPath = wxDownloader.cacheDir + '/' + cachedPath; + + if (cachedPath in cachedFiles) { + // cache new asset + _newAssets[cachedPath] = true; + item.url = localPath; + registerFailHandler(item, cachedPath); + handleItem(item, callback); + } + else { + if (!wxDownloader.REMOTE_SERVER_ROOT) { + callback(null, null); + return; + } + + downloadRemoteFile(item, callback); + } +} + +function cacheFile (url, isCopy, cachePath) { + cacheQueue[url] = { isCopy, cachePath }; + + if (!checkNextPeriod) { + checkNextPeriod = true; + function cache () { + checkNextPeriod = false; + for (var srcUrl in cacheQueue) { + if (!wxDownloader.outOfStorage) { + var item = cacheQueue[srcUrl] + var localPath = wxDownloader.cacheDir + '/' + item.cachePath; + var func = wxFsUtils.copyFile; + if (!item.isCopy) func = wxFsUtils.downloadFile; + func(srcUrl, localPath, function (err) { + if (err) { + errTest.test(err.message) && (wxDownloader.outOfStorage = true); + return; + } + cachedFiles[item.cachePath] = 1; + writeCacheFile(); + }); + delete cacheQueue[srcUrl]; + } + if (!cc.js.isEmptyObject(cacheQueue) && !checkNextPeriod) { + checkNextPeriod = true; + setTimeout(cache, wxDownloader.cachePeriod); + } + return; + } + }; + setTimeout(cache, wxDownloader.cachePeriod); + } +} + +function downloadRemoteFile (item, callback) { + // Download from remote server + var relatUrl = item.url; + + // filter protocol url (E.g: https:// or http:// or ftp://) + if (REGEX.test(relatUrl)) { + callback(null, null); + return; + } + + var remoteUrl = wxDownloader.REMOTE_SERVER_ROOT + '/' + relatUrl; + item.url = remoteUrl; + var cachePath = wxDownloader.getCacheName(relatUrl); + if (cc.sys.os === cc.sys.OS_ANDROID && item.type && getFileType(item.type) === FileType.IMAGE) { + if (wxDownloader.cacheAsset) { + cacheFile(remoteUrl, false, cachePath); + registerFailHandler(item, cachePath); + } + callback(null, null); + } + else { + wxFsUtils.downloadFile(remoteUrl, undefined, function (err, path) { + if (err) { + callback(err, null); + return; + } + item.url = path; + if (wxDownloader.cacheAsset) { + cacheFile(path, true, cachePath); + registerFailHandler(item, cachePath); + } + handleItem(item, callback); + }); + } + +} + +function writeCacheFile () { + function write () { + writeCacheFileList = null; + wxFsUtils.writeFile(wxDownloader.cacheDir + '/' + wxDownloader.cachedFileName, JSON.stringify(cachedFiles), 'utf8'); + } + !writeCacheFileList && (writeCacheFileList = setTimeout(write, wxDownloader.writeFilePeriod)); +} + +function shouldReadFile (type) { + return getFileType(type) >= FileType.LOADABLE_MIN; +} + +function getFileType (type) { + return (map[type] || FileType.DEFAULT); +} + +var FileType = { + 'IMAGE': 1, + 'FONT': 2, + 'AUDIO': 3, + 'SCRIPT': 4, + 'TEXT': 5, + 'BIN': 6, + 'DEFAULT': 7, + 'LOADABLE_MIN': 5 +}; + +var map = { + // JS + 'js' : FileType.SCRIPT, + + // Images + 'png' : FileType.IMAGE, + 'jpg' : FileType.IMAGE, + 'bmp' : FileType.IMAGE, + 'jpeg' : FileType.IMAGE, + 'gif' : FileType.IMAGE, + 'ico' : FileType.IMAGE, + 'tiff' : FileType.IMAGE, + 'webp' : FileType.IMAGE, + 'image' : FileType.IMAGE, + + // Audio + 'mp3' : FileType.AUDIO, + 'ogg' : FileType.AUDIO, + 'wav' : FileType.AUDIO, + 'm4a' : FileType.AUDIO, + + // Txt + 'txt' : FileType.TEXT, + 'xml' : FileType.TEXT, + 'vsh' : FileType.TEXT, + 'fsh' : FileType.TEXT, + 'atlas' : FileType.TEXT, + + 'tmx' : FileType.TEXT, + 'tsx' : FileType.TEXT, + + 'json' : FileType.TEXT, + 'ExportJson' : FileType.TEXT, + 'plist' : FileType.TEXT, + + 'fnt' : FileType.TEXT, + + // Font + 'font' : FileType.FONT, + 'eot' : FileType.FONT, + 'ttf' : FileType.FONT, + 'woff' : FileType.FONT, + 'svg' : FileType.FONT, + 'ttc' : FileType.FONT, + + // Binary + 'binary' : FileType.BIN, + 'dbbin' : FileType.BIN, + 'bin': FileType.BIN, + 'pvr': FileType.BIN, + 'pkm': FileType.BIN +}; +// function downloadRemoteTextFile (item, callback) { +// // Download from remote server +// var relatUrl = item.url; +// var remoteUrl = wxDownloader.REMOTE_SERVER_ROOT + '/' + relatUrl; +// item.url = remoteUrl; +// wx.request({ +// url: remoteUrl, +// success: function(res) { +// if (res.data) { +// if (res.statusCode === 200 || res.statusCode === 0) { +// var data = res.data; +// item.states[cc.loader.downloader.ID] = cc.Pipeline.ItemState.COMPLETE; +// if (data) { +// if (typeof data !== 'string' && !(data instanceof ArrayBuffer)) { +// // Should we check if item.type is json ? If not, loader behavior could be different +// item.states[cc.loader.loader.ID] = cc.Pipeline.ItemState.COMPLETE; +// callback(null, data); +// data = JSON.stringify(data); +// } +// else { +// callback(null, data); +// } +// } + +// // Save to local path +// var localPath = wx.env.USER_DATA_PATH + '/' + relatUrl; +// // Should recursively mkdir first +// fs.writeFile({ +// filePath: localPath, +// data: data, +// encoding: 'utf8', +// success: function (res) { +// cc.log('Write file to ' + res.savedFilePath + ' successfully!'); +// }, +// fail: function (res) { +// // undone implementation +// } +// }); +// } else { +// cc.warn("Download text file failed: " + remoteUrl); +// callback({ +// status:0, +// errorMessage: res && res.errMsg ? res.errMsg : "Download text file failed: " + remoteUrl +// }); +// } +// } +// }, +// fail: function (res) { +// // Continue to try download with downloader, most probably will also fail +// callback(null, null); +// } +// }); +// } diff --git a/frontend/build-templates/wechatgame/libs/wx-fs-utils.js b/frontend/build-templates/wechatgame/libs/wx-fs-utils.js new file mode 100644 index 0000000..a097a57 --- /dev/null +++ b/frontend/build-templates/wechatgame/libs/wx-fs-utils.js @@ -0,0 +1,238 @@ +/**************************************************************************** + Copyright (c) 2017-2019 Xiamen Yaji Software Co., Ltd. + + https://www.cocos.com/ + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ +var fs = wx.getFileSystemManager ? wx.getFileSystemManager() : null; + +function checkFsValid () { + if (!fs) { + console.warn('can not get the file system!'); + return new Error('file system does not exist!'); + } + return null; +} + +function deleteFile (filePath, callback) { + var result = checkFsValid(); + if (result) return result; + fs.unlink({ + filePath: filePath, + success: function () { + cc.log('Removed local file ' + filePath + ' successfully!'); + callback && callback(null); + }, + fail: function (res) { + console.warn(res.errMsg); + callback && callback(new Error(res.errMsg)); + } + }); +} + +function downloadFile (remoteUrl, filePath, callback) { + var currentDownloadTask = wx.downloadFile({ + url: remoteUrl, + filePath: filePath, + success: function (res) { + if (res.statusCode === 200) { + callback && callback(null, res.tempFilePath || res.filePath); + } + else { + if (res.filePath) { + deleteFile(res.filePath); + } + console.warn("Download file failed: " + remoteUrl); + callback && callback(new Error(res.errMsg), null); + } + }, + fail: function (res) { + if (true == wxDownloader.totalBytesExpectedToWriteAlreadyCounted.has(remoteUrl)) { + wxDownloader.totalBytesExpectedToWriteForAllTasks -= res.totalBytesExpectedToWrite; + const bytesWrittenOfThisRemoteUrl = parseInt(wxDownloader.totalBytesExpectedToWriteAlreadyCounted.get(remoteUrl)); + if (isNaN(bytesWrittenOfThisRemoteUrl)) { + return; + } + wxDownloader.totalBytesWrittenForAllTasks -= bytesWrittenOfThisRemoteUrl; + wxDownloader.totalBytesExpectedToWriteAlreadyCounted.delete(remoteUrl); + } + console.warn(res.errMsg); + callback && callback(new Error(res.errMsg), null); + } + }); + + currentDownloadTask.onProgressUpdate((res) => { + if (false == wxDownloader.totalBytesExpectedToWriteAlreadyCounted.has(remoteUrl)) { + wxDownloader.totalBytesExpectedToWriteForAllTasks += res.totalBytesExpectedToWrite; + wxDownloader.totalBytesExpectedToWriteAlreadyCounted.set(remoteUrl, 0); + } + const bytesWrittenOfThisRemoteUrl = wxDownloader.totalBytesExpectedToWriteAlreadyCounted.get(remoteUrl); + if (isNaN(bytesWrittenOfThisRemoteUrl)) { + return; + } + wxDownloader.totalBytesWrittenForAllTasks += (res.totalBytesWritten - bytesWrittenOfThisRemoteUrl); + wxDownloader.totalBytesExpectedToWriteAlreadyCounted.set(remoteUrl, res.totalBytesWritten); + }); +} + +function saveFile (srcPath, destPath, callback) { + wx.saveFile({ + tempFilePath: srcPath, + filePath: destPath, + success: function (res) { + cc.log('save file finished:' + destPath); + callback && callback(null, res.savedFilePath); + }, + fail: function (res) { + cc.log('save file failed:' + res.errMsg); + callback && callback(new Error(res.errMsg), null); + } + }); +} + +function copyFile (srcPath, destPath, callback) { + var result = checkFsValid(); + if (result) return result; + fs.copyFile({ + srcPath: srcPath, + destPath: destPath, + success: function () { + cc.log('copy file finished:' + destPath); + callback && callback(null); + }, + fail: function (res) { + cc.log('copy file failed:' + res.errMsg); + callback && callback(new Error(res.errMsg)); + } + }); +} + +function writeFile (path, data, encoding, callback) { + var result = checkFsValid(); + if (result) return result; + fs.writeFile({ + filePath: path, + encoding: encoding, + data: data, + success: callback ? function () { + callback(null); + } : undefined, + fail: function (res) { + console.warn(res.errMsg); + callback && callback(new Error(res.errMsg)); + } + }); +} + +function writeFileSync (path, data, encoding) { + var result = checkFsValid(); + if (result) return result; + try { + fs.writeFileSync(path, data, encoding); + return null; + } + catch (e) { + console.warn(e.message); + return new Error(e.message); + } +} + +function readFile (filePath, encoding, callback) { + var result = checkFsValid(); + if (result) return result; + fs.readFile({ + filePath: filePath, + encoding: encoding, + success: callback ? function (res) { + callback(null, res.data); + } : undefined, + fail: function (res) { + console.warn(res.errMsg); + callback && callback (new Error(res.errMsg), null); + } + }); +} + +function readDir (filePath, callback) { + var result = checkFsValid(); + if (result) { + return result; + } + fs.readdir({ + dirPath: filePath, + success: callback ? function (res) { + callback(null, res.files); + } : undefined, + fail: callback ? function (res) { + callback(new Error(res.errMsg), null); + } : undefined + }); +} + +function readText (filePath, callback) { + return readFile(filePath, 'utf8', callback); +} + +function readArrayBuffer (filePath, callback) { + return readFile(filePath, '', callback); +} + +function readJsonSync (path) { + var result = checkFsValid(); + if (result) return result; + try { + var str = fs.readFileSync(path, 'utf8'); + return JSON.parse(str); + } + catch (e) { + console.warn(e.message); + return new Error(e.message); + } +} + +function makeDirSync (path, recursive) { + var result = checkFsValid(); + if (result) return result; + try { + fs.mkdirSync(path, recursive); + return null; + } + catch (e) { + console.warn(e.message); + return new Error(e.message); + } +} + +function exists (filePath, callback) { + var result = checkFsValid(); + if (result) return result; + fs.access({ + path: filePath, + success: callback ? function () { + callback(true); + } : undefined, + fail: callback ? function () { + callback(false); + } : undefined, + }); +} + +window.wxFsUtils = module.exports = {fs, checkFsValid, readDir, exists, copyFile, downloadFile, readText, readArrayBuffer, saveFile, writeFile, deleteFile, writeFileSync, readJsonSync, makeDirSync}; diff --git a/frontend/build-templates/wechatgame/libs/xmldom/dom-parser.js b/frontend/build-templates/wechatgame/libs/xmldom/dom-parser.js new file mode 100644 index 0000000..e45dd47 --- /dev/null +++ b/frontend/build-templates/wechatgame/libs/xmldom/dom-parser.js @@ -0,0 +1,252 @@ +function DOMParser(options){ + this.options = options ||{locator:{}}; + +} + +DOMParser.prototype.parseFromString = function(source,mimeType){ + var options = this.options; + var sax = new XMLReader(); + var domBuilder = options.domBuilder || new DOMHandler();//contentHandler and LexicalHandler + var errorHandler = options.errorHandler; + var locator = options.locator; + var defaultNSMap = options.xmlns||{}; + var isHTML = /\/x?html?$/.test(mimeType);//mimeType.toLowerCase().indexOf('html') > -1; + var entityMap = isHTML?htmlEntity.entityMap:{'lt':'<','gt':'>','amp':'&','quot':'"','apos':"'"}; + if(locator){ + domBuilder.setDocumentLocator(locator) + } + + sax.errorHandler = buildErrorHandler(errorHandler,domBuilder,locator); + sax.domBuilder = options.domBuilder || domBuilder; + if(isHTML){ + defaultNSMap['']= 'http://www.w3.org/1999/xhtml'; + } + defaultNSMap.xml = defaultNSMap.xml || 'http://www.w3.org/XML/1998/namespace'; + if(source){ + sax.parse(source,defaultNSMap,entityMap); + }else{ + sax.errorHandler.error("invalid doc source"); + } + return domBuilder.doc; +} +function buildErrorHandler(errorImpl,domBuilder,locator){ + if(!errorImpl){ + if(domBuilder instanceof DOMHandler){ + return domBuilder; + } + errorImpl = domBuilder ; + } + var errorHandler = {} + var isCallback = errorImpl instanceof Function; + locator = locator||{} + function build(key){ + var fn = errorImpl[key]; + if(!fn && isCallback){ + fn = errorImpl.length == 2?function(msg){errorImpl(key,msg)}:errorImpl; + } + errorHandler[key] = fn && function(msg){ + fn('[xmldom '+key+']\t'+msg+_locator(locator)); + }||function(){}; + } + build('warning'); + build('error'); + build('fatalError'); + return errorHandler; +} + +//console.log('#\n\n\n\n\n\n\n####') +/** + * +ContentHandler+ErrorHandler + * +LexicalHandler+EntityResolver2 + * -DeclHandler-DTDHandler + * + * DefaultHandler:EntityResolver, DTDHandler, ContentHandler, ErrorHandler + * DefaultHandler2:DefaultHandler,LexicalHandler, DeclHandler, EntityResolver2 + * @link http://www.saxproject.org/apidoc/org/xml/sax/helpers/DefaultHandler.html + */ +function DOMHandler() { + this.cdata = false; +} +function position(locator,node){ + node.lineNumber = locator.lineNumber; + node.columnNumber = locator.columnNumber; +} +/** + * @see org.xml.sax.ContentHandler#startDocument + * @link http://www.saxproject.org/apidoc/org/xml/sax/ContentHandler.html + */ +DOMHandler.prototype = { + startDocument : function() { + this.doc = new DOMImplementation().createDocument(null, null, null); + if (this.locator) { + this.doc.documentURI = this.locator.systemId; + } + }, + startElement:function(namespaceURI, localName, qName, attrs) { + var doc = this.doc; + var el = doc.createElementNS(namespaceURI, qName||localName); + var len = attrs.length; + appendElement(this, el); + this.currentElement = el; + + this.locator && position(this.locator,el) + for (var i = 0 ; i < len; i++) { + var namespaceURI = attrs.getURI(i); + var value = attrs.getValue(i); + var qName = attrs.getQName(i); + var attr = doc.createAttributeNS(namespaceURI, qName); + this.locator &&position(attrs.getLocator(i),attr); + attr.value = attr.nodeValue = value; + el.setAttributeNode(attr) + } + }, + endElement:function(namespaceURI, localName, qName) { + var current = this.currentElement + var tagName = current.tagName; + this.currentElement = current.parentNode; + }, + startPrefixMapping:function(prefix, uri) { + }, + endPrefixMapping:function(prefix) { + }, + processingInstruction:function(target, data) { + var ins = this.doc.createProcessingInstruction(target, data); + this.locator && position(this.locator,ins) + appendElement(this, ins); + }, + ignorableWhitespace:function(ch, start, length) { + }, + characters:function(chars, start, length) { + chars = _toString.apply(this,arguments) + //console.log(chars) + if(chars){ + if (this.cdata) { + var charNode = this.doc.createCDATASection(chars); + } else { + var charNode = this.doc.createTextNode(chars); + } + if(this.currentElement){ + this.currentElement.appendChild(charNode); + }else if(/^\s*$/.test(chars)){ + this.doc.appendChild(charNode); + //process xml + } + this.locator && position(this.locator,charNode) + } + }, + skippedEntity:function(name) { + }, + endDocument:function() { + this.doc.normalize(); + }, + setDocumentLocator:function (locator) { + if(this.locator = locator){// && !('lineNumber' in locator)){ + locator.lineNumber = 0; + } + }, + //LexicalHandler + comment:function(chars, start, length) { + chars = _toString.apply(this,arguments) + var comm = this.doc.createComment(chars); + this.locator && position(this.locator,comm) + appendElement(this, comm); + }, + + startCDATA:function() { + //used in characters() methods + this.cdata = true; + }, + endCDATA:function() { + this.cdata = false; + }, + + startDTD:function(name, publicId, systemId) { + var impl = this.doc.implementation; + if (impl && impl.createDocumentType) { + var dt = impl.createDocumentType(name, publicId, systemId); + this.locator && position(this.locator,dt) + appendElement(this, dt); + } + }, + /** + * @see org.xml.sax.ErrorHandler + * @link http://www.saxproject.org/apidoc/org/xml/sax/ErrorHandler.html + */ + warning:function(error) { + console.warn('[xmldom warning]\t'+error,_locator(this.locator)); + }, + error:function(error) { + console.error('[xmldom error]\t'+error,_locator(this.locator)); + }, + fatalError:function(error) { + console.error('[xmldom fatalError]\t'+error,_locator(this.locator)); + throw error; + } +} +function _locator(l){ + if(l){ + return '\n@'+(l.systemId ||'')+'#[line:'+l.lineNumber+',col:'+l.columnNumber+']' + } +} +function _toString(chars,start,length){ + if(typeof chars == 'string'){ + return chars.substr(start,length) + }else{//java sax connect width xmldom on rhino(what about: "? && !(chars instanceof String)") + if(chars.length >= start+length || start){ + return new java.lang.String(chars,start,length)+''; + } + return chars; + } +} + +/* + * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/LexicalHandler.html + * used method of org.xml.sax.ext.LexicalHandler: + * #comment(chars, start, length) + * #startCDATA() + * #endCDATA() + * #startDTD(name, publicId, systemId) + * + * + * IGNORED method of org.xml.sax.ext.LexicalHandler: + * #endDTD() + * #startEntity(name) + * #endEntity(name) + * + * + * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/DeclHandler.html + * IGNORED method of org.xml.sax.ext.DeclHandler + * #attributeDecl(eName, aName, type, mode, value) + * #elementDecl(name, model) + * #externalEntityDecl(name, publicId, systemId) + * #internalEntityDecl(name, value) + * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/EntityResolver2.html + * IGNORED method of org.xml.sax.EntityResolver2 + * #resolveEntity(String name,String publicId,String baseURI,String systemId) + * #resolveEntity(publicId, systemId) + * #getExternalSubset(name, baseURI) + * @link http://www.saxproject.org/apidoc/org/xml/sax/DTDHandler.html + * IGNORED method of org.xml.sax.DTDHandler + * #notationDecl(name, publicId, systemId) {}; + * #unparsedEntityDecl(name, publicId, systemId, notationName) {}; + */ +"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(key){ + DOMHandler.prototype[key] = function(){return null} +}) + +/* Private static helpers treated below as private instance methods, so don't need to add these to the public API; we might use a Relator to also get rid of non-standard public properties */ +function appendElement (hander,node) { + if (!hander.currentElement) { + hander.doc.appendChild(node); + } else { + hander.currentElement.appendChild(node); + } +}//appendChild and setAttributeNS are preformance key + +//if(typeof require == 'function'){ +var htmlEntity = require('./entities'); +var XMLReader = require('./sax').XMLReader; +var DOMImplementation = exports.DOMImplementation = require('./dom').DOMImplementation; +exports.XMLSerializer = require('./dom').XMLSerializer ; +exports.DOMParser = DOMParser; +//} diff --git a/frontend/build-templates/wechatgame/libs/xmldom/dom.js b/frontend/build-templates/wechatgame/libs/xmldom/dom.js new file mode 100644 index 0000000..935531b --- /dev/null +++ b/frontend/build-templates/wechatgame/libs/xmldom/dom.js @@ -0,0 +1,1246 @@ +/* + * DOM Level 2 + * Object DOMException + * @see http://www.w3.org/TR/REC-DOM-Level-1/ecma-script-language-binding.html + * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/ecma-script-binding.html + */ + +function copy(src,dest){ + for(var p in src){ + dest[p] = src[p]; + } +} +/** +^\w+\.prototype\.([_\w]+)\s*=\s*((?:.*\{\s*?[\r\n][\s\S]*?^})|\S.*?(?=[;\r\n]));? +^\w+\.prototype\.([_\w]+)\s*=\s*(\S.*?(?=[;\r\n]));? + */ +function _extends(Class,Super){ + var pt = Class.prototype; + if(!(pt instanceof Super)){ + function t(){}; + t.prototype = Super.prototype; + t = new t(); + // copy(pt,t); + for(var p in pt){ + t[p] = pt[p]; + } + Class.prototype = pt = t; + } + if(pt.constructor != Class){ + if(typeof Class != 'function'){ + console.error("unknow Class:"+Class) + } + pt.constructor = Class + } +} +var htmlns = 'http://www.w3.org/1999/xhtml' ; +// Node Types +var NodeType = {} +var ELEMENT_NODE = NodeType.ELEMENT_NODE = 1; +var ATTRIBUTE_NODE = NodeType.ATTRIBUTE_NODE = 2; +var TEXT_NODE = NodeType.TEXT_NODE = 3; +var CDATA_SECTION_NODE = NodeType.CDATA_SECTION_NODE = 4; +var ENTITY_REFERENCE_NODE = NodeType.ENTITY_REFERENCE_NODE = 5; +var ENTITY_NODE = NodeType.ENTITY_NODE = 6; +var PROCESSING_INSTRUCTION_NODE = NodeType.PROCESSING_INSTRUCTION_NODE = 7; +var COMMENT_NODE = NodeType.COMMENT_NODE = 8; +var DOCUMENT_NODE = NodeType.DOCUMENT_NODE = 9; +var DOCUMENT_TYPE_NODE = NodeType.DOCUMENT_TYPE_NODE = 10; +var DOCUMENT_FRAGMENT_NODE = NodeType.DOCUMENT_FRAGMENT_NODE = 11; +var NOTATION_NODE = NodeType.NOTATION_NODE = 12; + +// ExceptionCode +var ExceptionCode = {} +var ExceptionMessage = {}; +var INDEX_SIZE_ERR = ExceptionCode.INDEX_SIZE_ERR = ((ExceptionMessage[1]="Index size error"),1); +var DOMSTRING_SIZE_ERR = ExceptionCode.DOMSTRING_SIZE_ERR = ((ExceptionMessage[2]="DOMString size error"),2); +var HIERARCHY_REQUEST_ERR = ExceptionCode.HIERARCHY_REQUEST_ERR = ((ExceptionMessage[3]="Hierarchy request error"),3); +var WRONG_DOCUMENT_ERR = ExceptionCode.WRONG_DOCUMENT_ERR = ((ExceptionMessage[4]="Wrong document"),4); +var INVALID_CHARACTER_ERR = ExceptionCode.INVALID_CHARACTER_ERR = ((ExceptionMessage[5]="Invalid character"),5); +var NO_DATA_ALLOWED_ERR = ExceptionCode.NO_DATA_ALLOWED_ERR = ((ExceptionMessage[6]="No data allowed"),6); +var NO_MODIFICATION_ALLOWED_ERR = ExceptionCode.NO_MODIFICATION_ALLOWED_ERR = ((ExceptionMessage[7]="No modification allowed"),7); +var NOT_FOUND_ERR = ExceptionCode.NOT_FOUND_ERR = ((ExceptionMessage[8]="Not found"),8); +var NOT_SUPPORTED_ERR = ExceptionCode.NOT_SUPPORTED_ERR = ((ExceptionMessage[9]="Not supported"),9); +var INUSE_ATTRIBUTE_ERR = ExceptionCode.INUSE_ATTRIBUTE_ERR = ((ExceptionMessage[10]="Attribute in use"),10); +//level2 +var INVALID_STATE_ERR = ExceptionCode.INVALID_STATE_ERR = ((ExceptionMessage[11]="Invalid state"),11); +var SYNTAX_ERR = ExceptionCode.SYNTAX_ERR = ((ExceptionMessage[12]="Syntax error"),12); +var INVALID_MODIFICATION_ERR = ExceptionCode.INVALID_MODIFICATION_ERR = ((ExceptionMessage[13]="Invalid modification"),13); +var NAMESPACE_ERR = ExceptionCode.NAMESPACE_ERR = ((ExceptionMessage[14]="Invalid namespace"),14); +var INVALID_ACCESS_ERR = ExceptionCode.INVALID_ACCESS_ERR = ((ExceptionMessage[15]="Invalid access"),15); + + +function DOMException(code, message) { + if(message instanceof Error){ + var error = message; + }else{ + error = this; + Error.call(this, ExceptionMessage[code]); + this.message = ExceptionMessage[code]; + if(Error.captureStackTrace) Error.captureStackTrace(this, DOMException); + } + error.code = code; + if(message) this.message = this.message + ": " + message; + return error; +}; +DOMException.prototype = Error.prototype; +copy(ExceptionCode,DOMException) +/** + * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-536297177 + * The NodeList interface provides the abstraction of an ordered collection of nodes, without defining or constraining how this collection is implemented. NodeList objects in the DOM are live. + * The items in the NodeList are accessible via an integral index, starting from 0. + */ +function NodeList() { +}; +NodeList.prototype = { + /** + * The number of nodes in the list. The range of valid child node indices is 0 to length-1 inclusive. + * @standard level1 + */ + length:0, + /** + * Returns the indexth item in the collection. If index is greater than or equal to the number of nodes in the list, this returns null. + * @standard level1 + * @param index unsigned long + * Index into the collection. + * @return Node + * The node at the indexth position in the NodeList, or null if that is not a valid index. + */ + item: function(index) { + return this[index] || null; + }, + toString:function(isHTML,nodeFilter){ + for(var buf = [], i = 0;i=0){ + var lastIndex = list.length-1 + while(i0 || key == 'xmlns'){ +// return null; +// } + //console.log() + var i = this.length; + while(i--){ + var attr = this[i]; + //console.log(attr.nodeName,key) + if(attr.nodeName == key){ + return attr; + } + } + }, + setNamedItem: function(attr) { + var el = attr.ownerElement; + if(el && el!=this._ownerElement){ + throw new DOMException(INUSE_ATTRIBUTE_ERR); + } + var oldAttr = this.getNamedItem(attr.nodeName); + _addNamedNode(this._ownerElement,this,attr,oldAttr); + return oldAttr; + }, + /* returns Node */ + setNamedItemNS: function(attr) {// raises: WRONG_DOCUMENT_ERR,NO_MODIFICATION_ALLOWED_ERR,INUSE_ATTRIBUTE_ERR + var el = attr.ownerElement, oldAttr; + if(el && el!=this._ownerElement){ + throw new DOMException(INUSE_ATTRIBUTE_ERR); + } + oldAttr = this.getNamedItemNS(attr.namespaceURI,attr.localName); + _addNamedNode(this._ownerElement,this,attr,oldAttr); + return oldAttr; + }, + + /* returns Node */ + removeNamedItem: function(key) { + var attr = this.getNamedItem(key); + _removeNamedNode(this._ownerElement,this,attr); + return attr; + + + },// raises: NOT_FOUND_ERR,NO_MODIFICATION_ALLOWED_ERR + + //for level2 + removeNamedItemNS:function(namespaceURI,localName){ + var attr = this.getNamedItemNS(namespaceURI,localName); + _removeNamedNode(this._ownerElement,this,attr); + return attr; + }, + getNamedItemNS: function(namespaceURI, localName) { + var i = this.length; + while(i--){ + var node = this[i]; + if(node.localName == localName && node.namespaceURI == namespaceURI){ + return node; + } + } + return null; + } +}; +/** + * @see http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-102161490 + */ +function DOMImplementation(/* Object */ features) { + this._features = {}; + if (features) { + for (var feature in features) { + this._features = features[feature]; + } + } +}; + +DOMImplementation.prototype = { + hasFeature: function(/* string */ feature, /* string */ version) { + var versions = this._features[feature.toLowerCase()]; + if (versions && (!version || version in versions)) { + return true; + } else { + return false; + } + }, + // Introduced in DOM Level 2: + createDocument:function(namespaceURI, qualifiedName, doctype){// raises:INVALID_CHARACTER_ERR,NAMESPACE_ERR,WRONG_DOCUMENT_ERR + var doc = new Document(); + doc.implementation = this; + doc.childNodes = new NodeList(); + doc.doctype = doctype; + if(doctype){ + doc.appendChild(doctype); + } + if(qualifiedName){ + var root = doc.createElementNS(namespaceURI,qualifiedName); + doc.appendChild(root); + } + return doc; + }, + // Introduced in DOM Level 2: + createDocumentType:function(qualifiedName, publicId, systemId){// raises:INVALID_CHARACTER_ERR,NAMESPACE_ERR + var node = new DocumentType(); + node.name = qualifiedName; + node.nodeName = qualifiedName; + node.publicId = publicId; + node.systemId = systemId; + // Introduced in DOM Level 2: + //readonly attribute DOMString internalSubset; + + //TODO:.. + // readonly attribute NamedNodeMap entities; + // readonly attribute NamedNodeMap notations; + return node; + } +}; + + +/** + * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1950641247 + */ + +function Node() { +}; + +Node.prototype = { + firstChild : null, + lastChild : null, + previousSibling : null, + nextSibling : null, + attributes : null, + parentNode : null, + childNodes : null, + ownerDocument : null, + nodeValue : null, + namespaceURI : null, + prefix : null, + localName : null, + // Modified in DOM Level 2: + insertBefore:function(newChild, refChild){//raises + return _insertBefore(this,newChild,refChild); + }, + replaceChild:function(newChild, oldChild){//raises + this.insertBefore(newChild,oldChild); + if(oldChild){ + this.removeChild(oldChild); + } + }, + removeChild:function(oldChild){ + return _removeChild(this,oldChild); + }, + appendChild:function(newChild){ + return this.insertBefore(newChild,null); + }, + hasChildNodes:function(){ + return this.firstChild != null; + }, + cloneNode:function(deep){ + return cloneNode(this.ownerDocument||this,this,deep); + }, + // Modified in DOM Level 2: + normalize:function(){ + var child = this.firstChild; + while(child){ + var next = child.nextSibling; + if(next && next.nodeType == TEXT_NODE && child.nodeType == TEXT_NODE){ + this.removeChild(next); + child.appendData(next.data); + }else{ + child.normalize(); + child = next; + } + } + }, + // Introduced in DOM Level 2: + isSupported:function(feature, version){ + return this.ownerDocument.implementation.hasFeature(feature,version); + }, + // Introduced in DOM Level 2: + hasAttributes:function(){ + return this.attributes.length>0; + }, + lookupPrefix:function(namespaceURI){ + var el = this; + while(el){ + var map = el._nsMap; + //console.dir(map) + if(map){ + for(var n in map){ + if(map[n] == namespaceURI){ + return n; + } + } + } + el = el.nodeType == ATTRIBUTE_NODE?el.ownerDocument : el.parentNode; + } + return null; + }, + // Introduced in DOM Level 3: + lookupNamespaceURI:function(prefix){ + var el = this; + while(el){ + var map = el._nsMap; + //console.dir(map) + if(map){ + if(prefix in map){ + return map[prefix] ; + } + } + el = el.nodeType == ATTRIBUTE_NODE?el.ownerDocument : el.parentNode; + } + return null; + }, + // Introduced in DOM Level 3: + isDefaultNamespace:function(namespaceURI){ + var prefix = this.lookupPrefix(namespaceURI); + return prefix == null; + } +}; + + +function _xmlEncoder(c){ + return c == '<' && '<' || + c == '>' && '>' || + c == '&' && '&' || + c == '"' && '"' || + '&#'+c.charCodeAt()+';' +} + + +copy(NodeType,Node); +copy(NodeType,Node.prototype); + +/** + * @param callback return true for continue,false for break + * @return boolean true: break visit; + */ +function _visitNode(node,callback){ + if(callback(node)){ + return true; + } + if(node = node.firstChild){ + do{ + if(_visitNode(node,callback)){return true} + }while(node=node.nextSibling) + } +} + + + +function Document(){ +} +function _onAddAttribute(doc,el,newAttr){ + doc && doc._inc++; + var ns = newAttr.namespaceURI ; + if(ns == 'http://www.w3.org/2000/xmlns/'){ + //update namespace + el._nsMap[newAttr.prefix?newAttr.localName:''] = newAttr.value + } +} +function _onRemoveAttribute(doc,el,newAttr,remove){ + doc && doc._inc++; + var ns = newAttr.namespaceURI ; + if(ns == 'http://www.w3.org/2000/xmlns/'){ + //update namespace + delete el._nsMap[newAttr.prefix?newAttr.localName:''] + } +} +function _onUpdateChild(doc,el,newChild){ + if(doc && doc._inc){ + doc._inc++; + //update childNodes + var cs = el.childNodes; + if(newChild){ + cs[cs.length++] = newChild; + }else{ + //console.log(1) + var child = el.firstChild; + var i = 0; + while(child){ + cs[i++] = child; + child =child.nextSibling; + } + cs.length = i; + } + } +} + +/** + * attributes; + * children; + * + * writeable properties: + * nodeValue,Attr:value,CharacterData:data + * prefix + */ +function _removeChild(parentNode,child){ + var previous = child.previousSibling; + var next = child.nextSibling; + if(previous){ + previous.nextSibling = next; + }else{ + parentNode.firstChild = next + } + if(next){ + next.previousSibling = previous; + }else{ + parentNode.lastChild = previous; + } + _onUpdateChild(parentNode.ownerDocument,parentNode); + return child; +} +/** + * preformance key(refChild == null) + */ +function _insertBefore(parentNode,newChild,nextChild){ + var cp = newChild.parentNode; + if(cp){ + cp.removeChild(newChild);//remove and update + } + if(newChild.nodeType === DOCUMENT_FRAGMENT_NODE){ + var newFirst = newChild.firstChild; + if (newFirst == null) { + return newChild; + } + var newLast = newChild.lastChild; + }else{ + newFirst = newLast = newChild; + } + var pre = nextChild ? nextChild.previousSibling : parentNode.lastChild; + + newFirst.previousSibling = pre; + newLast.nextSibling = nextChild; + + + if(pre){ + pre.nextSibling = newFirst; + }else{ + parentNode.firstChild = newFirst; + } + if(nextChild == null){ + parentNode.lastChild = newLast; + }else{ + nextChild.previousSibling = newLast; + } + do{ + newFirst.parentNode = parentNode; + }while(newFirst !== newLast && (newFirst= newFirst.nextSibling)) + _onUpdateChild(parentNode.ownerDocument||parentNode,parentNode); + //console.log(parentNode.lastChild.nextSibling == null) + if (newChild.nodeType == DOCUMENT_FRAGMENT_NODE) { + newChild.firstChild = newChild.lastChild = null; + } + return newChild; +} +function _appendSingleChild(parentNode,newChild){ + var cp = newChild.parentNode; + if(cp){ + var pre = parentNode.lastChild; + cp.removeChild(newChild);//remove and update + var pre = parentNode.lastChild; + } + var pre = parentNode.lastChild; + newChild.parentNode = parentNode; + newChild.previousSibling = pre; + newChild.nextSibling = null; + if(pre){ + pre.nextSibling = newChild; + }else{ + parentNode.firstChild = newChild; + } + parentNode.lastChild = newChild; + _onUpdateChild(parentNode.ownerDocument,parentNode,newChild); + return newChild; + //console.log("__aa",parentNode.lastChild.nextSibling == null) +} +Document.prototype = { + //implementation : null, + nodeName : '#document', + nodeType : DOCUMENT_NODE, + doctype : null, + documentElement : null, + _inc : 1, + + insertBefore : function(newChild, refChild){//raises + if(newChild.nodeType == DOCUMENT_FRAGMENT_NODE){ + var child = newChild.firstChild; + while(child){ + var next = child.nextSibling; + this.insertBefore(child,refChild); + child = next; + } + return newChild; + } + if(this.documentElement == null && newChild.nodeType == ELEMENT_NODE){ + this.documentElement = newChild; + } + + return _insertBefore(this,newChild,refChild),(newChild.ownerDocument = this),newChild; + }, + removeChild : function(oldChild){ + if(this.documentElement == oldChild){ + this.documentElement = null; + } + return _removeChild(this,oldChild); + }, + // Introduced in DOM Level 2: + importNode : function(importedNode,deep){ + return importNode(this,importedNode,deep); + }, + // Introduced in DOM Level 2: + getElementById : function(id){ + var rtv = null; + _visitNode(this.documentElement,function(node){ + if(node.nodeType == ELEMENT_NODE){ + if(node.getAttribute('id') == id){ + rtv = node; + return true; + } + } + }) + return rtv; + }, + + //document factory method: + createElement : function(tagName){ + var node = new Element(); + node.ownerDocument = this; + node.nodeName = tagName; + node.tagName = tagName; + node.childNodes = new NodeList(); + var attrs = node.attributes = new NamedNodeMap(); + attrs._ownerElement = node; + return node; + }, + createDocumentFragment : function(){ + var node = new DocumentFragment(); + node.ownerDocument = this; + node.childNodes = new NodeList(); + return node; + }, + createTextNode : function(data){ + var node = new Text(); + node.ownerDocument = this; + node.appendData(data) + return node; + }, + createComment : function(data){ + var node = new Comment(); + node.ownerDocument = this; + node.appendData(data) + return node; + }, + createCDATASection : function(data){ + var node = new CDATASection(); + node.ownerDocument = this; + node.appendData(data) + return node; + }, + createProcessingInstruction : function(target,data){ + var node = new ProcessingInstruction(); + node.ownerDocument = this; + node.tagName = node.target = target; + node.nodeValue= node.data = data; + return node; + }, + createAttribute : function(name){ + var node = new Attr(); + node.ownerDocument = this; + node.name = name; + node.nodeName = name; + node.localName = name; + node.specified = true; + return node; + }, + createEntityReference : function(name){ + var node = new EntityReference(); + node.ownerDocument = this; + node.nodeName = name; + return node; + }, + // Introduced in DOM Level 2: + createElementNS : function(namespaceURI,qualifiedName){ + var node = new Element(); + var pl = qualifiedName.split(':'); + var attrs = node.attributes = new NamedNodeMap(); + node.childNodes = new NodeList(); + node.ownerDocument = this; + node.nodeName = qualifiedName; + node.tagName = qualifiedName; + node.namespaceURI = namespaceURI; + if(pl.length == 2){ + node.prefix = pl[0]; + node.localName = pl[1]; + }else{ + //el.prefix = null; + node.localName = qualifiedName; + } + attrs._ownerElement = node; + return node; + }, + // Introduced in DOM Level 2: + createAttributeNS : function(namespaceURI,qualifiedName){ + var node = new Attr(); + var pl = qualifiedName.split(':'); + node.ownerDocument = this; + node.nodeName = qualifiedName; + node.name = qualifiedName; + node.namespaceURI = namespaceURI; + node.specified = true; + if(pl.length == 2){ + node.prefix = pl[0]; + node.localName = pl[1]; + }else{ + //el.prefix = null; + node.localName = qualifiedName; + } + return node; + } +}; +_extends(Document,Node); + + +function Element() { + this._nsMap = {}; +}; +Element.prototype = { + nodeType : ELEMENT_NODE, + hasAttribute : function(name){ + return this.getAttributeNode(name)!=null; + }, + getAttribute : function(name){ + var attr = this.getAttributeNode(name); + return attr && attr.value || ''; + }, + getAttributeNode : function(name){ + return this.attributes.getNamedItem(name); + }, + setAttribute : function(name, value){ + var attr = this.ownerDocument.createAttribute(name); + attr.value = attr.nodeValue = "" + value; + this.setAttributeNode(attr) + }, + removeAttribute : function(name){ + var attr = this.getAttributeNode(name) + attr && this.removeAttributeNode(attr); + }, + + //four real opeartion method + appendChild:function(newChild){ + if(newChild.nodeType === DOCUMENT_FRAGMENT_NODE){ + return this.insertBefore(newChild,null); + }else{ + return _appendSingleChild(this,newChild); + } + }, + setAttributeNode : function(newAttr){ + return this.attributes.setNamedItem(newAttr); + }, + setAttributeNodeNS : function(newAttr){ + return this.attributes.setNamedItemNS(newAttr); + }, + removeAttributeNode : function(oldAttr){ + //console.log(this == oldAttr.ownerElement) + return this.attributes.removeNamedItem(oldAttr.nodeName); + }, + //get real attribute name,and remove it by removeAttributeNode + removeAttributeNS : function(namespaceURI, localName){ + var old = this.getAttributeNodeNS(namespaceURI, localName); + old && this.removeAttributeNode(old); + }, + + hasAttributeNS : function(namespaceURI, localName){ + return this.getAttributeNodeNS(namespaceURI, localName)!=null; + }, + getAttributeNS : function(namespaceURI, localName){ + var attr = this.getAttributeNodeNS(namespaceURI, localName); + return attr && attr.value || ''; + }, + setAttributeNS : function(namespaceURI, qualifiedName, value){ + var attr = this.ownerDocument.createAttributeNS(namespaceURI, qualifiedName); + attr.value = attr.nodeValue = "" + value; + this.setAttributeNode(attr) + }, + getAttributeNodeNS : function(namespaceURI, localName){ + return this.attributes.getNamedItemNS(namespaceURI, localName); + }, + + getElementsByTagName : function(tagName){ + return new LiveNodeList(this,function(base){ + var ls = []; + _visitNode(base,function(node){ + if(node !== base && node.nodeType == ELEMENT_NODE && (tagName === '*' || node.tagName == tagName)){ + ls.push(node); + } + }); + return ls; + }); + }, + getElementsByTagNameNS : function(namespaceURI, localName){ + return new LiveNodeList(this,function(base){ + var ls = []; + _visitNode(base,function(node){ + if(node !== base && node.nodeType === ELEMENT_NODE && (namespaceURI === '*' || node.namespaceURI === namespaceURI) && (localName === '*' || node.localName == localName)){ + ls.push(node); + } + }); + return ls; + + }); + } +}; +Document.prototype.getElementsByTagName = Element.prototype.getElementsByTagName; +Document.prototype.getElementsByTagNameNS = Element.prototype.getElementsByTagNameNS; + + +_extends(Element,Node); +function Attr() { +}; +Attr.prototype.nodeType = ATTRIBUTE_NODE; +_extends(Attr,Node); + + +function CharacterData() { +}; +CharacterData.prototype = { + data : '', + substringData : function(offset, count) { + return this.data.substring(offset, offset+count); + }, + appendData: function(text) { + text = this.data+text; + this.nodeValue = this.data = text; + this.length = text.length; + }, + insertData: function(offset,text) { + this.replaceData(offset,0,text); + + }, + appendChild:function(newChild){ + throw new Error(ExceptionMessage[HIERARCHY_REQUEST_ERR]) + }, + deleteData: function(offset, count) { + this.replaceData(offset,count,""); + }, + replaceData: function(offset, count, text) { + var start = this.data.substring(0,offset); + var end = this.data.substring(offset+count); + text = start + text + end; + this.nodeValue = this.data = text; + this.length = text.length; + } +} +_extends(CharacterData,Node); +function Text() { +}; +Text.prototype = { + nodeName : "#text", + nodeType : TEXT_NODE, + splitText : function(offset) { + var text = this.data; + var newText = text.substring(offset); + text = text.substring(0, offset); + this.data = this.nodeValue = text; + this.length = text.length; + var newNode = this.ownerDocument.createTextNode(newText); + if(this.parentNode){ + this.parentNode.insertBefore(newNode, this.nextSibling); + } + return newNode; + } +} +_extends(Text,CharacterData); +function Comment() { +}; +Comment.prototype = { + nodeName : "#comment", + nodeType : COMMENT_NODE +} +_extends(Comment,CharacterData); + +function CDATASection() { +}; +CDATASection.prototype = { + nodeName : "#cdata-section", + nodeType : CDATA_SECTION_NODE +} +_extends(CDATASection,CharacterData); + + +function DocumentType() { +}; +DocumentType.prototype.nodeType = DOCUMENT_TYPE_NODE; +_extends(DocumentType,Node); + +function Notation() { +}; +Notation.prototype.nodeType = NOTATION_NODE; +_extends(Notation,Node); + +function Entity() { +}; +Entity.prototype.nodeType = ENTITY_NODE; +_extends(Entity,Node); + +function EntityReference() { +}; +EntityReference.prototype.nodeType = ENTITY_REFERENCE_NODE; +_extends(EntityReference,Node); + +function DocumentFragment() { +}; +DocumentFragment.prototype.nodeName = "#document-fragment"; +DocumentFragment.prototype.nodeType = DOCUMENT_FRAGMENT_NODE; +_extends(DocumentFragment,Node); + + +function ProcessingInstruction() { +} +ProcessingInstruction.prototype.nodeType = PROCESSING_INSTRUCTION_NODE; +_extends(ProcessingInstruction,Node); +function XMLSerializer(){} +XMLSerializer.prototype.serializeToString = function(node,isHtml,nodeFilter){ + return nodeSerializeToString.call(node,isHtml,nodeFilter); +} +Node.prototype.toString = nodeSerializeToString; +function nodeSerializeToString(isHtml,nodeFilter){ + var buf = []; + var refNode = this.nodeType == 9 && this.documentElement || this; + var prefix = refNode.prefix; + var uri = refNode.namespaceURI; + + if(uri && prefix == null){ + //console.log(prefix) + var prefix = refNode.lookupPrefix(uri); + if(prefix == null){ + //isHTML = true; + var visibleNamespaces=[ + {namespace:uri,prefix:null} + //{namespace:uri,prefix:''} + ] + } + } + serializeToString(this,buf,isHtml,nodeFilter,visibleNamespaces); + //console.log('###',this.nodeType,uri,prefix,buf.join('')) + return buf.join(''); +} +function needNamespaceDefine(node,isHTML, visibleNamespaces) { + var prefix = node.prefix||''; + var uri = node.namespaceURI; + if (!prefix && !uri){ + return false; + } + if (prefix === "xml" && uri === "http://www.w3.org/XML/1998/namespace" + || uri == 'http://www.w3.org/2000/xmlns/'){ + return false; + } + + var i = visibleNamespaces.length + //console.log('@@@@',node.tagName,prefix,uri,visibleNamespaces) + while (i--) { + var ns = visibleNamespaces[i]; + // get namespace prefix + //console.log(node.nodeType,node.tagName,ns.prefix,prefix) + if (ns.prefix == prefix){ + return ns.namespace != uri; + } + } + //console.log(isHTML,uri,prefix=='') + //if(isHTML && prefix ==null && uri == 'http://www.w3.org/1999/xhtml'){ + // return false; + //} + //node.flag = '11111' + //console.error(3,true,node.flag,node.prefix,node.namespaceURI) + return true; +} +function serializeToString(node,buf,isHTML,nodeFilter,visibleNamespaces){ + if(nodeFilter){ + node = nodeFilter(node); + if(node){ + if(typeof node == 'string'){ + buf.push(node); + return; + } + }else{ + return; + } + //buf.sort.apply(attrs, attributeSorter); + } + switch(node.nodeType){ + case ELEMENT_NODE: + if (!visibleNamespaces) visibleNamespaces = []; + var startVisibleNamespaces = visibleNamespaces.length; + var attrs = node.attributes; + var len = attrs.length; + var child = node.firstChild; + var nodeName = node.tagName; + + isHTML = (htmlns === node.namespaceURI) ||isHTML + buf.push('<',nodeName); + + + + for(var i=0;i'); + //if is cdata child node + if(isHTML && /^script$/i.test(nodeName)){ + while(child){ + if(child.data){ + buf.push(child.data); + }else{ + serializeToString(child,buf,isHTML,nodeFilter,visibleNamespaces); + } + child = child.nextSibling; + } + }else + { + while(child){ + serializeToString(child,buf,isHTML,nodeFilter,visibleNamespaces); + child = child.nextSibling; + } + } + buf.push(''); + }else{ + buf.push('/>'); + } + // remove added visible namespaces + //visibleNamespaces.length = startVisibleNamespaces; + return; + case DOCUMENT_NODE: + case DOCUMENT_FRAGMENT_NODE: + var child = node.firstChild; + while(child){ + serializeToString(child,buf,isHTML,nodeFilter,visibleNamespaces); + child = child.nextSibling; + } + return; + case ATTRIBUTE_NODE: + return buf.push(' ',node.name,'="',node.value.replace(/[<&"]/g,_xmlEncoder),'"'); + case TEXT_NODE: + return buf.push(node.data.replace(/[<&]/g,_xmlEncoder)); + case CDATA_SECTION_NODE: + return buf.push( ''); + case COMMENT_NODE: + return buf.push( ""); + case DOCUMENT_TYPE_NODE: + var pubid = node.publicId; + var sysid = node.systemId; + buf.push(''); + }else if(sysid && sysid!='.'){ + buf.push(' SYSTEM "',sysid,'">'); + }else{ + var sub = node.internalSubset; + if(sub){ + buf.push(" [",sub,"]"); + } + buf.push(">"); + } + return; + case PROCESSING_INSTRUCTION_NODE: + return buf.push( ""); + case ENTITY_REFERENCE_NODE: + return buf.push( '&',node.nodeName,';'); + //case ENTITY_NODE: + //case NOTATION_NODE: + default: + buf.push('??',node.nodeName); + } +} +function importNode(doc,node,deep){ + var node2; + switch (node.nodeType) { + case ELEMENT_NODE: + node2 = node.cloneNode(false); + node2.ownerDocument = doc; + //var attrs = node2.attributes; + //var len = attrs.length; + //for(var i=0;i', + amp: '&', + quot: '"', + apos: "'", + Agrave: "À", + Aacute: "Á", + Acirc: "Â", + Atilde: "Ã", + Auml: "Ä", + Aring: "Å", + AElig: "Æ", + Ccedil: "Ç", + Egrave: "È", + Eacute: "É", + Ecirc: "Ê", + Euml: "Ë", + Igrave: "Ì", + Iacute: "Í", + Icirc: "Î", + Iuml: "Ï", + ETH: "Ð", + Ntilde: "Ñ", + Ograve: "Ò", + Oacute: "Ó", + Ocirc: "Ô", + Otilde: "Õ", + Ouml: "Ö", + Oslash: "Ø", + Ugrave: "Ù", + Uacute: "Ú", + Ucirc: "Û", + Uuml: "Ü", + Yacute: "Ý", + THORN: "Þ", + szlig: "ß", + agrave: "à", + aacute: "á", + acirc: "â", + atilde: "ã", + auml: "ä", + aring: "å", + aelig: "æ", + ccedil: "ç", + egrave: "è", + eacute: "é", + ecirc: "ê", + euml: "ë", + igrave: "ì", + iacute: "í", + icirc: "î", + iuml: "ï", + eth: "ð", + ntilde: "ñ", + ograve: "ò", + oacute: "ó", + ocirc: "ô", + otilde: "õ", + ouml: "ö", + oslash: "ø", + ugrave: "ù", + uacute: "ú", + ucirc: "û", + uuml: "ü", + yacute: "ý", + thorn: "þ", + yuml: "ÿ", + nbsp: " ", + iexcl: "¡", + cent: "¢", + pound: "£", + curren: "¤", + yen: "¥", + brvbar: "¦", + sect: "§", + uml: "¨", + copy: "©", + ordf: "ª", + laquo: "«", + not: "¬", + shy: "­­", + reg: "®", + macr: "¯", + deg: "°", + plusmn: "±", + sup2: "²", + sup3: "³", + acute: "´", + micro: "µ", + para: "¶", + middot: "·", + cedil: "¸", + sup1: "¹", + ordm: "º", + raquo: "»", + frac14: "¼", + frac12: "½", + frac34: "¾", + iquest: "¿", + times: "×", + divide: "÷", + forall: "∀", + part: "∂", + exist: "∃", + empty: "∅", + nabla: "∇", + isin: "∈", + notin: "∉", + ni: "∋", + prod: "∏", + sum: "∑", + minus: "−", + lowast: "∗", + radic: "√", + prop: "∝", + infin: "∞", + ang: "∠", + and: "∧", + or: "∨", + cap: "∩", + cup: "∪", + 'int': "∫", + there4: "∴", + sim: "∼", + cong: "≅", + asymp: "≈", + ne: "≠", + equiv: "≡", + le: "≤", + ge: "≥", + sub: "⊂", + sup: "⊃", + nsub: "⊄", + sube: "⊆", + supe: "⊇", + oplus: "⊕", + otimes: "⊗", + perp: "⊥", + sdot: "⋅", + Alpha: "Α", + Beta: "Β", + Gamma: "Γ", + Delta: "Δ", + Epsilon: "Ε", + Zeta: "Ζ", + Eta: "Η", + Theta: "Θ", + Iota: "Ι", + Kappa: "Κ", + Lambda: "Λ", + Mu: "Μ", + Nu: "Ν", + Xi: "Ξ", + Omicron: "Ο", + Pi: "Π", + Rho: "Ρ", + Sigma: "Σ", + Tau: "Τ", + Upsilon: "Υ", + Phi: "Φ", + Chi: "Χ", + Psi: "Ψ", + Omega: "Ω", + alpha: "α", + beta: "β", + gamma: "γ", + delta: "δ", + epsilon: "ε", + zeta: "ζ", + eta: "η", + theta: "θ", + iota: "ι", + kappa: "κ", + lambda: "λ", + mu: "μ", + nu: "ν", + xi: "ξ", + omicron: "ο", + pi: "π", + rho: "ρ", + sigmaf: "ς", + sigma: "σ", + tau: "τ", + upsilon: "υ", + phi: "φ", + chi: "χ", + psi: "ψ", + omega: "ω", + thetasym: "ϑ", + upsih: "ϒ", + piv: "ϖ", + OElig: "Œ", + oelig: "œ", + Scaron: "Š", + scaron: "š", + Yuml: "Ÿ", + fnof: "ƒ", + circ: "ˆ", + tilde: "˜", + ensp: " ", + emsp: " ", + thinsp: " ", + zwnj: "‌", + zwj: "‍", + lrm: "‎", + rlm: "‏", + ndash: "–", + mdash: "—", + lsquo: "‘", + rsquo: "’", + sbquo: "‚", + ldquo: "“", + rdquo: "”", + bdquo: "„", + dagger: "†", + Dagger: "‡", + bull: "•", + hellip: "…", + permil: "‰", + prime: "′", + Prime: "″", + lsaquo: "‹", + rsaquo: "›", + oline: "‾", + euro: "€", + trade: "™", + larr: "←", + uarr: "↑", + rarr: "→", + darr: "↓", + harr: "↔", + crarr: "↵", + lceil: "⌈", + rceil: "⌉", + lfloor: "⌊", + rfloor: "⌋", + loz: "◊", + spades: "♠", + clubs: "♣", + hearts: "♥", + diams: "♦" +}; +//for(var n in exports.entityMap){console.log(exports.entityMap[n].charCodeAt())} \ No newline at end of file diff --git a/frontend/build-templates/wechatgame/libs/xmldom/sax.js b/frontend/build-templates/wechatgame/libs/xmldom/sax.js new file mode 100644 index 0000000..f8b494e --- /dev/null +++ b/frontend/build-templates/wechatgame/libs/xmldom/sax.js @@ -0,0 +1,616 @@ +//[4] NameStartChar ::= ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF] +//[4a] NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040] +//[5] Name ::= NameStartChar (NameChar)* +var nameStartChar = /[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]///\u10000-\uEFFFF +var nameChar = new RegExp("[\\-\\.0-9"+nameStartChar.source.slice(1,-1)+"\\u00B7\\u0300-\\u036F\\u203F-\\u2040]"); +var tagNamePattern = new RegExp('^'+nameStartChar.source+nameChar.source+'*(?:\:'+nameStartChar.source+nameChar.source+'*)?$'); +//var tagNamePattern = /^[a-zA-Z_][\w\-\.]*(?:\:[a-zA-Z_][\w\-\.]*)?$/ +//var handlers = 'resolveEntity,getExternalSubset,characters,endDocument,endElement,endPrefixMapping,ignorableWhitespace,processingInstruction,setDocumentLocator,skippedEntity,startDocument,startElement,startPrefixMapping,notationDecl,unparsedEntityDecl,error,fatalError,warning,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,comment,endCDATA,endDTD,endEntity,startCDATA,startDTD,startEntity'.split(',') + +//S_TAG, S_ATTR, S_EQ, S_ATTR_NOQUOT_VALUE +//S_ATTR_SPACE, S_ATTR_END, S_TAG_SPACE, S_TAG_CLOSE +var S_TAG = 0;//tag name offerring +var S_ATTR = 1;//attr name offerring +var S_ATTR_SPACE=2;//attr name end and space offer +var S_EQ = 3;//=space? +var S_ATTR_NOQUOT_VALUE = 4;//attr value(no quot value only) +var S_ATTR_END = 5;//attr value end and no space(quot end) +var S_TAG_SPACE = 6;//(attr value end || tag end ) && (space offer) +var S_TAG_CLOSE = 7;//closed el + +function XMLReader(){ + +} + +XMLReader.prototype = { + parse:function(source,defaultNSMap,entityMap){ + var domBuilder = this.domBuilder; + domBuilder.startDocument(); + _copy(defaultNSMap ,defaultNSMap = {}) + parse(source,defaultNSMap,entityMap, + domBuilder,this.errorHandler); + domBuilder.endDocument(); + } +} +function parse(source,defaultNSMapCopy,entityMap,domBuilder,errorHandler){ + function fixedFromCharCode(code) { + // String.prototype.fromCharCode does not supports + // > 2 bytes unicode chars directly + if (code > 0xffff) { + code -= 0x10000; + var surrogate1 = 0xd800 + (code >> 10) + , surrogate2 = 0xdc00 + (code & 0x3ff); + + return String.fromCharCode(surrogate1, surrogate2); + } else { + return String.fromCharCode(code); + } + } + function entityReplacer(a){ + var k = a.slice(1,-1); + if(k in entityMap){ + return entityMap[k]; + }else if(k.charAt(0) === '#'){ + return fixedFromCharCode(parseInt(k.substr(1).replace('x','0x'))) + }else{ + errorHandler.error('entity not found:'+a); + return a; + } + } + function appendText(end){//has some bugs + if(end>start){ + var xt = source.substring(start,end).replace(/&#?\w+;/g,entityReplacer); + locator&&position(start); + domBuilder.characters(xt,0,end-start); + start = end + } + } + function position(p,m){ + while(p>=lineEnd && (m = linePattern.exec(source))){ + lineStart = m.index; + lineEnd = lineStart + m[0].length; + locator.lineNumber++; + //console.log('line++:',locator,startPos,endPos) + } + locator.columnNumber = p-lineStart+1; + } + var lineStart = 0; + var lineEnd = 0; + var linePattern = /.*(?:\r\n?|\n)|.*$/g + var locator = domBuilder.locator; + + var parseStack = [{currentNSMap:defaultNSMapCopy}] + var closeMap = {}; + var start = 0; + while(true){ + try{ + var tagStart = source.indexOf('<',start); + if(tagStart<0){ + if(!source.substr(start).match(/^\s*$/)){ + var doc = domBuilder.doc; + var text = doc.createTextNode(source.substr(start)); + doc.appendChild(text); + domBuilder.currentElement = text; + } + return; + } + if(tagStart>start){ + appendText(tagStart); + } + switch(source.charAt(tagStart+1)){ + case '/': + var end = source.indexOf('>',tagStart+3); + var tagName = source.substring(tagStart+2,end); + var config = parseStack.pop(); + if(end<0){ + + tagName = source.substring(tagStart+2).replace(/[\s<].*/,''); + //console.error('#@@@@@@'+tagName) + errorHandler.error("end tag name: "+tagName+' is not complete:'+config.tagName); + end = tagStart+1+tagName.length; + }else if(tagName.match(/\s + locator&&position(tagStart); + end = parseInstruction(source,tagStart,domBuilder); + break; + case '!':// start){ + start = end; + }else{ + //TODO: 这里有可能sax回退,有位置错误风险 + appendText(Math.max(tagStart,start)+1); + } + } +} +function copyLocator(f,t){ + t.lineNumber = f.lineNumber; + t.columnNumber = f.columnNumber; + return t; +} + +/** + * @see #appendElement(source,elStartEnd,el,selfClosed,entityReplacer,domBuilder,parseStack); + * @return end of the elementStartPart(end of elementEndPart for selfClosed el) + */ +function parseElementStartPart(source,start,el,currentNSMap,entityReplacer,errorHandler){ + var attrName; + var value; + var p = ++start; + var s = S_TAG;//status + while(true){ + var c = source.charAt(p); + switch(c){ + case '=': + if(s === S_ATTR){//attrName + attrName = source.slice(start,p); + s = S_EQ; + }else if(s === S_ATTR_SPACE){ + s = S_EQ; + }else{ + //fatalError: equal must after attrName or space after attrName + throw new Error('attribute equal must after attrName'); + } + break; + case '\'': + case '"': + if(s === S_EQ || s === S_ATTR //|| s == S_ATTR_SPACE + ){//equal + if(s === S_ATTR){ + errorHandler.warning('attribute value must after "="') + attrName = source.slice(start,p) + } + start = p+1; + p = source.indexOf(c,start) + if(p>0){ + value = source.slice(start,p).replace(/&#?\w+;/g,entityReplacer); + el.add(attrName,value,start-1); + s = S_ATTR_END; + }else{ + //fatalError: no end quot match + throw new Error('attribute value no end \''+c+'\' match'); + } + }else if(s == S_ATTR_NOQUOT_VALUE){ + value = source.slice(start,p).replace(/&#?\w+;/g,entityReplacer); + //console.log(attrName,value,start,p) + el.add(attrName,value,start); + //console.dir(el) + errorHandler.warning('attribute "'+attrName+'" missed start quot('+c+')!!'); + start = p+1; + s = S_ATTR_END + }else{ + //fatalError: no equal before + throw new Error('attribute value must after "="'); + } + break; + case '/': + switch(s){ + case S_TAG: + el.setTagName(source.slice(start,p)); + case S_ATTR_END: + case S_TAG_SPACE: + case S_TAG_CLOSE: + s =S_TAG_CLOSE; + el.closed = true; + case S_ATTR_NOQUOT_VALUE: + case S_ATTR: + case S_ATTR_SPACE: + break; + //case S_EQ: + default: + throw new Error("attribute invalid close char('/')") + } + break; + case ''://end document + //throw new Error('unexpected end of input') + errorHandler.error('unexpected end of input'); + if(s == S_TAG){ + el.setTagName(source.slice(start,p)); + } + return p; + case '>': + switch(s){ + case S_TAG: + el.setTagName(source.slice(start,p)); + case S_ATTR_END: + case S_TAG_SPACE: + case S_TAG_CLOSE: + break;//normal + case S_ATTR_NOQUOT_VALUE://Compatible state + case S_ATTR: + value = source.slice(start,p); + if(value.slice(-1) === '/'){ + el.closed = true; + value = value.slice(0,-1) + } + case S_ATTR_SPACE: + if(s === S_ATTR_SPACE){ + value = attrName; + } + if(s == S_ATTR_NOQUOT_VALUE){ + errorHandler.warning('attribute "'+value+'" missed quot(")!!'); + el.add(attrName,value.replace(/&#?\w+;/g,entityReplacer),start) + }else{ + if(currentNSMap[''] !== 'http://www.w3.org/1999/xhtml' || !value.match(/^(?:disabled|checked|selected)$/i)){ + errorHandler.warning('attribute "'+value+'" missed value!! "'+value+'" instead!!') + } + el.add(value,value,start) + } + break; + case S_EQ: + throw new Error('attribute value missed!!'); + } +// console.log(tagName,tagNamePattern,tagNamePattern.test(tagName)) + return p; + /*xml space '\x20' | #x9 | #xD | #xA; */ + case '\u0080': + c = ' '; + default: + if(c<= ' '){//space + switch(s){ + case S_TAG: + el.setTagName(source.slice(start,p));//tagName + s = S_TAG_SPACE; + break; + case S_ATTR: + attrName = source.slice(start,p) + s = S_ATTR_SPACE; + break; + case S_ATTR_NOQUOT_VALUE: + var value = source.slice(start,p).replace(/&#?\w+;/g,entityReplacer); + errorHandler.warning('attribute "'+value+'" missed quot(")!!'); + el.add(attrName,value,start) + case S_ATTR_END: + s = S_TAG_SPACE; + break; + //case S_TAG_SPACE: + //case S_EQ: + //case S_ATTR_SPACE: + // void();break; + //case S_TAG_CLOSE: + //ignore warning + } + }else{//not space +//S_TAG, S_ATTR, S_EQ, S_ATTR_NOQUOT_VALUE +//S_ATTR_SPACE, S_ATTR_END, S_TAG_SPACE, S_TAG_CLOSE + switch(s){ + //case S_TAG:void();break; + //case S_ATTR:void();break; + //case S_ATTR_NOQUOT_VALUE:void();break; + case S_ATTR_SPACE: + var tagName = el.tagName; + if(currentNSMap[''] !== 'http://www.w3.org/1999/xhtml' || !attrName.match(/^(?:disabled|checked|selected)$/i)){ + errorHandler.warning('attribute "'+attrName+'" missed value!! "'+attrName+'" instead2!!') + } + el.add(attrName,attrName,start); + start = p; + s = S_ATTR; + break; + case S_ATTR_END: + errorHandler.warning('attribute space is required"'+attrName+'"!!') + case S_TAG_SPACE: + s = S_ATTR; + start = p; + break; + case S_EQ: + s = S_ATTR_NOQUOT_VALUE; + start = p; + break; + case S_TAG_CLOSE: + throw new Error("elements closed character '/' and '>' must be connected to"); + } + } + }//end outer switch + //console.log('p++',p) + p++; + } +} +/** + * @return true if has new namespace define + */ +function appendElement(el,domBuilder,currentNSMap){ + var tagName = el.tagName; + var localNSMap = null; + //var currentNSMap = parseStack[parseStack.length-1].currentNSMap; + var i = el.length; + while(i--){ + var a = el[i]; + var qName = a.qName; + var value = a.value; + var nsp = qName.indexOf(':'); + if(nsp>0){ + var prefix = a.prefix = qName.slice(0,nsp); + var localName = qName.slice(nsp+1); + var nsPrefix = prefix === 'xmlns' && localName + }else{ + localName = qName; + prefix = null + nsPrefix = qName === 'xmlns' && '' + } + //can not set prefix,because prefix !== '' + a.localName = localName ; + //prefix == null for no ns prefix attribute + if(nsPrefix !== false){//hack!! + if(localNSMap == null){ + localNSMap = {} + //console.log(currentNSMap,0) + _copy(currentNSMap,currentNSMap={}) + //console.log(currentNSMap,1) + } + currentNSMap[nsPrefix] = localNSMap[nsPrefix] = value; + a.uri = 'http://www.w3.org/2000/xmlns/' + domBuilder.startPrefixMapping(nsPrefix, value) + } + } + var i = el.length; + while(i--){ + a = el[i]; + var prefix = a.prefix; + if(prefix){//no prefix attribute has no namespace + if(prefix === 'xml'){ + a.uri = 'http://www.w3.org/XML/1998/namespace'; + }if(prefix !== 'xmlns'){ + a.uri = currentNSMap[prefix || ''] + + //{console.log('###'+a.qName,domBuilder.locator.systemId+'',currentNSMap,a.uri)} + } + } + } + var nsp = tagName.indexOf(':'); + if(nsp>0){ + prefix = el.prefix = tagName.slice(0,nsp); + localName = el.localName = tagName.slice(nsp+1); + }else{ + prefix = null;//important!! + localName = el.localName = tagName; + } + //no prefix element has default namespace + var ns = el.uri = currentNSMap[prefix || '']; + domBuilder.startElement(ns,localName,tagName,el); + //endPrefixMapping and startPrefixMapping have not any help for dom builder + //localNSMap = null + if(el.closed){ + domBuilder.endElement(ns,localName,tagName); + if(localNSMap){ + for(prefix in localNSMap){ + domBuilder.endPrefixMapping(prefix) + } + } + }else{ + el.currentNSMap = currentNSMap; + el.localNSMap = localNSMap; + //parseStack.push(el); + return true; + } +} +function parseHtmlSpecialContent(source,elStartEnd,tagName,entityReplacer,domBuilder){ + if(/^(?:script|textarea)$/i.test(tagName)){ + var elEndStart = source.indexOf('',elStartEnd); + var text = source.substring(elStartEnd+1,elEndStart); + if(/[&<]/.test(text)){ + if(/^script$/i.test(tagName)){ + //if(!/\]\]>/.test(text)){ + //lexHandler.startCDATA(); + domBuilder.characters(text,0,text.length); + //lexHandler.endCDATA(); + return elEndStart; + //} + }//}else{//text area + text = text.replace(/&#?\w+;/g,entityReplacer); + domBuilder.characters(text,0,text.length); + return elEndStart; + //} + + } + } + return elStartEnd+1; +} +function fixSelfClosed(source,elStartEnd,tagName,closeMap){ + //if(tagName in closeMap){ + var pos = closeMap[tagName]; + if(pos == null){ + //console.log(tagName) + pos = source.lastIndexOf('') + if(pos',start+4); + //append comment source.substring(4,end)//