Str dict global (#3064)
* testing global string dictionary * ui: v bump * tracker: save last prefix * tracker: substract years from dateid * tracker: fix digit shaving
This commit is contained in:
parent
264f35cc9e
commit
ac232ef599
18 changed files with 248 additions and 21 deletions
|
|
@ -10,5 +10,5 @@ func IsMobileType(id int) bool {
|
|||
}
|
||||
|
||||
func IsDOMType(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 || 37 == id || 38 == id || 49 == id || 50 == id || 51 == id || 43 == id || 52 == id || 54 == id || 55 == id || 57 == id || 58 == id || 59 == id || 60 == id || 61 == id || 67 == id || 68 == id || 69 == id || 70 == id || 71 == id || 72 == id || 73 == id || 74 == id || 75 == id || 76 == id || 77 == id || 113 == id || 114 == id || 117 == id || 118 == id || 119 == id || 122 == id || 93 == id || 96 == id || 100 == id || 101 == id || 102 == id || 103 == id || 104 == id || 105 == id || 106 == id || 111 == 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 || 34 == id || 35 == id || 37 == id || 38 == id || 49 == id || 50 == id || 51 == id || 43 == id || 52 == id || 54 == id || 55 == id || 57 == id || 58 == id || 59 == id || 60 == id || 61 == id || 67 == id || 68 == id || 69 == id || 70 == id || 71 == id || 72 == id || 73 == id || 74 == id || 75 == id || 76 == id || 77 == id || 113 == id || 114 == id || 117 == id || 118 == id || 119 == id || 122 == id || 93 == id || 96 == id || 100 == id || 101 == id || 102 == id || 103 == id || 104 == id || 105 == id || 106 == id || 111 == id
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@ const (
|
|||
MsgPageEventDeprecated = 31
|
||||
MsgInputEvent = 32
|
||||
MsgPageEvent = 33
|
||||
MsgStringDictGlobal = 34
|
||||
MsgSetNodeAttributeDictGlobal = 35
|
||||
MsgCSSInsertRule = 37
|
||||
MsgCSSDeleteRule = 38
|
||||
MsgFetch = 39
|
||||
|
|
@ -1015,6 +1017,54 @@ func (msg *PageEvent) TypeID() int {
|
|||
return 33
|
||||
}
|
||||
|
||||
type StringDictGlobal struct {
|
||||
message
|
||||
Key uint64
|
||||
Value string
|
||||
}
|
||||
|
||||
func (msg *StringDictGlobal) Encode() []byte {
|
||||
buf := make([]byte, 21+len(msg.Value))
|
||||
buf[0] = 34
|
||||
p := 1
|
||||
p = WriteUint(msg.Key, buf, p)
|
||||
p = WriteString(msg.Value, buf, p)
|
||||
return buf[:p]
|
||||
}
|
||||
|
||||
func (msg *StringDictGlobal) Decode() Message {
|
||||
return msg
|
||||
}
|
||||
|
||||
func (msg *StringDictGlobal) TypeID() int {
|
||||
return 34
|
||||
}
|
||||
|
||||
type SetNodeAttributeDictGlobal struct {
|
||||
message
|
||||
ID uint64
|
||||
Name uint64
|
||||
Value uint64
|
||||
}
|
||||
|
||||
func (msg *SetNodeAttributeDictGlobal) Encode() []byte {
|
||||
buf := make([]byte, 31)
|
||||
buf[0] = 35
|
||||
p := 1
|
||||
p = WriteUint(msg.ID, buf, p)
|
||||
p = WriteUint(msg.Name, buf, p)
|
||||
p = WriteUint(msg.Value, buf, p)
|
||||
return buf[:p]
|
||||
}
|
||||
|
||||
func (msg *SetNodeAttributeDictGlobal) Decode() Message {
|
||||
return msg
|
||||
}
|
||||
|
||||
func (msg *SetNodeAttributeDictGlobal) TypeID() int {
|
||||
return 35
|
||||
}
|
||||
|
||||
type CSSInsertRule struct {
|
||||
message
|
||||
ID uint64
|
||||
|
|
|
|||
|
|
@ -606,6 +606,33 @@ func DecodePageEvent(reader BytesReader) (Message, error) {
|
|||
return msg, err
|
||||
}
|
||||
|
||||
func DecodeStringDictGlobal(reader BytesReader) (Message, error) {
|
||||
var err error = nil
|
||||
msg := &StringDictGlobal{}
|
||||
if msg.Key, err = reader.ReadUint(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if msg.Value, err = reader.ReadString(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return msg, err
|
||||
}
|
||||
|
||||
func DecodeSetNodeAttributeDictGlobal(reader BytesReader) (Message, error) {
|
||||
var err error = nil
|
||||
msg := &SetNodeAttributeDictGlobal{}
|
||||
if msg.ID, err = reader.ReadUint(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if msg.Name, err = reader.ReadUint(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if msg.Value, err = reader.ReadUint(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return msg, err
|
||||
}
|
||||
|
||||
func DecodeCSSInsertRule(reader BytesReader) (Message, error) {
|
||||
var err error = nil
|
||||
msg := &CSSInsertRule{}
|
||||
|
|
@ -2123,6 +2150,10 @@ func ReadMessage(t uint64, reader BytesReader) (Message, error) {
|
|||
return DecodeInputEvent(reader)
|
||||
case 33:
|
||||
return DecodePageEvent(reader)
|
||||
case 34:
|
||||
return DecodeStringDictGlobal(reader)
|
||||
case 35:
|
||||
return DecodeSetNodeAttributeDictGlobal(reader)
|
||||
case 37:
|
||||
return DecodeCSSInsertRule(reader)
|
||||
case 38:
|
||||
|
|
|
|||
|
|
@ -300,6 +300,7 @@ export default class DOMManager extends ListWalker<Message> {
|
|||
case MType.SetNodeAttribute:
|
||||
this.setNodeAttribute(msg);
|
||||
return;
|
||||
case MType.SetNodeAttributeDictGlobal:
|
||||
case MType.SetNodeAttributeDict:
|
||||
const name = this.globalDict.get(msg.name);
|
||||
const value = this.globalDict.get(msg.value);
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ export default class PagesManager extends ListWalker<DOMManager> {
|
|||
*/
|
||||
falseOrder = false;
|
||||
appendMessage(m: Message): void {
|
||||
if (m.tp === MType.StringDict) {
|
||||
if ([MType.StringDict, MType.StringDictGlobal].includes(m.tp)) {
|
||||
this.globalDictionary.set(m.key, m.value);
|
||||
return;
|
||||
}
|
||||
|
|
@ -61,6 +61,7 @@ export default class PagesManager extends ListWalker<DOMManager> {
|
|||
},
|
||||
})
|
||||
);
|
||||
console.log(this.globalDictionary)
|
||||
this.falseOrder = false;
|
||||
}
|
||||
if (this.last === null) {
|
||||
|
|
|
|||
|
|
@ -233,6 +233,28 @@ export default class RawMessageReader extends PrimitiveReader {
|
|||
};
|
||||
}
|
||||
|
||||
case 34: {
|
||||
const key = this.readUint(); if (key === null) { return resetPointer() }
|
||||
const value = this.readString(); if (value === null) { return resetPointer() }
|
||||
return {
|
||||
tp: MType.StringDictGlobal,
|
||||
key,
|
||||
value,
|
||||
};
|
||||
}
|
||||
|
||||
case 35: {
|
||||
const id = this.readUint(); if (id === null) { return resetPointer() }
|
||||
const name = this.readUint(); if (name === null) { return resetPointer() }
|
||||
const value = this.readUint(); if (value === null) { return resetPointer() }
|
||||
return {
|
||||
tp: MType.SetNodeAttributeDictGlobal,
|
||||
id,
|
||||
name,
|
||||
value,
|
||||
};
|
||||
}
|
||||
|
||||
case 37: {
|
||||
const id = this.readUint(); if (id === null) { return resetPointer() }
|
||||
const rule = this.readString(); if (rule === null) { return resetPointer() }
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
import { MType } from './raw.gen'
|
||||
|
||||
const IOS_TYPES = [90,91,92,93,94,95,96,97,98,100,101,102,103,104,105,106,107,110,111]
|
||||
const DOM_TYPES = [0,4,5,6,7,8,9,10,11,12,13,14,15,16,18,19,20,37,38,49,50,51,43,52,54,55,57,58,59,60,61,67,68,69,70,71,72,73,74,75,76,77,113,114,117,118,119,122]
|
||||
const DOM_TYPES = [0,4,5,6,7,8,9,10,11,12,13,14,15,16,18,19,20,34,35,37,38,49,50,51,43,52,54,55,57,58,59,60,61,67,68,69,70,71,72,73,74,75,76,77,113,114,117,118,119,122]
|
||||
export function isDOMType(t: MType) {
|
||||
return DOM_TYPES.includes(t)
|
||||
}
|
||||
|
|
@ -23,6 +23,8 @@ import type {
|
|||
RawMouseMove,
|
||||
RawNetworkRequestDeprecated,
|
||||
RawConsoleLog,
|
||||
RawStringDictGlobal,
|
||||
RawSetNodeAttributeDictGlobal,
|
||||
RawCssInsertRule,
|
||||
RawCssDeleteRule,
|
||||
RawFetch,
|
||||
|
|
@ -123,6 +125,10 @@ export type NetworkRequestDeprecated = RawNetworkRequestDeprecated & Timed
|
|||
|
||||
export type ConsoleLog = RawConsoleLog & Timed
|
||||
|
||||
export type StringDictGlobal = RawStringDictGlobal & Timed
|
||||
|
||||
export type SetNodeAttributeDictGlobal = RawSetNodeAttributeDictGlobal & Timed
|
||||
|
||||
export type CssInsertRule = RawCssInsertRule & Timed
|
||||
|
||||
export type CssDeleteRule = RawCssDeleteRule & Timed
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ export const enum MType {
|
|||
MouseMove = 20,
|
||||
NetworkRequestDeprecated = 21,
|
||||
ConsoleLog = 22,
|
||||
StringDictGlobal = 34,
|
||||
SetNodeAttributeDictGlobal = 35,
|
||||
CssInsertRule = 37,
|
||||
CssDeleteRule = 38,
|
||||
Fetch = 39,
|
||||
|
|
@ -207,6 +209,19 @@ export interface RawConsoleLog {
|
|||
value: string,
|
||||
}
|
||||
|
||||
export interface RawStringDictGlobal {
|
||||
tp: MType.StringDictGlobal,
|
||||
key: number,
|
||||
value: string,
|
||||
}
|
||||
|
||||
export interface RawSetNodeAttributeDictGlobal {
|
||||
tp: MType.SetNodeAttributeDictGlobal,
|
||||
id: number,
|
||||
name: number,
|
||||
value: number,
|
||||
}
|
||||
|
||||
export interface RawCssInsertRule {
|
||||
tp: MType.CssInsertRule,
|
||||
id: number,
|
||||
|
|
@ -647,4 +662,4 @@ export interface RawMobileIssueEvent {
|
|||
}
|
||||
|
||||
|
||||
export type RawMessage = RawTimestamp | RawSetPageLocationDeprecated | RawSetViewportSize | RawSetViewportScroll | RawCreateDocument | RawCreateElementNode | RawCreateTextNode | RawMoveNode | RawRemoveNode | RawSetNodeAttribute | RawRemoveNodeAttribute | RawSetNodeData | RawSetCssData | RawSetNodeScroll | RawSetInputValue | RawSetInputChecked | RawMouseMove | RawNetworkRequestDeprecated | RawConsoleLog | RawCssInsertRule | RawCssDeleteRule | RawFetch | RawProfiler | RawOTable | RawReduxDeprecated | RawVuex | RawMobX | RawNgRx | RawGraphQlDeprecated | RawPerformanceTrack | RawStringDictDeprecated | RawSetNodeAttributeDictDeprecated | RawStringDict | RawSetNodeAttributeDict | RawResourceTimingDeprecated | RawConnectionInformation | RawSetPageVisibility | RawLoadFontFace | RawSetNodeFocus | RawLongTask | RawSetNodeAttributeURLBased | RawSetCssDataURLBased | RawCssInsertRuleURLBased | RawMouseClick | RawMouseClickDeprecated | RawCreateIFrameDocument | RawAdoptedSsReplaceURLBased | RawAdoptedSsReplace | RawAdoptedSsInsertRuleURLBased | RawAdoptedSsInsertRule | RawAdoptedSsDeleteRule | RawAdoptedSsAddOwner | RawAdoptedSsRemoveOwner | RawZustand | RawNetworkRequest | RawWsChannel | RawSelectionChange | RawMouseThrashing | RawResourceTiming | RawTabChange | RawTabData | RawCanvasNode | RawTagTrigger | RawRedux | RawSetPageLocation | RawGraphQl | RawMobileEvent | RawMobileScreenChanges | RawMobileClickEvent | RawMobileInputEvent | RawMobilePerformanceEvent | RawMobileLog | RawMobileInternalError | RawMobileNetworkCall | RawMobileSwipeEvent | RawMobileIssueEvent;
|
||||
export type RawMessage = RawTimestamp | RawSetPageLocationDeprecated | RawSetViewportSize | RawSetViewportScroll | RawCreateDocument | RawCreateElementNode | RawCreateTextNode | RawMoveNode | RawRemoveNode | RawSetNodeAttribute | RawRemoveNodeAttribute | RawSetNodeData | RawSetCssData | RawSetNodeScroll | RawSetInputValue | RawSetInputChecked | RawMouseMove | RawNetworkRequestDeprecated | RawConsoleLog | RawStringDictGlobal | RawSetNodeAttributeDictGlobal | RawCssInsertRule | RawCssDeleteRule | RawFetch | RawProfiler | RawOTable | RawReduxDeprecated | RawVuex | RawMobX | RawNgRx | RawGraphQlDeprecated | RawPerformanceTrack | RawStringDictDeprecated | RawSetNodeAttributeDictDeprecated | RawStringDict | RawSetNodeAttributeDict | RawResourceTimingDeprecated | RawConnectionInformation | RawSetPageVisibility | RawLoadFontFace | RawSetNodeFocus | RawLongTask | RawSetNodeAttributeURLBased | RawSetCssDataURLBased | RawCssInsertRuleURLBased | RawMouseClick | RawMouseClickDeprecated | RawCreateIFrameDocument | RawAdoptedSsReplaceURLBased | RawAdoptedSsReplace | RawAdoptedSsInsertRuleURLBased | RawAdoptedSsInsertRule | RawAdoptedSsDeleteRule | RawAdoptedSsAddOwner | RawAdoptedSsRemoveOwner | RawZustand | RawNetworkRequest | RawWsChannel | RawSelectionChange | RawMouseThrashing | RawResourceTiming | RawTabChange | RawTabData | RawCanvasNode | RawTagTrigger | RawRedux | RawSetPageLocation | RawGraphQl | RawMobileEvent | RawMobileScreenChanges | RawMobileClickEvent | RawMobileInputEvent | RawMobilePerformanceEvent | RawMobileLog | RawMobileInternalError | RawMobileNetworkCall | RawMobileSwipeEvent | RawMobileIssueEvent;
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ export const TP_MAP = {
|
|||
20: MType.MouseMove,
|
||||
21: MType.NetworkRequestDeprecated,
|
||||
22: MType.ConsoleLog,
|
||||
34: MType.StringDictGlobal,
|
||||
35: MType.SetNodeAttributeDictGlobal,
|
||||
37: MType.CssInsertRule,
|
||||
38: MType.CssDeleteRule,
|
||||
39: MType.Fetch,
|
||||
|
|
|
|||
|
|
@ -173,6 +173,19 @@ type TrMetadata = [
|
|||
value: string,
|
||||
]
|
||||
|
||||
type TrStringDictGlobal = [
|
||||
type: 34,
|
||||
key: number,
|
||||
value: string,
|
||||
]
|
||||
|
||||
type TrSetNodeAttributeDictGlobal = [
|
||||
type: 35,
|
||||
id: number,
|
||||
name: number,
|
||||
value: number,
|
||||
]
|
||||
|
||||
type TrCSSInsertRule = [
|
||||
type: 37,
|
||||
id: number,
|
||||
|
|
@ -570,7 +583,7 @@ type TrWebVitals = [
|
|||
]
|
||||
|
||||
|
||||
export type TrackerMessage = TrTimestamp | TrSetPageLocationDeprecated | TrSetViewportSize | TrSetViewportScroll | TrCreateDocument | TrCreateElementNode | TrCreateTextNode | TrMoveNode | TrRemoveNode | TrSetNodeAttribute | TrRemoveNodeAttribute | TrSetNodeData | TrSetNodeScroll | TrSetInputTarget | TrSetInputValue | TrSetInputChecked | TrMouseMove | TrNetworkRequestDeprecated | TrConsoleLog | TrPageLoadTiming | TrPageRenderTiming | TrCustomEvent | TrUserID | TrUserAnonymousID | TrMetadata | TrCSSInsertRule | TrCSSDeleteRule | TrFetch | TrProfiler | TrOTable | TrStateAction | TrReduxDeprecated | TrVuex | TrMobX | TrNgRx | TrGraphQLDeprecated | TrPerformanceTrack | TrStringDictDeprecated | TrSetNodeAttributeDictDeprecated | TrStringDict | TrSetNodeAttributeDict | TrResourceTimingDeprecated | TrConnectionInformation | TrSetPageVisibility | TrLoadFontFace | TrSetNodeFocus | TrLongTask | TrSetNodeAttributeURLBased | TrSetCSSDataURLBased | TrTechnicalInfo | TrCustomIssue | TrCSSInsertRuleURLBased | TrMouseClick | TrMouseClickDeprecated | TrCreateIFrameDocument | TrAdoptedSSReplaceURLBased | TrAdoptedSSInsertRuleURLBased | TrAdoptedSSDeleteRule | TrAdoptedSSAddOwner | TrAdoptedSSRemoveOwner | TrJSException | TrZustand | TrBatchMetadata | TrPartitionedMessage | TrNetworkRequest | TrWSChannel | TrInputChange | TrSelectionChange | TrMouseThrashing | TrUnbindNodes | TrResourceTiming | TrTabChange | TrTabData | TrCanvasNode | TrTagTrigger | TrRedux | TrSetPageLocation | TrGraphQL | TrWebVitals
|
||||
export type TrackerMessage = TrTimestamp | TrSetPageLocationDeprecated | TrSetViewportSize | TrSetViewportScroll | TrCreateDocument | TrCreateElementNode | TrCreateTextNode | TrMoveNode | TrRemoveNode | TrSetNodeAttribute | TrRemoveNodeAttribute | TrSetNodeData | TrSetNodeScroll | TrSetInputTarget | TrSetInputValue | TrSetInputChecked | TrMouseMove | TrNetworkRequestDeprecated | TrConsoleLog | TrPageLoadTiming | TrPageRenderTiming | TrCustomEvent | TrUserID | TrUserAnonymousID | TrMetadata | TrStringDictGlobal | TrSetNodeAttributeDictGlobal | TrCSSInsertRule | TrCSSDeleteRule | TrFetch | TrProfiler | TrOTable | TrStateAction | TrReduxDeprecated | TrVuex | TrMobX | TrNgRx | TrGraphQLDeprecated | TrPerformanceTrack | TrStringDictDeprecated | TrSetNodeAttributeDictDeprecated | TrStringDict | TrSetNodeAttributeDict | TrResourceTimingDeprecated | TrConnectionInformation | TrSetPageVisibility | TrLoadFontFace | TrSetNodeFocus | TrLongTask | TrSetNodeAttributeURLBased | TrSetCSSDataURLBased | TrTechnicalInfo | TrCustomIssue | TrCSSInsertRuleURLBased | TrMouseClick | TrMouseClickDeprecated | TrCreateIFrameDocument | TrAdoptedSSReplaceURLBased | TrAdoptedSSInsertRuleURLBased | TrAdoptedSSDeleteRule | TrAdoptedSSAddOwner | TrAdoptedSSRemoveOwner | TrJSException | TrZustand | TrBatchMetadata | TrPartitionedMessage | TrNetworkRequest | TrWSChannel | TrInputChange | TrSelectionChange | TrMouseThrashing | TrUnbindNodes | TrResourceTiming | TrTabChange | TrTabData | TrCanvasNode | TrTagTrigger | TrRedux | TrSetPageLocation | TrGraphQL | TrWebVitals
|
||||
|
||||
export default function translate(tMsg: TrackerMessage): RawMessage | null {
|
||||
switch(tMsg[0]) {
|
||||
|
|
@ -731,6 +744,23 @@ export default function translate(tMsg: TrackerMessage): RawMessage | null {
|
|||
}
|
||||
}
|
||||
|
||||
case 34: {
|
||||
return {
|
||||
tp: MType.StringDictGlobal,
|
||||
key: tMsg[1],
|
||||
value: tMsg[2],
|
||||
}
|
||||
}
|
||||
|
||||
case 35: {
|
||||
return {
|
||||
tp: MType.SetNodeAttributeDictGlobal,
|
||||
id: tMsg[1],
|
||||
name: tMsg[2],
|
||||
value: tMsg[3],
|
||||
}
|
||||
}
|
||||
|
||||
case 37: {
|
||||
return {
|
||||
tp: MType.CssInsertRule,
|
||||
|
|
|
|||
|
|
@ -210,6 +210,16 @@ message 33, 'PageEvent', :tracker => false, :replayer => false do
|
|||
string 'WebVitals'
|
||||
end
|
||||
|
||||
message 34, "StringDictGlobal" do
|
||||
uint "Key"
|
||||
string "Value"
|
||||
end
|
||||
message 35, 'SetNodeAttributeDictGlobal' do
|
||||
uint 'ID'
|
||||
uint 'Name'
|
||||
uint 'Value'
|
||||
end
|
||||
|
||||
# DEPRECATED since 4.0.2 in favor of AdoptedSSInsertRule + AdoptedSSAddOwner
|
||||
message 37, 'CSSInsertRule' do
|
||||
uint 'ID'
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "@openreplay/tracker",
|
||||
"description": "The OpenReplay tracker main package",
|
||||
"version": "15.0.5-beta.1",
|
||||
"version": "16.0.0-beta.4",
|
||||
"keywords": [
|
||||
"logging",
|
||||
"replay"
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ export declare const enum Type {
|
|||
UserID = 28,
|
||||
UserAnonymousID = 29,
|
||||
Metadata = 30,
|
||||
StringDictGlobal = 34,
|
||||
SetNodeAttributeDictGlobal = 35,
|
||||
CSSInsertRule = 37,
|
||||
CSSDeleteRule = 38,
|
||||
Fetch = 39,
|
||||
|
|
@ -252,6 +254,19 @@ export type Metadata = [
|
|||
/*value:*/ string,
|
||||
]
|
||||
|
||||
export type StringDictGlobal = [
|
||||
/*type:*/ Type.StringDictGlobal,
|
||||
/*key:*/ number,
|
||||
/*value:*/ string,
|
||||
]
|
||||
|
||||
export type SetNodeAttributeDictGlobal = [
|
||||
/*type:*/ Type.SetNodeAttributeDictGlobal,
|
||||
/*id:*/ number,
|
||||
/*name:*/ number,
|
||||
/*value:*/ number,
|
||||
]
|
||||
|
||||
export type CSSInsertRule = [
|
||||
/*type:*/ Type.CSSInsertRule,
|
||||
/*id:*/ number,
|
||||
|
|
@ -649,5 +664,5 @@ export type WebVitals = [
|
|||
]
|
||||
|
||||
|
||||
type Message = Timestamp | SetPageLocationDeprecated | SetViewportSize | SetViewportScroll | CreateDocument | CreateElementNode | CreateTextNode | MoveNode | RemoveNode | SetNodeAttribute | RemoveNodeAttribute | SetNodeData | SetNodeScroll | SetInputTarget | SetInputValue | SetInputChecked | MouseMove | NetworkRequestDeprecated | ConsoleLog | PageLoadTiming | PageRenderTiming | CustomEvent | UserID | UserAnonymousID | Metadata | CSSInsertRule | CSSDeleteRule | Fetch | Profiler | OTable | StateAction | ReduxDeprecated | Vuex | MobX | NgRx | GraphQLDeprecated | PerformanceTrack | StringDictDeprecated | SetNodeAttributeDictDeprecated | StringDict | SetNodeAttributeDict | ResourceTimingDeprecated | ConnectionInformation | SetPageVisibility | LoadFontFace | SetNodeFocus | LongTask | SetNodeAttributeURLBased | SetCSSDataURLBased | TechnicalInfo | CustomIssue | CSSInsertRuleURLBased | MouseClick | MouseClickDeprecated | CreateIFrameDocument | AdoptedSSReplaceURLBased | AdoptedSSInsertRuleURLBased | AdoptedSSDeleteRule | AdoptedSSAddOwner | AdoptedSSRemoveOwner | JSException | Zustand | BatchMetadata | PartitionedMessage | NetworkRequest | WSChannel | InputChange | SelectionChange | MouseThrashing | UnbindNodes | ResourceTiming | TabChange | TabData | CanvasNode | TagTrigger | Redux | SetPageLocation | GraphQL | WebVitals
|
||||
type Message = Timestamp | SetPageLocationDeprecated | SetViewportSize | SetViewportScroll | CreateDocument | CreateElementNode | CreateTextNode | MoveNode | RemoveNode | SetNodeAttribute | RemoveNodeAttribute | SetNodeData | SetNodeScroll | SetInputTarget | SetInputValue | SetInputChecked | MouseMove | NetworkRequestDeprecated | ConsoleLog | PageLoadTiming | PageRenderTiming | CustomEvent | UserID | UserAnonymousID | Metadata | StringDictGlobal | SetNodeAttributeDictGlobal | CSSInsertRule | CSSDeleteRule | Fetch | Profiler | OTable | StateAction | ReduxDeprecated | Vuex | MobX | NgRx | GraphQLDeprecated | PerformanceTrack | StringDictDeprecated | SetNodeAttributeDictDeprecated | StringDict | SetNodeAttributeDict | ResourceTimingDeprecated | ConnectionInformation | SetPageVisibility | LoadFontFace | SetNodeFocus | LongTask | SetNodeAttributeURLBased | SetCSSDataURLBased | TechnicalInfo | CustomIssue | CSSInsertRuleURLBased | MouseClick | MouseClickDeprecated | CreateIFrameDocument | AdoptedSSReplaceURLBased | AdoptedSSInsertRuleURLBased | AdoptedSSDeleteRule | AdoptedSSAddOwner | AdoptedSSRemoveOwner | JSException | Zustand | BatchMetadata | PartitionedMessage | NetworkRequest | WSChannel | InputChange | SelectionChange | MouseThrashing | UnbindNodes | ResourceTiming | TabChange | TabData | CanvasNode | TagTrigger | Redux | SetPageLocation | GraphQL | WebVitals
|
||||
export default Message
|
||||
|
|
|
|||
|
|
@ -316,6 +316,30 @@ export function Metadata(
|
|||
]
|
||||
}
|
||||
|
||||
export function StringDictGlobal(
|
||||
key: number,
|
||||
value: string,
|
||||
): Messages.StringDictGlobal {
|
||||
return [
|
||||
Messages.Type.StringDictGlobal,
|
||||
key,
|
||||
value,
|
||||
]
|
||||
}
|
||||
|
||||
export function SetNodeAttributeDictGlobal(
|
||||
id: number,
|
||||
name: number,
|
||||
value: number,
|
||||
): Messages.SetNodeAttributeDictGlobal {
|
||||
return [
|
||||
Messages.Type.SetNodeAttributeDictGlobal,
|
||||
id,
|
||||
name,
|
||||
value,
|
||||
]
|
||||
}
|
||||
|
||||
export function CSSInsertRule(
|
||||
id: number,
|
||||
rule: string,
|
||||
|
|
|
|||
|
|
@ -1,21 +1,33 @@
|
|||
import { SetNodeAttributeDict, SetNodeAttribute, Type } from '../../common/messages.gen.js'
|
||||
import {
|
||||
SetNodeAttributeDictGlobal,
|
||||
SetNodeAttribute,
|
||||
Type,
|
||||
} from '../../common/messages.gen.js'
|
||||
import App from '../app/index.js'
|
||||
|
||||
export class StringDictionary {
|
||||
private idx = 1
|
||||
private lastTs = 0
|
||||
private lastSuffix = 1
|
||||
/** backwards dictionary of
|
||||
* [repeated str:key]
|
||||
* */
|
||||
private backDict: Record<string, string> = {}
|
||||
private backDict: Record<string, number> = {}
|
||||
|
||||
constructor(private readonly getPageNo: () => number | undefined) {}
|
||||
|
||||
getKey = (str: string): [string, boolean] => {
|
||||
getKey = (str: string): [number, boolean] => {
|
||||
let isNew = false
|
||||
if (!this.backDict[str]) {
|
||||
isNew = true
|
||||
this.backDict[str] = `${this.getPageNo() ?? 0}_${this.idx}`
|
||||
this.idx += 1
|
||||
const digits = Math.floor(Math.log10(Date.now())) + 1
|
||||
const shavedTs = Date.now() % (10 ** (digits - 2))
|
||||
let id: number = shavedTs
|
||||
if (id === this.lastTs) {
|
||||
id = id * 10000 + this.lastSuffix
|
||||
this.lastSuffix += 1
|
||||
} else {
|
||||
this.lastSuffix = 1
|
||||
}
|
||||
this.backDict[str] = id
|
||||
this.lastTs = shavedTs
|
||||
}
|
||||
return [this.backDict[str], isNew]
|
||||
}
|
||||
|
|
@ -28,7 +40,7 @@ export default class AttributeSender {
|
|||
constructor(options: { app: App; isDictDisabled: boolean }) {
|
||||
this.app = options.app
|
||||
this.isDictDisabled = options.isDictDisabled
|
||||
this.dict = new StringDictionary(this.app.session.getPageNumber)
|
||||
this.dict = new StringDictionary()
|
||||
}
|
||||
|
||||
public sendSetAttribute = (id: number, name: string, value: string) => {
|
||||
|
|
@ -36,8 +48,8 @@ export default class AttributeSender {
|
|||
const msg: SetNodeAttribute = [Type.SetNodeAttribute, id, name, value]
|
||||
return this.app.send(msg)
|
||||
} else {
|
||||
const message: SetNodeAttributeDict = [
|
||||
Type.SetNodeAttributeDict,
|
||||
const message: SetNodeAttributeDictGlobal = [
|
||||
Type.SetNodeAttributeDictGlobal,
|
||||
id,
|
||||
this.applyDict(name),
|
||||
this.applyDict(value),
|
||||
|
|
@ -46,15 +58,15 @@ export default class AttributeSender {
|
|||
}
|
||||
}
|
||||
|
||||
private applyDict(str: string): string {
|
||||
private applyDict(str: string): number {
|
||||
const [key, isNew] = this.dict.getKey(str)
|
||||
if (isNew) {
|
||||
this.app.send([Type.StringDict, key, str])
|
||||
this.app.send([Type.StringDictGlobal, key, str])
|
||||
}
|
||||
return key
|
||||
}
|
||||
|
||||
clear() {
|
||||
this.dict = new StringDictionary(this.app.session.getPageNumber)
|
||||
this.dict = new StringDictionary()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,6 +110,14 @@ export default class MessageEncoder extends PrimitiveEncoder {
|
|||
return this.string(msg[1]) && this.string(msg[2])
|
||||
break
|
||||
|
||||
case Messages.Type.StringDictGlobal:
|
||||
return this.uint(msg[1]) && this.string(msg[2])
|
||||
break
|
||||
|
||||
case Messages.Type.SetNodeAttributeDictGlobal:
|
||||
return this.uint(msg[1]) && this.uint(msg[2]) && this.uint(msg[3])
|
||||
break
|
||||
|
||||
case Messages.Type.CSSInsertRule:
|
||||
return this.uint(msg[1]) && this.string(msg[2]) && this.uint(msg[3])
|
||||
break
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue