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

fast-forward implementation v2: virtual dom optimization #853

Merged
merged 91 commits into from
May 10, 2022
Merged
Show file tree
Hide file tree
Changes from 90 commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
5068664
rrdom: add a diff function for properties
YunFeng0817 Dec 29, 2021
b387927
implement diffChildren function and unit tests
YunFeng0817 Jan 6, 2022
4b1421f
finish basic functions of diff algorithm
YunFeng0817 Jan 6, 2022
d0dd136
fix several bugs in the diff algorithm
YunFeng0817 Jan 13, 2022
110b0ba
replace the virtual parent optimization in applyMutation()
YunFeng0817 Jan 15, 2022
d396cbd
fix: moveAndHover after the diff algorithm is executed
YunFeng0817 Jan 17, 2022
3c1d37d
replace virtual style map with rrdom
YunFeng0817 Jan 18, 2022
37c3ec2
fix: failed virtual style tests in replayer.test.ts
YunFeng0817 Jan 19, 2022
553583d
fix: failed polyfill tests caused by nodejs compatibility of differen…
YunFeng0817 Jan 19, 2022
ff1bc52
fix: svg viewBox attribute doesn't work
YunFeng0817 Jan 19, 2022
38dbb23
feat: replace treeIndex optimization with rrdom
YunFeng0817 Jan 19, 2022
8cac9c0
fix bug of diffProps and disable smooth scrolling animation in fast-f…
YunFeng0817 Jan 21, 2022
623e7c5
feat: add iframe support
YunFeng0817 Jan 28, 2022
d3a7009
fix: @rollup/plugin-typescript build errors in rrweb-player
YunFeng0817 Jan 28, 2022
16ec25d
fix: bug when fast-forward input events and add test for it
YunFeng0817 Jan 28, 2022
b2a0cbe
add test for fast-forward scroll events
YunFeng0817 Jan 29, 2022
e3a3da7
fix: custom style rules don't get inserted into some iframe elements
YunFeng0817 Feb 3, 2022
150a40f
code style tweak
YunFeng0817 Feb 3, 2022
32e06c7
fix: enable to diff iframe elements
YunFeng0817 Feb 4, 2022
eecc976
Merge branch 'master' into virtual-dom
YunFeng0817 Feb 4, 2022
0ba4349
fix the jest error "Unexpected token 'export'"
YunFeng0817 Feb 4, 2022
5bc3bbd
try to fix build error of rrweb-player
YunFeng0817 Feb 4, 2022
7ca376d
correct the attributes definition in rrdom
YunFeng0817 Feb 4, 2022
9c5ec6a
fix: custom style rules are not inserted in some iframes
YunFeng0817 Feb 4, 2022
a16e278
Merge commit 'c5b409629334717c2216d4b2a98ba106b2abdbf2' into virtual-dom
YunFeng0817 Feb 7, 2022
90800fe
Merge branch 'master' into virtual-dom
YunFeng0817 Feb 10, 2022
9bd5fd8
add support for shadow dom
YunFeng0817 Feb 10, 2022
039c5bd
add support for MediaInteraction
YunFeng0817 Feb 12, 2022
1dd18c5
add canvas support
YunFeng0817 Feb 15, 2022
8937ea1
fix unit test error in rrdom
YunFeng0817 Feb 15, 2022
94b6b09
Merge branch 'master' into virtual-dom
YunFeng0817 Feb 15, 2022
62398a9
add support for Text, Comment
YunFeng0817 Feb 16, 2022
fc88361
try to refactor RRDom
YunFeng0817 Feb 18, 2022
b98f0a2
refactor RRDom to reduce duplicate code
YunFeng0817 Feb 19, 2022
f96477c
rename document-browser to virtual-dom
YunFeng0817 Feb 19, 2022
d980878
increase the test coverage for document.ts and add ownerDocument for it
YunFeng0817 Mar 2, 2022
a8633bf
Merge branch 'master' into virtual-dom
YunFeng0817 Mar 2, 2022
80cc629
add more test for virtual-dom.ts
YunFeng0817 Mar 3, 2022
b1487bd
use cssstyle in document-nodejs
YunFeng0817 Mar 3, 2022
e40e19d
fix: bundle error
YunFeng0817 Mar 3, 2022
d8c2974
improve document-nodejs
YunFeng0817 Mar 3, 2022
81eac97
enable to diff scroll positions of an element
YunFeng0817 Mar 3, 2022
46a44d2
rename rrdom to virtualDom for more readability and make the tree public
YunFeng0817 Mar 3, 2022
5458ba0
Merge branch 'master' into virtual-dom
YunFeng0817 Mar 3, 2022
af762d0
revert unknown change
YunFeng0817 Mar 3, 2022
555c937
improve the css style parser for comments
YunFeng0817 Mar 4, 2022
086bc6f
improve code style
YunFeng0817 Mar 4, 2022
37ee65e
update typings
YunFeng0817 Mar 4, 2022
8544074
add handling for the case where legacy_missingNodeRetryMap is not empty
YunFeng0817 Mar 5, 2022
f780e58
only import types from rrweb into rrdom
YunFeng0817 Mar 7, 2022
1cc430e
Apply suggestions from code review
YunFeng0817 Mar 8, 2022
f231101
Apply suggestions from code review
YunFeng0817 Mar 8, 2022
e745322
fix building error in rrweb
YunFeng0817 Mar 8, 2022
3e12f66
add a method setDefaultSN to set a default value for a RRNode's __sn
YunFeng0817 Mar 8, 2022
acd36d5
Merge branch 'master' into virtual-dom
Juice10 Mar 8, 2022
3f9e638
fix rrweb test error and bump up other packages
YunFeng0817 Mar 9, 2022
b6810f6
add support for custom property of css styles
YunFeng0817 Mar 11, 2022
ab540bb
add a switch for virtual-dom optimization
YunFeng0817 Mar 13, 2022
23c53e1
Merge branch 'master' into virtual-dom
YunFeng0817 Mar 18, 2022
d69970d
Apply suggestions from code review
YunFeng0817 Mar 21, 2022
991f557
Merge branch 'master' into virtual-dom
YunFeng0817 Mar 27, 2022
6096651
adapt changes of #865 to virtual-dom and improve the test case for mo…
YunFeng0817 Mar 27, 2022
bfbf5d3
apply review suggestions
YunFeng0817 Mar 27, 2022
97b373a
tweak the diff algorithm
YunFeng0817 Mar 30, 2022
5743b32
add description of the flag useVirtualDom and remove outdated logConfig
YunFeng0817 Apr 2, 2022
41ac222
Merge branch 'master' of https://github.com/rrweb-io/rrweb into virtu…
Juice10 Apr 29, 2022
4a170a0
Merge branch 'master' of https://github.com/rrweb-io/rrweb into virtu…
Juice10 Apr 29, 2022
551dd64
Remove console.log
Juice10 Apr 29, 2022
8e263d3
Contain changes to document
Juice10 Apr 29, 2022
b1be81a
Upgrade rollup to 2.70.2
Juice10 Apr 29, 2022
aded41c
Revert "Upgrade rollup to 2.70.2"
Juice10 Apr 29, 2022
be4c35c
Fix type checking rrdom
Juice10 Apr 29, 2022
c62be20
Fix typing error while bundling
Juice10 Apr 30, 2022
6105a74
Fix tslib error on build
Juice10 May 1, 2022
61e1a5d
Increase memory limit for rollup
Juice10 May 1, 2022
85d600a
Use esbuild for bundling
Juice10 May 2, 2022
72e23b8
Avoid circular dependencies and import un-bundled rrdom
Juice10 May 2, 2022
b7b3c8d
Fix imports
Juice10 May 2, 2022
2d584aa
Revert back to pre-esbuild
Juice10 May 2, 2022
3c7eb56
Set node to lts (12 is no longer supported)
Juice10 May 2, 2022
d50b72c
Speed up bundling and use less memory
Juice10 May 3, 2022
de0ef9f
remove __sn from rrdom
YunFeng0817 May 4, 2022
15247dc
fix typo
YunFeng0817 May 4, 2022
f6b4456
test: add a test case for StyleSheet mutation exceptions while fast-f…
YunFeng0817 May 5, 2022
0f6729d
rename Array.prototype.slice.call() to Array.from()
YunFeng0817 May 5, 2022
70db46b
improve test cases
YunFeng0817 May 5, 2022
fdfa0c0
Merge branch 'stylesheet-test' into virtual-dom
YunFeng0817 May 5, 2022
52b7ec6
fix: PR #887 in 'virtual-dom' branch
YunFeng0817 May 5, 2022
993eff7
apply justin's suggestion on 'Array.from' refactor
YunFeng0817 May 5, 2022
b72b065
improve import code structure
YunFeng0817 May 5, 2022
753cea5
Merge remote-tracking branch 'origin/master' into virtual-dom
YunFeng0817 May 10, 2022
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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ os: linux
dist: focal

