@cloudcare/browser-rum 3.2.33 → 3.2.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundle/dataflux-rum.js +1 -1
- package/cjs/boot/buildEnv.js +1 -1
- package/cjs/domain/assembly.js +1 -0
- package/cjs/domain/assembly.js.map +1 -1
- package/cjs/domain/contexts/internalContext.js +1 -0
- package/cjs/domain/contexts/internalContext.js.map +1 -1
- package/cjs/domain/contexts/urlContexts.js +4 -2
- package/cjs/domain/contexts/urlContexts.js.map +1 -1
- package/cjs/domain/deflate/deflateEncoder.js +36 -41
- package/cjs/domain/deflate/deflateEncoder.js.map +1 -1
- package/cjs/domain/deflate/deflateWorker.js +1 -1
- package/cjs/domain/locationChangeObservable.js +7 -2
- package/cjs/domain/locationChangeObservable.js.map +1 -1
- package/esm/boot/buildEnv.js +1 -1
- package/esm/domain/assembly.js +1 -0
- package/esm/domain/assembly.js.map +1 -1
- package/esm/domain/contexts/internalContext.js +1 -0
- package/esm/domain/contexts/internalContext.js.map +1 -1
- package/esm/domain/contexts/urlContexts.js +4 -2
- package/esm/domain/contexts/urlContexts.js.map +1 -1
- package/esm/domain/deflate/deflateEncoder.js +36 -41
- package/esm/domain/deflate/deflateEncoder.js.map +1 -1
- package/esm/domain/deflate/deflateWorker.js +1 -1
- package/esm/domain/locationChangeObservable.js +7 -2
- package/esm/domain/locationChangeObservable.js.map +1 -1
- package/package.json +4 -4
- package/src/domain/assembly.js +1 -0
- package/src/domain/contexts/internalContext.js +1 -0
- package/src/domain/contexts/urlContexts.js +4 -2
- package/src/domain/deflate/deflateEncoder.js +42 -40
- package/src/domain/locationChangeObservable.js +9 -2
- package/types/index.d.ts +1 -0
|
@@ -13,6 +13,7 @@ export function createDeflateEncoder(worker, streamId) {
|
|
|
13
13
|
var compressedData = []
|
|
14
14
|
var compressedDataTrailer
|
|
15
15
|
|
|
16
|
+
var isEmpty = true
|
|
16
17
|
var nextWriteActionId = 0
|
|
17
18
|
var pendingWriteActions = []
|
|
18
19
|
|
|
@@ -24,40 +25,41 @@ export function createDeflateEncoder(worker, streamId) {
|
|
|
24
25
|
) {
|
|
25
26
|
return
|
|
26
27
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
nextPendingAction.
|
|
28
|
+
var nextPendingAction = pendingWriteActions[0]
|
|
29
|
+
if (nextPendingAction) {
|
|
30
|
+
if (nextPendingAction.id === workerResponse.id) {
|
|
31
|
+
pendingWriteActions.shift()
|
|
32
|
+
|
|
33
|
+
rawBytesCount += workerResponse.additionalBytesCount
|
|
34
|
+
compressedData.push(workerResponse.result)
|
|
35
|
+
compressedDataTrailer = workerResponse.trailer
|
|
36
|
+
|
|
37
|
+
if (nextPendingAction.writeCallback) {
|
|
38
|
+
nextPendingAction.writeCallback(workerResponse.result.byteLength)
|
|
39
|
+
} else if (nextPendingAction.finishCallback) {
|
|
40
|
+
nextPendingAction.finishCallback()
|
|
41
|
+
}
|
|
42
|
+
} else if (nextPendingAction.id < workerResponse.id) {
|
|
43
|
+
removeMessageListener()
|
|
44
|
+
addTelemetryDebug('Worker responses received out of order.')
|
|
37
45
|
}
|
|
38
|
-
} else {
|
|
39
|
-
removeMessageListener()
|
|
40
|
-
addTelemetryDebug('Worker responses received out of order.')
|
|
41
46
|
}
|
|
47
|
+
// rawBytesCount += workerResponse.additionalBytesCount
|
|
48
|
+
// compressedData.push(workerResponse.result)
|
|
49
|
+
// compressedDataTrailer = workerResponse.trailer
|
|
50
|
+
// var nextPendingAction = pendingWriteActions.shift()
|
|
51
|
+
// if (nextPendingAction && nextPendingAction.id === workerResponse.id) {
|
|
52
|
+
// if (nextPendingAction.writeCallback) {
|
|
53
|
+
// nextPendingAction.writeCallback(workerResponse.result.byteLength)
|
|
54
|
+
// } else if (nextPendingAction.finishCallback) {
|
|
55
|
+
// nextPendingAction.finishCallback()
|
|
56
|
+
// }
|
|
57
|
+
// } else {
|
|
58
|
+
// removeMessageListener()
|
|
59
|
+
// addTelemetryDebug('Worker responses received out of order.')
|
|
60
|
+
// }
|
|
42
61
|
})
|
|
43
|
-
function uint8ToBase64(uint8, start = 0, end = uint8.length) {
|
|
44
|
-
// 截取需要的部分
|
|
45
|
-
const sliced = uint8.slice(start, end)
|
|
46
62
|
|
|
47
|
-
// 转成字符串
|
|
48
|
-
const binary = Array.from(sliced, (byte) => String.fromCharCode(byte)).join(
|
|
49
|
-
''
|
|
50
|
-
)
|
|
51
|
-
|
|
52
|
-
// 编码成 base64
|
|
53
|
-
return btoa(binary)
|
|
54
|
-
}
|
|
55
|
-
function uint8ToHex(uint8, start = 0, end = uint8.length) {
|
|
56
|
-
const sliced = uint8.slice(start, end)
|
|
57
|
-
return Array.from(sliced)
|
|
58
|
-
.map((byte) => byte.toString(16).padStart(2, '0'))
|
|
59
|
-
.join('')
|
|
60
|
-
}
|
|
61
63
|
var removeMessageListener = wokerListener.stop
|
|
62
64
|
|
|
63
65
|
function consumeResult() {
|
|
@@ -78,18 +80,18 @@ export function createDeflateEncoder(worker, streamId) {
|
|
|
78
80
|
}
|
|
79
81
|
|
|
80
82
|
function sendResetIfNeeded() {
|
|
81
|
-
if (
|
|
83
|
+
if (!isEmpty) {
|
|
82
84
|
worker.postMessage({
|
|
83
85
|
action: 'reset',
|
|
84
86
|
streamId: streamId
|
|
85
87
|
})
|
|
86
|
-
|
|
88
|
+
isEmpty = true
|
|
87
89
|
}
|
|
88
90
|
}
|
|
89
91
|
return {
|
|
90
92
|
isAsync: true,
|
|
91
93
|
isEmpty: function () {
|
|
92
|
-
return
|
|
94
|
+
return isEmpty
|
|
93
95
|
},
|
|
94
96
|
|
|
95
97
|
write: function (data, callback) {
|
|
@@ -104,6 +106,7 @@ export function createDeflateEncoder(worker, streamId) {
|
|
|
104
106
|
writeCallback: callback,
|
|
105
107
|
data: data
|
|
106
108
|
})
|
|
109
|
+
isEmpty = false
|
|
107
110
|
nextWriteActionId += 1
|
|
108
111
|
},
|
|
109
112
|
|
|
@@ -129,13 +132,12 @@ export function createDeflateEncoder(worker, streamId) {
|
|
|
129
132
|
finishSync: function () {
|
|
130
133
|
sendResetIfNeeded()
|
|
131
134
|
|
|
132
|
-
var pendingData = pendingWriteActions
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
135
|
+
var pendingData = pendingWriteActions
|
|
136
|
+
.map(function (pendingWriteAction) {
|
|
137
|
+
return pendingWriteAction.data
|
|
138
|
+
})
|
|
139
|
+
.join('')
|
|
140
|
+
pendingWriteActions.length = 0
|
|
139
141
|
return assign(consumeResult(), {
|
|
140
142
|
pendingData: pendingData
|
|
141
143
|
})
|
|
@@ -32,7 +32,7 @@ export function createLocationChangeObservable(location) {
|
|
|
32
32
|
function trackHistory(onHistoryChange) {
|
|
33
33
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
34
34
|
var pushState = instrumentMethod(
|
|
35
|
-
|
|
35
|
+
getHistoryInstrumentationTarget('pushState'),
|
|
36
36
|
'pushState',
|
|
37
37
|
function (params) {
|
|
38
38
|
var onPostCall = params.onPostCall
|
|
@@ -40,7 +40,7 @@ function trackHistory(onHistoryChange) {
|
|
|
40
40
|
}
|
|
41
41
|
)
|
|
42
42
|
var replaceState = instrumentMethod(
|
|
43
|
-
|
|
43
|
+
getHistoryInstrumentationTarget('replaceState'),
|
|
44
44
|
'replaceState',
|
|
45
45
|
function (params) {
|
|
46
46
|
var onPostCall = params.onPostCall
|
|
@@ -61,3 +61,10 @@ function trackHistory(onHistoryChange) {
|
|
|
61
61
|
function trackHash(onHashChange) {
|
|
62
62
|
return addEventListener(window, DOM_EVENT.HASH_CHANGE, onHashChange)
|
|
63
63
|
}
|
|
64
|
+
function getHistoryInstrumentationTarget(methodName) {
|
|
65
|
+
// Ideally we should always instument the method on the prototype, however some frameworks (e.g [Next.js](https://github.com/vercel/next.js/blob/d3f5532065f3e3bb84fb54bd2dfd1a16d0f03a21/packages/next/src/client/components/app-router.tsx#L429))
|
|
66
|
+
// are wrapping the instance method. In that case we should also wrap the instance method.
|
|
67
|
+
return Object.prototype.hasOwnProperty.call(history, methodName)
|
|
68
|
+
? history
|
|
69
|
+
: History.prototype
|
|
70
|
+
}
|