Commit Graph

132 Commits

Author SHA1 Message Date
dbseel
5ba933cce3 isBlocked factors in the selector (#894)
* isBlocked factors in the selector

* Ensure contains parameter is a node

* Fix blockSelector blocking for closest nodes

* Fix integration test

* adding ignoreCSSAttributes to ignore the addition of certain css attributes

* tested ignoreCSSAttributes

* Update test snapshot

* swapped the wrapping of htmlelement to be element

* Fix linter errors

* Address MR feedback

* Rebase

Co-authored-by: Filip <filipslatinac@gmail.com>
2022-08-30 13:27:24 +08:00
何遇
ac7935e378 fix: record canvas by fps when blockClass is RegExp (#966)
* fix: Fixed a bug where FPSObserver cannot record Canvas when blockClass is a regular expression

* Update packages/rrweb/src/record/observers/canvas/canvas-manager.ts

Co-authored-by: Justin Halsall <Juice10@users.noreply.github.com>
2022-08-27 09:04:26 +08:00
Yun Feng
5f59f9171e feat: add a destroy function to destroy the whole player (#953)
* feat: add a destroy function to destroy the whole player

* doc: update guidance document

* Update packages/rrweb/src/replay/index.ts

Co-authored-by: Justin Halsall <Juice10@users.noreply.github.com>

Co-authored-by: Justin Halsall <Juice10@users.noreply.github.com>
2022-08-11 19:39:16 +08:00
Yun Feng
a0d53738f8 fix: errors when fast-forward selection events (#952) 2022-08-11 13:08:42 +08:00
Justin Halsall
fd85c79ea9 Handle negative ids in rrdom correctly + extra tests (#927)
* inline stylesheets when loaded

* set empty link elements to loaded by default

* Clean up stylesheet manager

* Remove attribute mutation code

* Update packages/rrweb/test/record.test.ts

* Update packages/rrweb/test/record.test.ts

* Update packages/rrweb/test/record.test.ts

* Update packages/rrweb/scripts/repl.js

* Update packages/rrweb/test/record.test.ts

* Update packages/rrweb/src/record/index.ts

* Add todo

* Move require out of time sensitive assert

* Add waitForRAF, its more reliable than waitForTimeout

* Remove flaky tests

* Add recording stylesheets in iframes

* Remove variability from flaky test

* Make test more robust

* Fix naming

* Add test cases for inlineImages

* Add test cases for inlineImages

* Record iframe mutations cross page

* Test: should record images inside iframe with blob url after iframe was reloaded

* Handle negative ids in rrdom correctly

When iframes get inserted they create untracked elements, both on the dom and rrdom side.
Because they are untracked they generate negative numbers when fetching the id from mirror.
This creates a problem when comparing and fetching ids across mirrors.
This commit tries to get away from using negative ids as much as possible in rrdom's comparisons

* Update packages/rrdom/src/diff.ts

Co-authored-by: Yun Feng <yun.feng@anu.edu.au>

* Start unserialized nodes at -2

This way we don't accidentally think of them as mirror misses

* Set unserialized id starting number at -2

* Remove duplication

Co-authored-by: Yun Feng <yun.feng@anu.edu.au>
2022-08-06 17:00:05 +08:00
Jinxing Lin
b2d56898a8 rrweb: add selection observer (#936)
* rrweb: add selection observer

* Update packages/rrweb/src/record/observer.ts

Co-authored-by: Yun Feng <yun.feng0817@gmail.com>

* Update packages/rrweb/src/record/observer.ts

Co-authored-by: Yun Feng <yun.feng0817@gmail.com>

* Update packages/rrweb/src/replay/index.ts

Co-authored-by: Yun Feng <yun.feng0817@gmail.com>

* remove: repeat updateSelection

* Update packages/rrweb/src/record/observer.ts

Co-authored-by: Yun Feng <yun.feng0817@gmail.com>

* remove: utils sample events

Co-authored-by: Yun Feng <yun.feng0817@gmail.com>
2022-08-06 16:59:42 +08:00
Yanzhen Yu
abc035fd00 chore(release): publish new version
- rrdom-nodejs@0.1.4
 - rrdom@0.1.4
 - rrweb-player@1.0.0-alpha.1
 - rrweb-snapshot@2.0.0-alpha.1
 - rrweb@2.0.0-alpha.1
2022-07-31 11:48:29 +08:00
Yun Feng
cb24aaf6aa add benchmark for replayer's fast-forward mode (#947)
* add benchmark for replayer's fast-forward mode

* add comments

* change the title

* build: make benchmark a seperate command
2022-07-31 11:45:57 +08:00
Yun Feng
f1b23ddccc fix: canvas data in iframe wasn't applied in the fast-forward mode (#944)
* fix: canvas data in iframe wasn't applied in the fastforward mode

* add more comments

* Update packages/rrdom/src/diff.ts

Co-authored-by: Justin Halsall <Juice10@users.noreply.github.com>

* apply Juice10's suggestion

Co-authored-by: Justin Halsall <Juice10@users.noreply.github.com>
2022-07-31 09:01:04 +08:00
Yun Feng
aecaefbf45 chore: remove all typings, add them all to .gitignore file and update turbo.json (#949) 2022-07-31 08:38:22 +08:00
Eoghan Murray
b618f095df Remove typings files as these can be regenerated with npm run typings from their src/types.ts masters, and are an extra source of conflicts if they remain in git (#946) 2022-07-26 22:54:27 +08:00
Eoghan Murray
ba4bcbea8d Bump jsdom to latest version as was getting error TS2305: Module '"parse5"' has no exported member 'ElementLocation'. (#945) 2022-07-25 23:44:55 +08:00
Yun Feng
f03504a731 fix issue #933 (#942)
* fix: style not applied to polyfillled shadow dom

* test: add integration test for shadydom and @lwc/synthetic-shadow

* improve the implementation of function isNativeShadowDom

* apply lele0108's review suggestion
2022-07-22 20:36:43 +08:00
Yun Feng
999f1a5242 style: remove all tslint related comments (#934) 2022-07-22 20:33:41 +08:00
Yun Feng
8ad43254ff add special handling for undefined console content (#935) 2022-07-22 19:02:08 +08:00
Jimmy Liu
f3064c1f2d Fix href in <use> to not use absolute url (#938) 2022-07-16 14:51:56 +08:00
Yanzhen Yu
2d4dd22966 chore(release): publish new version
- rrdom-nodejs@0.1.3
 - rrdom@0.1.3
 - rrweb-player@1.0.0-alpha.0
 - rrweb-snapshot@2.0.0-alpha.0
 - rrweb@2.0.0-alpha.0
2022-07-10 15:51:45 +08:00
Yun Feng
83394c3db4 refactor: eliminate eslint errors (#920)
* refactor: eliminate eslint errors as many as I can

* refactor: fix more eslint errors in the record module

* LINT: fix @typescript-eslint/unbound-method

* LINT: fix all eslint errors in source code

* LINT: fix as many eslint warnings as possible

Co-authored-by: Justin Halsall <Juice10@users.noreply.github.com>
2022-07-10 15:49:20 +08:00
Yun Feng
01612b7a75 update cssom package to rrweb self-owned package 'rrweb-cssom' (#925)
* test: update cssom package to rrweb self-owned package 'rrweb-cssom'

* style: remove outdated comments
2022-07-02 13:55:45 +08:00
Justin Halsall
d5d877e380 Inline stylesheets on load (#909)
* inline stylesheets when loaded

* set empty link elements to loaded by default

* Clean up stylesheet manager

* Remove attribute mutation code

* Update packages/rrweb/test/record.test.ts

* Update packages/rrweb/test/record.test.ts

* Update packages/rrweb/test/record.test.ts

* Update packages/rrweb/scripts/repl.js

* Update packages/rrweb/test/record.test.ts

* Update packages/rrweb/src/record/index.ts

* Add todo

* Move require out of time sensitive assert

* Add waitForRAF, its more reliable than waitForTimeout

* Remove flaky tests

* Add recording stylesheets in iframes

* Remove variability from flaky test

* Make test more robust

* Fix naming
2022-07-01 13:29:09 +08:00
Justin Halsall
a31e272bf2 Remove children of Document even if doc not in mirror (#923)
* Remove children of Document even if doc not in mirror

* fix flaky test

* Update packages/rrdom/test/diff.test.ts

Co-authored-by: Yun Feng <yun.feng@anu.edu.au>

Co-authored-by: Yun Feng <yun.feng@anu.edu.au>
2022-07-01 12:26:24 +08:00
Justin Halsall
c81e609d7b Lock yarn to 1.23.0 (#922)
* Lock yarn to 1.23.0

* fix flaky test

* Fix flaky tests
2022-06-30 23:20:26 +08:00
yz-yu
af8ed5513c unify typescript version and rollup plugins (#921) 2022-06-25 21:08:06 +08:00
yz-yu
74f553afc3 move browser-only rrdom features to the new rrdom package (#913) 2022-06-20 22:02:21 +08:00
Justin Halsall
058c4579b4 Speed up snapshotting of many new dom nodes (#903)
* Speed up snapshotting of many new dom nodes

By avoiding reflow we shave about 15-25% off our snapshotting time

* Improve newlyAddedElement docs

* Optimize needMaskingText by using el.closest and less recursion

* Serve all rrweb dist files

* Split serializeNode into smaller functions

Makes it easier to profile

* Slow down cpu enhance tracing on fast machines

* Increase timeout

* Perf: only loop through ancestors when they have something to compare to

* Perf: `hasNode` is cheaper than `getMeta`

* Perf: If parents where already checked, no need to do it again

* Perf: reverse for loops are faster

Because they only do the .lenght check once. In this case I don't think we'll see much performance gains if any

* Clean up code

* Perf: check ancestors once with isBlocked

* guessing this might fixes canvas test

* Update packages/rrweb/src/record/observers/canvas/webgl.ts

Co-authored-by: yz-yu <yanzhen@smartx.com>

* Fix #904 (#906)

Properly remove crossorigin attribute

* Bump minimist from 1.2.5 to 1.2.6 (#902)

Bumps [minimist](https://github.com/substack/minimist) from 1.2.5 to 1.2.6.
- [Release notes](https://github.com/substack/minimist/releases)
- [Commits](https://github.com/substack/minimist/compare/1.2.5...1.2.6)

---
updated-dependencies:
- dependency-name: minimist
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Co-authored-by: yz-yu <yanzhen@smartx.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-06 22:55:15 +08:00
Justin Halsall
9da1e432cc Fix #904 (#906)
Properly remove crossorigin attribute
2022-05-31 16:15:48 +08:00
Justin Halsall
1355917e1b Chore: Add issue/pr template and general housekeeping tools and docs (#900)
* Add linting

* Add issue templates and docs

* Add root eslint config and remove tslint

* Autofix lint issues
2022-05-22 09:59:42 +08:00
yz-yu
a43d4e4255 Introduce benchmark tests and improve snapshot attributes traversing (#897)
* housekeeping: refine test utils

* setup benchmark tests

* improve snapshot attributes loop perf
2022-05-14 14:52:26 +08:00
Justin Halsall
de755ae577 #853 Second try: fast-forward implementation v2: virtual dom optimization (#895)
* rrdom: add a diff function for properties

* implement diffChildren function and unit tests

* finish basic functions of diff algorithm

* fix several bugs in the diff algorithm

* replace the virtual parent optimization in applyMutation()

* fix: moveAndHover after the diff algorithm is executed

* replace virtual style map with rrdom

cssom version has to be above 0.5.0 to pass virtual style tests

* fix: failed virtual style tests in replayer.test.ts

* fix: failed polyfill tests caused by nodejs compatibility of different versions

* fix: svg viewBox attribute doesn't work

Cause the attribute viewBox is case sensitive, set value for viewbox doesn't work

* feat: replace treeIndex optimization with rrdom

* fix bug of diffProps and disable smooth scrolling animation in fast-forward mode

* feat: add iframe support

* fix: @rollup/plugin-typescript build errors in rrweb-player

Error: @rollup/plugin-typescript TS1371: This import is never used as a value and must use 'import type' because the 'importsNotUsedAsValues' is set to 'error'

* fix: bug when fast-forward input events and add test for it

* add test for fast-forward scroll events

* fix: custom style rules don't get inserted into some iframe elements

* code style tweak

* fix: enable to diff iframe elements

* fix  the jest error "Unexpected token 'export'"

* try to fix build error of rrweb-player

* correct the attributes definition in rrdom

* fix: custom style rules are not inserted in some iframes

* add support for shadow dom

* add support for MediaInteraction

* add canvas support

* fix unit test error in rrdom

* add support for Text, Comment

* try to refactor RRDom

* refactor RRDom to reduce duplicate code

* rename document-browser to virtual-dom

* increase the test coverage for document.ts and add ownerDocument for it

* Merge branch 'master' into virtual-dom

* add more test for virtual-dom.ts

* use cssstyle in document-nodejs

* fix: bundle error

* improve document-nodejs

* enable to diff scroll positions of an element

* rename rrdom to virtualDom for more readability and make the tree public

* revert unknown change

* improve the css style parser for comments

* improve code style

* update typings

* add handling for the case where legacy_missingNodeRetryMap is not empty

* only import types from rrweb into rrdom

* Apply suggestions from code review

Co-authored-by: Justin Halsall <Juice10@users.noreply.github.com>

* Apply suggestions from code review

* fix building error in rrweb

* add a method setDefaultSN to set a default value for a RRNode's __sn

* fix rrweb test error and bump up other packages

* add support for custom property of css styles

* add a switch for virtual-dom optimization

* Apply suggestions from code review

1. add an enum type for NodeType
2. rename nodeType from rrweb-snapshot to RRNodeType
3. rename notSerializedId to unserializedId
4. add comments for some confusing variables

* adapt changes of #865 to virtual-dom and improve the test case for more coverage

* apply review suggestions

https://github.com/rrweb-io/rrweb/pull/853#pullrequestreview-922474953

* tweak the diff algorithm

* add description of the flag useVirtualDom and remove outdated logConfig

* Remove console.log

* Contain changes to document

* Upgrade rollup to 2.70.2

* Revert "Upgrade rollup to 2.70.2"

This reverts commit b1be81a2a76565935c9dc391f31beb7f64d25956.

* Fix type checking rrdom

* Fix typing error while bundling

* Fix tslib error on build

Rollup would output the following error:
`semantic error TS2343: This syntax requires an imported helper named '__spreadArray' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.`

* Increase memory limit for rollup

* Use esbuild for bundling

Speeds up bundling significantly

* Avoid circular dependencies and import un-bundled rrdom

* Fix imports

* Revert back to pre-esbuild

This reverts the following commits:
b7b3c8dbaa551a0129da1477136b1baaad28e6e1
72e23b8e27f9030d911358d3a17fe5ad1b3b5d4f
85d600a20c56cfa764cf1f858932ba14e67b1d23
61e1a5d323212ca8fbe0569e0b3062ddd53fc612

* Set node to lts (12 is no longer supported)

* Speed up bundling and use less memory

This fixes the out of memory errors happening while bundling

* remove __sn from rrdom

* fix typo

* test: add a test case for StyleSheet mutation exceptions while fast-forwarding

* rename Array.prototype.slice.call() to Array.from()

* improve test cases

* fix: PR #887 in 'virtual-dom' branch

* apply justin's suggestion on 'Array.from' refactor

related commit 0f6729d27a323260b36fbe79485a86715c0bc98a

* improve import code structure

Co-authored-by: Yun Feng <yun.feng@anu.edu.au>
2022-05-12 12:01:13 +08:00
Justin Halsall
69499be6e2 Perf: Apply the latest text mutation only (#885)
* Perf: apply the latest text mutation only

* Find unique text mutations in one iteration
2022-05-09 22:29:00 +08:00
Dmytro Kozlovskyi
3cdcb8a12b Fix for issue #890 (#891) 2022-05-09 22:28:36 +08:00
Justin Halsall
a0e6641505 Test: Stylesheet append text node (#886) 2022-05-05 12:40:55 +08:00
Justin Halsall
e238462f30 Record canvas snapshots N times per second (#859)
* Only record canvas when recordCanvas is true

* All should be compiled first

Makes recompiling+debugging a lot faster

* Add support for compiling web workes

Replaces @rollup/plugin-typescript for rollup-plugin-typescript2 as the former is incompatible with rollup-plugin-web-worker-loader

* Update yarn.lock

* Upgrade to typescript 4.5.5

* add support for replay of ImageBitmap in 2d canvas

* Snapshot canvases in a web-worker on FPS basis

* Fix performance of canvas recording and playback

* Wait for all images to be preloaded before checking results

* flatten base64 strings, as encoding isn't consistent

* Cleanup

* Add serializing to 2d canvases as well

* Disable blob serialize test

We don't have any code for it yet

* Upgrade @rollup/plugin-commonjs to 21.0.2

Fixes
https://linguinecode.com/post/import-export-appear-at-the-top-level

* Move canvas recording options to `sampling`

Based on: https://github.com/rrweb-io/rrweb/pull/859#discussion_r846582146
2022-04-18 13:24:51 +08:00
Rahul Lingala
93fec1f3e7 Fix mutation edge case when blocked class gets unblocked (#867)
* Fix mutation edge case when blocked class gets unblocked

* Add integration test

* Update isSerialized logic
2022-04-15 11:56:25 +08:00
Justin Halsall
e4f680e8c9 Remove INode (node.__sn) and use Mirror as source of truth (#868)
* Move ids to weakmap

* Fix typo

* Move from INode to storing serialized data in mirror

* Update packages/rrweb-snapshot/src/rebuild.ts

Co-authored-by: Yun Feng <yun.feng@anu.edu.au>

* Remove unnessisary `as Node` typecastings

Fixes: https://github.com/rrweb-io/rrweb/pull/868#discussion_r842240758

* Remove unnessisary `as unknown as ...`

* Remove unnessisary `as unknown as ...`

* Reset mirror when recording starts

Solves: https://github.com/rrweb-io/rrweb/pull/868#discussion_r842249599

* API has changed for snapshot, change test to reflect that

* Allow for es5 compatibility

* Remove unnessisary as unknown as ... and change test to reflect the API change

* Refactor mirror to remove `nodeIdMap`

Fixes: https://github.com/rrweb-io/rrweb/pull/868#discussion_r842732696

Co-authored-by: Yun Feng <yun.feng@anu.edu.au>
2022-04-06 23:56:39 +08:00
Yanzhen Yu
539f7c8c06 update typings 2022-04-04 16:20:49 +08:00
Yanzhen Yu
e110660ac6 chore(release): publish new version
- rrdom@0.1.2
 - rrweb@1.1.3
 - rrweb-player@0.7.14
 - rrweb-snapshot@1.1.14
2022-04-04 16:14:49 +08:00
Justin Halsall
9ed6767ada Don't serialize all cssRules if multiple text nodes exists (#866) 2022-03-31 21:51:25 +08:00
Justin Halsall
072b81b534 Apply textContent on flush (#865)
* Apply textContent on flush

* fix typo

* Style sheet rules applied after <style>'s textContent override should work
2022-03-27 14:07:19 +08:00
Yanzhen Yu
423372b0c4 fix #864 use for loop instead of forEach 2022-03-24 19:47:06 +08:00
Yun Feng
d8f9290ca4 add support for nested shadow dom (#834)
* fix: can't record shadow host and shadow dom in incremental mutations

* enable to record newly added shadow dom

* Revert "enable to record newly added shadow dom"

This reverts commit cf7c0ad551ac457f00e3f754702c1464314f6a86.

* Revert "fix: can't record shadow host and shadow dom in incremental mutations"

This reverts commit 8b25cc97f83cbc333702c0ba73684e54eeadaabe.

* fix: can't record shadow host and shadow dom in incremental mutations

* add support for nested shadow root and add integration test

* fix test error

* enable to record shadow-dom in iframes

* add an integration test case for nested iframes and shadow-doms

* use the patch function
2022-03-18 11:08:41 +08:00
Justin Halsall
8afeed3224 Upgrade Typescript to 4.6.2, and bump up other packages (#856) 2022-03-08 23:07:32 +08:00
Yanzhen Yu
bd144be39b chore(release): publish new version
- rrdom@0.1.1
 - rrweb@1.1.2
 - rrweb-player@0.7.13
 - rrweb-snapshot@1.1.13
2022-02-26 17:33:59 +08:00
Cristi Constantin
e104300f25 Decrease embedded img size for inlineImages (#836)
* Decrease embedded img size for inlineImages

* Fix the test

* Use webp for image snapshots

* Implemented optional param dataURLOptions
2022-02-25 12:45:53 +08:00
Yun Feng
e9531d420a fix: can't record SVG element inside iframe properly (#843)
el instanceof SVGElement is false if the svg element is inside iframe so that the isSVG property is missing in the recorded data
2022-02-24 09:02:55 +08:00
Yun Feng
5ae208b174 fix: Uncaught TypeError: Illegal invocation when recording incremental canvas mutation (#844) 2022-02-24 09:02:47 +08:00
Eoghan Murray
f74b7bb28d Use the .closest method to transfer recursive parent class checking into the browser engine for an expected performance improvement (#840)
https://developer.mozilla.org/en-US/docs/Web/API/Element/closest available on all modern browsers
2022-02-22 23:48:32 +08:00
Yun Feng
167f0fa08d improve captured message of Error object (#835)
try to fix this problem:
https://github.com/rrweb-io/rrweb/issues/814#issuecomment-1033735775
2022-02-17 14:12:07 +08:00
Yun Feng
1935bf606f console plugin fix (#832)
* fix: empty payload in console-plugin

* update unit test
2022-02-10 11:30:58 +08:00
Alex Dehe Ng
69acc73136 close all pages to avoid EPERM error on Windows 10 (#830) 2022-02-08 23:07:18 +08:00