wmpf

package
v0.0.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 14, 2026 License: GPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CategorySetupContext             = "setupContext"
	CategoryCallInterface            = "callInterface"
	CategoryCallInterfaceResult      = "callInterfaceResult"
	CategoryEvaluateJavascript       = "evaluateJavascript"
	CategoryEvaluateJavascriptResult = "evaluateJavascriptResult"
	CategoryBreakpoint               = "breakpoint"
	CategoryPing                     = "ping"
	CategoryPong                     = "pong"
	CategoryDomOp                    = "domOp"
	CategoryDomEvent                 = "domEvent"
	CategoryNetworkDebugAPI          = "networkDebugAPI"
	CategoryChromeDevtools           = "chromeDevtools"
	CategoryChromeDevtoolsResult     = "chromeDevtoolsResult"
	CategoryAddJsContext             = "addJsContext"
	CategoryRemoveJsContext          = "removeJsContext"
	CategoryConnectJsContext         = "connectJsContext"
	CategoryCustomMessage            = "customMessage"
)
View Source
const (
	CmdClientHeartbeat             uint32 = 1001
	CmdClientLogin                 uint32 = 1002
	CmdClientJoinRoom              uint32 = 1003
	CmdClientQuitRoom              uint32 = 1004
	CmdClientSyncMessage           uint32 = 1005
	CmdClientMessageNotify         uint32 = 2000
	CmdClientMessageNotifyParallel uint32 = 2006
	CmdClientSendDebug             uint32 = 1000
	CmdClientSendDebugParallel     uint32 = 1006
	CmdDevHeartbeat                uint32 = 2001
	CmdDevLogin                    uint32 = 2002
	CmdDevJoinRoom                 uint32 = 2003
	CmdDevQuitRoom                 uint32 = 2004
	CmdDevSyncMessage              uint32 = 2005
	CmdDevMessageNotify            uint32 = 1000
	CmdDevMessageNotifyParallel    uint32 = 1006
	CmdDevSendDebug                uint32 = 2000
	CmdDevSendDebugParallel        uint32 = 2006
	CmdEventBegin                  uint32 = 3001
	CmdEventEnd                    uint32 = 3002
	CmdEventBlock                  uint32 = 3003
)

Command values are the wire values from RemoteDebugConstants.js. The 100x range is the client side and 200x is the developer side of the same RPC.

View Source
const DefaultMaxDecompressedDebugMessageBytes = 16 << 20

DefaultMaxDecompressedDebugMessageBytes bounds one inflated WMPF debug message. It is intentionally much smaller than the native shim's process safety ceiling while leaving room for large CDP payloads.

Variables

View Source
var (
	// ErrDecompressedDebugMessageTooLarge reports a declared or actual output
	// larger than the active WMPF decompression limit.
	ErrDecompressedDebugMessageTooLarge = errors.New("wmpf: decompressed debug message exceeds limit")
	// ErrDecompressedDebugMessageSizeMismatch reports a non-zero OriginalSize
	// that does not match the inflated payload.
	ErrDecompressedDebugMessageSizeMismatch = errors.New("wmpf: decompressed debug message size mismatch")
)

Functions

func CompressionSavedBytes

func CompressionSavedBytes() int64

func DecodeCategory

func DecodeCategory(category string, d []byte) (any, error)

func DecodeCommandPayload

func DecodeCommandPayload(role EndpointRole, cmd uint32, data []byte) (any, error)

DecodeCommandPayload matches the two reference Codex unwrap entry points: client frames are requests and developer frames are responses. Unknown commands produce an empty object while the caller retains DataFormat.Data.

func DecodeRequestPayload

func DecodeRequestPayload(role EndpointRole, cmd uint32, data []byte) (any, error)

func DecodeResponsePayload

func DecodeResponsePayload(role EndpointRole, cmd uint32, data []byte) (any, error)

func EncodeCategory

func EncodeCategory(category string, value any) ([]byte, error)

func EncodeChrome

func EncodeChrome(m ChromeDevtools) []byte

func EncodeClientResponseDataFormat

func EncodeClientResponseDataFormat(cmd uint32, uuid string, value any) ([]byte, error)

EncodeClientResponseDataFormat mirrors wrapClientResponseDataFormatToProto.

