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

refactor: improved tab recording to improve stability #1632

Merged
merged 6 commits into from
Jan 20, 2025
Merged
Changes from 1 commit
Commits
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
Prev Previous commit
prevent duplicate rrweb player in the dev mode
YunFeng0817 committed Jan 18, 2025

Verified

This commit was signed with the committer’s verified signature.
commit 7f7d96c48afeb56d7370662072cb741095afdc40
3 changes: 3 additions & 0 deletions packages/web-extension/src/pages/Player.tsx
Original file line number Diff line number Diff line change
@@ -29,6 +29,7 @@ export default function Player() {
getEvents(sessionId)
.then((events) => {
if (!playerElRef.current) return;
if (playerRef.current) return;

const manifest = chrome.runtime.getManifest();
const rrwebPlayerVersion = manifest.version_name || manifest.version;
@@ -50,6 +51,8 @@ export default function Player() {
return () => {
// eslint-disable-next-line
playerRef.current?.pause();
// eslint-disable-next-line
playerRef.current?.$destroy();
};
}, [sessionId]);

3 changes: 1 addition & 2 deletions packages/web-extension/vite.config.ts
Original file line number Diff line number Diff line change
@@ -81,7 +81,6 @@ export default defineConfig({
// A function to generate manifest file dynamically.
manifest: () => {
const packageJson = readJsonFile('package.json') as PackageJson;
const isProduction = process.env.NODE_ENV === 'production';
type ManifestBase = {
common: Record<string, unknown>;
chrome: Record<string, unknown>;
@@ -93,7 +92,7 @@ export default defineConfig({
v3: ManifestBase;
};
const ManifestVersion =
process.env.TARGET_BROWSER === 'chrome' && isProduction ? 'v3' : 'v2';
process.env.TARGET_BROWSER === 'chrome' ? 'v3' : 'v2';
const BrowserName =
process.env.TARGET_BROWSER === 'chrome' ? 'chrome' : 'firefox';
const commonManifest = originalManifest.common;

Unchanged files with check annotations Beta

export type customElementCallback = (c: customElementParam) => void;
/**
* @deprecated

Check warning on line 612 in packages/types/src/index.ts

GitHub Actions / ESLint Check and Report Upload

tsdoc-missing-deprecation-message: The @deprecated block must include a deprecation message, e.g. describing the recommended alternative
*/
interface INode extends Node {
__sn: serializedNodeWithId;
// should warn? maybe a text node isn't attached to a parent node yet?
return false;
} else {
el = dom.parentElement(node)!;

Check warning on line 285 in packages/rrweb-snapshot/src/snapshot.ts

GitHub Actions / ESLint Check and Report Upload

Forbidden non-null assertion

Check warning on line 285 in packages/rrweb-snapshot/src/snapshot.ts

GitHub Actions / ESLint Check and Report Upload

Forbidden non-null assertion
}
try {
if (typeof maskTextClass === 'string') {
const recordInlineImage = () => {
image.removeEventListener('load', recordInlineImage);
try {
canvasService!.width = image.naturalWidth;

Check warning on line 705 in packages/rrweb-snapshot/src/snapshot.ts

GitHub Actions / ESLint Check and Report Upload

Forbidden non-null assertion

Check warning on line 705 in packages/rrweb-snapshot/src/snapshot.ts

GitHub Actions / ESLint Check and Report Upload

Forbidden non-null assertion
canvasService!.height = image.naturalHeight;

Check warning on line 706 in packages/rrweb-snapshot/src/snapshot.ts

GitHub Actions / ESLint Check and Report Upload

Forbidden non-null assertion

Check warning on line 706 in packages/rrweb-snapshot/src/snapshot.ts

GitHub Actions / ESLint Check and Report Upload

Forbidden non-null assertion
canvasCtx!.drawImage(image, 0, 0);

Check warning on line 707 in packages/rrweb-snapshot/src/snapshot.ts

GitHub Actions / ESLint Check and Report Upload

Forbidden non-null assertion

Check warning on line 707 in packages/rrweb-snapshot/src/snapshot.ts

GitHub Actions / ESLint Check and Report Upload

Forbidden non-null assertion
attributes.rr_dataURL = canvasService!.toDataURL(

Check warning on line 708 in packages/rrweb-snapshot/src/snapshot.ts

GitHub Actions / ESLint Check and Report Upload

Forbidden non-null assertion

Check warning on line 708 in packages/rrweb-snapshot/src/snapshot.ts

GitHub Actions / ESLint Check and Report Upload

Forbidden non-null assertion
dataURLOptions.type,
dataURLOptions.quality,
);
* Browsers sometimes incorrectly escape `@import` on `.cssText` statements.
* This function tries to correct the escaping.
* more info: https://bugs.chromium.org/p/chromium/issues/detail?id=1472259
* @param cssImportRule

Check warning on line 83 in packages/rrweb-snapshot/src/utils.ts

GitHub Actions / ESLint Check and Report Upload

tsdoc-param-tag-missing-hyphen: The @param block should be followed by a parameter name and then a hyphen

Check warning on line 83 in packages/rrweb-snapshot/src/utils.ts

GitHub Actions / ESLint Check and Report Upload

tsdoc-param-tag-missing-hyphen: The @param block should be followed by a parameter name and then a hyphen
* @returns `cssText` with browser inconsistencies fixed, or null if not applicable.
*/
export function escapeImportStatement(rule: CSSImportRule): string {
childNodes[i].textContent &&
typeof childNodes[i].textContent === 'string'
) {
const textContentNorm = normalizeCssString(childNodes[i].textContent!);

Check warning on line 478 in packages/rrweb-snapshot/src/utils.ts

GitHub Actions / ESLint Check and Report Upload

Forbidden non-null assertion

Check warning on line 478 in packages/rrweb-snapshot/src/utils.ts

GitHub Actions / ESLint Check and Report Upload

Forbidden non-null assertion
let j = 3;
for (; j < textContentNorm.length; j++) {
if (
plugins
?.filter((p) => p.observer)
?.map((p) => ({
observer: p.observer!,

Check warning on line 560 in packages/rrweb/src/record/index.ts

GitHub Actions / ESLint Check and Report Upload

Forbidden non-null assertion

Check warning on line 560 in packages/rrweb/src/record/index.ts

GitHub Actions / ESLint Check and Report Upload

Forbidden non-null assertion
options: p.options,
callback: (payload: object) =>
wrappedEmit({
iframeManager.addLoadListener((iframeEl) => {
try {
handlers.push(observe(iframeEl.contentDocument!));

Check warning on line 578 in packages/rrweb/src/record/index.ts

GitHub Actions / ESLint Check and Report Upload

Forbidden non-null assertion

Check warning on line 578 in packages/rrweb/src/record/index.ts

GitHub Actions / ESLint Check and Report Upload

Forbidden non-null assertion
} catch (error) {
// TODO: handle internal error
console.warn(error);
};
while (this.mapRemoves.length) {
this.mirror.removeNodeFromMap(this.mapRemoves.shift()!);

Check warning on line 366 in packages/rrweb/src/record/mutation.ts

GitHub Actions / ESLint Check and Report Upload

Forbidden non-null assertion
}
for (const n of this.movedSet) {