Skip to content

Commit f3d7fa3

Browse files
Impl record iframe (#481)
* Impl record iframe * iframe observe * temp: add bundle file to git * update bundle * update with pick * update bundle * fix fragment map remove * feat: add an option to determine whether to pause CSS animation when playback is paused (#428) set pauseAnimation to true by default * fix: elements would lose some states like scroll position because of "virtual parent" optimization (#427) * fix: elements would lose some state like scroll position because of "virtual parent" optimization * refactor: the bugfix code bug: elements would lose some state like scroll position because of "virtual parent" optimization * fix: an error occured at applyMutation(remove nodes part) error message: Uncaught (in promise) DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node * pick fixes * revert ignore file * re-impl iframe record * re-impl iframe replay * code housekeeping * move multi layer dimension calculation to replay side * update test cases * teardown test server * upgrade rrweb-snapshot with iframe load timeout Co-authored-by: Lucky Feng <[email protected]>
1 parent 5021c7a commit f3d7fa3

24 files changed

+1414
-246
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,6 @@
6262
"@xstate/fsm": "^1.4.0",
6363
"fflate": "^0.4.4",
6464
"mitt": "^1.1.3",
65-
"rrweb-snapshot": "^1.0.4"
65+
"rrweb-snapshot": "^1.0.6"
6666
}
6767
}

scripts/repl.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,11 @@ function getCode(): string {
8181
width: 1600,
8282
height: 900,
8383
},
84-
args: ['--start-maximized', '--ignore-certificate-errors'],
84+
args: [
85+
'--start-maximized',
86+
'--ignore-certificate-errors',
87+
'--no-sandbox',
88+
],
8589
});
8690
const page = await browser.newPage();
8791
await page.goto(url, {
@@ -128,7 +132,7 @@ function getCode(): string {
128132
width: 1600,
129133
height: 900,
130134
},
131-
args: ['--start-maximized'],
135+
args: ['--start-maximized', '--no-sandbox'],
132136
});
133137
const page = await browser.newPage();
134138
await page.goto('about:blank');

src/record/iframe-manager.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { serializedNodeWithId, INode } from 'rrweb-snapshot';
2+
import { mutationCallBack } from '../types';
3+
4+
export class IframeManager {
5+
private iframes: WeakMap<HTMLIFrameElement, true> = new WeakMap();
6+
private mutationCb: mutationCallBack;
7+
private loadListener?: (iframeEl: HTMLIFrameElement) => unknown;
8+
9+
constructor(options: { mutationCb: mutationCallBack }) {
10+
this.mutationCb = options.mutationCb;
11+
}
12+
13+
public addIframe(iframeEl: HTMLIFrameElement) {
14+
this.iframes.set(iframeEl, true);
15+
}
16+
17+
public addLoadListener(cb: (iframeEl: HTMLIFrameElement) => unknown) {
18+
this.loadListener = cb;
19+
}
20+
21+
public attachIframe(iframeEl: INode, childSn: serializedNodeWithId) {
22+
this.mutationCb({
23+
adds: [
24+
{
25+
parentId: iframeEl.__sn.id,
26+
nextId: null,
27+
node: childSn,
28+
},
29+
],
30+
removes: [],
31+
texts: [],
32+
attributes: [],
33+
});
34+
this.loadListener?.((iframeEl as unknown) as HTMLIFrameElement);
35+
}
36+
}

0 commit comments

Comments
 (0)