func EncodeCommandPayload

func EncodeCommandPayload(role EndpointRole, cmd uint32, value any) ([]byte, error)

func EncodeCustom

func EncodeCustom(m CustomMessage) []byte

func EncodeDataFormat

func EncodeDataFormat(v DataFormat) ([]byte, error)

func EncodeDebugMessage

func EncodeDebugMessage(m DebugMessage) []byte

func EncodeDeveloperOutgoingDataFormat

func EncodeDeveloperOutgoingDataFormat(cmd uint32, uuid string, value any, parallelNotify bool) ([]byte, error)

EncodeDeveloperOutgoingDataFormat mirrors RemoteDebugCodex.wrapOutgoingToProto. Its debug-message list intentionally emits explicit zero compression fields and omits the schema's `after` field, matching the reference helper d().

func EncodeGeneric

func EncodeGeneric(m GenericMessage) []byte

func EncodeOutgoingDebugMessage

func EncodeOutgoingDebugMessage(m DebugMessage) []byte

EncodeOutgoingDebugMessage mirrors src/index.ts outData. The reference omits after entirely but explicitly supplies both zero-valued compression fields.

func HasMessageType

func HasMessageType(name string) bool

func MarshalMessage

func MarshalMessage(v any) ([]byte, error)

func MessageTypeCount

func MessageTypeCount() int

func MessageTypes

func MessageTypes() []string

func NewMessage

func NewMessage(typeName string) (any, bool)

func ResetCompressionStatistics

func ResetCompressionStatistics()

func SchemaFieldCount

func SchemaFieldCount(name string) int

func UnmarshalMessage

func UnmarshalMessage(d []byte, out any) error

func WrapData

func WrapData(data []byte, category string, algo CompressAlgo) ([]byte, uint32, error)

func ZlibVersion

func ZlibVersion() string

Types

type AddJsContext

type AddJsContext struct {
	ProtoUnknown
	JscontextId   string `pb:"1,string"`
	JscontextName string `pb:"2,string"`
}

type BaseReq

type BaseReq struct {
	ProtoUnknown
	ClientVersion uint32 `pb:"1,varint"`
}

type BaseResp

type BaseResp struct {
	ProtoUnknown
	Errcode int32  `pb:"1,varint"`
	Errmsg  string `pb:"2,string"`
}

type Breakpoint

type Breakpoint struct{ IsHit bool }

type BreakpointProto

type BreakpointProto struct {
	ProtoUnknown
	IsHit bool `pb:"1,varint"`
}

type CallInterface

type CallInterface struct {
	ObjName, MethodName string
	MethodArgs          []string
	CallID              uint32
}

type CallInterfaceProto

type CallInterfaceProto struct {
	ProtoUnknown
	ObjName    string   `pb:"1,string"`
	MethodName string   `pb:"2,string"`
	MethodArgs []string `pb:"3,string"`
	CallId     uint32   `pb:"4,varint"`
}

type CallInterfaceResult

type CallInterfaceResult struct {
	Ret       string
	CallID    uint32
	DebugInfo string
}

type CallInterfaceResultProto

type CallInterfaceResultProto struct {
	ProtoUnknown
	Ret       string `pb:"1,string"`
	CallId    uint32 `pb:"2,varint"`
	DebugInfo string `pb:"3,string"`
}

type ChromeDevtools

type ChromeDevtools struct {
	OpID                 uint64
	Payload, JSContextID string
}

func DecodeChrome

func DecodeChrome(d []byte) (ChromeDevtools, error)

type ChromeDevtoolsProto

type ChromeDevtoolsProto struct {
	ProtoUnknown
	OpId        uint64 `pb:"1,varint"`
	Payload     string `pb:"2,string"`
	JscontextId string `pb:"3,string"`
}

type ChromeDevtoolsResultProto

type ChromeDevtoolsResultProto = ChromeDevtoolsProto

type CommReq

type CommReq struct {
	ProtoUnknown
	BaseRequest *BaseReq `pb:"1,msg"`
}

type CommResp

type CommResp struct {
	ProtoUnknown
	BaseResponse *BaseResp `pb:"1,msg"`
}

type CompressAlgo

type CompressAlgo uint32
const CompressNone CompressAlgo = 0
const CompressZlib CompressAlgo = 1

