upgrade to rrweb-snapshot v1.0

This commit is contained in:
Yanzhen Yu
2020-11-29 13:54:37 +08:00
parent f9d8fb7844
commit 7d817be155
7 changed files with 53 additions and 48 deletions

View File

@@ -86,8 +86,8 @@ function record<T = eventWithTime>(
mutationBuffer.isFrozen() &&
e.type !== EventType.FullSnapshot &&
!(
e.type == EventType.IncrementalSnapshot &&
e.data.source == IncrementalSource.Mutation
e.type === EventType.IncrementalSnapshot &&
e.data.source === IncrementalSource.Mutation
)
) {
// we've got a user initiated event so first we need to apply
@@ -128,15 +128,12 @@ function record<T = eventWithTime>(
let wasFrozen = mutationBuffer.isFrozen();
mutationBuffer.freeze(); // don't allow any mirror modifications during snapshotting
const [node, idNodeMap] = snapshot(
document,
const [node, idNodeMap] = snapshot(document, {
blockClass,
inlineStylesheet,
maskInputOptions,
// TODO: bypass slim DOM options
false,
maskAllInputs: maskInputOptions,
recordCanvas,
);
});
if (!node) {
return console.warn('Failed to snapshot the document');

View File

@@ -209,18 +209,17 @@ export default class MutationBuffer {
adds.push({
parentId,
nextId,
node: serializeNodeWithId(
n,
document,
mirror.map,
this.blockClass,
null,
true,
this.inlineStylesheet,
this.maskInputOptions,
undefined,
this.recordCanvas,
)!,
node: serializeNodeWithId(n, {
doc: document,
map: mirror.map,
blockClass: this.blockClass,
blockSelector: null,
skipChild: true,
inlineStylesheet: this.inlineStylesheet,
maskInputOptions: this.maskInputOptions,
slimDOMOptions: {},
recordCanvas: this.recordCanvas,
})!,
});
};
@@ -305,7 +304,7 @@ export default class MutationBuffer {
// attribute mutation's id was not in the mirror map means the target node has been removed
.filter((attribute) => mirror.has(attribute.id)),
removes: this.removes,
adds: adds,
adds,
};
// payload may be empty if the mutations happened in some blocked elements
if (

View File

@@ -57,7 +57,7 @@ function initMutationObserver(
recordCanvas,
);
const observer = new MutationObserver(
mutationBuffer.processMutations.bind(mutationBuffer)
mutationBuffer.processMutations.bind(mutationBuffer),
);
observer.observe(document, {
attributes: true,
@@ -254,8 +254,8 @@ function initInputObserver(
] ||
maskInputOptions[type as keyof MaskInputOptions]
) {
if(maskInputFn) {
text = maskInputFn(text)
if (maskInputFn) {
text = maskInputFn(text);
} else {
text = '*'.repeat(text.length);
}