feat(tracker): add messages, draft mapping method

This commit is contained in:
sylenien 2022-09-08 17:22:56 +02:00
parent 5899a78322
commit 849b33f921
31 changed files with 1447 additions and 504 deletions

View file

@ -2,7 +2,7 @@
package messages package messages
func IsReplayerType(id int) bool { func IsReplayerType(id int) bool {
return 0 == id || 4 == id || 5 == id || 6 == id || 7 == id || 8 == id || 9 == id || 10 == id || 11 == id || 12 == id || 13 == id || 14 == id || 15 == id || 16 == id || 18 == id || 19 == id || 20 == id || 22 == id || 37 == id || 38 == id || 39 == id || 40 == id || 41 == id || 44 == id || 45 == id || 46 == id || 47 == id || 48 == id || 49 == id || 54 == id || 55 == id || 59 == id || 60 == id || 61 == id || 67 == id || 69 == id || 70 == id || 71 == id || 72 == id || 73 == id || 74 == id || 75 == id || 76 == id || 77 == id || 79 == id || 90 == id || 93 == id || 96 == id || 100 == id || 102 == id || 103 == id || 105 == id return 0 == id || 4 == id || 5 == id || 6 == id || 7 == id || 8 == id || 9 == id || 10 == id || 11 == id || 12 == id || 13 == id || 14 == id || 15 == id || 16 == id || 18 == id || 19 == id || 20 == id || 22 == id || 37 == id || 38 == id || 39 == id || 40 == id || 41 == id || 44 == id || 45 == id || 46 == id || 47 == id || 48 == id || 49 == id || 54 == id || 55 == id || 59 == id || 60 == id || 61 == id || 67 == id || 69 == id || 70 == id || 71 == id || 72 == id || 73 == id || 74 == id || 75 == id || 76 == id || 77 == id || 79 == id || 83 == id || 90 == id || 93 == id || 96 == id || 100 == id || 102 == id || 103 == id || 105 == id
} }
func IsIOSType(id int) bool { func IsIOSType(id int) bool {

View file

@ -158,6 +158,8 @@ const (
MsgZustand = 79 MsgZustand = 79
MsgReplaceVCSS = 83
MsgIOSBatchMeta = 107 MsgIOSBatchMeta = 107
MsgIOSSessionStart = 90 MsgIOSSessionStart = 90
@ -3066,6 +3068,36 @@ func (msg *Zustand) EncodeWithIndex() []byte {
return data return data
} }
type ReplaceVCSS struct {
message
ID uint64
Styles string
SheetID string
BaseURL string
}
func (msg *ReplaceVCSS) Encode() []byte {
buf := make([]byte, 41+len(msg.Styles)+len(msg.SheetID)+len(msg.BaseURL))
buf[0] = 83
p := 1
p = WriteUint(msg.ID, buf, p)
p = WriteString(msg.Styles, buf, p)
p = WriteString(msg.SheetID, buf, p)
p = WriteString(msg.BaseURL, buf, p)
return buf[:p]
}
func (msg *ReplaceVCSS) EncodeWithIndex() []byte {
encoded := msg.Encode()
if IsIOSType(msg.TypeID()) {
return encoded
}
data := make([]byte, len(encoded)+8)
copy(data[8:], encoded[:])
binary.LittleEndian.PutUint64(data[0:], msg.Meta().Index)
return data
}
func (msg *Zustand) Decode() Message { func (msg *Zustand) Decode() Message {
return msg return msg
} }
@ -3074,6 +3106,14 @@ func (msg *Zustand) TypeID() int {
return 79 return 79
} }
func (msg *ReplaceVCSS) Decode() Message {
return msg
}
func (msg *ReplaceVCSS) TypeID() int {
return 83
}
type IOSBatchMeta struct { type IOSBatchMeta struct {
message message
Timestamp uint64 Timestamp uint64

View file

@ -1318,6 +1318,24 @@ func DecodeZustand(reader io.Reader) (Message, error) {
return msg, err return msg, err
} }
func DecodeReplaceVCSS(reader io.Reader) (Message, error) {
var err error = nil
msg := &ReplaceVCSS{}
if msg.ID, err = ReadUint(reader); err != nil {
return nil, err
}
if msg.Styles, err = ReadString(reader); err != nil {
return nil, err
}
if msg.SheetID, err = ReadString(reader); err != nil {
return nil, err
}
if msg.BaseURL, err = ReadString(reader); err != nil {
return nil, err
}
return msg, err
}
func DecodeIOSBatchMeta(reader io.Reader) (Message, error) { func DecodeIOSBatchMeta(reader io.Reader) (Message, error) {
var err error = nil var err error = nil
msg := &IOSBatchMeta{} msg := &IOSBatchMeta{}
@ -1954,6 +1972,9 @@ func ReadMessage(t uint64, reader io.Reader) (Message, error) {
case 79: case 79:
return DecodeZustand(reader) return DecodeZustand(reader)
case 83:
return DecodeReplaceVCSS(reader)
case 107: case 107:
return DecodeIOSBatchMeta(reader) return DecodeIOSBatchMeta(reader)

View file

@ -99,7 +99,7 @@ class CreateDocument(Message):
__id__ = 7 __id__ = 7
def __init__(self, ): def __init__(self, ):
class CreateElementNode(Message): class CreateElementNode(Message):
@ -752,6 +752,16 @@ class Zustand(Message):
self.state = state self.state = state
class ReplaceVCSS(Message):
__id__ = 83
def __init__(self, id, styles, sheet_id, base_url):
self.id = id
self.styles = styles
self.sheet_id = sheet_id
self.base_url = base_url
class IOSBatchMeta(Message): class IOSBatchMeta(Message):
__id__ = 107 __id__ = 107
@ -960,5 +970,3 @@ class IOSIssueEvent(Message):
self.context_string = context_string self.context_string = context_string
self.context = context self.context = context
self.payload = payload self.payload = payload

View file

@ -149,7 +149,7 @@ class MessageCodec(Codec):
if message_id == 7: if message_id == 7:
return CreateDocument( return CreateDocument(
) )
if message_id == 8: if message_id == 8:
@ -668,6 +668,14 @@ class MessageCodec(Codec):
state=self.read_string(reader) state=self.read_string(reader)
) )
if message_id == 83:
return ReplaceVCSS(
id=self.read_uint(reader),
styles=self.read_string(reader),
sheet_id=self.read_string(reader),
base_url=self.read_string(reader)
)
if message_id == 107: if message_id == 107:
return IOSBatchMeta( return IOSBatchMeta(
timestamp=self.read_uint(reader), timestamp=self.read_uint(reader),
@ -839,4 +847,3 @@ class MessageCodec(Codec):
context=self.read_string(reader), context=self.read_string(reader),
payload=self.read_string(reader) payload=self.read_string(reader)
) )

View file

@ -16,221 +16,221 @@ export default class RawMessageReader extends PrimitiveReader {
if (tp === null) { return resetPointer() } if (tp === null) { return resetPointer() }
switch (tp) { switch (tp) {
case 0: { case 0: {
const timestamp = this.readUint(); if (timestamp === null) { return resetPointer() } const timestamp = this.readUint(); if (timestamp === null) { return resetPointer() }
return { return {
tp: "timestamp", tp: "timestamp",
timestamp, timestamp,
}; };
} }
case 4: { case 4: {
const url = this.readString(); if (url === null) { return resetPointer() } const url = this.readString(); if (url === null) { return resetPointer() }
const referrer = this.readString(); if (referrer === null) { return resetPointer() } const referrer = this.readString(); if (referrer === null) { return resetPointer() }
const navigationStart = this.readUint(); if (navigationStart === null) { return resetPointer() } const navigationStart = this.readUint(); if (navigationStart === null) { return resetPointer() }
return { return {
tp: "set_page_location", tp: "set_page_location",
url, url,
referrer, referrer,
navigationStart, navigationStart,
}; };
} }
case 5: { case 5: {
const width = this.readUint(); if (width === null) { return resetPointer() } const width = this.readUint(); if (width === null) { return resetPointer() }
const height = this.readUint(); if (height === null) { return resetPointer() } const height = this.readUint(); if (height === null) { return resetPointer() }
return { return {
tp: "set_viewport_size", tp: "set_viewport_size",
width, width,
height, height,
}; };
} }
case 6: { case 6: {
const x = this.readInt(); if (x === null) { return resetPointer() } const x = this.readInt(); if (x === null) { return resetPointer() }
const y = this.readInt(); if (y === null) { return resetPointer() } const y = this.readInt(); if (y === null) { return resetPointer() }
return { return {
tp: "set_viewport_scroll", tp: "set_viewport_scroll",
x, x,
y, y,
}; };
} }
case 7: { case 7: {
return { return {
tp: "create_document", tp: "create_document",
}; };
} }
case 8: { case 8: {
const id = this.readUint(); if (id === null) { return resetPointer() } const id = this.readUint(); if (id === null) { return resetPointer() }
const parentID = this.readUint(); if (parentID === null) { return resetPointer() } const parentID = this.readUint(); if (parentID === null) { return resetPointer() }
const index = this.readUint(); if (index === null) { return resetPointer() } const index = this.readUint(); if (index === null) { return resetPointer() }
const tag = this.readString(); if (tag === null) { return resetPointer() } const tag = this.readString(); if (tag === null) { return resetPointer() }
const svg = this.readBoolean(); if (svg === null) { return resetPointer() } const svg = this.readBoolean(); if (svg === null) { return resetPointer() }
return { return {
tp: "create_element_node", tp: "create_element_node",
id, id,
parentID, parentID,
index, index,
tag, tag,
svg, svg,
}; };
} }
case 9: { case 9: {
const id = this.readUint(); if (id === null) { return resetPointer() } const id = this.readUint(); if (id === null) { return resetPointer() }
const parentID = this.readUint(); if (parentID === null) { return resetPointer() } const parentID = this.readUint(); if (parentID === null) { return resetPointer() }
const index = this.readUint(); if (index === null) { return resetPointer() } const index = this.readUint(); if (index === null) { return resetPointer() }
return { return {
tp: "create_text_node", tp: "create_text_node",
id, id,
parentID, parentID,
index, index,
}; };
} }
case 10: { case 10: {
const id = this.readUint(); if (id === null) { return resetPointer() } const id = this.readUint(); if (id === null) { return resetPointer() }
const parentID = this.readUint(); if (parentID === null) { return resetPointer() } const parentID = this.readUint(); if (parentID === null) { return resetPointer() }
const index = this.readUint(); if (index === null) { return resetPointer() } const index = this.readUint(); if (index === null) { return resetPointer() }
return { return {
tp: "move_node", tp: "move_node",
id, id,
parentID, parentID,
index, index,
}; };
} }
case 11: { case 11: {
const id = this.readUint(); if (id === null) { return resetPointer() } const id = this.readUint(); if (id === null) { return resetPointer() }
return { return {
tp: "remove_node", tp: "remove_node",
id, id,
}; };
} }
case 12: { case 12: {
const id = this.readUint(); if (id === null) { return resetPointer() } const id = this.readUint(); if (id === null) { return resetPointer() }
const name = this.readString(); if (name === null) { return resetPointer() } const name = this.readString(); if (name === null) { return resetPointer() }
const value = this.readString(); if (value === null) { return resetPointer() } const value = this.readString(); if (value === null) { return resetPointer() }
return { return {
tp: "set_node_attribute", tp: "set_node_attribute",
id, id,
name, name,
value, value,
}; };
} }
case 13: { case 13: {
const id = this.readUint(); if (id === null) { return resetPointer() } const id = this.readUint(); if (id === null) { return resetPointer() }
const name = this.readString(); if (name === null) { return resetPointer() } const name = this.readString(); if (name === null) { return resetPointer() }
return { return {
tp: "remove_node_attribute", tp: "remove_node_attribute",
id, id,
name, name,
}; };
} }
case 14: { case 14: {
const id = this.readUint(); if (id === null) { return resetPointer() } const id = this.readUint(); if (id === null) { return resetPointer() }
const data = this.readString(); if (data === null) { return resetPointer() } const data = this.readString(); if (data === null) { return resetPointer() }
return { return {
tp: "set_node_data", tp: "set_node_data",
id, id,
data, data,
}; };
} }
case 15: { case 15: {
const id = this.readUint(); if (id === null) { return resetPointer() } const id = this.readUint(); if (id === null) { return resetPointer() }
const data = this.readString(); if (data === null) { return resetPointer() } const data = this.readString(); if (data === null) { return resetPointer() }
return { return {
tp: "set_css_data", tp: "set_css_data",
id, id,
data, data,
}; };
} }
case 16: { case 16: {
const id = this.readUint(); if (id === null) { return resetPointer() } const id = this.readUint(); if (id === null) { return resetPointer() }
const x = this.readInt(); if (x === null) { return resetPointer() } const x = this.readInt(); if (x === null) { return resetPointer() }
const y = this.readInt(); if (y === null) { return resetPointer() } const y = this.readInt(); if (y === null) { return resetPointer() }
return { return {
tp: "set_node_scroll", tp: "set_node_scroll",
id, id,
x, x,
y, y,
}; };
} }
case 18: { case 18: {
const id = this.readUint(); if (id === null) { return resetPointer() } const id = this.readUint(); if (id === null) { return resetPointer() }
const value = this.readString(); if (value === null) { return resetPointer() } const value = this.readString(); if (value === null) { return resetPointer() }
const mask = this.readInt(); if (mask === null) { return resetPointer() } const mask = this.readInt(); if (mask === null) { return resetPointer() }
return { return {
tp: "set_input_value", tp: "set_input_value",
id, id,
value, value,
mask, mask,
}; };
} }
case 19: { case 19: {
const id = this.readUint(); if (id === null) { return resetPointer() } const id = this.readUint(); if (id === null) { return resetPointer() }
const checked = this.readBoolean(); if (checked === null) { return resetPointer() } const checked = this.readBoolean(); if (checked === null) { return resetPointer() }
return { return {
tp: "set_input_checked", tp: "set_input_checked",
id, id,
checked, checked,
}; };
} }
case 20: { case 20: {
const x = this.readUint(); if (x === null) { return resetPointer() } const x = this.readUint(); if (x === null) { return resetPointer() }
const y = this.readUint(); if (y === null) { return resetPointer() } const y = this.readUint(); if (y === null) { return resetPointer() }
return { return {
tp: "mouse_move", tp: "mouse_move",
x, x,
y, y,
}; };
} }
case 22: { case 22: {
const level = this.readString(); if (level === null) { return resetPointer() } const level = this.readString(); if (level === null) { return resetPointer() }
const value = this.readString(); if (value === null) { return resetPointer() } const value = this.readString(); if (value === null) { return resetPointer() }
return { return {
tp: "console_log", tp: "console_log",
level, level,
value, value,
}; };
} }
case 37: { case 37: {
const id = this.readUint(); if (id === null) { return resetPointer() } const id = this.readUint(); if (id === null) { return resetPointer() }
const rule = this.readString(); if (rule === null) { return resetPointer() } const rule = this.readString(); if (rule === null) { return resetPointer() }
const index = this.readUint(); if (index === null) { return resetPointer() } const index = this.readUint(); if (index === null) { return resetPointer() }
return { return {
tp: "css_insert_rule", tp: "css_insert_rule",
id, id,
rule, rule,
index, index,
}; };
} }
case 38: { case 38: {
const id = this.readUint(); if (id === null) { return resetPointer() } const id = this.readUint(); if (id === null) { return resetPointer() }
const index = this.readUint(); if (index === null) { return resetPointer() } const index = this.readUint(); if (index === null) { return resetPointer() }
return { return {
tp: "css_delete_rule", tp: "css_delete_rule",
id, id,
index, index,
}; };
} }
case 39: { case 39: {
const method = this.readString(); if (method === null) { return resetPointer() } const method = this.readString(); if (method === null) { return resetPointer() }
const url = this.readString(); if (url === null) { return resetPointer() } const url = this.readString(); if (url === null) { return resetPointer() }
@ -238,133 +238,133 @@ export default class RawMessageReader extends PrimitiveReader {
const response = this.readString(); if (response === null) { return resetPointer() } const response = this.readString(); if (response === null) { return resetPointer() }
const status = this.readUint(); if (status === null) { return resetPointer() } const status = this.readUint(); if (status === null) { return resetPointer() }
const timestamp = this.readUint(); if (timestamp === null) { return resetPointer() } const timestamp = this.readUint(); if (timestamp === null) { return resetPointer() }
const duration = this.readUint(); if (duration === null) { return resetPointer() } const duration = this.readUint(); if (duration === null) { return resetPointer() }
return { return {
tp: "fetch", tp: "fetch",
method, method,
url, url,
request, request,
response, response,
status, status,
timestamp, timestamp,
duration, duration,
}; };
} }
case 40: { case 40: {
const name = this.readString(); if (name === null) { return resetPointer() } const name = this.readString(); if (name === null) { return resetPointer() }
const duration = this.readUint(); if (duration === null) { return resetPointer() } const duration = this.readUint(); if (duration === null) { return resetPointer() }
const args = this.readString(); if (args === null) { return resetPointer() } const args = this.readString(); if (args === null) { return resetPointer() }
const result = this.readString(); if (result === null) { return resetPointer() } const result = this.readString(); if (result === null) { return resetPointer() }
return { return {
tp: "profiler", tp: "profiler",
name, name,
duration, duration,
args, args,
result, result,
}; };
} }
case 41: { case 41: {
const key = this.readString(); if (key === null) { return resetPointer() } const key = this.readString(); if (key === null) { return resetPointer() }
const value = this.readString(); if (value === null) { return resetPointer() } const value = this.readString(); if (value === null) { return resetPointer() }
return { return {
tp: "o_table", tp: "o_table",
key, key,
value, value,
}; };
} }
case 44: { case 44: {
const action = this.readString(); if (action === null) { return resetPointer() } const action = this.readString(); if (action === null) { return resetPointer() }
const state = this.readString(); if (state === null) { return resetPointer() } const state = this.readString(); if (state === null) { return resetPointer() }
const duration = this.readUint(); if (duration === null) { return resetPointer() } const duration = this.readUint(); if (duration === null) { return resetPointer() }
return { return {
tp: "redux", tp: "redux",
action, action,
state, state,
duration, duration,
}; };
} }
case 45: { case 45: {
const mutation = this.readString(); if (mutation === null) { return resetPointer() } const mutation = this.readString(); if (mutation === null) { return resetPointer() }
const state = this.readString(); if (state === null) { return resetPointer() } const state = this.readString(); if (state === null) { return resetPointer() }
return { return {
tp: "vuex", tp: "vuex",
mutation, mutation,
state, state,
}; };
} }
case 46: { case 46: {
const type = this.readString(); if (type === null) { return resetPointer() } const type = this.readString(); if (type === null) { return resetPointer() }
const payload = this.readString(); if (payload === null) { return resetPointer() } const payload = this.readString(); if (payload === null) { return resetPointer() }
return { return {
tp: "mob_x", tp: "mob_x",
type, type,
payload, payload,
}; };
} }
case 47: { case 47: {
const action = this.readString(); if (action === null) { return resetPointer() } const action = this.readString(); if (action === null) { return resetPointer() }
const state = this.readString(); if (state === null) { return resetPointer() } const state = this.readString(); if (state === null) { return resetPointer() }
const duration = this.readUint(); if (duration === null) { return resetPointer() } const duration = this.readUint(); if (duration === null) { return resetPointer() }
return { return {
tp: "ng_rx", tp: "ng_rx",
action, action,
state, state,
duration, duration,
}; };
} }
case 48: { case 48: {
const operationKind = this.readString(); if (operationKind === null) { return resetPointer() } const operationKind = this.readString(); if (operationKind === null) { return resetPointer() }
const operationName = this.readString(); if (operationName === null) { return resetPointer() } const operationName = this.readString(); if (operationName === null) { return resetPointer() }
const variables = this.readString(); if (variables === null) { return resetPointer() } const variables = this.readString(); if (variables === null) { return resetPointer() }
const response = this.readString(); if (response === null) { return resetPointer() } const response = this.readString(); if (response === null) { return resetPointer() }
return { return {
tp: "graph_ql", tp: "graph_ql",
operationKind, operationKind,
operationName, operationName,
variables, variables,
response, response,
}; };
} }
case 49: { case 49: {
const frames = this.readInt(); if (frames === null) { return resetPointer() } const frames = this.readInt(); if (frames === null) { return resetPointer() }
const ticks = this.readInt(); if (ticks === null) { return resetPointer() } const ticks = this.readInt(); if (ticks === null) { return resetPointer() }
const totalJSHeapSize = this.readUint(); if (totalJSHeapSize === null) { return resetPointer() } const totalJSHeapSize = this.readUint(); if (totalJSHeapSize === null) { return resetPointer() }
const usedJSHeapSize = this.readUint(); if (usedJSHeapSize === null) { return resetPointer() } const usedJSHeapSize = this.readUint(); if (usedJSHeapSize === null) { return resetPointer() }
return { return {
tp: "performance_track", tp: "performance_track",
frames, frames,
ticks, ticks,
totalJSHeapSize, totalJSHeapSize,
usedJSHeapSize, usedJSHeapSize,
}; };
} }
case 54: { case 54: {
const downlink = this.readUint(); if (downlink === null) { return resetPointer() } const downlink = this.readUint(); if (downlink === null) { return resetPointer() }
const type = this.readString(); if (type === null) { return resetPointer() } const type = this.readString(); if (type === null) { return resetPointer() }
return { return {
tp: "connection_information", tp: "connection_information",
downlink, downlink,
type, type,
}; };
} }
case 55: { case 55: {
const hidden = this.readBoolean(); if (hidden === null) { return resetPointer() } const hidden = this.readBoolean(); if (hidden === null) { return resetPointer() }
return { return {
tp: "set_page_visibility", tp: "set_page_visibility",
hidden, hidden,
}; };
} }
case 59: { case 59: {
const timestamp = this.readUint(); if (timestamp === null) { return resetPointer() } const timestamp = this.readUint(); if (timestamp === null) { return resetPointer() }
const duration = this.readUint(); if (duration === null) { return resetPointer() } const duration = this.readUint(); if (duration === null) { return resetPointer() }
@ -372,171 +372,185 @@ export default class RawMessageReader extends PrimitiveReader {
const containerType = this.readUint(); if (containerType === null) { return resetPointer() } const containerType = this.readUint(); if (containerType === null) { return resetPointer() }
const containerSrc = this.readString(); if (containerSrc === null) { return resetPointer() } const containerSrc = this.readString(); if (containerSrc === null) { return resetPointer() }
const containerId = this.readString(); if (containerId === null) { return resetPointer() } const containerId = this.readString(); if (containerId === null) { return resetPointer() }
const containerName = this.readString(); if (containerName === null) { return resetPointer() } const containerName = this.readString(); if (containerName === null) { return resetPointer() }
return { return {
tp: "long_task", tp: "long_task",
timestamp, timestamp,
duration, duration,
context, context,
containerType, containerType,
containerSrc, containerSrc,
containerId, containerId,
containerName, containerName,
}; };
} }
case 60: { case 60: {
const id = this.readUint(); if (id === null) { return resetPointer() } const id = this.readUint(); if (id === null) { return resetPointer() }
const name = this.readString(); if (name === null) { return resetPointer() } const name = this.readString(); if (name === null) { return resetPointer() }
const value = this.readString(); if (value === null) { return resetPointer() } const value = this.readString(); if (value === null) { return resetPointer() }
const baseURL = this.readString(); if (baseURL === null) { return resetPointer() } const baseURL = this.readString(); if (baseURL === null) { return resetPointer() }
return { return {
tp: "set_node_attribute_url_based", tp: "set_node_attribute_url_based",
id, id,
name, name,
value, value,
baseURL, baseURL,
}; };
} }
case 61: { case 61: {
const id = this.readUint(); if (id === null) { return resetPointer() } const id = this.readUint(); if (id === null) { return resetPointer() }
const data = this.readString(); if (data === null) { return resetPointer() } const data = this.readString(); if (data === null) { return resetPointer() }
const baseURL = this.readString(); if (baseURL === null) { return resetPointer() } const baseURL = this.readString(); if (baseURL === null) { return resetPointer() }
return { return {
tp: "set_css_data_url_based", tp: "set_css_data_url_based",
id, id,
data, data,
baseURL, baseURL,
}; };
} }
case 67: { case 67: {
const id = this.readUint(); if (id === null) { return resetPointer() } const id = this.readUint(); if (id === null) { return resetPointer() }
const rule = this.readString(); if (rule === null) { return resetPointer() } const rule = this.readString(); if (rule === null) { return resetPointer() }
const index = this.readUint(); if (index === null) { return resetPointer() } const index = this.readUint(); if (index === null) { return resetPointer() }
const baseURL = this.readString(); if (baseURL === null) { return resetPointer() } const baseURL = this.readString(); if (baseURL === null) { return resetPointer() }
return { return {
tp: "css_insert_rule_url_based", tp: "css_insert_rule_url_based",
id, id,
rule, rule,
index, index,
baseURL, baseURL,
}; };
} }
case 69: { case 69: {
const id = this.readUint(); if (id === null) { return resetPointer() } const id = this.readUint(); if (id === null) { return resetPointer() }
const hesitationTime = this.readUint(); if (hesitationTime === null) { return resetPointer() } const hesitationTime = this.readUint(); if (hesitationTime === null) { return resetPointer() }
const label = this.readString(); if (label === null) { return resetPointer() } const label = this.readString(); if (label === null) { return resetPointer() }
const selector = this.readString(); if (selector === null) { return resetPointer() } const selector = this.readString(); if (selector === null) { return resetPointer() }
return { return {
tp: "mouse_click", tp: "mouse_click",
id, id,
hesitationTime, hesitationTime,
label, label,
selector, selector,
}; };
} }
case 70: { case 70: {
const frameID = this.readUint(); if (frameID === null) { return resetPointer() } const frameID = this.readUint(); if (frameID === null) { return resetPointer() }
const id = this.readUint(); if (id === null) { return resetPointer() } const id = this.readUint(); if (id === null) { return resetPointer() }
return { return {
tp: "create_i_frame_document", tp: "create_i_frame_document",
frameID, frameID,
id, id,
}; };
} }
case 71: { case 71: {
const sheetID = this.readUint(); if (sheetID === null) { return resetPointer() } const sheetID = this.readUint(); if (sheetID === null) { return resetPointer() }
const text = this.readString(); if (text === null) { return resetPointer() } const text = this.readString(); if (text === null) { return resetPointer() }
const baseURL = this.readString(); if (baseURL === null) { return resetPointer() } const baseURL = this.readString(); if (baseURL === null) { return resetPointer() }
return { return {
tp: "adopted_ss_replace_url_based", tp: "adopted_ss_replace_url_based",
sheetID, sheetID,
text, text,
baseURL, baseURL,
}; };
} }
case 72: { case 72: {
const sheetID = this.readUint(); if (sheetID === null) { return resetPointer() } const sheetID = this.readUint(); if (sheetID === null) { return resetPointer() }
const text = this.readString(); if (text === null) { return resetPointer() } const text = this.readString(); if (text === null) { return resetPointer() }
return { return {
tp: "adopted_ss_replace", tp: "adopted_ss_replace",
sheetID, sheetID,
text, text,
}; };
} }
case 73: { case 73: {
const sheetID = this.readUint(); if (sheetID === null) { return resetPointer() } const sheetID = this.readUint(); if (sheetID === null) { return resetPointer() }
const rule = this.readString(); if (rule === null) { return resetPointer() } const rule = this.readString(); if (rule === null) { return resetPointer() }
const index = this.readUint(); if (index === null) { return resetPointer() } const index = this.readUint(); if (index === null) { return resetPointer() }
const baseURL = this.readString(); if (baseURL === null) { return resetPointer() } const baseURL = this.readString(); if (baseURL === null) { return resetPointer() }
return { return {
tp: "adopted_ss_insert_rule_url_based", tp: "adopted_ss_insert_rule_url_based",
sheetID, sheetID,
rule, rule,
index, index,
baseURL, baseURL,
}; };
} }
case 74: { case 74: {
const sheetID = this.readUint(); if (sheetID === null) { return resetPointer() } const sheetID = this.readUint(); if (sheetID === null) { return resetPointer() }
const rule = this.readString(); if (rule === null) { return resetPointer() } const rule = this.readString(); if (rule === null) { return resetPointer() }
const index = this.readUint(); if (index === null) { return resetPointer() } const index = this.readUint(); if (index === null) { return resetPointer() }
return { return {
tp: "adopted_ss_insert_rule", tp: "adopted_ss_insert_rule",
sheetID, sheetID,
rule, rule,
index, index,
}; };
} }
case 75: { case 75: {
const sheetID = this.readUint(); if (sheetID === null) { return resetPointer() } const sheetID = this.readUint(); if (sheetID === null) { return resetPointer() }
const index = this.readUint(); if (index === null) { return resetPointer() } const index = this.readUint(); if (index === null) { return resetPointer() }
return { return {
tp: "adopted_ss_delete_rule", tp: "adopted_ss_delete_rule",
sheetID, sheetID,
index, index,
}; };
} }
case 76: { case 76: {
const sheetID = this.readUint(); if (sheetID === null) { return resetPointer() } const sheetID = this.readUint(); if (sheetID === null) { return resetPointer() }
const id = this.readUint(); if (id === null) { return resetPointer() } const id = this.readUint(); if (id === null) { return resetPointer() }
return { return {
tp: "adopted_ss_add_owner", tp: "adopted_ss_add_owner",
sheetID, sheetID,
id, id,
}; };
} }
case 77: { case 77: {
const sheetID = this.readUint(); if (sheetID === null) { return resetPointer() } const sheetID = this.readUint(); if (sheetID === null) { return resetPointer() }
const id = this.readUint(); if (id === null) { return resetPointer() } const id = this.readUint(); if (id === null) { return resetPointer() }
return { return {
tp: "adopted_ss_remove_owner", tp: "adopted_ss_remove_owner",
sheetID, sheetID,
id, id,
}; };
} }
case 79: { case 79: {
const mutation = this.readString(); if (mutation === null) { return resetPointer() } const mutation = this.readString(); if (mutation === null) { return resetPointer() }
const state = this.readString(); if (state === null) { return resetPointer() } const state = this.readString(); if (state === null) { return resetPointer() }
return { return {
tp: "zustand", tp: "zustand",
mutation, mutation,
state, state,
}; };
} }
case 83: {
const id = this.readUint(); if (id === null) { return resetPointer() }
const styles = this.readString(); if (styles === null) { return resetPointer() }
const sheetID = this.readString(); if (sheetID === null) { return resetPointer() }
const baseURL = this.readString(); if (baseURL === null) { return resetPointer() }
return {
tp: "replace_vcss",
id,
styles,
sheetID,
baseURL,
};
}
case 90: { case 90: {
const timestamp = this.readUint(); if (timestamp === null) { return resetPointer() } const timestamp = this.readUint(); if (timestamp === null) { return resetPointer() }
const projectID = this.readUint(); if (projectID === null) { return resetPointer() } const projectID = this.readUint(); if (projectID === null) { return resetPointer() }
@ -547,9 +561,9 @@ export default class RawMessageReader extends PrimitiveReader {
const userOSVersion = this.readString(); if (userOSVersion === null) { return resetPointer() } const userOSVersion = this.readString(); if (userOSVersion === null) { return resetPointer() }
const userDevice = this.readString(); if (userDevice === null) { return resetPointer() } const userDevice = this.readString(); if (userDevice === null) { return resetPointer() }
const userDeviceType = this.readString(); if (userDeviceType === null) { return resetPointer() } const userDeviceType = this.readString(); if (userDeviceType === null) { return resetPointer() }
const userCountry = this.readString(); if (userCountry === null) { return resetPointer() } const userCountry = this.readString(); if (userCountry === null) { return resetPointer() }
return { return {
tp: "ios_session_start", tp: "ios_session_start",
timestamp, timestamp,
projectID, projectID,
trackerVersion, trackerVersion,
@ -559,86 +573,86 @@ export default class RawMessageReader extends PrimitiveReader {
userOSVersion, userOSVersion,
userDevice, userDevice,
userDeviceType, userDeviceType,
userCountry, userCountry,
}; };
} }
case 93: { case 93: {
const timestamp = this.readUint(); if (timestamp === null) { return resetPointer() } const timestamp = this.readUint(); if (timestamp === null) { return resetPointer() }
const length = this.readUint(); if (length === null) { return resetPointer() } const length = this.readUint(); if (length === null) { return resetPointer() }
const name = this.readString(); if (name === null) { return resetPointer() } const name = this.readString(); if (name === null) { return resetPointer() }
const payload = this.readString(); if (payload === null) { return resetPointer() } const payload = this.readString(); if (payload === null) { return resetPointer() }
return { return {
tp: "ios_custom_event", tp: "ios_custom_event",
timestamp, timestamp,
length, length,
name, name,
payload, payload,
}; };
} }
case 96: { case 96: {
const timestamp = this.readUint(); if (timestamp === null) { return resetPointer() } const timestamp = this.readUint(); if (timestamp === null) { return resetPointer() }
const length = this.readUint(); if (length === null) { return resetPointer() } const length = this.readUint(); if (length === null) { return resetPointer() }
const x = this.readUint(); if (x === null) { return resetPointer() } const x = this.readUint(); if (x === null) { return resetPointer() }
const y = this.readUint(); if (y === null) { return resetPointer() } const y = this.readUint(); if (y === null) { return resetPointer() }
const width = this.readUint(); if (width === null) { return resetPointer() } const width = this.readUint(); if (width === null) { return resetPointer() }
const height = this.readUint(); if (height === null) { return resetPointer() } const height = this.readUint(); if (height === null) { return resetPointer() }
return { return {
tp: "ios_screen_changes", tp: "ios_screen_changes",
timestamp, timestamp,
length, length,
x, x,
y, y,
width, width,
height, height,
}; };
} }
case 100: { case 100: {
const timestamp = this.readUint(); if (timestamp === null) { return resetPointer() } const timestamp = this.readUint(); if (timestamp === null) { return resetPointer() }
const length = this.readUint(); if (length === null) { return resetPointer() } const length = this.readUint(); if (length === null) { return resetPointer() }
const label = this.readString(); if (label === null) { return resetPointer() } const label = this.readString(); if (label === null) { return resetPointer() }
const x = this.readUint(); if (x === null) { return resetPointer() } const x = this.readUint(); if (x === null) { return resetPointer() }
const y = this.readUint(); if (y === null) { return resetPointer() } const y = this.readUint(); if (y === null) { return resetPointer() }
return { return {
tp: "ios_click_event", tp: "ios_click_event",
timestamp, timestamp,
length, length,
label, label,
x, x,
y, y,
}; };
} }
case 102: { case 102: {
const timestamp = this.readUint(); if (timestamp === null) { return resetPointer() } const timestamp = this.readUint(); if (timestamp === null) { return resetPointer() }
const length = this.readUint(); if (length === null) { return resetPointer() } const length = this.readUint(); if (length === null) { return resetPointer() }
const name = this.readString(); if (name === null) { return resetPointer() } const name = this.readString(); if (name === null) { return resetPointer() }
const value = this.readUint(); if (value === null) { return resetPointer() } const value = this.readUint(); if (value === null) { return resetPointer() }
return { return {
tp: "ios_performance_event", tp: "ios_performance_event",
timestamp, timestamp,
length, length,
name, name,
value, value,
}; };
} }
case 103: { case 103: {
const timestamp = this.readUint(); if (timestamp === null) { return resetPointer() } const timestamp = this.readUint(); if (timestamp === null) { return resetPointer() }
const length = this.readUint(); if (length === null) { return resetPointer() } const length = this.readUint(); if (length === null) { return resetPointer() }
const severity = this.readString(); if (severity === null) { return resetPointer() } const severity = this.readString(); if (severity === null) { return resetPointer() }
const content = this.readString(); if (content === null) { return resetPointer() } const content = this.readString(); if (content === null) { return resetPointer() }
return { return {
tp: "ios_log", tp: "ios_log",
timestamp, timestamp,
length, length,
severity, severity,
content, content,
}; };
} }
case 105: { case 105: {
const timestamp = this.readUint(); if (timestamp === null) { return resetPointer() } const timestamp = this.readUint(); if (timestamp === null) { return resetPointer() }
const length = this.readUint(); if (length === null) { return resetPointer() } const length = this.readUint(); if (length === null) { return resetPointer() }
@ -648,9 +662,9 @@ export default class RawMessageReader extends PrimitiveReader {
const url = this.readString(); if (url === null) { return resetPointer() } const url = this.readString(); if (url === null) { return resetPointer() }
const success = this.readBoolean(); if (success === null) { return resetPointer() } const success = this.readBoolean(); if (success === null) { return resetPointer() }
const method = this.readString(); if (method === null) { return resetPointer() } const method = this.readString(); if (method === null) { return resetPointer() }
const status = this.readUint(); if (status === null) { return resetPointer() } const status = this.readUint(); if (status === null) { return resetPointer() }
return { return {
tp: "ios_network_call", tp: "ios_network_call",
timestamp, timestamp,
length, length,
duration, duration,
@ -659,10 +673,10 @@ export default class RawMessageReader extends PrimitiveReader {
url, url,
success, success,
method, method,
status, status,
}; };
} }
default: default:
throw new Error(`Unrecognizable message type: ${ tp }; Pointer at the position ${this.p} of ${this.buf.length}`) throw new Error(`Unrecognizable message type: ${ tp }; Pointer at the position ${this.p} of ${this.buf.length}`)
return null; return null;

View file

@ -2,7 +2,7 @@
import type { Timed } from './timed' import type { Timed } from './timed'
import type { RawMessage } from './raw' import type { RawMessage } from './raw'
import type { import type {
RawTimestamp, RawTimestamp,
RawSetPageLocation, RawSetPageLocation,
RawSetViewportSize, RawSetViewportSize,
@ -48,6 +48,7 @@ import type {
RawAdoptedSsAddOwner, RawAdoptedSsAddOwner,
RawAdoptedSsRemoveOwner, RawAdoptedSsRemoveOwner,
RawZustand, RawZustand,
RawReplaceVcss,
RawIosSessionStart, RawIosSessionStart,
RawIosCustomEvent, RawIosCustomEvent,
RawIosScreenChanges, RawIosScreenChanges,
@ -150,6 +151,8 @@ export type AdoptedSsRemoveOwner = RawAdoptedSsRemoveOwner & Timed
export type Zustand = RawZustand & Timed export type Zustand = RawZustand & Timed
export type ReplaceVcss = RawReplaceVcss & Timed
export type IosSessionStart = RawIosSessionStart & Timed export type IosSessionStart = RawIosSessionStart & Timed
export type IosCustomEvent = RawIosCustomEvent & Timed export type IosCustomEvent = RawIosCustomEvent & Timed

View file

@ -306,6 +306,14 @@ export interface RawZustand {
state: string, state: string,
} }
export interface RawReplaceVcss {
tp: "replace_vcss",
id: number,
styles: string,
sheetID: string,
baseURL: string,
}
export interface RawIosSessionStart { export interface RawIosSessionStart {
tp: "ios_session_start", tp: "ios_session_start",
timestamp: number, timestamp: number,
@ -377,4 +385,4 @@ export interface RawIosNetworkCall {
} }
export type RawMessage = RawTimestamp | RawSetPageLocation | RawSetViewportSize | RawSetViewportScroll | RawCreateDocument | RawCreateElementNode | RawCreateTextNode | RawMoveNode | RawRemoveNode | RawSetNodeAttribute | RawRemoveNodeAttribute | RawSetNodeData | RawSetCssData | RawSetNodeScroll | RawSetInputValue | RawSetInputChecked | RawMouseMove | RawConsoleLog | RawCssInsertRule | RawCssDeleteRule | RawFetch | RawProfiler | RawOTable | RawRedux | RawVuex | RawMobX | RawNgRx | RawGraphQl | RawPerformanceTrack | RawConnectionInformation | RawSetPageVisibility | RawLongTask | RawSetNodeAttributeURLBased | RawSetCssDataURLBased | RawCssInsertRuleURLBased | RawMouseClick | RawCreateIFrameDocument | RawAdoptedSsReplaceURLBased | RawAdoptedSsReplace | RawAdoptedSsInsertRuleURLBased | RawAdoptedSsInsertRule | RawAdoptedSsDeleteRule | RawAdoptedSsAddOwner | RawAdoptedSsRemoveOwner | RawZustand | RawIosSessionStart | RawIosCustomEvent | RawIosScreenChanges | RawIosClickEvent | RawIosPerformanceEvent | RawIosLog | RawIosNetworkCall; export type RawMessage = RawTimestamp | RawSetPageLocation | RawSetViewportSize | RawSetViewportScroll | RawCreateDocument | RawCreateElementNode | RawCreateTextNode | RawMoveNode | RawRemoveNode | RawSetNodeAttribute | RawRemoveNodeAttribute | RawSetNodeData | RawSetCssData | RawSetNodeScroll | RawSetInputValue | RawSetInputChecked | RawMouseMove | RawConsoleLog | RawCssInsertRule | RawCssDeleteRule | RawFetch | RawProfiler | RawOTable | RawRedux | RawVuex | RawMobX | RawNgRx | RawGraphQl | RawPerformanceTrack | RawConnectionInformation | RawSetPageVisibility | RawLongTask | RawSetNodeAttributeURLBased | RawSetCssDataURLBased | RawCssInsertRuleURLBased | RawMouseClick | RawCreateIFrameDocument | RawAdoptedSsReplaceURLBased | RawAdoptedSsReplace | RawAdoptedSsInsertRuleURLBased | RawAdoptedSsInsertRule | RawAdoptedSsDeleteRule | RawAdoptedSsAddOwner | RawAdoptedSsRemoveOwner | RawZustand | RawReplaceVcss | RawIosSessionStart | RawIosCustomEvent | RawIosScreenChanges | RawIosClickEvent | RawIosPerformanceEvent | RawIosLog | RawIosNetworkCall;

View file

@ -61,6 +61,7 @@ export const TP_MAP = {
76: "adopted_ss_add_owner", 76: "adopted_ss_add_owner",
77: "adopted_ss_remove_owner", 77: "adopted_ss_remove_owner",
79: "zustand", 79: "zustand",
83: "replace_vcss",
90: "ios_session_start", 90: "ios_session_start",
93: "ios_custom_event", 93: "ios_custom_event",
96: "ios_screen_changes", 96: "ios_screen_changes",
@ -69,5 +70,3 @@ export const TP_MAP = {
103: "ios_log", 103: "ios_log",
105: "ios_network_call", 105: "ios_network_call",
} as const } as const

View file

@ -1,6 +1,6 @@
// Auto-generated, do not edit // Auto-generated, do not edit
import type { RawMessage } from './raw' import type { RawMessage } from './raw'
type TrBatchMetadata = [ type TrBatchMetadata = [
@ -44,7 +44,7 @@ type TrSetViewportScroll = [
type TrCreateDocument = [ type TrCreateDocument = [
type: 7, type: 7,
] ]
type TrCreateElementNode = [ type TrCreateElementNode = [
@ -388,54 +388,61 @@ type TrZustand = [
state: string, state: string,
] ]
type TrReplaceVCSS = [
type: 83,
id: number,
styles: string,
sheetID: string,
baseURL: string,
]
export type TrackerMessage = TrBatchMetadata | TrPartitionedMessage | TrTimestamp | TrSetPageLocation | TrSetViewportSize | TrSetViewportScroll | TrCreateDocument | TrCreateElementNode | TrCreateTextNode | TrMoveNode | TrRemoveNode | TrSetNodeAttribute | TrRemoveNodeAttribute | TrSetNodeData | TrSetNodeScroll | TrSetInputTarget | TrSetInputValue | TrSetInputChecked | TrMouseMove | TrConsoleLog | TrPageLoadTiming | TrPageRenderTiming | TrJSException | TrRawCustomEvent | TrUserID | TrUserAnonymousID | TrMetadata | TrCSSInsertRule | TrCSSDeleteRule | TrFetch | TrProfiler | TrOTable | TrStateAction | TrRedux | TrVuex | TrMobX | TrNgRx | TrGraphQL | TrPerformanceTrack | TrResourceTiming | TrConnectionInformation | TrSetPageVisibility | TrLongTask | TrSetNodeAttributeURLBased | TrSetCSSDataURLBased | TrTechnicalInfo | TrCustomIssue | TrCSSInsertRuleURLBased | TrMouseClick | TrCreateIFrameDocument | TrAdoptedSSReplaceURLBased | TrAdoptedSSInsertRuleURLBased | TrAdoptedSSDeleteRule | TrAdoptedSSAddOwner | TrAdoptedSSRemoveOwner | TrZustand export type TrackerMessage = TrBatchMetadata | TrPartitionedMessage | TrTimestamp | TrSetPageLocation | TrSetViewportSize | TrSetViewportScroll | TrCreateDocument | TrCreateElementNode | TrCreateTextNode | TrMoveNode | TrRemoveNode | TrSetNodeAttribute | TrRemoveNodeAttribute | TrSetNodeData | TrSetNodeScroll | TrSetInputTarget | TrSetInputValue | TrSetInputChecked | TrMouseMove | TrConsoleLog | TrPageLoadTiming | TrPageRenderTiming | TrJSException | TrRawCustomEvent | TrUserID | TrUserAnonymousID | TrMetadata | TrCSSInsertRule | TrCSSDeleteRule | TrFetch | TrProfiler | TrOTable | TrStateAction | TrRedux | TrVuex | TrMobX | TrNgRx | TrGraphQL | TrPerformanceTrack | TrResourceTiming | TrConnectionInformation | TrSetPageVisibility | TrLongTask | TrSetNodeAttributeURLBased | TrSetCSSDataURLBased | TrTechnicalInfo | TrCustomIssue | TrCSSInsertRuleURLBased | TrMouseClick | TrCreateIFrameDocument | TrAdoptedSSReplaceURLBased | TrAdoptedSSInsertRuleURLBased | TrAdoptedSSDeleteRule | TrAdoptedSSAddOwner | TrAdoptedSSRemoveOwner | TrZustand | TrReplaceVCSS
export default function translate(tMsg: TrackerMessage): RawMessage | null { export default function translate(tMsg: TrackerMessage): RawMessage | null {
switch(tMsg[0]) { switch(tMsg[0]) {
case 0: { case 0: {
return { return {
tp: "timestamp", tp: "timestamp",
timestamp: tMsg[1], timestamp: tMsg[1],
} }
} }
case 4: { case 4: {
return { return {
tp: "set_page_location", tp: "set_page_location",
url: tMsg[1], url: tMsg[1],
referrer: tMsg[2], referrer: tMsg[2],
navigationStart: tMsg[3], navigationStart: tMsg[3],
} }
} }
case 5: { case 5: {
return { return {
tp: "set_viewport_size", tp: "set_viewport_size",
width: tMsg[1], width: tMsg[1],
height: tMsg[2], height: tMsg[2],
} }
} }
case 6: { case 6: {
return { return {
tp: "set_viewport_scroll", tp: "set_viewport_scroll",
x: tMsg[1], x: tMsg[1],
y: tMsg[2], y: tMsg[2],
} }
} }
case 7: { case 7: {
return { return {
tp: "create_document", tp: "create_document",
} }
} }
case 8: { case 8: {
return { return {
tp: "create_element_node", tp: "create_element_node",
id: tMsg[1], id: tMsg[1],
parentID: tMsg[2], parentID: tMsg[2],
index: tMsg[3], index: tMsg[3],
@ -443,119 +450,119 @@ export default function translate(tMsg: TrackerMessage): RawMessage | null {
svg: tMsg[5], svg: tMsg[5],
} }
} }
case 9: { case 9: {
return { return {
tp: "create_text_node", tp: "create_text_node",
id: tMsg[1], id: tMsg[1],
parentID: tMsg[2], parentID: tMsg[2],
index: tMsg[3], index: tMsg[3],
} }
} }
case 10: { case 10: {
return { return {
tp: "move_node", tp: "move_node",
id: tMsg[1], id: tMsg[1],
parentID: tMsg[2], parentID: tMsg[2],
index: tMsg[3], index: tMsg[3],
} }
} }
case 11: { case 11: {
return { return {
tp: "remove_node", tp: "remove_node",
id: tMsg[1], id: tMsg[1],
} }
} }
case 12: { case 12: {
return { return {
tp: "set_node_attribute", tp: "set_node_attribute",
id: tMsg[1], id: tMsg[1],
name: tMsg[2], name: tMsg[2],
value: tMsg[3], value: tMsg[3],
} }
} }
case 13: { case 13: {
return { return {
tp: "remove_node_attribute", tp: "remove_node_attribute",
id: tMsg[1], id: tMsg[1],
name: tMsg[2], name: tMsg[2],
} }
} }
case 14: { case 14: {
return { return {
tp: "set_node_data", tp: "set_node_data",
id: tMsg[1], id: tMsg[1],
data: tMsg[2], data: tMsg[2],
} }
} }
case 16: { case 16: {
return { return {
tp: "set_node_scroll", tp: "set_node_scroll",
id: tMsg[1], id: tMsg[1],
x: tMsg[2], x: tMsg[2],
y: tMsg[3], y: tMsg[3],
} }
} }
case 18: { case 18: {
return { return {
tp: "set_input_value", tp: "set_input_value",
id: tMsg[1], id: tMsg[1],
value: tMsg[2], value: tMsg[2],
mask: tMsg[3], mask: tMsg[3],
} }
} }
case 19: { case 19: {
return { return {
tp: "set_input_checked", tp: "set_input_checked",
id: tMsg[1], id: tMsg[1],
checked: tMsg[2], checked: tMsg[2],
} }
} }
case 20: { case 20: {
return { return {
tp: "mouse_move", tp: "mouse_move",
x: tMsg[1], x: tMsg[1],
y: tMsg[2], y: tMsg[2],
} }
} }
case 22: { case 22: {
return { return {
tp: "console_log", tp: "console_log",
level: tMsg[1], level: tMsg[1],
value: tMsg[2], value: tMsg[2],
} }
} }
case 37: { case 37: {
return { return {
tp: "css_insert_rule", tp: "css_insert_rule",
id: tMsg[1], id: tMsg[1],
rule: tMsg[2], rule: tMsg[2],
index: tMsg[3], index: tMsg[3],
} }
} }
case 38: { case 38: {
return { return {
tp: "css_delete_rule", tp: "css_delete_rule",
id: tMsg[1], id: tMsg[1],
index: tMsg[2], index: tMsg[2],
} }
} }
case 39: { case 39: {
return { return {
tp: "fetch", tp: "fetch",
method: tMsg[1], method: tMsg[1],
url: tMsg[2], url: tMsg[2],
request: tMsg[3], request: tMsg[3],
@ -565,97 +572,97 @@ export default function translate(tMsg: TrackerMessage): RawMessage | null {
duration: tMsg[7], duration: tMsg[7],
} }
} }
case 40: { case 40: {
return { return {
tp: "profiler", tp: "profiler",
name: tMsg[1], name: tMsg[1],
duration: tMsg[2], duration: tMsg[2],
args: tMsg[3], args: tMsg[3],
result: tMsg[4], result: tMsg[4],
} }
} }
case 41: { case 41: {
return { return {
tp: "o_table", tp: "o_table",
key: tMsg[1], key: tMsg[1],
value: tMsg[2], value: tMsg[2],
} }
} }
case 44: { case 44: {
return { return {
tp: "redux", tp: "redux",
action: tMsg[1], action: tMsg[1],
state: tMsg[2], state: tMsg[2],
duration: tMsg[3], duration: tMsg[3],
} }
} }
case 45: { case 45: {
return { return {
tp: "vuex", tp: "vuex",
mutation: tMsg[1], mutation: tMsg[1],
state: tMsg[2], state: tMsg[2],
} }
} }
case 46: { case 46: {
return { return {
tp: "mob_x", tp: "mob_x",
type: tMsg[1], type: tMsg[1],
payload: tMsg[2], payload: tMsg[2],
} }
} }
case 47: { case 47: {
return { return {
tp: "ng_rx", tp: "ng_rx",
action: tMsg[1], action: tMsg[1],
state: tMsg[2], state: tMsg[2],
duration: tMsg[3], duration: tMsg[3],
} }
} }
case 48: { case 48: {
return { return {
tp: "graph_ql", tp: "graph_ql",
operationKind: tMsg[1], operationKind: tMsg[1],
operationName: tMsg[2], operationName: tMsg[2],
variables: tMsg[3], variables: tMsg[3],
response: tMsg[4], response: tMsg[4],
} }
} }
case 49: { case 49: {
return { return {
tp: "performance_track", tp: "performance_track",
frames: tMsg[1], frames: tMsg[1],
ticks: tMsg[2], ticks: tMsg[2],
totalJSHeapSize: tMsg[3], totalJSHeapSize: tMsg[3],
usedJSHeapSize: tMsg[4], usedJSHeapSize: tMsg[4],
} }
} }
case 54: { case 54: {
return { return {
tp: "connection_information", tp: "connection_information",
downlink: tMsg[1], downlink: tMsg[1],
type: tMsg[2], type: tMsg[2],
} }
} }
case 55: { case 55: {
return { return {
tp: "set_page_visibility", tp: "set_page_visibility",
hidden: tMsg[1], hidden: tMsg[1],
} }
} }
case 59: { case 59: {
return { return {
tp: "long_task", tp: "long_task",
timestamp: tMsg[1], timestamp: tMsg[1],
duration: tMsg[2], duration: tMsg[2],
context: tMsg[3], context: tMsg[3],
@ -665,107 +672,117 @@ export default function translate(tMsg: TrackerMessage): RawMessage | null {
containerName: tMsg[7], containerName: tMsg[7],
} }
} }
case 60: { case 60: {
return { return {
tp: "set_node_attribute_url_based", tp: "set_node_attribute_url_based",
id: tMsg[1], id: tMsg[1],
name: tMsg[2], name: tMsg[2],
value: tMsg[3], value: tMsg[3],
baseURL: tMsg[4], baseURL: tMsg[4],
} }
} }
case 61: { case 61: {
return { return {
tp: "set_css_data_url_based", tp: "set_css_data_url_based",
id: tMsg[1], id: tMsg[1],
data: tMsg[2], data: tMsg[2],
baseURL: tMsg[3], baseURL: tMsg[3],
} }
} }
case 67: { case 67: {
return { return {
tp: "css_insert_rule_url_based", tp: "css_insert_rule_url_based",
id: tMsg[1], id: tMsg[1],
rule: tMsg[2], rule: tMsg[2],
index: tMsg[3], index: tMsg[3],
baseURL: tMsg[4], baseURL: tMsg[4],
} }
} }
case 69: { case 69: {
return { return {
tp: "mouse_click", tp: "mouse_click",
id: tMsg[1], id: tMsg[1],
hesitationTime: tMsg[2], hesitationTime: tMsg[2],
label: tMsg[3], label: tMsg[3],
selector: tMsg[4], selector: tMsg[4],
} }
} }
case 70: { case 70: {
return { return {
tp: "create_i_frame_document", tp: "create_i_frame_document",
frameID: tMsg[1], frameID: tMsg[1],
id: tMsg[2], id: tMsg[2],
} }
} }
case 71: { case 71: {
return { return {
tp: "adopted_ss_replace_url_based", tp: "adopted_ss_replace_url_based",
sheetID: tMsg[1], sheetID: tMsg[1],
text: tMsg[2], text: tMsg[2],
baseURL: tMsg[3], baseURL: tMsg[3],
} }
} }
case 73: { case 73: {
return { return {
tp: "adopted_ss_insert_rule_url_based", tp: "adopted_ss_insert_rule_url_based",
sheetID: tMsg[1], sheetID: tMsg[1],
rule: tMsg[2], rule: tMsg[2],
index: tMsg[3], index: tMsg[3],
baseURL: tMsg[4], baseURL: tMsg[4],
} }
} }
case 75: { case 75: {
return { return {
tp: "adopted_ss_delete_rule", tp: "adopted_ss_delete_rule",
sheetID: tMsg[1], sheetID: tMsg[1],
index: tMsg[2], index: tMsg[2],
} }
} }
case 76: { case 76: {
return { return {
tp: "adopted_ss_add_owner", tp: "adopted_ss_add_owner",
sheetID: tMsg[1], sheetID: tMsg[1],
id: tMsg[2], id: tMsg[2],
} }
} }
case 77: { case 77: {
return { return {
tp: "adopted_ss_remove_owner", tp: "adopted_ss_remove_owner",
sheetID: tMsg[1], sheetID: tMsg[1],
id: tMsg[2], id: tMsg[2],
} }
} }
case 79: { case 79: {
return { return {
tp: "zustand", tp: "zustand",
mutation: tMsg[1], mutation: tMsg[1],
state: tMsg[2], state: tMsg[2],
} }
} }
case 83: {
return {
tp: "replace_vcss",
id: tMsg[1],
styles: tMsg[2],
sheetID: tMsg[3],
baseURL: tMsg[4],
}
}
default: default:
return null return null
} }
} }

View file

@ -460,3 +460,10 @@ message 79, 'Zustand' do
string 'Mutation' string 'Mutation'
string 'State' string 'State'
end end
message 83, 'ReplaceVCSS' do
uint 'ID'
string 'Styles'
string 'SheetID'
string 'BaseURL'
end

View file

@ -0,0 +1,42 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tracker_1 = require("@openreplay/tracker/cjs");
const index_js_1 = require("./syncod/index.js");
function processMutationAndState(app, options, encoder, mutation, state) {
if (options.filter(mutation, state)) {
try {
const _mutation = encoder.encode(options.mutationTransformer(mutation));
const _state = encoder.encode(options.transformer(state));
const _table = encoder.commit();
for (let key in _table)
app.send(tracker_1.Messages.OTable(key, _table[key]));
app.send(tracker_1.Messages.Zustand(_mutation, _state));
}
catch (e) {
encoder.clear();
app.debug.error(e);
}
}
}
function default_1(opts = {}) {
const options = Object.assign({
filter: () => true,
transformer: state => state,
mutationTransformer: mutation => mutation,
}, opts);
return (app) => {
if (app === null) {
return Function.prototype;
}
const encoder = new index_js_1.Encoder(index_js_1.sha1, 50);
const state = {};
return (storeName = Math.random().toString(36).substring(2, 9)) => (config) => (set, get, api) => config((...args) => {
set(...args);
const newState = get();
state[storeName] = newState;
const triggeredActions = args.map(action => { var _a; return (_a = action.toString) === null || _a === void 0 ? void 0 : _a.call(action); });
processMutationAndState(app, options, encoder, triggeredActions, state);
}, get, api);
};
}
exports.default = default_1;

View file

@ -0,0 +1 @@
{ "type": "commonjs" }

View file

@ -0,0 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const chars = {};
[
"DEL",
"UNDEF",
"TRUE",
"FALSE",
"NUMBER",
"BIGINT",
"FUNCTION",
"STRING",
"SYMBOL",
"NULL",
"OBJECT",
"ARRAY"
].forEach((k, i) => (chars[k] = String.fromCharCode(i + 0xe000)));
exports.default = chars;

View file

@ -0,0 +1,213 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const chars_js_1 = require("./chars.js");
// @ts-ignore
// @ts-ignore
class Encoder {
// @ts-ignore
constructor(hash, slen = Infinity) {
// @ts-ignore
this._hash = hash;
// @ts-ignore
this._slen = slen;
// @ts-ignore
this._refmap = new Map();
// @ts-ignore
this._refset = new Set();
// @ts-ignore
}
// @ts-ignore
// @ts-ignore
_ref_str(str) {
// @ts-ignore
if (str.length < this._slen && str.indexOf(chars_js_1.default.DEL) === -1) {
// @ts-ignore
return str;
// @ts-ignore
}
// @ts-ignore
let ref = this._refmap.get(str);
// @ts-ignore
if (ref === undefined) {
// @ts-ignore
ref = this._hash(str);
// @ts-ignore
this._refmap.set(str, ref);
// @ts-ignore
}
// @ts-ignore
return ref;
// @ts-ignore
}
// @ts-ignore
// @ts-ignore
_encode_prim(obj) {
// @ts-ignore
switch (typeof obj) {
// @ts-ignore
case "undefined":
// @ts-ignore
return chars_js_1.default.UNDEF;
// @ts-ignore
case "boolean":
// @ts-ignore
return obj ? chars_js_1.default.TRUE : chars_js_1.default.FALSE;
// @ts-ignore
case "number":
// @ts-ignore
return chars_js_1.default.NUMBER + obj.toString();
// @ts-ignore
case "bigint":
// @ts-ignore
return chars_js_1.default.BIGINT + obj.toString();
// @ts-ignore
case "function":
// @ts-ignore
return chars_js_1.default.FUNCTION;
// @ts-ignore
case "string":
// @ts-ignore
return chars_js_1.default.STRING + this._ref_str(obj);
// @ts-ignore
case "symbol":
// @ts-ignore
return chars_js_1.default.SYMBOL + this._ref_str(obj.toString().slice(7, -1));
// @ts-ignore
}
// @ts-ignore
if (obj === null) {
// @ts-ignore
return chars_js_1.default.NULL;
// @ts-ignore
}
// @ts-ignore
}
// @ts-ignore
// @ts-ignore
_encode_obj(obj, ref = this._refmap.get(obj)) {
// @ts-ignore
return (Array.isArray(obj) ? chars_js_1.default.ARRAY : chars_js_1.default.OBJECT) + ref;
// @ts-ignore
}
// @ts-ignore
// @ts-ignore
_encode_term(obj) {
// @ts-ignore
return this._encode_prim(obj) || this._encode_obj(obj);
// @ts-ignore
}
// @ts-ignore
// @ts-ignore
_encode_deep(obj, depth) {
// @ts-ignore
const enc = this._encode_prim(obj);
// @ts-ignore
if (enc !== undefined) {
// @ts-ignore
return enc;
// @ts-ignore
}
// @ts-ignore
const ref = this._refmap.get(obj);
// @ts-ignore
switch (typeof ref) {
// @ts-ignore
case "number":
// @ts-ignore
return (depth - ref).toString();
// @ts-ignore
case "string":
// @ts-ignore
return this._encode_obj(obj, ref);
// @ts-ignore
}
// @ts-ignore
this._refmap.set(obj, depth);
// @ts-ignore
const hash = this._hash(
// @ts-ignore
(Array.isArray(obj)
// @ts-ignore
? obj.map(v => this._encode_deep(v, depth + 1))
// @ts-ignore
: Object.keys(obj)
// @ts-ignore
.sort()
// @ts-ignore
.map(
// @ts-ignore
k =>
// @ts-ignore
this._ref_str(k) + chars_js_1.default.DEL + this._encode_deep(obj[k], depth + 1)
// @ts-ignore
)
// @ts-ignore
).join(chars_js_1.default.DEL)
// @ts-ignore
);
// @ts-ignore
this._refmap.set(obj, hash);
// @ts-ignore
return this._encode_obj(obj, hash);
// @ts-ignore
}
// @ts-ignore
// @ts-ignore
encode(obj) {
// @ts-ignore
return this._encode_deep(obj, 0);
// @ts-ignore
}
// @ts-ignore
// @ts-ignore
commit() {
// @ts-ignore
const dict = {};
// @ts-ignore
this._refmap.forEach((ref, obj) => {
// @ts-ignore
if (this._refset.has(ref)) {
// @ts-ignore
return;
// @ts-ignore
}
// @ts-ignore
this._refset.add(ref);
// @ts-ignore
if (typeof obj !== "string") {
// @ts-ignore
obj = (Array.isArray(obj)
// @ts-ignore
? obj.map(v => this._encode_term(v))
// @ts-ignore
: Object.keys(obj).map(
// @ts-ignore
k => this._ref_str(k) + chars_js_1.default.DEL + this._encode_term(obj[k])
// @ts-ignore
)
// @ts-ignore
).join(chars_js_1.default.DEL);
// @ts-ignore
}
// @ts-ignore
dict[ref] = obj;
// @ts-ignore
});
// @ts-ignore
this._refmap.clear();
// @ts-ignore
return dict;
// @ts-ignore
}
// @ts-ignore
// @ts-ignore
clear() {
// @ts-ignore
this._refmap.clear();
// @ts-ignore
this._refset.clear();
// @ts-ignore
}
}
exports.default = Encoder;
// @ts-ignore

View file

@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.sha1 = exports.Encoder = void 0;
// TODO: SSR solution for all asayer libraries
const encoder_js_1 = require("./encoder.js");
exports.Encoder = encoder_js_1.default;
const sha1_js_1 = require("./sha1.js");
exports.sha1 = sha1_js_1.default;

View file

@ -0,0 +1,96 @@
"use strict";
/*
* A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
* in FIPS PUB 180-1
* Version 2.1a Copyright Paul Johnston 2000 - 2002.
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
* Distributed under the BSD License
* See http://pajhome.org.uk/crypt/md5 for details.
*/
Object.defineProperty(exports, "__esModule", { value: true });
function core_sha1(x, len) {
x[len >> 5] |= 0x80 << (24 - (len % 32));
x[(((len + 64) >> 9) << 4) + 15] = len;
var w = Array(80);
var a = 1732584193;
var b = -271733879;
var c = -1732584194;
var d = 271733878;
var e = -1009589776;
for (var i = 0; i < x.length; i += 16) {
var olda = a;
var oldb = b;
var oldc = c;
var oldd = d;
var olde = e;
for (var j = 0; j < 80; j++) {
if (j < 16)
w[j] = x[i + j];
else
w[j] = rol(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1);
var t = safe_add(safe_add(rol(a, 5), sha1_ft(j, b, c, d)), safe_add(safe_add(e, w[j]), sha1_kt(j)));
e = d;
d = c;
c = rol(b, 30);
b = a;
a = t;
}
a = safe_add(a, olda);
b = safe_add(b, oldb);
c = safe_add(c, oldc);
d = safe_add(d, oldd);
e = safe_add(e, olde);
}
return Array(a, b, c, d, e);
}
function sha1_ft(t, b, c, d) {
if (t < 20)
return (b & c) | (~b & d);
if (t < 40)
return b ^ c ^ d;
if (t < 60)
return (b & c) | (b & d) | (c & d);
return b ^ c ^ d;
}
function sha1_kt(t) {
return t < 20
? 1518500249
: t < 40
? 1859775393
: t < 60
? -1894007588
: -899497514;
}
function safe_add(x, y) {
var lsw = (x & 0xffff) + (y & 0xffff);
var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
return (msw << 16) | (lsw & 0xffff);
}
function rol(num, cnt) {
return (num << cnt) | (num >>> (32 - cnt));
}
function str2binb(str) {
var bin = Array();
var mask = (1 << 16) - 1;
for (var i = 0; i < str.length * 16; i += 16)
bin[i >> 5] |= (str.charCodeAt(i / 16) & mask) << (32 - 16 - (i % 32));
return bin;
}
function binb2b64(binarray) {
var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var str = "";
for (var i = 0; i < binarray.length * 4; i += 3) {
var triplet = (((binarray[i >> 2] >> (8 * (3 - (i % 4)))) & 0xff) << 16) |
(((binarray[(i + 1) >> 2] >> (8 * (3 - ((i + 1) % 4)))) & 0xff) << 8) |
((binarray[(i + 2) >> 2] >> (8 * (3 - ((i + 2) % 4)))) & 0xff);
for (var j = 0; j < 4; j++) {
if (i * 8 + j * 6 <= binarray.length * 32)
str += tab.charAt((triplet >> (6 * (3 - j))) & 0x3f);
}
}
return str;
}
function default_1(s) {
return binb2b64(core_sha1(str2binb(s), s.length * 16));
}
exports.default = default_1;

View file

@ -0,0 +1,7 @@
import { App } from "@openreplay/tracker";
export interface Options {
filter: (mutation: any, state: any) => boolean;
transformer: (state: any) => any;
mutationTransformer: (mutation: any) => any;
}
export default function (opts?: Partial<Options>): (app: App | null) => Function;

View file

@ -0,0 +1,39 @@
import { Messages } from "@openreplay/tracker";
import { Encoder, sha1 } from "./syncod/index.js";
function processMutationAndState(app, options, encoder, mutation, state) {
if (options.filter(mutation, state)) {
try {
const _mutation = encoder.encode(options.mutationTransformer(mutation));
const _state = encoder.encode(options.transformer(state));
const _table = encoder.commit();
for (let key in _table)
app.send(Messages.OTable(key, _table[key]));
app.send(Messages.Zustand(_mutation, _state));
}
catch (e) {
encoder.clear();
app.debug.error(e);
}
}
}
export default function (opts = {}) {
const options = Object.assign({
filter: () => true,
transformer: state => state,
mutationTransformer: mutation => mutation,
}, opts);
return (app) => {
if (app === null) {
return Function.prototype;
}
const encoder = new Encoder(sha1, 50);
const state = {};
return (storeName = Math.random().toString(36).substring(2, 9)) => (config) => (set, get, api) => config((...args) => {
set(...args);
const newState = get();
state[storeName] = newState;
const triggeredActions = args.map(action => { var _a; return (_a = action.toString) === null || _a === void 0 ? void 0 : _a.call(action); });
processMutationAndState(app, options, encoder, triggeredActions, state);
}, get, api);
};
}

View file

@ -0,0 +1,2 @@
declare const chars: {};
export default chars;

View file

@ -0,0 +1,16 @@
const chars = {};
[
"DEL",
"UNDEF",
"TRUE",
"FALSE",
"NUMBER",
"BIGINT",
"FUNCTION",
"STRING",
"SYMBOL",
"NULL",
"OBJECT",
"ARRAY"
].forEach((k, i) => (chars[k] = String.fromCharCode(i + 0xe000)));
export default chars;

View file

@ -0,0 +1,11 @@
export default class Encoder {
constructor(hash: any, slen?: number);
_ref_str(str: any): any;
_encode_prim(obj: any): any;
_encode_obj(obj: any, ref?: any): any;
_encode_term(obj: any): any;
_encode_deep(obj: any, depth: any): any;
encode(obj: any): any;
commit(): {};
clear(): void;
}

View file

@ -0,0 +1,210 @@
import _ from "./chars.js";
// @ts-ignore
// @ts-ignore
export default class Encoder {
// @ts-ignore
constructor(hash, slen = Infinity) {
// @ts-ignore
this._hash = hash;
// @ts-ignore
this._slen = slen;
// @ts-ignore
this._refmap = new Map();
// @ts-ignore
this._refset = new Set();
// @ts-ignore
}
// @ts-ignore
// @ts-ignore
_ref_str(str) {
// @ts-ignore
if (str.length < this._slen && str.indexOf(_.DEL) === -1) {
// @ts-ignore
return str;
// @ts-ignore
}
// @ts-ignore
let ref = this._refmap.get(str);
// @ts-ignore
if (ref === undefined) {
// @ts-ignore
ref = this._hash(str);
// @ts-ignore
this._refmap.set(str, ref);
// @ts-ignore
}
// @ts-ignore
return ref;
// @ts-ignore
}
// @ts-ignore
// @ts-ignore
_encode_prim(obj) {
// @ts-ignore
switch (typeof obj) {
// @ts-ignore
case "undefined":
// @ts-ignore
return _.UNDEF;
// @ts-ignore
case "boolean":
// @ts-ignore
return obj ? _.TRUE : _.FALSE;
// @ts-ignore
case "number":
// @ts-ignore
return _.NUMBER + obj.toString();
// @ts-ignore
case "bigint":
// @ts-ignore
return _.BIGINT + obj.toString();
// @ts-ignore
case "function":
// @ts-ignore
return _.FUNCTION;
// @ts-ignore
case "string":
// @ts-ignore
return _.STRING + this._ref_str(obj);
// @ts-ignore
case "symbol":
// @ts-ignore
return _.SYMBOL + this._ref_str(obj.toString().slice(7, -1));
// @ts-ignore
}
// @ts-ignore
if (obj === null) {
// @ts-ignore
return _.NULL;
// @ts-ignore
}
// @ts-ignore
}
// @ts-ignore
// @ts-ignore
_encode_obj(obj, ref = this._refmap.get(obj)) {
// @ts-ignore
return (Array.isArray(obj) ? _.ARRAY : _.OBJECT) + ref;
// @ts-ignore
}
// @ts-ignore
// @ts-ignore
_encode_term(obj) {
// @ts-ignore
return this._encode_prim(obj) || this._encode_obj(obj);
// @ts-ignore
}
// @ts-ignore
// @ts-ignore
_encode_deep(obj, depth) {
// @ts-ignore
const enc = this._encode_prim(obj);
// @ts-ignore
if (enc !== undefined) {
// @ts-ignore
return enc;
// @ts-ignore
}
// @ts-ignore
const ref = this._refmap.get(obj);
// @ts-ignore
switch (typeof ref) {
// @ts-ignore
case "number":
// @ts-ignore
return (depth - ref).toString();
// @ts-ignore
case "string":
// @ts-ignore
return this._encode_obj(obj, ref);
// @ts-ignore
}
// @ts-ignore
this._refmap.set(obj, depth);
// @ts-ignore
const hash = this._hash(
// @ts-ignore
(Array.isArray(obj)
// @ts-ignore
? obj.map(v => this._encode_deep(v, depth + 1))
// @ts-ignore
: Object.keys(obj)
// @ts-ignore
.sort()
// @ts-ignore
.map(
// @ts-ignore
k =>
// @ts-ignore
this._ref_str(k) + _.DEL + this._encode_deep(obj[k], depth + 1)
// @ts-ignore
)
// @ts-ignore
).join(_.DEL)
// @ts-ignore
);
// @ts-ignore
this._refmap.set(obj, hash);
// @ts-ignore
return this._encode_obj(obj, hash);
// @ts-ignore
}
// @ts-ignore
// @ts-ignore
encode(obj) {
// @ts-ignore
return this._encode_deep(obj, 0);
// @ts-ignore
}
// @ts-ignore
// @ts-ignore
commit() {
// @ts-ignore
const dict = {};
// @ts-ignore
this._refmap.forEach((ref, obj) => {
// @ts-ignore
if (this._refset.has(ref)) {
// @ts-ignore
return;
// @ts-ignore
}
// @ts-ignore
this._refset.add(ref);
// @ts-ignore
if (typeof obj !== "string") {
// @ts-ignore
obj = (Array.isArray(obj)
// @ts-ignore
? obj.map(v => this._encode_term(v))
// @ts-ignore
: Object.keys(obj).map(
// @ts-ignore
k => this._ref_str(k) + _.DEL + this._encode_term(obj[k])
// @ts-ignore
)
// @ts-ignore
).join(_.DEL);
// @ts-ignore
}
// @ts-ignore
dict[ref] = obj;
// @ts-ignore
});
// @ts-ignore
this._refmap.clear();
// @ts-ignore
return dict;
// @ts-ignore
}
// @ts-ignore
// @ts-ignore
clear() {
// @ts-ignore
this._refmap.clear();
// @ts-ignore
this._refset.clear();
// @ts-ignore
}
}
// @ts-ignore

View file

@ -0,0 +1,3 @@
import Encoder from "./encoder.js";
import sha1 from "./sha1.js";
export { Encoder, sha1 };

View file

@ -0,0 +1,4 @@
// TODO: SSR solution for all asayer libraries
import Encoder from "./encoder.js";
import sha1 from "./sha1.js";
export { Encoder, sha1 };

View file

@ -0,0 +1 @@
export default function (s: any): string;

View file

@ -0,0 +1,93 @@
/*
* A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
* in FIPS PUB 180-1
* Version 2.1a Copyright Paul Johnston 2000 - 2002.
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
* Distributed under the BSD License
* See http://pajhome.org.uk/crypt/md5 for details.
*/
function core_sha1(x, len) {
x[len >> 5] |= 0x80 << (24 - (len % 32));
x[(((len + 64) >> 9) << 4) + 15] = len;
var w = Array(80);
var a = 1732584193;
var b = -271733879;
var c = -1732584194;
var d = 271733878;
var e = -1009589776;
for (var i = 0; i < x.length; i += 16) {
var olda = a;
var oldb = b;
var oldc = c;
var oldd = d;
var olde = e;
for (var j = 0; j < 80; j++) {
if (j < 16)
w[j] = x[i + j];
else
w[j] = rol(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1);
var t = safe_add(safe_add(rol(a, 5), sha1_ft(j, b, c, d)), safe_add(safe_add(e, w[j]), sha1_kt(j)));
e = d;
d = c;
c = rol(b, 30);
b = a;
a = t;
}
a = safe_add(a, olda);
b = safe_add(b, oldb);
c = safe_add(c, oldc);
d = safe_add(d, oldd);
e = safe_add(e, olde);
}
return Array(a, b, c, d, e);
}
function sha1_ft(t, b, c, d) {
if (t < 20)
return (b & c) | (~b & d);
if (t < 40)
return b ^ c ^ d;
if (t < 60)
return (b & c) | (b & d) | (c & d);
return b ^ c ^ d;
}
function sha1_kt(t) {
return t < 20
? 1518500249
: t < 40
? 1859775393
: t < 60
? -1894007588
: -899497514;
}
function safe_add(x, y) {
var lsw = (x & 0xffff) + (y & 0xffff);
var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
return (msw << 16) | (lsw & 0xffff);
}
function rol(num, cnt) {
return (num << cnt) | (num >>> (32 - cnt));
}
function str2binb(str) {
var bin = Array();
var mask = (1 << 16) - 1;
for (var i = 0; i < str.length * 16; i += 16)
bin[i >> 5] |= (str.charCodeAt(i / 16) & mask) << (32 - 16 - (i % 32));
return bin;
}
function binb2b64(binarray) {
var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var str = "";
for (var i = 0; i < binarray.length * 4; i += 3) {
var triplet = (((binarray[i >> 2] >> (8 * (3 - (i % 4)))) & 0xff) << 16) |
(((binarray[(i + 1) >> 2] >> (8 * (3 - ((i + 1) % 4)))) & 0xff) << 8) |
((binarray[(i + 2) >> 2] >> (8 * (3 - ((i + 2) % 4)))) & 0xff);
for (var j = 0; j < 4; j++) {
if (i * 8 + j * 6 <= binarray.length * 32)
str += tab.charAt((triplet >> (6 * (3 - j))) & 0x3f);
}
}
return str;
}
export default function (s) {
return binb2b64(core_sha1(str2binb(s), s.length * 16));
}

View file

@ -57,6 +57,7 @@ export declare const enum Type {
AdoptedSSAddOwner = 76, AdoptedSSAddOwner = 76,
AdoptedSSRemoveOwner = 77, AdoptedSSRemoveOwner = 77,
Zustand = 79, Zustand = 79,
ReplaceVCSS = 83,
} }
@ -101,7 +102,7 @@ export type SetViewportScroll = [
export type CreateDocument = [ export type CreateDocument = [
/*type:*/ Type.CreateDocument, /*type:*/ Type.CreateDocument,
] ]
export type CreateElementNode = [ export type CreateElementNode = [
@ -445,6 +446,15 @@ export type Zustand = [
/*state:*/ string, /*state:*/ string,
] ]
export type ReplaceVCSS = [
/*type:*/ Type.ReplaceVCSS,
/*id:*/ number,
/*styles:*/ string,
/*sheetID:*/ string,
/*baseURL:*/ string,
]
type Message = BatchMetadata | PartitionedMessage | Timestamp | SetPageLocation | SetViewportSize | SetViewportScroll | CreateDocument | CreateElementNode | CreateTextNode | MoveNode | RemoveNode | SetNodeAttribute | RemoveNodeAttribute | SetNodeData | SetNodeScroll | SetInputTarget | SetInputValue | SetInputChecked | MouseMove | ConsoleLog | PageLoadTiming | PageRenderTiming | JSException | RawCustomEvent | UserID | UserAnonymousID | Metadata | CSSInsertRule | CSSDeleteRule | Fetch | Profiler | OTable | StateAction | Redux | Vuex | MobX | NgRx | GraphQL | PerformanceTrack | ResourceTiming | ConnectionInformation | SetPageVisibility | LongTask | SetNodeAttributeURLBased | SetCSSDataURLBased | TechnicalInfo | CustomIssue | CSSInsertRuleURLBased | MouseClick | CreateIFrameDocument | AdoptedSSReplaceURLBased | AdoptedSSInsertRuleURLBased | AdoptedSSDeleteRule | AdoptedSSAddOwner | AdoptedSSRemoveOwner | Zustand | ReplaceVCSS
type Message = BatchMetadata | PartitionedMessage | Timestamp | SetPageLocation | SetViewportSize | SetViewportScroll | CreateDocument | CreateElementNode | CreateTextNode | MoveNode | RemoveNode | SetNodeAttribute | RemoveNodeAttribute | SetNodeData | SetNodeScroll | SetInputTarget | SetInputValue | SetInputChecked | MouseMove | ConsoleLog | PageLoadTiming | PageRenderTiming | JSException | RawCustomEvent | UserID | UserAnonymousID | Metadata | CSSInsertRule | CSSDeleteRule | Fetch | Profiler | OTable | StateAction | Redux | Vuex | MobX | NgRx | GraphQL | PerformanceTrack | ResourceTiming | ConnectionInformation | SetPageVisibility | LongTask | SetNodeAttributeURLBased | SetCSSDataURLBased | TechnicalInfo | CustomIssue | CSSInsertRuleURLBased | MouseClick | CreateIFrameDocument | AdoptedSSReplaceURLBased | AdoptedSSInsertRuleURLBased | AdoptedSSDeleteRule | AdoptedSSAddOwner | AdoptedSSRemoveOwner | Zustand
export default Message export default Message

View file

@ -11,7 +11,7 @@ export function BatchMetadata(
timestamp: number, timestamp: number,
location: string, location: string,
): Messages.BatchMetadata { ): Messages.BatchMetadata {
return [ return [
Messages.Type.BatchMetadata, Messages.Type.BatchMetadata,
version, version,
pageNo, pageNo,
@ -25,7 +25,7 @@ export function PartitionedMessage(
partNo: number, partNo: number,
partTotal: number, partTotal: number,
): Messages.PartitionedMessage { ): Messages.PartitionedMessage {
return [ return [
Messages.Type.PartitionedMessage, Messages.Type.PartitionedMessage,
partNo, partNo,
partTotal, partTotal,
@ -35,7 +35,7 @@ export function PartitionedMessage(
export function Timestamp( export function Timestamp(
timestamp: number, timestamp: number,
): Messages.Timestamp { ): Messages.Timestamp {
return [ return [
Messages.Type.Timestamp, Messages.Type.Timestamp,
timestamp, timestamp,
] ]
@ -46,7 +46,7 @@ export function SetPageLocation(
referrer: string, referrer: string,
navigationStart: number, navigationStart: number,
): Messages.SetPageLocation { ): Messages.SetPageLocation {
return [ return [
Messages.Type.SetPageLocation, Messages.Type.SetPageLocation,
url, url,
referrer, referrer,
@ -58,7 +58,7 @@ export function SetViewportSize(
width: number, width: number,
height: number, height: number,
): Messages.SetViewportSize { ): Messages.SetViewportSize {
return [ return [
Messages.Type.SetViewportSize, Messages.Type.SetViewportSize,
width, width,
height, height,
@ -69,7 +69,7 @@ export function SetViewportScroll(
x: number, x: number,
y: number, y: number,
): Messages.SetViewportScroll { ): Messages.SetViewportScroll {
return [ return [
Messages.Type.SetViewportScroll, Messages.Type.SetViewportScroll,
x, x,
y, y,
@ -77,11 +77,11 @@ export function SetViewportScroll(
} }
export function CreateDocument( export function CreateDocument(
): Messages.CreateDocument { ): Messages.CreateDocument {
return [ return [
Messages.Type.CreateDocument, Messages.Type.CreateDocument,
] ]
} }
@ -92,7 +92,7 @@ export function CreateElementNode(
tag: string, tag: string,
svg: boolean, svg: boolean,
): Messages.CreateElementNode { ): Messages.CreateElementNode {
return [ return [
Messages.Type.CreateElementNode, Messages.Type.CreateElementNode,
id, id,
parentID, parentID,
@ -107,7 +107,7 @@ export function CreateTextNode(
parentID: number, parentID: number,
index: number, index: number,
): Messages.CreateTextNode { ): Messages.CreateTextNode {
return [ return [
Messages.Type.CreateTextNode, Messages.Type.CreateTextNode,
id, id,
parentID, parentID,
@ -120,7 +120,7 @@ export function MoveNode(
parentID: number, parentID: number,
index: number, index: number,
): Messages.MoveNode { ): Messages.MoveNode {
return [ return [
Messages.Type.MoveNode, Messages.Type.MoveNode,
id, id,
parentID, parentID,
@ -131,7 +131,7 @@ export function MoveNode(
export function RemoveNode( export function RemoveNode(
id: number, id: number,
): Messages.RemoveNode { ): Messages.RemoveNode {
return [ return [
Messages.Type.RemoveNode, Messages.Type.RemoveNode,
id, id,
] ]
@ -142,7 +142,7 @@ export function SetNodeAttribute(
name: string, name: string,
value: string, value: string,
): Messages.SetNodeAttribute { ): Messages.SetNodeAttribute {
return [ return [
Messages.Type.SetNodeAttribute, Messages.Type.SetNodeAttribute,
id, id,
name, name,
@ -154,7 +154,7 @@ export function RemoveNodeAttribute(
id: number, id: number,
name: string, name: string,
): Messages.RemoveNodeAttribute { ): Messages.RemoveNodeAttribute {
return [ return [
Messages.Type.RemoveNodeAttribute, Messages.Type.RemoveNodeAttribute,
id, id,
name, name,
@ -165,7 +165,7 @@ export function SetNodeData(
id: number, id: number,
data: string, data: string,
): Messages.SetNodeData { ): Messages.SetNodeData {
return [ return [
Messages.Type.SetNodeData, Messages.Type.SetNodeData,
id, id,
data, data,
@ -177,7 +177,7 @@ export function SetNodeScroll(
x: number, x: number,
y: number, y: number,
): Messages.SetNodeScroll { ): Messages.SetNodeScroll {
return [ return [
Messages.Type.SetNodeScroll, Messages.Type.SetNodeScroll,
id, id,
x, x,
@ -189,7 +189,7 @@ export function SetInputTarget(
id: number, id: number,
label: string, label: string,
): Messages.SetInputTarget { ): Messages.SetInputTarget {
return [ return [
Messages.Type.SetInputTarget, Messages.Type.SetInputTarget,
id, id,
label, label,
@ -201,7 +201,7 @@ export function SetInputValue(
value: string, value: string,
mask: number, mask: number,
): Messages.SetInputValue { ): Messages.SetInputValue {
return [ return [
Messages.Type.SetInputValue, Messages.Type.SetInputValue,
id, id,
value, value,
@ -213,7 +213,7 @@ export function SetInputChecked(
id: number, id: number,
checked: boolean, checked: boolean,
): Messages.SetInputChecked { ): Messages.SetInputChecked {
return [ return [
Messages.Type.SetInputChecked, Messages.Type.SetInputChecked,
id, id,
checked, checked,
@ -224,7 +224,7 @@ export function MouseMove(
x: number, x: number,
y: number, y: number,
): Messages.MouseMove { ): Messages.MouseMove {
return [ return [
Messages.Type.MouseMove, Messages.Type.MouseMove,
x, x,
y, y,
@ -235,7 +235,7 @@ export function ConsoleLog(
level: string, level: string,
value: string, value: string,
): Messages.ConsoleLog { ): Messages.ConsoleLog {
return [ return [
Messages.Type.ConsoleLog, Messages.Type.ConsoleLog,
level, level,
value, value,
@ -253,7 +253,7 @@ export function PageLoadTiming(
firstPaint: number, firstPaint: number,
firstContentfulPaint: number, firstContentfulPaint: number,
): Messages.PageLoadTiming { ): Messages.PageLoadTiming {
return [ return [
Messages.Type.PageLoadTiming, Messages.Type.PageLoadTiming,
requestStart, requestStart,
responseStart, responseStart,
@ -272,7 +272,7 @@ export function PageRenderTiming(
visuallyComplete: number, visuallyComplete: number,
timeToInteractive: number, timeToInteractive: number,
): Messages.PageRenderTiming { ): Messages.PageRenderTiming {
return [ return [
Messages.Type.PageRenderTiming, Messages.Type.PageRenderTiming,
speedIndex, speedIndex,
visuallyComplete, visuallyComplete,
@ -285,7 +285,7 @@ export function JSException(
message: string, message: string,
payload: string, payload: string,
): Messages.JSException { ): Messages.JSException {
return [ return [
Messages.Type.JSException, Messages.Type.JSException,
name, name,
message, message,
@ -297,7 +297,7 @@ export function RawCustomEvent(
name: string, name: string,
payload: string, payload: string,
): Messages.RawCustomEvent { ): Messages.RawCustomEvent {
return [ return [
Messages.Type.RawCustomEvent, Messages.Type.RawCustomEvent,
name, name,
payload, payload,
@ -307,7 +307,7 @@ export function RawCustomEvent(
export function UserID( export function UserID(
id: string, id: string,
): Messages.UserID { ): Messages.UserID {
return [ return [
Messages.Type.UserID, Messages.Type.UserID,
id, id,
] ]
@ -316,7 +316,7 @@ export function UserID(
export function UserAnonymousID( export function UserAnonymousID(
id: string, id: string,
): Messages.UserAnonymousID { ): Messages.UserAnonymousID {
return [ return [
Messages.Type.UserAnonymousID, Messages.Type.UserAnonymousID,
id, id,
] ]
@ -326,7 +326,7 @@ export function Metadata(
key: string, key: string,
value: string, value: string,
): Messages.Metadata { ): Messages.Metadata {
return [ return [
Messages.Type.Metadata, Messages.Type.Metadata,
key, key,
value, value,
@ -338,7 +338,7 @@ export function CSSInsertRule(
rule: string, rule: string,
index: number, index: number,
): Messages.CSSInsertRule { ): Messages.CSSInsertRule {
return [ return [
Messages.Type.CSSInsertRule, Messages.Type.CSSInsertRule,
id, id,
rule, rule,
@ -350,7 +350,7 @@ export function CSSDeleteRule(
id: number, id: number,
index: number, index: number,
): Messages.CSSDeleteRule { ): Messages.CSSDeleteRule {
return [ return [
Messages.Type.CSSDeleteRule, Messages.Type.CSSDeleteRule,
id, id,
index, index,
@ -366,7 +366,7 @@ export function Fetch(
timestamp: number, timestamp: number,
duration: number, duration: number,
): Messages.Fetch { ): Messages.Fetch {
return [ return [
Messages.Type.Fetch, Messages.Type.Fetch,
method, method,
url, url,
@ -384,7 +384,7 @@ export function Profiler(
args: string, args: string,
result: string, result: string,
): Messages.Profiler { ): Messages.Profiler {
return [ return [
Messages.Type.Profiler, Messages.Type.Profiler,
name, name,
duration, duration,
@ -397,7 +397,7 @@ export function OTable(
key: string, key: string,
value: string, value: string,
): Messages.OTable { ): Messages.OTable {
return [ return [
Messages.Type.OTable, Messages.Type.OTable,
key, key,
value, value,
@ -407,7 +407,7 @@ export function OTable(
export function StateAction( export function StateAction(
type: string, type: string,
): Messages.StateAction { ): Messages.StateAction {
return [ return [
Messages.Type.StateAction, Messages.Type.StateAction,
type, type,
] ]
@ -418,7 +418,7 @@ export function Redux(
state: string, state: string,
duration: number, duration: number,
): Messages.Redux { ): Messages.Redux {
return [ return [
Messages.Type.Redux, Messages.Type.Redux,
action, action,
state, state,
@ -430,7 +430,7 @@ export function Vuex(
mutation: string, mutation: string,
state: string, state: string,
): Messages.Vuex { ): Messages.Vuex {
return [ return [
Messages.Type.Vuex, Messages.Type.Vuex,
mutation, mutation,
state, state,
@ -441,7 +441,7 @@ export function MobX(
type: string, type: string,
payload: string, payload: string,
): Messages.MobX { ): Messages.MobX {
return [ return [
Messages.Type.MobX, Messages.Type.MobX,
type, type,
payload, payload,
@ -453,7 +453,7 @@ export function NgRx(
state: string, state: string,
duration: number, duration: number,
): Messages.NgRx { ): Messages.NgRx {
return [ return [
Messages.Type.NgRx, Messages.Type.NgRx,
action, action,
state, state,
@ -467,7 +467,7 @@ export function GraphQL(
variables: string, variables: string,
response: string, response: string,
): Messages.GraphQL { ): Messages.GraphQL {
return [ return [
Messages.Type.GraphQL, Messages.Type.GraphQL,
operationKind, operationKind,
operationName, operationName,
@ -482,7 +482,7 @@ export function PerformanceTrack(
totalJSHeapSize: number, totalJSHeapSize: number,
usedJSHeapSize: number, usedJSHeapSize: number,
): Messages.PerformanceTrack { ): Messages.PerformanceTrack {
return [ return [
Messages.Type.PerformanceTrack, Messages.Type.PerformanceTrack,
frames, frames,
ticks, ticks,
@ -501,7 +501,7 @@ export function ResourceTiming(
url: string, url: string,
initiator: string, initiator: string,
): Messages.ResourceTiming { ): Messages.ResourceTiming {
return [ return [
Messages.Type.ResourceTiming, Messages.Type.ResourceTiming,
timestamp, timestamp,
duration, duration,
@ -518,7 +518,7 @@ export function ConnectionInformation(
downlink: number, downlink: number,
type: string, type: string,
): Messages.ConnectionInformation { ): Messages.ConnectionInformation {
return [ return [
Messages.Type.ConnectionInformation, Messages.Type.ConnectionInformation,
downlink, downlink,
type, type,
@ -528,7 +528,7 @@ export function ConnectionInformation(
export function SetPageVisibility( export function SetPageVisibility(
hidden: boolean, hidden: boolean,
): Messages.SetPageVisibility { ): Messages.SetPageVisibility {
return [ return [
Messages.Type.SetPageVisibility, Messages.Type.SetPageVisibility,
hidden, hidden,
] ]
@ -543,7 +543,7 @@ export function LongTask(
containerId: string, containerId: string,
containerName: string, containerName: string,
): Messages.LongTask { ): Messages.LongTask {
return [ return [
Messages.Type.LongTask, Messages.Type.LongTask,
timestamp, timestamp,
duration, duration,
@ -561,7 +561,7 @@ export function SetNodeAttributeURLBased(
value: string, value: string,
baseURL: string, baseURL: string,
): Messages.SetNodeAttributeURLBased { ): Messages.SetNodeAttributeURLBased {
return [ return [
Messages.Type.SetNodeAttributeURLBased, Messages.Type.SetNodeAttributeURLBased,
id, id,
name, name,
@ -575,7 +575,7 @@ export function SetCSSDataURLBased(
data: string, data: string,
baseURL: string, baseURL: string,
): Messages.SetCSSDataURLBased { ): Messages.SetCSSDataURLBased {
return [ return [
Messages.Type.SetCSSDataURLBased, Messages.Type.SetCSSDataURLBased,
id, id,
data, data,
@ -587,7 +587,7 @@ export function TechnicalInfo(
type: string, type: string,
value: string, value: string,
): Messages.TechnicalInfo { ): Messages.TechnicalInfo {
return [ return [
Messages.Type.TechnicalInfo, Messages.Type.TechnicalInfo,
type, type,
value, value,
@ -598,7 +598,7 @@ export function CustomIssue(
name: string, name: string,
payload: string, payload: string,
): Messages.CustomIssue { ): Messages.CustomIssue {
return [ return [
Messages.Type.CustomIssue, Messages.Type.CustomIssue,
name, name,
payload, payload,
@ -611,7 +611,7 @@ export function CSSInsertRuleURLBased(
index: number, index: number,
baseURL: string, baseURL: string,
): Messages.CSSInsertRuleURLBased { ): Messages.CSSInsertRuleURLBased {
return [ return [
Messages.Type.CSSInsertRuleURLBased, Messages.Type.CSSInsertRuleURLBased,
id, id,
rule, rule,
@ -626,7 +626,7 @@ export function MouseClick(
label: string, label: string,
selector: string, selector: string,
): Messages.MouseClick { ): Messages.MouseClick {
return [ return [
Messages.Type.MouseClick, Messages.Type.MouseClick,
id, id,
hesitationTime, hesitationTime,
@ -639,7 +639,7 @@ export function CreateIFrameDocument(
frameID: number, frameID: number,
id: number, id: number,
): Messages.CreateIFrameDocument { ): Messages.CreateIFrameDocument {
return [ return [
Messages.Type.CreateIFrameDocument, Messages.Type.CreateIFrameDocument,
frameID, frameID,
id, id,
@ -651,7 +651,7 @@ export function AdoptedSSReplaceURLBased(
text: string, text: string,
baseURL: string, baseURL: string,
): Messages.AdoptedSSReplaceURLBased { ): Messages.AdoptedSSReplaceURLBased {
return [ return [
Messages.Type.AdoptedSSReplaceURLBased, Messages.Type.AdoptedSSReplaceURLBased,
sheetID, sheetID,
text, text,
@ -665,7 +665,7 @@ export function AdoptedSSInsertRuleURLBased(
index: number, index: number,
baseURL: string, baseURL: string,
): Messages.AdoptedSSInsertRuleURLBased { ): Messages.AdoptedSSInsertRuleURLBased {
return [ return [
Messages.Type.AdoptedSSInsertRuleURLBased, Messages.Type.AdoptedSSInsertRuleURLBased,
sheetID, sheetID,
rule, rule,
@ -678,7 +678,7 @@ export function AdoptedSSDeleteRule(
sheetID: number, sheetID: number,
index: number, index: number,
): Messages.AdoptedSSDeleteRule { ): Messages.AdoptedSSDeleteRule {
return [ return [
Messages.Type.AdoptedSSDeleteRule, Messages.Type.AdoptedSSDeleteRule,
sheetID, sheetID,
index, index,
@ -689,7 +689,7 @@ export function AdoptedSSAddOwner(
sheetID: number, sheetID: number,
id: number, id: number,
): Messages.AdoptedSSAddOwner { ): Messages.AdoptedSSAddOwner {
return [ return [
Messages.Type.AdoptedSSAddOwner, Messages.Type.AdoptedSSAddOwner,
sheetID, sheetID,
id, id,
@ -700,7 +700,7 @@ export function AdoptedSSRemoveOwner(
sheetID: number, sheetID: number,
id: number, id: number,
): Messages.AdoptedSSRemoveOwner { ): Messages.AdoptedSSRemoveOwner {
return [ return [
Messages.Type.AdoptedSSRemoveOwner, Messages.Type.AdoptedSSRemoveOwner,
sheetID, sheetID,
id, id,
@ -711,10 +711,24 @@ export function Zustand(
mutation: string, mutation: string,
state: string, state: string,
): Messages.Zustand { ): Messages.Zustand {
return [ return [
Messages.Type.Zustand, Messages.Type.Zustand,
mutation, mutation,
state, state,
] ]
} }
export function ReplaceVCSS(
id: number,
styles: string,
sheetID: string,
baseURL: string,
): Messages.ReplaceVCSS {
return [
Messages.Type.ReplaceVCSS,
id,
styles,
sheetID,
baseURL,
]
}

View file

@ -1,5 +1,10 @@
import type App from '../app/index.js' import type App from '../app/index.js'
import { CSSInsertRuleURLBased, CSSDeleteRule, TechnicalInfo } from '../app/messages.gen.js' import {
CSSInsertRuleURLBased,
CSSDeleteRule,
TechnicalInfo,
ReplaceVCSS,
} from '../app/messages.gen.js'
import { hasTag } from '../app/guards.js' import { hasTag } from '../app/guards.js'
export default function (app: App | null) { export default function (app: App | null) {
@ -11,23 +16,46 @@ export default function (app: App | null) {
return return
} }
const processOperation = app.safe( const processOperation = app.safe((stylesheet: CSSStyleSheet, index: number, rule?: string) => {
(stylesheet: CSSStyleSheet | CSSGroupingRule, index: number, rule?: string) => { const sendMessage =
const sendMessage = typeof rule === 'string'
typeof rule === 'string' ? (nodeID: number) =>
? (nodeID: number) => app.send(CSSInsertRuleURLBased(nodeID, rule, index, app.getBaseHref()))
app.send(CSSInsertRuleURLBased(nodeID, rule, index, app.getBaseHref())) : (nodeID: number) => app.send(CSSDeleteRule(nodeID, index))
: (nodeID: number) => app.send(CSSDeleteRule(nodeID, index)) // TODO: Extend messages to maintain nested rules (CSSGroupingRule prototype, as well as CSSKeyframesRule)
// TODO: Extend messages to maintain nested rules (CSSGroupingRule prototype, as well as CSSKeyframesRule) if (!stylesheet.ownerNode) {
if (!stylesheet.ownerNode) { throw new Error('Owner Node not found')
throw new Error('Owner Node not found') }
const nodeID = app.nodes.getID(stylesheet.ownerNode)
if (nodeID !== undefined) {
sendMessage(nodeID)
} // else error?
})
const replaceVirtualCss = app.safe((ctx: CSSGroupingRule) => {
let uppermostRuleset = ctx.parentRule
while (uppermostRuleset?.parentRule) {
uppermostRuleset = uppermostRuleset.parentRule
}
if (uppermostRuleset?.parentStyleSheet?.ownerNode) {
const entireStyle = uppermostRuleset.cssText
const parentNodeID = app.nodes.getID(uppermostRuleset.parentStyleSheet.ownerNode)
const ruleList = uppermostRuleset.parentStyleSheet.cssRules
let id = -1
for (let i = 0; i < ruleList.length; i++) {
const rule = ruleList.item(i)
if (rule === uppermostRuleset) {
id = i
break
}
} }
const nodeID = app.nodes.getID(stylesheet.ownerNode) if (parentNodeID && id >= 0) {
if (nodeID !== undefined) { app.send(ReplaceVCSS(parentNodeID, entireStyle, id.toString(), app.getBaseHref()))
sendMessage(nodeID) }
} // else error? } else {
}, app.debug.error('Owner Node not found')
) }
})
const patchContext = (context: typeof globalThis) => { const patchContext = (context: typeof globalThis) => {
const { insertRule, deleteRule } = context.CSSStyleSheet.prototype const { insertRule, deleteRule } = context.CSSStyleSheet.prototype
@ -46,15 +74,15 @@ export default function (app: App | null) {
context.CSSGroupingRule.prototype.insertRule = function (rule: string, index = 0) { context.CSSGroupingRule.prototype.insertRule = function (rule: string, index = 0) {
const result = groupInsertRule.call(this, rule, index) as number const result = groupInsertRule.call(this, rule, index) as number
const entireStyle = this.parentStyleSheet?.cssRules replaceVirtualCss(this)
// const nodeID = getID(this.parentStyleSheet?.ownerNode)
// app.send(updateGroup(nodeID, entireStyle.csstext))
return result return result
} }
context.CSSGroupingRule.prototype.deleteRule = function (index = 0) { context.CSSGroupingRule.prototype.deleteRule = function (index = 0) {
const result = groupDeleteRule.call(this, index) as number const result = groupDeleteRule.call(this, index) as number
replaceVirtualCss(this)
return result return result
} }
} }

View file

@ -8,233 +8,236 @@ import PrimitiveEncoder from './PrimitiveEncoder.js'
export default class MessageEncoder extends PrimitiveEncoder { export default class MessageEncoder extends PrimitiveEncoder {
encode(msg: Message): boolean { encode(msg: Message): boolean {
switch(msg[0]) { switch(msg[0]) {
case Messages.Type.BatchMetadata: case Messages.Type.BatchMetadata:
return this.uint(msg[1]) && this.uint(msg[2]) && this.uint(msg[3]) && this.int(msg[4]) && this.string(msg[5]) return this.uint(msg[1]) && this.uint(msg[2]) && this.uint(msg[3]) && this.int(msg[4]) && this.string(msg[5])
break break
case Messages.Type.PartitionedMessage: case Messages.Type.PartitionedMessage:
return this.uint(msg[1]) && this.uint(msg[2]) return this.uint(msg[1]) && this.uint(msg[2])
break break
case Messages.Type.Timestamp: case Messages.Type.Timestamp:
return this.uint(msg[1]) return this.uint(msg[1])
break break
case Messages.Type.SetPageLocation: case Messages.Type.SetPageLocation:
return this.string(msg[1]) && this.string(msg[2]) && this.uint(msg[3]) return this.string(msg[1]) && this.string(msg[2]) && this.uint(msg[3])
break break
case Messages.Type.SetViewportSize: case Messages.Type.SetViewportSize:
return this.uint(msg[1]) && this.uint(msg[2]) return this.uint(msg[1]) && this.uint(msg[2])
break break
case Messages.Type.SetViewportScroll: case Messages.Type.SetViewportScroll:
return this.int(msg[1]) && this.int(msg[2]) return this.int(msg[1]) && this.int(msg[2])
break break
case Messages.Type.CreateDocument: case Messages.Type.CreateDocument:
return true return true
break break
case Messages.Type.CreateElementNode: case Messages.Type.CreateElementNode:
return this.uint(msg[1]) && this.uint(msg[2]) && this.uint(msg[3]) && this.string(msg[4]) && this.boolean(msg[5]) return this.uint(msg[1]) && this.uint(msg[2]) && this.uint(msg[3]) && this.string(msg[4]) && this.boolean(msg[5])
break break
case Messages.Type.CreateTextNode: case Messages.Type.CreateTextNode:
return this.uint(msg[1]) && this.uint(msg[2]) && this.uint(msg[3]) return this.uint(msg[1]) && this.uint(msg[2]) && this.uint(msg[3])
break break
case Messages.Type.MoveNode: case Messages.Type.MoveNode:
return this.uint(msg[1]) && this.uint(msg[2]) && this.uint(msg[3]) return this.uint(msg[1]) && this.uint(msg[2]) && this.uint(msg[3])
break break
case Messages.Type.RemoveNode: case Messages.Type.RemoveNode:
return this.uint(msg[1]) return this.uint(msg[1])
break break
case Messages.Type.SetNodeAttribute: case Messages.Type.SetNodeAttribute:
return this.uint(msg[1]) && this.string(msg[2]) && this.string(msg[3]) return this.uint(msg[1]) && this.string(msg[2]) && this.string(msg[3])
break break
case Messages.Type.RemoveNodeAttribute: case Messages.Type.RemoveNodeAttribute:
return this.uint(msg[1]) && this.string(msg[2]) return this.uint(msg[1]) && this.string(msg[2])
break break
case Messages.Type.SetNodeData: case Messages.Type.SetNodeData:
return this.uint(msg[1]) && this.string(msg[2]) return this.uint(msg[1]) && this.string(msg[2])
break break
case Messages.Type.SetNodeScroll: case Messages.Type.SetNodeScroll:
return this.uint(msg[1]) && this.int(msg[2]) && this.int(msg[3]) return this.uint(msg[1]) && this.int(msg[2]) && this.int(msg[3])
break break
case Messages.Type.SetInputTarget: case Messages.Type.SetInputTarget:
return this.uint(msg[1]) && this.string(msg[2]) return this.uint(msg[1]) && this.string(msg[2])
break break
case Messages.Type.SetInputValue: case Messages.Type.SetInputValue:
return this.uint(msg[1]) && this.string(msg[2]) && this.int(msg[3]) return this.uint(msg[1]) && this.string(msg[2]) && this.int(msg[3])
break break
case Messages.Type.SetInputChecked: case Messages.Type.SetInputChecked:
return this.uint(msg[1]) && this.boolean(msg[2]) return this.uint(msg[1]) && this.boolean(msg[2])
break break
case Messages.Type.MouseMove: case Messages.Type.MouseMove:
return this.uint(msg[1]) && this.uint(msg[2]) return this.uint(msg[1]) && this.uint(msg[2])
break break
case Messages.Type.ConsoleLog: case Messages.Type.ConsoleLog:
return this.string(msg[1]) && this.string(msg[2]) return this.string(msg[1]) && this.string(msg[2])
break break
case Messages.Type.PageLoadTiming: case Messages.Type.PageLoadTiming:
return this.uint(msg[1]) && this.uint(msg[2]) && this.uint(msg[3]) && this.uint(msg[4]) && this.uint(msg[5]) && this.uint(msg[6]) && this.uint(msg[7]) && this.uint(msg[8]) && this.uint(msg[9]) return this.uint(msg[1]) && this.uint(msg[2]) && this.uint(msg[3]) && this.uint(msg[4]) && this.uint(msg[5]) && this.uint(msg[6]) && this.uint(msg[7]) && this.uint(msg[8]) && this.uint(msg[9])
break break
case Messages.Type.PageRenderTiming: case Messages.Type.PageRenderTiming:
return this.uint(msg[1]) && this.uint(msg[2]) && this.uint(msg[3]) return this.uint(msg[1]) && this.uint(msg[2]) && this.uint(msg[3])
break break
case Messages.Type.JSException: case Messages.Type.JSException:
return this.string(msg[1]) && this.string(msg[2]) && this.string(msg[3]) return this.string(msg[1]) && this.string(msg[2]) && this.string(msg[3])
break break
case Messages.Type.RawCustomEvent: case Messages.Type.RawCustomEvent:
return this.string(msg[1]) && this.string(msg[2]) return this.string(msg[1]) && this.string(msg[2])
break break
case Messages.Type.UserID: case Messages.Type.UserID:
return this.string(msg[1]) return this.string(msg[1])
break break
case Messages.Type.UserAnonymousID: case Messages.Type.UserAnonymousID:
return this.string(msg[1]) return this.string(msg[1])
break break
case Messages.Type.Metadata: case Messages.Type.Metadata:
return this.string(msg[1]) && this.string(msg[2]) return this.string(msg[1]) && this.string(msg[2])
break break
case Messages.Type.CSSInsertRule: case Messages.Type.CSSInsertRule:
return this.uint(msg[1]) && this.string(msg[2]) && this.uint(msg[3]) return this.uint(msg[1]) && this.string(msg[2]) && this.uint(msg[3])
break break
case Messages.Type.CSSDeleteRule: case Messages.Type.CSSDeleteRule:
return this.uint(msg[1]) && this.uint(msg[2]) return this.uint(msg[1]) && this.uint(msg[2])
break break
case Messages.Type.Fetch: case Messages.Type.Fetch:
return this.string(msg[1]) && this.string(msg[2]) && this.string(msg[3]) && this.string(msg[4]) && this.uint(msg[5]) && this.uint(msg[6]) && this.uint(msg[7]) return this.string(msg[1]) && this.string(msg[2]) && this.string(msg[3]) && this.string(msg[4]) && this.uint(msg[5]) && this.uint(msg[6]) && this.uint(msg[7])
break break
case Messages.Type.Profiler: case Messages.Type.Profiler:
return this.string(msg[1]) && this.uint(msg[2]) && this.string(msg[3]) && this.string(msg[4]) return this.string(msg[1]) && this.uint(msg[2]) && this.string(msg[3]) && this.string(msg[4])
break break
case Messages.Type.OTable: case Messages.Type.OTable:
return this.string(msg[1]) && this.string(msg[2]) return this.string(msg[1]) && this.string(msg[2])
break break
case Messages.Type.StateAction: case Messages.Type.StateAction:
return this.string(msg[1]) return this.string(msg[1])
break break
case Messages.Type.Redux: case Messages.Type.Redux:
return this.string(msg[1]) && this.string(msg[2]) && this.uint(msg[3]) return this.string(msg[1]) && this.string(msg[2]) && this.uint(msg[3])
break break
case Messages.Type.Vuex: case Messages.Type.Vuex:
return this.string(msg[1]) && this.string(msg[2]) return this.string(msg[1]) && this.string(msg[2])
break break
case Messages.Type.MobX: case Messages.Type.MobX:
return this.string(msg[1]) && this.string(msg[2]) return this.string(msg[1]) && this.string(msg[2])
break break
case Messages.Type.NgRx: case Messages.Type.NgRx:
return this.string(msg[1]) && this.string(msg[2]) && this.uint(msg[3]) return this.string(msg[1]) && this.string(msg[2]) && this.uint(msg[3])
break break
case Messages.Type.GraphQL: case Messages.Type.GraphQL:
return this.string(msg[1]) && this.string(msg[2]) && this.string(msg[3]) && this.string(msg[4]) return this.string(msg[1]) && this.string(msg[2]) && this.string(msg[3]) && this.string(msg[4])
break break
case Messages.Type.PerformanceTrack: case Messages.Type.PerformanceTrack:
return this.int(msg[1]) && this.int(msg[2]) && this.uint(msg[3]) && this.uint(msg[4]) return this.int(msg[1]) && this.int(msg[2]) && this.uint(msg[3]) && this.uint(msg[4])
break break
case Messages.Type.ResourceTiming: case Messages.Type.ResourceTiming:
return this.uint(msg[1]) && this.uint(msg[2]) && this.uint(msg[3]) && this.uint(msg[4]) && this.uint(msg[5]) && this.uint(msg[6]) && this.string(msg[7]) && this.string(msg[8]) return this.uint(msg[1]) && this.uint(msg[2]) && this.uint(msg[3]) && this.uint(msg[4]) && this.uint(msg[5]) && this.uint(msg[6]) && this.string(msg[7]) && this.string(msg[8])
break break
case Messages.Type.ConnectionInformation: case Messages.Type.ConnectionInformation:
return this.uint(msg[1]) && this.string(msg[2]) return this.uint(msg[1]) && this.string(msg[2])
break break
case Messages.Type.SetPageVisibility: case Messages.Type.SetPageVisibility:
return this.boolean(msg[1]) return this.boolean(msg[1])
break break
case Messages.Type.LongTask: case Messages.Type.LongTask:
return this.uint(msg[1]) && this.uint(msg[2]) && this.uint(msg[3]) && this.uint(msg[4]) && this.string(msg[5]) && this.string(msg[6]) && this.string(msg[7]) return this.uint(msg[1]) && this.uint(msg[2]) && this.uint(msg[3]) && this.uint(msg[4]) && this.string(msg[5]) && this.string(msg[6]) && this.string(msg[7])
break break
case Messages.Type.SetNodeAttributeURLBased: case Messages.Type.SetNodeAttributeURLBased:
return this.uint(msg[1]) && this.string(msg[2]) && this.string(msg[3]) && this.string(msg[4]) return this.uint(msg[1]) && this.string(msg[2]) && this.string(msg[3]) && this.string(msg[4])
break break
case Messages.Type.SetCSSDataURLBased: case Messages.Type.SetCSSDataURLBased:
return this.uint(msg[1]) && this.string(msg[2]) && this.string(msg[3]) return this.uint(msg[1]) && this.string(msg[2]) && this.string(msg[3])
break break
case Messages.Type.TechnicalInfo: case Messages.Type.TechnicalInfo:
return this.string(msg[1]) && this.string(msg[2]) return this.string(msg[1]) && this.string(msg[2])
break break
case Messages.Type.CustomIssue: case Messages.Type.CustomIssue:
return this.string(msg[1]) && this.string(msg[2]) return this.string(msg[1]) && this.string(msg[2])
break break
case Messages.Type.CSSInsertRuleURLBased: case Messages.Type.CSSInsertRuleURLBased:
return this.uint(msg[1]) && this.string(msg[2]) && this.uint(msg[3]) && this.string(msg[4]) return this.uint(msg[1]) && this.string(msg[2]) && this.uint(msg[3]) && this.string(msg[4])
break break
case Messages.Type.MouseClick: case Messages.Type.MouseClick:
return this.uint(msg[1]) && this.uint(msg[2]) && this.string(msg[3]) && this.string(msg[4]) return this.uint(msg[1]) && this.uint(msg[2]) && this.string(msg[3]) && this.string(msg[4])
break break
case Messages.Type.CreateIFrameDocument: case Messages.Type.CreateIFrameDocument:
return this.uint(msg[1]) && this.uint(msg[2]) return this.uint(msg[1]) && this.uint(msg[2])
break break
case Messages.Type.AdoptedSSReplaceURLBased: case Messages.Type.AdoptedSSReplaceURLBased:
return this.uint(msg[1]) && this.string(msg[2]) && this.string(msg[3]) return this.uint(msg[1]) && this.string(msg[2]) && this.string(msg[3])
break break
case Messages.Type.AdoptedSSInsertRuleURLBased: case Messages.Type.AdoptedSSInsertRuleURLBased:
return this.uint(msg[1]) && this.string(msg[2]) && this.uint(msg[3]) && this.string(msg[4]) return this.uint(msg[1]) && this.string(msg[2]) && this.uint(msg[3]) && this.string(msg[4])
break break
case Messages.Type.AdoptedSSDeleteRule: case Messages.Type.AdoptedSSDeleteRule:
return this.uint(msg[1]) && this.uint(msg[2]) return this.uint(msg[1]) && this.uint(msg[2])
break break
case Messages.Type.AdoptedSSAddOwner: case Messages.Type.AdoptedSSAddOwner:
return this.uint(msg[1]) && this.uint(msg[2]) return this.uint(msg[1]) && this.uint(msg[2])
break break
case Messages.Type.AdoptedSSRemoveOwner: case Messages.Type.AdoptedSSRemoveOwner:
return this.uint(msg[1]) && this.uint(msg[2]) return this.uint(msg[1]) && this.uint(msg[2])
break break
case Messages.Type.Zustand: case Messages.Type.Zustand:
return this.string(msg[1]) && this.string(msg[2]) return this.string(msg[1]) && this.string(msg[2])
break
case Messages.Type.ReplaceVCSS:
return this.uint(msg[1]) && this.string(msg[2]) && this.string(msg[3]) && this.string(msg[4])
break break
} }
} }
}
}