node_js:
- 12
- lts/*

install:
- yarn
Expand Down
3 changes: 1 addition & 2 deletions .vscode/rrweb-monorepo.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
"settings": {
"jest.disabledWorkspaceFolders": [
" rrweb monorepo",
"rrweb-player (package)",
"rrdom (package)"
"rrweb-player (package)"
]
}
}
2 changes: 2 additions & 0 deletions guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,10 +299,12 @@ The replayer accepts options as its constructor's second parameter, and it has t
| insertStyleRules | [] | accepts multiple CSS rule string, which will be injected into the replay iframe |
| triggerFocus | true | whether to trigger focus during replay |
| UNSAFE_replayCanvas | false | whether to replay the canvas element. **Enable this will remove the sandbox, which is unsafe.** |
| pauseAnimation | true | whether to pause CSS animation when the replayer is paused |
| mouseTail | true | whether to show mouse tail during replay. Set to false to disable mouse tail. A complete config can be found in this [type](https://github.com/rrweb-io/rrweb/blob/9488deb6d54a5f04350c063d942da5e96ab74075/src/types.ts#L407) |
| unpackFn | - | refer to the [storage optimization recipe](./docs/recipes/optimize-storage.md) |
| logConfig | - | configuration of console output playback, refer to the [console recipe](./docs/recipes/console.md) |
| plugins | [] | load plugins to provide extended replay functions. [What is plugins?](./docs/recipes/plugin.md) |
| useVirtualDom | true | whether to use Virtual Dom optimization in the process of skipping to a new point of time |

#### Use rrweb-player

Expand Down
3 changes: 2 additions & 1 deletion guide.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,11 @@ replayer.pause(5000);
| insertStyleRules | [] | 可以传入多个 CSS rule string,用于自定义回放时 iframe 内的样式 |
| triggerFocus | true | 回放时是否回放 focus 交互 |
| UNSAFE_replayCanvas | false | 回放时是否回放 canvas 内容,**开启后将会关闭沙盒策略,导致一定风险** |
| pauseAnimation | true | 当播放器停止播放时,是否将 CSS 动画也停止播放 |
| mouseTail | true | 是否在回放时增加鼠标轨迹。传入 false 可关闭,传入对象可以定制轨迹持续时间、样式等,配置详见[类型](https://github.com/rrweb-io/rrweb/blob/9488deb6d54a5f04350c063d942da5e96ab74075/src/types.ts#L407) |
| unpackFn | - | 数据解压缩函数,详见[优化存储策略](./docs/recipes/optimize-storage.zh_CN.md) |
| logConfig | - | console logger 数据播放设置,详见[console 录制和播放](./docs/recipes/console.zh_CN.md) |
| plugins | [] | 加载插件以获得额外的回放功能. [什么是插件?](./docs/recipes/plugin.zh_CN.md) |
| useVirtualDom | true | 在播放器跳转到一个新的时间点的过程中,是否使用 Virtual Dom 优化 |

#### 使用 rrweb-player

Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,8 @@
"test:watch": "yarn lerna run test:watch --parallel",
"dev": "yarn lerna run dev --parallel",
"repl": "cd packages/rrweb && npm run repl"
},
"resolutions": {
"**/jsdom/cssom": "^0.5.0"
}
}
17 changes: 12 additions & 5 deletions packages/rrdom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"dev": "rollup -c -w",
"bundle": "rollup --config",
"bundle:es-only": "cross-env ES_ONLY=true rollup --config",
"check-types": "tsc -noEmit",
"test": "jest",
"prepublish": "npm run bundle"
},
Expand All @@ -27,18 +28,24 @@
"@rollup/plugin-commonjs": "^20.0.0",
"@rollup/plugin-node-resolve": "^13.0.4",
"@types/cssom": "^0.4.1",
"@types/jest": "^27.0.1",
"@types/cssstyle": "^2.2.1",
"@types/jest": "^27.4.1",
"@types/nwsapi": "^2.2.2",
"jest": "^27.1.1",
"@types/puppeteer": "^5.4.4",
"compare-versions": "^4.1.3",
"jest": "^27.5.1",
"puppeteer": "^9.1.1",
"rollup": "^2.56.3",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript2": "^0.30.0",
"rollup-plugin-typescript2": "^0.31.2",
"rollup-plugin-web-worker-loader": "^1.6.1",
"rrweb-snapshot": "^1.1.14",
"ts-jest": "^27.0.5",
"typescript": "^3.9.5"
"ts-jest": "^27.1.3",
"typescript": "^4.6.2"
},
"dependencies": {
"cssom": "^0.5.0",
"cssstyle": "^2.3.0",
"nwsapi": "^2.2.0"
}
}
10 changes: 10 additions & 0 deletions packages/rrdom/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import { terser } from 'rollup-plugin-terser';
import typescript from 'rollup-plugin-typescript2';
import webWorkerLoader from 'rollup-plugin-web-worker-loader';
import pkg from './package.json';

function toMinPath(path) {
Expand All @@ -11,6 +12,10 @@ function toMinPath(path) {
const basePlugins = [
resolve({ browser: true }),
commonjs(),

// supports bundling `web-worker:..filename` from rrweb
webWorkerLoader(),

typescript({
tsconfigOverride: { compilerOptions: { module: 'ESNext' } },
}),
Expand All @@ -27,6 +32,11 @@ const baseConfigs = [
name: 'RRDocument',
path: 'document-nodejs',
},
{
input: './src/virtual-dom.ts',
name: 'RRDocument',
path: 'virtual-dom',
},
];

let configs = [];
Expand Down
Loading