Skip to content

Commit

Permalink
Merge branch 'master' into jb/perf/replay
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasBa authored Aug 17, 2023
2 parents eed46b0 + 58c9104 commit bc2c8f2
Show file tree
Hide file tree
Showing 36 changed files with 472 additions and 216 deletions.
2 changes: 2 additions & 0 deletions .changeset/cuddly-readers-warn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
6 changes: 6 additions & 0 deletions .changeset/curvy-apples-lay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'rrweb-snapshot': patch
'rrweb': patch
---

Extend to run fixBrowserCompatibilityIssuesInCSS over inline stylesheets
8 changes: 8 additions & 0 deletions .changeset/itchy-dryers-double.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'rrweb-player': patch
'rrweb-snapshot': patch
'rrweb': patch
'@rrweb/types': patch
---

Upgrade all projects to typescript 4.9.5
6 changes: 6 additions & 0 deletions .changeset/nervous-mirrors-perform.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'rrweb-snapshot': patch
'rrweb': patch
---

Perf: Avoid creation of intermediary array when iterating over style rules
4 changes: 4 additions & 0 deletions .changeset/pre.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"clean-shrimps-lay",
"cold-eyes-hunt",
"controller-finish-flag",
"curvy-apples-lay",
"date-now-guard",
"eight-terms-hunt",
"empty-bikes-cheer",
Expand All @@ -32,6 +33,8 @@
"fresh-spoons-drive",
"gold-terms-look",
"grumpy-ways-own",
"itchy-dryers-double",
"khaki-dots-bathe",
"large-ants-prove",
"lazy-toes-confess",
"little-radios-thank",
Expand All @@ -53,6 +56,7 @@
"real-masks-explode",
"real-trains-switch",
"rich-crews-protect",
"rich-jars-remember",
"serious-ants-juggle",
"sixty-impalas-laugh",
"small-olives-arrive",
Expand Down
5 changes: 5 additions & 0 deletions .changeset/rich-jars-remember.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'rrweb-snapshot': patch
---

Add workaround for Chrome/Edge CSS `@import` escaping bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1472259
4 changes: 2 additions & 2 deletions .github/workflows/style-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
node-version: 16
cache: 'yarn'
- name: Install Dependencies
run: yarn
run: yarn install --frozen-lockfile
- name: Prettier Check
run: yarn prettier --check '**/*.{ts,md}'