type ConnectJsContext

type ConnectJsContext struct {
	ProtoUnknown
	JscontextId string `pb:"1,string"`
}

type CustomMessage

type CustomMessage struct {
	Method, Payload string
	Raw             []byte
}

func DecodeCustom

func DecodeCustom(d []byte) (CustomMessage, error)

type CustomMessageProto

type CustomMessageProto struct {
	ProtoUnknown
	Method  string `pb:"1,string"`
	Payload string `pb:"2,string"`
	Raw     []byte `pb:"3,bytes"`
}

type DataFormat

type DataFormat struct {
	ProtoUnknown
	Cmd  uint32 `pb:"1,varint"`
	Uuid string `pb:"2,string"`
	Data []byte `pb:"3,bytes"`
}

func DecodeDataFormat

func DecodeDataFormat(data []byte) (DataFormat, error)

type DebugMessage

type DebugMessage struct {
	Seq, After   uint32
	Category     string
	Data         []byte
	CompressAlgo CompressAlgo
	OriginalSize uint32
}

func DecodeDebugMessage

func DecodeDebugMessage(d []byte) (DebugMessage, error)

type DebugMessageProto

type DebugMessageProto struct {
	ProtoUnknown
	Seq          uint32 `pb:"1,varint"`
	After        uint32 `pb:"2,varint"`
	Category     string `pb:"3,string"`
	Data         []byte `pb:"4,bytes"`
	CompressAlgo uint32 `pb:"5,varint"`
	OriginalSize uint32 `pb:"6,varint"`
}

type DevHeartBeatReq

type DevHeartBeatReq struct {
	ProtoUnknown
	BaseRequest *BaseReq `pb:"1,msg"`
	RecvAck     uint32   `pb:"2,varint"`
}

type DevHeartBeatResp

type DevHeartBeatResp struct {
	ProtoUnknown
	BaseResponse *BaseResp `pb:"1,msg"`
}

type DevJoinRoomReq

type DevJoinRoomReq struct {
	ProtoUnknown
	BaseRequest *BaseReq `pb:"1,msg"`
	Appid       string   `pb:"2,string"`
	RoomId      string   `pb:"3,string"`
	WxpkgInfo   string   `pb:"4,string"`
}

type DevJoinRoomResp

type DevJoinRoomResp struct {
	ProtoUnknown
	BaseResponse *BaseResp `pb:"1,msg"`
}

type DevLoginReq

type DevLoginReq struct {
	ProtoUnknown
	BaseRequest *BaseReq `pb:"1,msg"`
	Newticket   string   `pb:"2,string"`
	Autodev     uint32   `pb:"3,varint"`
}

type DevLoginResp

type DevLoginResp struct {
	ProtoUnknown
	BaseResponse *BaseResp `pb:"1,msg"`
	RoomInfo     *RoomInfo `pb:"2,msg"`
}

type DevQuitRoomReq

type DevQuitRoomReq struct {
	ProtoUnknown
	BaseRequest *BaseReq `pb:"1,msg"`
}

type DevQuitRoomResp

type DevQuitRoomResp struct {
	ProtoUnknown
	BaseResponse *BaseResp `pb:"1,msg"`
}

type DevSyncMessageReq

type DevSyncMessageReq struct {
	ProtoUnknown
	BaseRequest *BaseReq `pb:"1,msg"`
	MinSeq      uint32   `pb:"2,varint"`
	MaxSeq      uint32   `pb:"3,varint"`
}

type DevSyncMessageResp

type DevSyncMessageResp struct {
	ProtoUnknown
	BaseResponse     *BaseResp           `pb:"1,msg"`
	DebugMessageList []DebugMessageProto `pb:"2,msg"`
	SendAck          uint32              `pb:"3,varint"`
}

type DeviceInfo

type DeviceInfo struct {
	ProtoUnknown
	DeviceName    string  `pb:"1,string"`
	DeviceModel   string  `pb:"2,string"`
	SystemVersion string  `pb:"3,string"`
	WechatVersion string  `pb:"4,string"`
	PublibVersion uint32  `pb:"5,varint"`
	ScreenWidth   float32 `pb:"6,fixed32"`
	PixelRatio    float32 `pb:"7,fixed32"`
	UserAgent     string  `pb:"8,string"`
}

