Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rrweb sync alpha 12 #22

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
0c6db64
🐞 fix(web-extension): typo (#1307)
huangkairan Oct 20, 2023
53b18a9
Pref: export eventWithTime (#1324)
BelenLuo-tech Oct 31, 2023
8fa01a1
Fix linting issues (#1347)
Juice10 Nov 3, 2023
a5ef2a8
ref: Avoid unnecessary cloning of objects or arrays (#1340)
mydea Nov 3, 2023
2398dd2
perf(rrweb): attribute mutation optimization (#1343)
mdellanoce Nov 3, 2023
331e46b
fix(web-extension): beforeunload logic (#1330)
huangkairan Nov 3, 2023
c763478
Added Gleap.io to "Who's using rrweb?" (#1332)
boehlerlukas Nov 3, 2023
3bfcc54
fix(web-extension): Fix types in vite config (#1333)
billyvg Nov 3, 2023
b29bfca
Md create html document (#1321)
eoghanmurray Nov 6, 2023
a1d5962
Feat: Add support for replaying :defined pseudo-class of custom eleme…
YunFeng0817 Nov 7, 2023
ba7f3d5
Masking: Avoid the repeated calls to `closest` when recursing through…
eoghanmurray Nov 24, 2023
1fa5c13
Fix serialization and mutation of <textarea> elements (#1351)
eoghanmurray Dec 1, 2023
ec5e0ac
chore: update linters (#1355)
pauldambra Dec 4, 2023
d48125e
perf(web-extension): conditional check (#1360)
huangkairan Dec 4, 2023
a73a5b0
[chore] Update changesets (#1362)
Juice10 Dec 4, 2023
2cfc0fd
[chore] [ci] Update Node version to LTS (#1365)
Juice10 Dec 4, 2023
4b6bf5a
Add UXWizz to Readme (#1371)
Cristy94 Dec 11, 2023
ccf2cd1
Docs: Add rrweb presentation + open to consulting (#1388)
Juice10 Jan 5, 2024
0c34ddd
chore: export canvasMutation (#1383)
daibhin Jan 22, 2024
e9cfd9f
fix: console logger can serialize bigint values (#1403)
pauldambra Jan 25, 2024
e08751d
Rrvideo receipe update (#1390)
patlopes Jan 26, 2024
858b952
fix the test CI (#1405)
Yuyz0112 Jan 28, 2024
d24237e
Make properties x and y optional in mouseInteractionParam (#1375)
avillegasn Feb 10, 2024
ffdf49c
Capture stylesheets designated as `rel="preload"` (#1374)
andrewpomeroy Feb 12, 2024
da3899e
fix guide doc (#1415)
xujiujiu Feb 23, 2024
a880f6c
fix: scrolling can be incorrect when fast-forwarding (#1352)
juliecheng Feb 27, 2024
ee01db7
Add HowdyGo to Who's using rrweb (#1423)
dengelke Mar 26, 2024
c405fd2
Apply formatting changes
jxiwang Jul 31, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/breezy-mice-breathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'rrweb': patch
---

safely capture BigInt values with the console log plugin"
2 changes: 2 additions & 0 deletions .changeset/cold-hounds-teach.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
2 changes: 2 additions & 0 deletions .changeset/few-rockets-travel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
5 changes: 5 additions & 0 deletions .changeset/fluffy-planes-retire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'rrweb': patch
---

Feat: Add support for replaying :defined pseudo-class of custom elements
2 changes: 2 additions & 0 deletions .changeset/friendly-numbers-leave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
5 changes: 5 additions & 0 deletions .changeset/gold-apples-joke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'rrweb': patch
---

ref: Avoid unnecessary cloning of objects or arrays
2 changes: 2 additions & 0 deletions .changeset/hip-worms-relax.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
5 changes: 5 additions & 0 deletions .changeset/lazy-squids-draw.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'rrweb': patch
---

export the canvasMutation function
5 changes: 5 additions & 0 deletions .changeset/lemon-lamps-switch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'rrweb': patch
---

export eventWithTime for consumption by typescript code
5 changes: 5 additions & 0 deletions .changeset/mighty-bulldogs-begin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rrweb/web-extension': patch
---

Update `vite.config.ts` to account for all potential entry types.
5 changes: 5 additions & 0 deletions .changeset/moody-dots-refuse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'rrweb': patch
---

use WeakMap for faster attributeCursor lookup while processing attribute mutations
6 changes: 6 additions & 0 deletions .changeset/rare-adults-sneeze.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'rrweb-snapshot': patch
'rrweb': patch
---

Don't double-record the values of <textarea>s when they already have some content prefilled #1301
2 changes: 2 additions & 0 deletions .changeset/silver-windows-float.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
7 changes: 7 additions & 0 deletions .changeset/smart-ears-refuse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'rrweb-snapshot': patch
---

Feat: Add 'isCustom' flag to serialized elements.

This flag is used to indicate whether the element is a custom element or not. This is useful for replaying the :defined pseudo-class of custom elements.
6 changes: 6 additions & 0 deletions .changeset/smooth-papayas-boil.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'rrweb-snapshot': patch
'rrweb': patch
---

Capture stylesheets designated as `rel="preload"`
5 changes: 5 additions & 0 deletions .changeset/spotty-bees-destroy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'rrdom': patch
---

fix: scrolling may not be applied when fast-forwarding
6 changes: 6 additions & 0 deletions .changeset/thin-vans-applaud.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'rrweb-snapshot': patch
'rrweb': patch
---

Snapshot performance when masking text: Avoid the repeated calls to `closest` when recursing through the DOM
5 changes: 5 additions & 0 deletions .changeset/tidy-swans-repair.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rrweb/web-extension': patch
---

🎈 perf(web-extension): conditional check in Player component
5 changes: 5 additions & 0 deletions .changeset/tiny-candles-whisper.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rrweb/web-extension': patch
---

🐞 fix(web-extension): typo
2 changes: 2 additions & 0 deletions .changeset/twenty-goats-kneel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
5 changes: 5 additions & 0 deletions .changeset/witty-kids-talk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rrweb/web-extension': patch
---

🐞 fix(web-extension): beforeunload logic
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ module.exports = {
plugins: ['@typescript-eslint', 'eslint-plugin-tsdoc', 'jest', 'compat'],
rules: {
'tsdoc/syntax': 'warn',
'@typescript-eslint/prefer-as-const': 'warn',
},
};
6 changes: 3 additions & 3 deletions .github/workflows/style-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16
node-version: lts/*
cache: 'yarn'
- name: Install Dependencies
run: yarn install --frozen-lockfile
Expand Down Expand Up @@ -62,7 +62,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16
node-version: lts/*
cache: 'yarn'
- name: Install Dependencies
run: yarn install --frozen-lockfile
Expand All @@ -82,7 +82,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16
node-version: lts/*
cache: 'yarn'
- name: Install Dependencies
run: yarn install --frozen-lockfile
Expand Down
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ rrweb refers to 'record and replay the web', which is a tool for recording and r

[**🍳 Recipes 🍳**](./docs/recipes/index.md)

[**📺 Presentation:** Hacking the browser to digital twin your users 📺](https://youtu.be/cWxpp9HwLYw)

## Project Structure

rrweb is mainly composed of 3 parts:
Expand Down Expand Up @@ -138,6 +140,7 @@ In addition to adding integration tests and unit tests, rrweb also provides a RE
alt=""
/>
<br /><sub><b>Yuyz0112</b></sub>
<br /><br />
</a>
</td>
<td align="center">
Expand All @@ -148,6 +151,7 @@ In addition to adding integration tests and unit tests, rrweb also provides a RE
alt=""
/>
<br /><sub><b>Yun Feng</b></sub>
<br /><br />
</a>
</td>
<td align="center">
Expand All @@ -158,6 +162,7 @@ In addition to adding integration tests and unit tests, rrweb also provides a RE
alt=""
/>
<br /><sub><b>eoghanmurray</b></sub>
<br /><br />
</a>
</td>
<td align="center">
Expand All @@ -168,6 +173,7 @@ In addition to adding integration tests and unit tests, rrweb also provides a RE
alt=""
/>
<br /><sub><b>Juice10</b></sub>
<br /><sub>open for rrweb consulting</sub>
</a>
</td>
</tr>
Expand Down Expand Up @@ -226,5 +232,20 @@ In addition to adding integration tests and unit tests, rrweb also provides a RE
<img style="padding: 8px" alt="Intercept, Modify, Record & Replay HTTP Requests." width="195px" src="https://github.com/requestly/requestly/assets/16779465/652552db-c867-44cb-9bb5-94a2026e04ca">
</a>
</td>
<td align="center">
<a href="https://gleap.io" target="_blank">
<img style="padding: 8px" alt="In-app bug reporting & customer feedback platform." width="195px" src="https://assets-global.website-files.com/6506f3f29c68b1724807619d/6506f56010237164c6306591_GleapLogo.svg">
</a>
</td>
<td align="center">
<a href="https://uxwizz.com" target="_blank">
<img style="padding: 8px" alt="Self-hosted website analytics with heatmaps and session recordings." width="195px" src="https://github.com/UXWizz/public-files/raw/main/assets/logo.png">
</a>
</td>
<td align="center">
<a href="https://www.howdygo.com" target="_blank">
<img style="padding: 8px" alt="Interactive product demos for small marketing teams" width="195px" src="https://assets-global.website-files.com/650afb446f1dd5bd410f00cc/650b2cec6188ff54dd9b01e1_Logo.svg">
</a>
</td>
</tr>
</table>
5 changes: 5 additions & 0 deletions README.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,5 +166,10 @@ rrweb 主要由 3 部分组成:
<img style="padding: 8px" alt="Intercept, Modify, Record & Replay HTTP Requests." width="195px" src="https://github.com/requestly/requestly/assets/16779465/652552db-c867-44cb-9bb5-94a2026e04ca">
</a>
</td>
<td align="center">
<a href="https://uxwizz.com" target="_blank">
<img style="padding: 8px" alt="Self-hosted website analytics with heatmaps and session recordings." width="195px" src="https://github.com/UXWizz/public-files/raw/main/assets/logo.png">
</a>
</td>
</tr>
</table>
2 changes: 1 addition & 1 deletion docs/recipes/export-to-video.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ The event data recorded by rrweb is a performant, easy to compress, text-based f

But if you really need to convert it into a video format, there are some tools that can do this work.

Use [rrvideo](https://github.com/rrweb-io/rrvideo).
Use [rrvideo](https://github.com/rrweb-io/rrweb/blob/master/packages/rrvideo/README.md).
2 changes: 1 addition & 1 deletion docs/recipes/export-to-video.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

rrweb 录制的数据是一种高效、易于压缩的文本格式,可以用于像素级的回放。但如果有进一步将录制数据转换为视频的需求,同样可以通过一些工具实现。

使用 [rrvideo](https://github.com/rrweb-io/rrvideo)。
使用 [rrvideo](https://github.com/rrweb-io/rrweb/blob/master/packages/rrvideo/README.zh_CN.md)。
2 changes: 1 addition & 1 deletion guide.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ setInterval(save, 10 * 1000);
| collectFonts | false | 是否记录页面中的字体文件 |
| userTriggeredOnInput | false | [什么是 `userTriggered`](https://github.com/rrweb-io/rrweb/pull/495) |
| plugins | [] | 加载插件以获得额外的录制功能. [什么是插件?](./docs/recipes/plugin.zh_CN.md) |
| errorHandler | - | 一个可以定制化处理错误的毁掉函数,它的参数是错误对象。如果 rrweb recorder 内部的某些内容抛出错误,则会调用该回调。 |
| errorHandler | - | 一个可以定制化处理错误的回调函数,它的参数是错误对象。如果 rrweb recorder 内部的某些内容抛出错误,则会调用该回调。 |

#### 隐私

Expand Down
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@
"packages/*"
],
"devDependencies": {
"@changesets/changelog-github": "^0.4.8",
"@changesets/cli": "^2.26.0",
"@changesets/changelog-github": "^0.5.0",
"@changesets/cli": "^2.27.1",
"@monorepo-utils/workspaces-to-typescript-project-references": "^2.8.2",
"@typescript-eslint/eslint-plugin": "^5.25.0",
"@typescript-eslint/parser": "^5.25.0",
"browserslist": "^4.21.4",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"browserslist": "^4.22.1",
"concurrently": "^7.1.0",
"eslint": "^8.19.0",
"eslint-plugin-compat": "^4.0.2",
"eslint-plugin-jest": "^27.1.3",
"eslint-plugin-tsdoc": "^0.2.16",
"eslint": "^8.53.0",
"eslint-plugin-compat": "^4.2.0",
"eslint-plugin-jest": "^27.6.0",
"eslint-plugin-tsdoc": "^0.2.17",
"markdownlint": "^0.25.1",
"markdownlint-cli": "^0.31.1",
"prettier": "2.8.4",
Expand All @@ -37,7 +37,7 @@
},
"scripts": {
"build:all": "NODE_OPTIONS='--max-old-space-size=4096' yarn run concurrently --success=all -r -m=1 'yarn workspaces-to-typescript-project-references' 'yarn turbo run prepublish'",
"test": "yarn run concurrently --success=all -r -m=1 'yarn workspaces-to-typescript-project-references --check' 'yarn turbo run test'",
"test": "yarn run concurrently --success=all -r -m=1 'yarn workspaces-to-typescript-project-references --check' 'yarn turbo run test --concurrency=1'",
"test:watch": "yarn turbo run test:watch",
"test:update": "yarn turbo run test:update",
"format": "yarn prettier --write '**/*.{ts,md}'",
Expand Down
13 changes: 10 additions & 3 deletions packages/rrdom/src/diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export function diff(

diffChildren(oldTree, newTree, replayer, rrnodeMirror);

diffAfterUpdatingChildren(oldTree, newTree, replayer, rrnodeMirror);
diffAfterUpdatingChildren(oldTree, newTree, replayer);
}

/**
Expand Down Expand Up @@ -194,6 +194,15 @@ function diffBeforeUpdatingChildren(
rrnodeMirror,
);
}
/**
* Attributes and styles of the old element need to be updated before updating its children because of an edge case:
* `applyScroll` may fail in `diffAfterUpdatingChildren` when the height of a node when `applyScroll` is called may be incorrect if
* 1. its parent node contains styles that affects the targeted node's height
* 2. the CSS selector is targeting an attribute of the parent node
* by running `diffProps` on the parent node before `diffChildren` is called,
* we can ensure that the correct attributes (and therefore styles) have applied to parent nodes
*/
diffProps(oldElement, newRRElement, rrnodeMirror);
break;
}
}
Expand All @@ -207,7 +216,6 @@ function diffAfterUpdatingChildren(
oldTree: Node,
newTree: IRRNode,
replayer: ReplayerHandler,
rrnodeMirror: Mirror,
) {
switch (newTree.RRNodeType) {
case RRNodeType.Document: {
Expand All @@ -218,7 +226,6 @@ function diffAfterUpdatingChildren(
case RRNodeType.Element: {
const oldElement = oldTree as HTMLElement;
const newRRElement = newTree as RRElement;
diffProps(oldElement, newRRElement, rrnodeMirror);
newRRElement.scrollData &&
replayer.applyScroll(newRRElement.scrollData, true);
/**
Expand Down
3 changes: 2 additions & 1 deletion packages/rrweb-snapshot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"scripts": {
"prepare": "npm run prepack",
"prepack": "npm run bundle && npm run typings",
"test": "jest",
"retest": "jest",
"test": "yarn bundle && yarn retest",
"test:watch": "jest --watch",
"test:update": "jest --updateSnapshot",
"bundle": "rollup --config",
Expand Down
22 changes: 14 additions & 8 deletions packages/rrweb-snapshot/src/rebuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
tagMap,
elementNode,
BuildCache,
attributes,
legacyAttributes,
} from './types';
import { isElement, Mirror, isNodeMetaEqual } from './utils';
Expand Down Expand Up @@ -170,6 +169,18 @@ function buildNode(
if (n.isSVG) {
node = doc.createElementNS('http://www.w3.org/2000/svg', tagName);
} else {
if (
// If the tag name is a custom element name
n.isCustom &&
// If the browser supports custom elements
doc.defaultView?.customElements &&
// If the custom element hasn't been defined yet
!doc.defaultView.customElements.get(n.tagName)
)
doc.defaultView.customElements.define(
n.tagName,
class extends doc.defaultView.HTMLElement {},
);
node = doc.createElement(tagName);
}
/**
Expand Down Expand Up @@ -216,14 +227,9 @@ function buildNode(
value = adaptCssForReplay(value, cache);
}
if ((isTextarea || isRemoteOrDynamicCss) && typeof value === 'string') {
const child = doc.createTextNode(value);
node.appendChild(doc.createTextNode(value));
// https://github.com/rrweb-io/rrweb/issues/112
for (const c of Array.from(node.childNodes)) {
if (c.nodeType === node.TEXT_NODE) {
node.removeChild(c);
}
}
node.appendChild(child);
n.childNodes = []; // value overrides childNodes
continue;
}

Expand Down
Loading