Expand All @@ -85,7 +85,7 @@ jobs:
node-version: 16
cache: 'yarn'
- name: Install Dependencies
run: yarn
run: yarn install --frozen-lockfile
- name: Prettify Code
run: yarn prettier --write '**/*.{ts,md}'
- name: Commit Changes
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"markdownlint-cli": "^0.31.1",
"prettier": "2.8.4",
"turbo": "^1.2.4",
"typescript": "^4.7.3"
"typescript": "^4.9.5"
},
"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'",
Expand All @@ -49,7 +49,8 @@
"release": "yarn build:all && changeset publish"
},
"resolutions": {
"**/jsdom/cssom": "https://registry.npmjs.org/rrweb-cssom/-/rrweb-cssom-0.6.0.tgz"
"**/jsdom/cssom": "https://registry.npmjs.org/rrweb-cssom/-/rrweb-cssom-0.6.0.tgz",
"**/@types/dom-webcodecs": "0.1.5"
},
"browserslist": [
"defaults",
Expand Down
8 changes: 8 additions & 0 deletions packages/rrdom-nodejs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# rrdom-nodejs

## 2.0.0-alpha.11

### Patch Changes

- Updated dependencies [[`11f6567`](https://github.com/rrweb-io/rrweb/commit/11f6567fd81ef9ed0f954a7b6d5e39653f56004f), [`efdc167`](https://github.com/rrweb-io/rrweb/commit/efdc167ca6c039d04af83612e3d92498bb9b41a7), [`efdc167`](https://github.com/rrweb-io/rrweb/commit/efdc167ca6c039d04af83612e3d92498bb9b41a7)]:
- rrweb-snapshot@2.0.0-alpha.11
- rrdom@2.0.0-alpha.11

## 2.0.0-alpha.10

### Patch Changes
Expand Down
6 changes: 3 additions & 3 deletions packages/rrdom-nodejs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rrdom-nodejs",
"version": "2.0.0-alpha.10",
"version": "2.0.0-alpha.11",
"scripts": {
"dev": "rollup -c -w",
"bundle": "rollup --config",
Expand Down Expand Up @@ -48,8 +48,8 @@
"cssom": "^0.5.0",
"cssstyle": "^2.3.0",
"nwsapi": "^2.2.0",
"rrdom": "^2.0.0-alpha.10",
"rrweb-snapshot": "^2.0.0-alpha.10"
"rrdom": "^2.0.0-alpha.11",
"rrweb-snapshot": "^2.0.0-alpha.11"
},
"browserslist": [
"supports es6-class"
Expand Down
7 changes: 7 additions & 0 deletions packages/rrdom/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# rrdom

## 2.0.0-alpha.11

### Patch Changes

- Updated dependencies [[`11f6567`](https://github.com/rrweb-io/rrweb/commit/11f6567fd81ef9ed0f954a7b6d5e39653f56004f), [`efdc167`](https://github.com/rrweb-io/rrweb/commit/efdc167ca6c039d04af83612e3d92498bb9b41a7), [`efdc167`](https://github.com/rrweb-io/rrweb/commit/efdc167ca6c039d04af83612e3d92498bb9b41a7)]:
- rrweb-snapshot@2.0.0-alpha.11

## 2.0.0-alpha.10

### Patch Changes
Expand Down
6 changes: 3 additions & 3 deletions packages/rrdom/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rrdom",
"version": "2.0.0-alpha.10",
"version": "2.0.0-alpha.11",
"homepage": "https://github.com/rrweb-io/rrweb/tree/main/packages/rrdom#readme",
"license": "MIT",
"main": "lib/rrdom.cjs",
Expand Down Expand Up @@ -32,7 +32,7 @@
},
"devDependencies": {
"@rollup/plugin-commonjs": "^20.0.0",
"@rrweb/types": "^2.0.0-alpha.10",
"@rrweb/types": "^2.0.0-alpha.11",
"@types/jest": "^27.4.1",
"@types/puppeteer": "^5.4.4",
"@typescript-eslint/eslint-plugin": "^5.23.0",
Expand All @@ -47,6 +47,6 @@
"ts-jest": "^27.1.3"
},
"dependencies": {
"rrweb-snapshot": "^2.0.0-alpha.10"
"rrweb-snapshot": "^2.0.0-alpha.11"
}
}
7 changes: 7 additions & 0 deletions packages/rrvideo/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# rrvideo

## 2.0.0-alpha.11

### Patch Changes

- Updated dependencies [[`efdc167`](https://github.com/rrweb-io/rrweb/commit/efdc167ca6c039d04af83612e3d92498bb9b41a7)]:
- rrweb-player@2.0.0-alpha.11

## 2.0.0-alpha.10

### Patch Changes
Expand Down
6 changes: 3 additions & 3 deletions packages/rrvideo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rrvideo",
"version": "2.0.0-alpha.10",
"version": "2.0.0-alpha.11",
"description": "transform rrweb session into video",
"main": "build/index.js",
"bin": {
Expand All @@ -26,13 +26,13 @@
"@types/node": "^18.15.11",
"jest": "^27.5.1",
"ts-jest": "^27.1.3",
"@rrweb/types": "^2.0.0-alpha.10"
"@rrweb/types": "^2.0.0-alpha.11"
},
"dependencies": {
"@open-tech-world/cli-progress-bar": "^2.0.2",
"fs-extra": "^11.1.1",
"minimist": "^1.2.5",
"playwright": "^1.32.1",
"rrweb-player": "^2.0.0-alpha.10"
"rrweb-player": "^2.0.0-alpha.11"
}
}
9 changes: 9 additions & 0 deletions packages/rrweb-player/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# rrweb-player

## 2.0.0-alpha.11

### Patch Changes

- [#1287](https://github.com/rrweb-io/rrweb/pull/1287) [`efdc167`](https://github.com/rrweb-io/rrweb/commit/efdc167ca6c039d04af83612e3d92498bb9b41a7) Thanks [@Juice10](https://github.com/Juice10)! - Upgrade all projects to typescript 4.9.5

- Updated dependencies [[`11f6567`](https://github.com/rrweb-io/rrweb/commit/11f6567fd81ef9ed0f954a7b6d5e39653f56004f), [`efdc167`](https://github.com/rrweb-io/rrweb/commit/efdc167ca6c039d04af83612e3d92498bb9b41a7)]:
- rrweb@2.0.0-alpha.11

## 2.0.0-alpha.10

### Patch Changes
Expand Down
12 changes: 6 additions & 6 deletions packages/rrweb-player/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "rrweb-player",
"version": "2.0.0-alpha.10",
"version": "2.0.0-alpha.11",
"devDependencies": {
"@rollup/plugin-commonjs": "^22.0.0",
"@rollup/plugin-node-resolve": "^13.2.1",
"@rrweb/types": "^2.0.0-alpha.10",
"@rrweb/types": "^2.0.0-alpha.11",
"@types/offscreencanvas": "^2019.6.4",
"eslint-config-google": "^0.14.0",
"eslint-plugin-svelte3": "^4.0.0",
Expand All @@ -17,14 +17,14 @@
"rollup-plugin-typescript2": "^0.31.2",
"rollup-plugin-web-worker-loader": "^1.6.1",
"sirv-cli": "^0.4.4",
"svelte": "^3.2.0",
"svelte-check": "^1.4.0",
"svelte-preprocess": "^4.0.0",
"svelte": "^3.59.2",
"svelte-check": "^3.0.1",
"svelte-preprocess": "^5.0.0",
"tslib": "^2.0.0"
},
"dependencies": {
"@tsconfig/svelte": "^1.0.0",
"rrweb": "^2.0.0-alpha.10"
"rrweb": "^2.0.0-alpha.11"
},
"scripts": {
"build": "rollup -c",
Expand Down
10 changes: 10 additions & 0 deletions packages/rrweb-snapshot/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# rrweb-snapshot

## 2.0.0-alpha.11

### Patch Changes

- [#1279](https://github.com/rrweb-io/rrweb/pull/1279) [`11f6567`](https://github.com/rrweb-io/rrweb/commit/11f6567fd81ef9ed0f954a7b6d5e39653f56004f) Thanks [@eoghanmurray](https://github.com/eoghanmurray)! - Extend to run fixBrowserCompatibilityIssuesInCSS over inline stylesheets

- [#1287](https://github.com/rrweb-io/rrweb/pull/1287) [`efdc167`](https://github.com/rrweb-io/rrweb/commit/efdc167ca6c039d04af83612e3d92498bb9b41a7) Thanks [@Juice10](https://github.com/Juice10)! - Upgrade all projects to typescript 4.9.5

- [#1287](https://github.com/rrweb-io/rrweb/pull/1287) [`efdc167`](https://github.com/rrweb-io/rrweb/commit/efdc167ca6c039d04af83612e3d92498bb9b41a7) Thanks [@Juice10](https://github.com/Juice10)! - Add workaround for Chrome/Edge CSS `@import` escaping bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1472259

## 2.0.0-alpha.10

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/rrweb-snapshot/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rrweb-snapshot",
"version": "2.0.0-alpha.10",
"version": "2.0.0-alpha.11",
"description": "rrweb's component to take a snapshot of DOM, aka DOM serializer",
"scripts": {
"prepare": "npm run prepack",
Expand Down
4 changes: 2 additions & 2 deletions packages/rrweb-snapshot/src/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ export function parse(css: string, options: ParserOptions = {}) {
whitespace();
comments(rules);
while (css.length && css.charAt(0) !== '}' && (node = atrule() || rule())) {
if (node !== false) {
if (node) {
rules.push(node);
comments(rules);
}
Expand Down Expand Up @@ -383,7 +383,7 @@ export function parse(css: string, options: ParserOptions = {}) {
function comments(rules: Rule[] = []) {
let c: Comment | void;
while ((c = comment())) {
if (c !== false) {
if (c) {
rules.push(c);
}
c = comment();
Expand Down
23 changes: 4 additions & 19 deletions packages/rrweb-snapshot/src/snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ import {
isShadowRoot,
maskInputValue,
isNativeShadowDom,
getCssRulesString,
stringifyStylesheet,
getInputType,
toLowerCase,
validateStringifiedCssRule,
} from './utils';

let _id = 1;
Expand Down Expand Up @@ -51,20 +50,6 @@ function getValidTagName(element: HTMLElement): Lowercase<string> {
return processedTagName;
}

function stringifyStyleSheet(sheet: CSSStyleSheet): string {
if (sheet.cssRules.length === 0) {
return '';
}

const buffer: string[] = new Array<string>(sheet.cssRules.length);

for (let i = 0; i < sheet.cssRules.length; i++) {
const rule = sheet.cssRules[i];
buffer[i] = rule.cssText ? validateStringifiedCssRule(rule.cssText) : '';
}
return buffer.join('');
}

function extractOrigin(url: string): string {
let origin = '';
if (url.indexOf('//') > -1) {
Expand Down Expand Up @@ -576,7 +561,7 @@ function serializeTextNode(
// to _only_ include the current rule(s) added by the text node.
// So we'll be conservative and keep textContent as-is.
} else if ((n.parentNode as HTMLStyleElement).sheet?.cssRules) {
textContent = stringifyStyleSheet(
textContent = stringifyStylesheet(
(n.parentNode as HTMLStyleElement).sheet!,
);
}
Expand Down Expand Up @@ -673,7 +658,7 @@ function serializeElementNode(
});
let cssText: string | null = null;
if (stylesheet) {
cssText = getCssRulesString(stylesheet);
cssText = stringifyStylesheet(stylesheet);
}
if (cssText) {
delete attributes.rel;
Expand All @@ -688,7 +673,7 @@ function serializeElementNode(
// TODO: Currently we only try to get dynamic stylesheet when it is an empty style element
!(n.innerText || n.textContent || '').trim().length
) {
const cssText = getCssRulesString(
const cssText = stringifyStylesheet(
(n as HTMLStyleElement).sheet as CSSStyleSheet,
);
if (cssText) {
Expand Down
Loading

0 comments on commit bc2c8f2

Please sign in to comment.