type DomEvent

type DomEvent struct {
	ProtoUnknown
	Params    string `pb:"1,string"`
	WebviewId uint32 `pb:"2,varint"`
}

type DomOp

type DomOp struct {
	ProtoUnknown
	Params    string `pb:"1,string"`
	WebviewId uint32 `pb:"2,varint"`
}

type EndpointRole

type EndpointRole uint8

DecodeCommandPayload decodes the inner protobuf selected by a DataFormat command while retaining the direction-specific message type.

const (
	RoleClient EndpointRole = iota
	RoleDeveloper
)

type EvaluateJavascript

type EvaluateJavascript struct {
	Script     string
	EvaluateID uint32
	DebugInfo  string
}

type EvaluateJavascriptProto

type EvaluateJavascriptProto struct {
	ProtoUnknown
	Script     string `pb:"1,string"`
	EvaluateId uint32 `pb:"2,varint"`
	DebugInfo  string `pb:"3,string"`
}

type EvaluateJavascriptResult

type EvaluateJavascriptResult struct {
	Ret        string
	EvaluateID uint32
}

type EvaluateJavascriptResultProto

type EvaluateJavascriptResultProto struct {
	ProtoUnknown
	Ret        string `pb:"1,string"`
	EvaluateId uint32 `pb:"2,varint"`
}

type EventNotify

type EventNotify struct{ ProtoUnknown }

type EventNotifyResp

type EventNotifyResp struct{ ProtoUnknown }

type GenericMessage

type GenericMessage struct {
	Type   string
	Fields []WireField
}

func DecodeGeneric

func DecodeGeneric(name string, data []byte) (GenericMessage, error)

type JsContext

type JsContext struct{ ID, Name string }

type MessageNotify

type MessageNotify struct {
	ProtoUnknown
	DebugMessageList []DebugMessageProto `pb:"1,msg"`
}

type MessageNotifyResp

type MessageNotifyResp struct {
	ProtoUnknown
	RecvAck uint32 `pb:"1,varint"`
}

type MethodWithArgs

type MethodWithArgs struct {
	ProtoUnknown
	MethodName    string   `pb:"1,string"`
	MethodArgList []string `pb:"2,string"`
}

type NetworkDebugAPI

type NetworkDebugAPI struct {
	ProtoUnknown
	ApiName        string `pb:"1,string"`
	TaskId         string `pb:"2,string"`
	RequestHeaders string `pb:"3,string"`
	Timestamp      uint64 `pb:"4,varint"`
}

type NewSendDebugMessageReq

type NewSendDebugMessageReq struct {
	ProtoUnknown
	BaseRequest      *BaseReq            `pb:"1,msg"`
	DebugMessageList []DebugMessageProto `pb:"2,msg"`
	RecvAck          uint32              `pb:"3,varint"`
}

type NewSendDebugMessageResp

type NewSendDebugMessageResp struct {
	ProtoUnknown
	BaseResponse *BaseResp `pb:"1,msg"`
	MinAck       uint32    `pb:"2,varint"`
	MaxAck       uint32    `pb:"3,varint"`
}

type Ping

type Ping struct {
	PingID  uint64
	Payload string
}

type PingProto

type PingProto struct {
	ProtoUnknown
	PingId  uint64 `pb:"1,varint"`
	Payload string `pb:"2,string"`
}

type Pong

type Pong struct {
	PingID      uint64
	NetworkType uint32
	Payload     string
}

type PongProto

type PongProto struct {
	ProtoUnknown
	PingId      uint64 `pb:"1,varint"`
	NetworkType uint32 `pb:"2,varint"`
	Payload     string `pb:"3,string"`
}

type ProtoUnknown

type ProtoUnknown struct {
	UnknownFields []byte `json:"-"`
}

type RegisterInterface

type RegisterInterface struct {
	ProtoUnknown
	ObjName       string           `pb:"1,string"`
	ObjMethodList []MethodWithArgs `pb:"2,msg"`
}

type RemoveJsContext

type RemoveJsContext struct {
	ProtoUnknown
	JscontextId string `pb:"1,string"`
}

type RoomInfo

