Commit Graph

292 Commits

Author SHA1 Message Date
Antonio Villegas
5844f60fd8 Make properties x and y optional in mouseInteractionParam (#1375)
* Make properties x and y optional in mouseInteractionParam

The event representing a mouse interaction of focus an element does not include the properties x and y. Thus, they must be defined as optional.

* Fix typings
2024-02-10 09:12:56 +08:00
yz-yu
fc2feee60a fix the test CI (#1405)
* run tests without concurrency

* do not use cache in rpt2 during test
2024-01-28 14:13:14 +08:00
Paul D'Ambra
af0962cc6c fix: console logger can serialize bigint values (#1403)
* fix: console logger can serialize bigint values

* teach test jsdom is present

* add a changeset
2024-01-25 16:55:52 +01:00
David Newell
1e0b273822 chore: export canvasMutation (#1383)
* chore: export canvasMutation

* add changeset
2024-01-22 16:32:32 +01:00
huangkairan
0f004af18d perf(web-extension): conditional check (#1360)
Co-authored-by: Yun Feng <yun.feng0817@gmail.com>
2023-12-04 21:45:53 +11:00
Eoghan Murray
a2be77b828 Fix serialization and mutation of <textarea> elements (#1351)
* Fix serialization and mutation of <textarea> elements taking account the duality that the value can be set in either the child node, or in the value _parameter_ (not attribute)

* Backwards compatibility: Bug fix and regression test for #112
 - this is to fix up 'historical' recordings, as duplicate textarea content should no longer be being created at record time
 - new test shows what the snapshot generated by previous versions of rrweb used to look like, hence 'bad'
 - original 0efe23f04a fix either didn't work or no longer works due to childNodes being appended subsequent to this part of the code
 - during review, we also verified that the `_cssText` case should still be handled okay, as there's currently no scenario where csstext is present with css child nodes of a <style>

* Masking: Fix that textarea values were being missed by the masking system if the value was recorded as a child node
 - I didn't notice that form.html was used in other tests, so lucky that I noticed that those tests also should have the 'pre value' masked out

* Simplify by always storing the textarea value in the `.value` attribute (from it's DOM property) and not as a childNode. It should still be rebuilt as a childNode rather than a property
---------

Authored-by: eoghanmurray <eoghan@getthere.ie>
2023-12-01 13:18:58 +00:00
Eoghan Murray
07ac5c9e13 Masking: Avoid the repeated calls to closest when recursing through the DOM (#1349)
* masking performance: avoid the repeated calls to `closest` when recursing through the DOM
 - needsMask===true means that an ancestor has tested positively for masking, and so this node and all descendents should be masked
 - needsMask===false means that no ancestors have tested positively for masking, we should check each node encountered
 - needsMask===undefined means that we don't know whether ancestors are masked or not (e.g. after a mutation) and should look up the tree
* Add tests including an explicit characterData mutation tests 
* Further performance improvement: avoid calls to `el.matches` when on a leaf node, e.g. a `<br/>`
---------

Authored-by: eoghanmurray <eoghan@getthere.ie>
Based on initial PR #1338 by Alexey Babik <alexey.babik@noibu.com>
2023-11-24 16:06:02 +00:00
Yun Feng
8aea5b00a4 Feat: Add support for replaying :defined pseudo-class of custom elements (#1155)
* Feat: Add support for replaying :defined pseudo-class of custom elements

* add isCustom flag to serialized elements

Applying Justin's review suggestion

* fix code lint error

* add custom element event

* fix: tests (#1348)

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

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

---------

Co-authored-by: Nafees Nehar <nafees87n@gmail.com>
Co-authored-by: Justin Halsall <Juice10@users.noreply.github.com>
2023-11-07 15:26:13 +01:00
Eoghan Murray
dbd15a9492 Md create html document (#1321)
* only call createHTMLDocument where it is needed

* Perf: create the mutation document once as a 'singleton' as it can be reused

---------

Co-authored-by: Michael Dellanoce <mdellanoce@pendo.io>
2023-11-06 11:10:07 +01:00
Billy Vong
40f484d088 fix(web-extension): Fix types in vite config (#1333) 2023-11-04 09:23:49 +11:00
huangkairan
9e65dda258 fix(web-extension): beforeunload logic (#1330) 2023-11-04 09:10:00 +11:00
Michael Dellanoce
05478c36dd perf(rrweb): attribute mutation optimization (#1343) 2023-11-04 09:03:59 +11:00
Francesco Novy
9c6edfe226 ref: Avoid unnecessary cloning of objects or arrays (#1340) 2023-11-03 12:09:21 +01:00
Justin Halsall
f362e7a84c Fix linting issues (#1347)
* Fix linting issues

* Apply formatting changes
2023-11-03 11:40:54 +01:00
蟹老板
1fe39ab0db Pref: export eventWithTime (#1324)
*  export eventWithTime for consumption in typescript code
2023-10-31 17:20:25 +00:00
huangkairan
8444cb2dad 🐞 fix(web-extension): typo (#1307)
Co-authored-by: Yun Feng <yun.feng0817@gmail.com>
2023-10-20 14:10:21 +11:00
Francesco Novy
57a940afac fix: Fix checking for patchTarget in initAdoptedStyleSheetObserver (#1327) 2023-10-13 22:05:26 +11:00
Ben White
7c0dc9dfe1 Extended text masking function to include relevant HTMLElement (#1310)
* Extends maskTextFn to pass the HTMLElement to the deciding function

---------

Authored-by: benjackwhite <benjackwhite@users.noreply.github.com>
Co-authored-by: Justin Halsall <Juice10@users.noreply.github.com>
Co-authored-by: Eoghan Murray <eoghan@getthere.ie>
2023-10-13 12:02:08 +01:00
Eoghan Murray
980a38c816 Add config option to turn off all snapshotting and related observers (#1311)
* Add config option to turn off all snapshotting and related observers

 - allows RRWEB to be used for click/movement tracking alone, e.g. for a heatmaps use case
 - could also be used if there was a separate process for recording the DOM (in which case a 3rd party library like https://github.com/antonmedv/finder could be added to record targets instead of the mirror)
---------

Authored-by: eoghanmurray <eoghanmurray@users.noreply.github.com>
Co-authored-by: Justin Halsall <Juice10@users.noreply.github.com>
2023-10-13 09:58:20 +01:00
Kento Moriwaki
297104cc8a Enable preserveSource (#1309) 2023-10-06 10:42:59 +01:00
Eoghan Murray
58c9104edd Perf: Avoid creation of intermediary array when iterating over style rules (#1272)
* Perf: Avoid creation of intermediary array when iterating over stylesheet rules by using the second `mapFn` argument of Array.from

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from

Performance analysis by: JonasBA <jonas@badalic.com>
Authored-by: Eoghan Murray <eoghan@getthere.ie>
2023-08-15 10:39:29 +01:00
Eoghan Murray
64420c7e46 Perf: don't run the regex replace unless the selectorText contains a colon (#1280)
* Perf: don't run the regex replace unless the selectorText contains a colon (rules generally contain colons)

* Need to check type before querying selectorText property - also good as it means we only try to fix colons at the leaf level
---------

Authored-by: eoghan murray <eoghan@getthere.ie>
2023-08-14 12:43:34 +01:00
github-actions[bot]
3119e0d1d8 Version Packages (alpha) (#1286)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-08-14 11:05:02 +02:00
Justin Halsall
efdc167ca6 Add workaround for Chrome/Edge css import escaping bug (#1287)
* Upgrade to typescript 4.9.5

* Apply formatting changes

* Add workaround for chrome incorrect escaping bug

More info: https://bugs.chromium.org/p/chromium/issues/detail?id=1472259

* Apply formatting changes

* Create itchy-dryers-double.md

* Create rich-jars-remember.md

* Apply formatting changes

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

* Apply formatting changes

* Update packages/rrweb-snapshot/test/__snapshots__/integration.test.ts.snap

* Apply formatting changes

* Update snapshot

* Apply formatting changes

* Rename and refactor fixBrowserCompatibilityIssuesInCSSImports, getCssRulesString and getCssRuleString based on @eoghanmurray feedback

* Apply formatting changes

* Apply formatting changes
2023-08-11 17:58:42 +02:00
Eoghan Murray
11f6567fd8 Extend to run fixBrowserCompatibilityIssuesInCSS over inline stylesheets (#1279)
* Extend to run fixBrowserCompatibilityIssuesInCSS over styles in inline style sheets

* Apply formatting changes

---------

Co-authored-by: eoghanmurray <eoghanmurray@users.noreply.github.com>
2023-08-11 15:19:33 +02:00
github-actions[bot]
8a48e42378 Version Packages (alpha) (#1252)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-08-07 10:21:52 +02:00
Justin Halsall
a3de582e9c Canvas recording: Preserve drawing buffer (#1273)
* Upgrade jest to 29 and puppeteer to 16 in rrweb

* Apply formatting changes

* Upgrade rrweb's puppeteer to v20

* Apply formatting changes

* Canvas: Reduce flickering and capturing of empty canvas elements

Turn on `preserveDrawingBuffer` by default for canvas FPS recording.
Has some negative performance implications, but really helps when capturing canvas.

* Apply formatting changes

* Include all test image snapshots in ci

* Apply formatting changes

* Allow more flexibility when capturing hover

* Apply formatting changes

* Create tiny-chairs-build.md

* Apply formatting changes

* Update hover.test.ts

* Apply formatting changes

* Document snapshotFormat jest config

* Freeze `yarn.lock` in ci for reproducible dependencies

* Apply formatting changes

* Apply formatting changes

* Revert to old style of puppeteer evaluation script notation

* Apply formatting changes

* Make test less flaky

* Apply formatting changes

* Apply formatting changes

* Make tests less flaky

* Apply formatting changes

* Make test more robust

* Apply formatting changes

* Apply formatting changes

* Add debugging code for test

* Apply formatting changes

* Also test not ignored input

* Apply formatting changes

* Apply formatting changes

* Apply formatting changes

* escape ignoreSelector

* Apply formatting changes

* Apply formatting changes
2023-08-04 18:35:49 +02:00
Billy Vong
36da39db36 feat: Add ignoreSelector option (#1262)
* feat: Add `ignoreSelector` option

Similar to `ignoreClass`, but accepts a CSS selector so that you can use any CSS selector.

* Apply formatting changes

* Create clean-shrimps-lay.md

* Apply formatting changes
2023-08-04 10:30:03 +02:00
Eoghan Murray
7103625b46 Mutation (attribute & text) duplicate info elimination (#1269)
* Add a test which demonstrates how no mutations are generated when an element is created & destroyed in the same 'cycle' (a cylce here being enforced by freezePage)

* Test demonstrating current behaviour I'm about to modify; the data-test="x" attribute is present twice in the mutation, as is the textContent value of 'y'

* Attribute or text modifications on just-added nodes are redundant as demonstrated in test case

* Some correct test changes from other tests; I've manually inspected each of these mutation removals and confirmed that the attribute values are already present in the newly added nodes elsewhere in the same mutation

* Improve reliability of test case as per Justin's advice
2023-08-03 17:11:43 +01:00
Eoghan Murray
d872d2809e Compact style mutation fixes and improvements (#1268)
* Don't use the CSSOM when there's `var()` present as it fails badly https://github.com/rrweb-io/rrweb/pull/1246

* As the CSS Object Model expands out shorthand properties, do a check on the string length before choosing which format to go for

 - this approach allows 'var()' in a styleOMValue as it's only a problem when combined with a shorthand property
 - before this change background:black; was getting expaned to 10 OM properties as follows:

'style': {
    'background-color': 'black',
    'background-image': false,
    'background-position-x': false,
    'background-position-y': false,
    'background-size': false,
    'background-repeat-x': false,
    'background-repeat-y': false,
    'background-attachment': false,
    'background-origin': false,
    'background-clip': false
}

* Updates to remainder of tests based on refined compact style mutations

* Apply suggestions from code review by: Justin Halsall <Juice10@users.noreply.github.com>

---------

Authored-by: eoghanmurray <eoghan@getthere.ie>
2023-08-03 13:56:31 +01:00
Francesco Novy
c6600e742b fix: Fix CSS rules captured in Safari (#1253)
* fix: Fix CSS rules captured in Safari

* Apply formatting changes

* add changeset

* fix

---------

Co-authored-by: mydea <mydea@users.noreply.github.com>
2023-07-07 15:23:38 +02:00
Francesco Novy
d0fbe23c63 fix: Handle case where event is null/undefined (#1254)
* fix: Handle case where `event` is null/undefined

* add changeset
2023-07-07 15:22:54 +02:00
fukang wang
bbbfa226fc fix: Resize and MediaInteraction events repeat generated after the iframe appeared (#1251)
* fix: Resize and MediaInteraction events repeat generated after the iframe appeared

* Create nervous-buses-pump.md

* Apply formatting changes

---------

Co-authored-by: wangfukang <wangfukang@kuaishou.com>
Co-authored-by: wfk007 <wfk007@users.noreply.github.com>
2023-07-07 11:57:37 +02:00
github-actions[bot]
46df5cd988 Version Packages (alpha) (#1216)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-06-30 10:54:51 +02:00
Justin Halsall
a01a12ef67 Fix types in rrwebPlayer (#1247)
* Export correct mirror in player

Was using DeprecatedMirror in its types, that shouldn't be used anymore.

* Add playRange to types

* Create smooth-poems-bake.md

* Apply formatting changes

* Add $set to player type

* Update smooth-poems-bake.md

* Apply formatting changes

* Last two arguments of playRange are optional
2023-06-30 02:35:38 +02:00
Eoghan Murray
490b3e2b62 Guard against redefinition of Date.now (#1196)
* Guard against presence of likely older third party libraries which (re)define Date.now, e.g. https://github.com/datejs/Datejs/issues/92

* Apply formatting changes

* (remove nowTimestamp import where Date.now() is not used)

* Add a PURE marker so an empty `ìf` statement doesn't show up in the rrweb-replay output

* Update packages/rrweb/src/utils.ts

Fix typing issue with regex against `Date.now()`

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

* Create little-radios-thank.md

* Apply formatting changes

* Update .changeset/little-radios-thank.md

* Apply formatting changes

---------

Co-authored-by: eoghanmurray <eoghanmurray@users.noreply.github.com>
Co-authored-by: Justin Halsall <Juice10@users.noreply.github.com>
2023-06-02 12:20:14 +02:00
Eoghan Murray
325a9f093e Update test commands (#1205)
* As per @Yun Feng: everyone has npm installed globally but maybe not yarn

* Add command to enable test result updating

* Default to running tests HEADLESS on rrweb

* Add command to build:all in a low memory environment

* Add a 'retest' command for when the code hasn't changed, but you are working on the test cases

* Add commands to reformat according to prettier. Named 'reformat' to indicate that we are doing a `--write`

* Update package.json

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

* Apply suggestions from code review

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

* Create few-turkeys-reflect.md

* Apply formatting changes

---------

Co-authored-by: Justin Halsall <Juice10@users.noreply.github.com>
Co-authored-by: Yun Feng <yun.feng0817@gmail.com>
2023-06-02 12:19:35 +02:00
Francesco Novy
d7c72bff07 fix: Ensure attributes are lowercased when checking (#1183)
* fix: Ensure attributes are lowercased when checking

* add changeset

* fix to lower case

* Apply formatting changes

---------

Co-authored-by: mydea <mydea@users.noreply.github.com>
2023-06-02 12:16:37 +02:00
Yun Feng
b798f2dbc0 Fix rrdom bugs (#1222)
* fix: rrdom bug

1. fix one bug of the diff algorithm
2. omit srcdoc attribute of iframe

* use linked list to iterate children

* fix the bug that the children of shadowRoot don't get diffed

* add test cases

* add change log
2023-06-02 11:44:00 +02:00
Eoghan Murray
a6ce7182ce Avoid triggering a CSP (content security policy) error (#846)
* Fix for #816 - avoid triggering a CSP (content security policy) error with `.setAttribute('style')`

* The bare unattachedDoc that I previously naively created didn't have a doctype and wasn't a HTML document, so the child style element didn't have the `old.style` attribute available

* Add a try/catch to provide some robustness in case `document.implementation.createHTMLDocument` isn't available
2023-05-22 12:53:36 +10:00
fukang wang
a1ec9a273e perf: optimize performance of the DoubleLinkedList get (#1220)
* perf: optimize performance of the DoubleLinkedList get

* fix: delete addedNodeIndexArr
2023-05-22 12:19:28 +10:00
Ben White
4dcdcf7ec4 fix: Rrror parser throw (#1225)
* Warn instead of throwing error when parsing for console logs

* Added error to warning
2023-05-15 22:19:42 +10:00
Yun Feng
23d01387f4 rrvideo: improve the video quality and add a progress bar for the CLI tool (#1197)
* refactor rrvideo: use playwright rather than puppeteer

* add a progress bar for the tool

* add tests for cli.ts

* fix build error

* add change log

* update readme file

* Apply a scaling method to improve the resolution of the output video
2023-05-01 14:04:38 +02:00
fukang wang
ebcbe8b0d7 perf: record processMutation (#1214)
* perf: record processMutation

* Create mean-tips-impress.md

* Apply formatting changes
2023-05-01 10:15:58 +08:00
github-actions[bot]
db66eb47a6 Version Packages (alpha) (#1199) 2023-04-16 14:33:43 +08:00
Eoghan Murray
c550cfa614 Reduce verbosity/redundancy of new pointerType attribute (#1206)
* Reduce verbosity/redundancy of output of new pointerType attribute by confining it only to clicks (and to a MouseDown/MouseUp from a PointerTypes.Pen, as these don't yet have a dedicated PendDown/PenUp)

* Update how the changeset will read for the next release based on the trimming in this PR

* Prefer triple equals

* The assignment to the outer `pointerType` variable in an anonymous function was somehow missed by the `typings` check

* Apply formatting changes

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

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

---------

Co-authored-by: Yun Feng <yun.feng0817@gmail.com>
2023-04-16 14:28:47 +08:00
Ben White
bc84246f78 feat: Added support maskInputFn with HTMLElement (#1188) 2023-04-15 09:31:39 +02:00
re-fort
94d06536e3 fix: change default value of input type from null to text (#1200)
* fix: change default value of input type from null to text

* Apply formatting changes

* add changeset

* add a comment related to the type of input element
2023-04-14 16:04:02 +08:00
Eoghan Murray
f88471184c Merge pull request #1201 from eoghanmurray/pointerTypeFixups
Pointer type fixups
2023-04-13 11:25:40 +01:00
Eoghan Murray
004d29ba70 eslint was giving an error here 2023-04-12 15:11:51 +01:00