type RoomInfo struct {
	ProtoUnknown
	JoinRoom      bool   `pb:"1,varint"`
	RoomId        string `pb:"2,string"`
	OriginalMd5   string `pb:"3,string"`
	RoomStatus    uint32 `pb:"4,varint"`
	WxConnStatus  uint32 `pb:"5,varint"`
	DevConnStatus uint32 `pb:"6,varint"`
}

type SendDebugMessageReq

type SendDebugMessageReq struct {
	ProtoUnknown
	BaseRequest      *BaseReq            `pb:"1,msg"`
	DebugMessageList []DebugMessageProto `pb:"2,msg"`
	RecvAck          uint32              `pb:"3,varint"`
}

type SendDebugMessageResp

type SendDebugMessageResp struct {
	ProtoUnknown
	BaseResponse *BaseResp `pb:"1,msg"`
	SendAck      uint32    `pb:"2,varint"`
}

type SetupContext

type SetupContext struct {
	ProtoUnknown
	RegisterInterface   *RegisterInterface `pb:"1,msg"`
	DeviceInfo          *DeviceInfo        `pb:"2,msg"`
	ConfigureJs         string             `pb:"3,string"`
	PublicJsMd5         string             `pb:"4,string"`
	ThreeJsMd5          string             `pb:"5,string"`
	SupportCompressAlgo uint32             `pb:"6,varint"`
}

type Unwrapped

type Unwrapped struct {
	Seq, Delay   uint32
	Category     string
	Data         any
	CompressAlgo CompressAlgo
	OriginalSize uint32
	Raw          []byte
}

func UnwrapDebugMessage

func UnwrapDebugMessage(m DebugMessage) (Unwrapped, error)

func UnwrapDebugMessageWithLimit added in v0.0.2

func UnwrapDebugMessageWithLimit(m DebugMessage, maxOutput int) (Unwrapped, error)

UnwrapDebugMessageWithLimit unwraps a debug message with a caller-supplied maximum inflated payload size.

type WireField

type WireField struct {
	Number   int
	WireType int
	Raw      []byte
	Value    []byte
}

type WxHeartBeatReq

type WxHeartBeatReq struct {
	ProtoUnknown
	BaseRequest *BaseReq `pb:"1,msg"`
	RecvAck     uint32   `pb:"2,varint"`
}

type WxHeartBeatResp

type WxHeartBeatResp struct {
	ProtoUnknown
	BaseResponse *BaseResp `pb:"1,msg"`
}

type WxJoinRoomReq

type WxJoinRoomReq struct {
	ProtoUnknown
	BaseRequest *BaseReq `pb:"1,msg"`
	Username    string   `pb:"2,string"`
	RoomId      string   `pb:"3,string"`
	WxpkgInfo   string   `pb:"4,string"`
}

type WxJoinRoomResp

type WxJoinRoomResp struct {
	ProtoUnknown
	BaseResponse *BaseResp `pb:"1,msg"`
}

type WxLoginReq

type WxLoginReq struct {
	ProtoUnknown
	BaseRequest *BaseReq `pb:"1,msg"`
	LoginTicket string   `pb:"2,string"`
}

type WxLoginResp

type WxLoginResp struct {
	ProtoUnknown
	BaseResponse *BaseResp `pb:"1,msg"`
	RoomInfo     *RoomInfo `pb:"2,msg"`
}

type WxQuitRoomReq

type WxQuitRoomReq struct {
	ProtoUnknown
	BaseRequest *BaseReq `pb:"1,msg"`
}

type WxQuitRoomResp

type WxQuitRoomResp struct {
	ProtoUnknown
	BaseResponse *BaseResp `pb:"1,msg"`
}

type WxSyncMessageReq

type WxSyncMessageReq struct {
	ProtoUnknown
	BaseRequest *BaseReq `pb:"1,msg"`
	MinSeq      uint32   `pb:"2,varint"`
	MaxSeq      uint32   `pb:"3,varint"`
}

type WxSyncMessageResp

type WxSyncMessageResp struct {
	ProtoUnknown
	BaseResponse     *BaseResp           `pb:"1,msg"`
	DebugMessageList []DebugMessageProto `pb:"2,msg"`
	SendAck          uint32              `pb:"3,varint"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL