Skip to content

Commit

Permalink
cherry-picking
Browse files Browse the repository at this point in the history
  • Loading branch information
jxiwang committed Feb 13, 2025
1 parent edc079c commit 8f468aa
Show file tree
Hide file tree
Showing 36 changed files with 293 additions and 309 deletions.
11 changes: 11 additions & 0 deletions .changeset/soft-worms-tan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"@rrweb/all": patch
"rrdom-nodejs": patch
"rrdom": patch
"rrweb-snapshot": major
"rrweb": patch
"@rrweb/rrweb-plugin-canvas-webrtc-record": patch
---

`NodeType` enum was moved from rrweb-snapshot to @rrweb/types
The following types where moved from rrweb-snapshot to @rrweb/types: `documentNode`, `documentTypeNode`, `legacyAttributes`, `textNode`, `cdataNode`, `commentNode`, `elementNode`, `serializedNode`, `serializedNodeWithId`, `serializedElementNodeWithId`, `serializedTextNodeWithId`, `IMirror`, `INode`, `mediaAttributes`, `attributes` and `DataURLOptions`
2 changes: 1 addition & 1 deletion packages/all/test/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NodeType } from '@amplitude/rrweb-snapshot';
import { expect } from 'vitest';
import {
NodeType,
EventType,
IncrementalSource,
eventWithTime,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { Mirror } from '@amplitude/rrweb-snapshot';
import SimplePeer from 'simple-peer-light';
import type {
ICrossOriginIframeMirror,
RecordPlugin,
ICrossOriginIframeMirror,
IMirror,
} from '@amplitude/rrweb-types';
import SimplePeer from 'simple-peer-light';
import type { WebRTCDataChannel } from './types';

export const PLUGIN_NAME = 'rrweb/canvas-webrtc@1';
Expand All @@ -28,7 +28,7 @@ export type CrossOriginIframeMessageEventContent = {

export class RRWebPluginCanvasWebRTCRecord {
private peer: SimplePeer.Instance | null = null;
private mirror: Mirror | undefined;
private mirror: IMirror<Node> | undefined;
private crossOriginIframeMirror: ICrossOriginIframeMirror | undefined;
private streamMap: Map<number, MediaStream> = new Map();
private incomingStreams = new Set<MediaStream>();
Expand Down
2 changes: 1 addition & 1 deletion packages/rrdom-nodejs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@
"cssstyle": "^2.3.0",
"nwsapi": "2.2.0",
"@amplitude/rrdom": "^2.0.0-alpha.26",
"@amplitude/rrweb-snapshot": "^2.0.0-alpha.26"
"@amplitude/rrweb-types": "^2.0.0-alpha.26"
}
}
5 changes: 2 additions & 3 deletions packages/rrdom-nodejs/src/document-nodejs.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import { NodeType as RRNodeType } from '@amplitude/rrweb-snapshot';
import { NodeType as RRNodeType } from '@amplitude/rrweb-types';
import type { NWSAPI } from 'nwsapi';
import type { CSSStyleDeclaration as CSSStyleDeclarationType } from 'cssstyle';
import {
Expand Down Expand Up @@ -345,7 +344,7 @@ export class RRStyleElement extends RRElement {
for (const child of this.childNodes)
if (child.RRNodeType === RRNodeType.Text)
result += (child as RRText).textContent;
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-assignment
this._sheet = cssom.parse(result);
}
return this._sheet;
Expand Down
2 changes: 1 addition & 1 deletion packages/rrdom-nodejs/test/document-nodejs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { describe, it, expect, beforeAll } from 'vitest';
import * as fs from 'fs';
import * as path from 'path';
import { NodeType as RRNodeType } from '@amplitude/rrweb-snapshot';
import { NodeType as RRNodeType } from '@amplitude/rrweb-types';
import {
RRCanvasElement,
RRCDATASection,
Expand Down
2 changes: 1 addition & 1 deletion packages/rrdom-nodejs/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"path": "../rrdom"
},
{
"path": "../rrweb-snapshot"
"path": "../types"
}
]
}
6 changes: 3 additions & 3 deletions packages/rrdom/src/diff.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {
Mirror as NodeMirror,
NodeType as NodeType_2,
type elementNode,
type Mirror as NodeMirror,
} from '@amplitude/rrweb-snapshot';
import { NodeType as NodeType_2 } from '@amplitude/rrweb-types';
import type {
canvasEventWithTime,
canvasMutationData,
elementNode,
inputData,
scrollData,
styleDeclarationData,
Expand Down
4 changes: 2 additions & 2 deletions packages/rrdom/src/document.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NodeType as NodeType_2 } from '@amplitude/rrweb-snapshot';
import { camelize, parseCSSText, toCSSText } from './style';
import { NodeType as NodeType_2 } from '@amplitude/rrweb-types';
import { parseCSSText, camelize, toCSSText } from './style';
export interface IRRNode {
parentElement: IRRNode | null;
parentNode: IRRNode | null;
Expand Down
12 changes: 4 additions & 8 deletions packages/rrdom/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import { createMirror as createNodeMirror } from '@amplitude/rrweb-snapshot';
import type { Mirror as NodeMirror } from '@amplitude/rrweb-snapshot';
import { NodeType as NodeType_2 } from '@amplitude/rrweb-types';
import type {
IMirror,
Mirror as NodeMirror,
serializedNodeWithId,
} from '@amplitude/rrweb-snapshot';
import {
NodeType as NodeType_2,
createMirror as createNodeMirror,
} from '@amplitude/rrweb-snapshot';
import type {
canvasEventWithTime,
canvasMutationData,
canvasEventWithTime,
inputData,
scrollData,
styleDeclarationData,
Expand Down
30 changes: 15 additions & 15 deletions packages/rrdom/test/diff.test.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
/**
* @jest-environment jsdom
*/
import {
Mirror as NodeMirror,
NodeType as RRNodeType,
createMirror,
serializedNodeWithId,
} from '@amplitude/rrweb-snapshot';
import type {
canvasMutationData,
styleSheetRuleData,
} from '@amplitude/rrweb-types';
import { EventType, IncrementalSource } from '@amplitude/rrweb-types';
import * as fs from 'fs';
import * as path from 'path';
import * as puppeteer from 'puppeteer';
import { vi, MockInstance } from 'vitest';
import { createMirror, Mirror as NodeMirror } from '@amplitude/rrweb-snapshot';
import {
RRDocument,
RRMediaElement,
Mirror as RRNodeMirror,
buildFromDom,
getDefaultSN,
Mirror as RRNodeMirror,
RRDocument,
RRMediaElement,
printRRDom,
} from '../src';
import {
ReplayerHandler,
createOrGetNode,
diff,
ReplayerHandler,
nodeMatching,
sameNodeType,
} from '../src/diff';
import type { IRRElement, IRRNode } from '../src/document';
import type {
serializedNodeWithId,
canvasMutationData,
styleSheetRuleData,
} from '@amplitude/rrweb-types';
import {
NodeType as RRNodeType,
EventType,
IncrementalSource,
} from '@amplitude/rrweb-types';

const elementSn = {
type: RRNodeType.Element,
Expand Down
2 changes: 1 addition & 1 deletion packages/rrdom/test/diff/dialog.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
*/
import { vi, MockInstance } from 'vitest';
import {
NodeType as RRNodeType,
createMirror,
Mirror as NodeMirror,
serializedNodeWithId,
} from '@amplitude/rrweb-snapshot';
import { NodeType as RRNodeType } from '@amplitude/rrweb-types';
import { RRDocument } from '../../src';
import { diff, ReplayerHandler } from '../../src/diff';

Expand Down
2 changes: 1 addition & 1 deletion packages/rrdom/test/document.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @jest-environment jsdom
*/
import { NodeType as RRNodeType } from '@amplitude/rrweb-snapshot';
import { NodeType as RRNodeType } from '@amplitude/rrweb-types';
import {
BaseRRDocument,
BaseRRDocumentType,
Expand Down
5 changes: 2 additions & 3 deletions packages/rrdom/test/virtual-dom.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,17 @@ import * as path from 'path';
import * as puppeteer from 'puppeteer';
import { vi } from 'vitest';
import { JSDOM } from 'jsdom';
import { buildNodeWithSN, Mirror } from '@amplitude/rrweb-snapshot';
import {
buildNodeWithSN,
cdataNode,
commentNode,
documentNode,
documentTypeNode,
elementNode,
Mirror,
NodeType,
NodeType as RRNodeType,
textNode,
} from '@amplitude/rrweb-snapshot';
} from '@amplitude/rrweb-types';
import {
buildFromDom,
buildFromNode,
Expand Down
1 change: 1 addition & 0 deletions packages/rrweb-snapshot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
},
"homepage": "https://github.com/amplitude/rrweb/tree/master/packages/rrweb-snapshot#readme",
"devDependencies": {
"@amplitude/rrweb-types": "^2.0.0-alpha.26",
"@amplitude/rrweb-utils": "^2.0.0-alpha.26",
"@types/jsdom": "^20.0.0",
"@types/node": "^18.15.11",
Expand Down
8 changes: 3 additions & 5 deletions packages/rrweb-snapshot/src/rebuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ import { mediaSelectorPlugin, pseudoClassPlugin } from './css';
import {
type serializedNodeWithId,
type serializedElementNodeWithId,
type serializedTextNodeWithId,
NodeType,
type tagMap,
type elementNode,
type BuildCache,
type legacyAttributes,
} from './types';
} from '@rrweb/types';
import { type tagMap, type BuildCache } from './types';
import { isElement, Mirror, isNodeMetaEqual } from './utils';
import postcss from 'postcss';

Expand Down Expand Up @@ -96,7 +94,7 @@ export function applyCssSplits(
hackCss: boolean,
cache: BuildCache,
): void {
const childTextNodes: serializedTextNodeWithId[] = [];
const childTextNodes = [];
for (const scn of n.childNodes) {
if (scn.type === NodeType.Text) {
childTextNodes.push(scn);
Expand Down
34 changes: 18 additions & 16 deletions packages/rrweb-snapshot/src/snapshot.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import {
type serializedNode,
type serializedNodeWithId,
NodeType,
type attributes,
type MaskInputOptions,
type SlimDOMOptions,
type DataURLOptions,
type DialogAttributes,
type MaskTextFn,
type MaskInputFn,
type KeepIframeSrcFn,
type ICanvas,
type elementNode,
type serializedElementNodeWithId,
type mediaAttributes,
import type {
MaskInputOptions,
SlimDOMOptions,
MaskTextFn,
MaskInputFn,
KeepIframeSrcFn,
ICanvas,
DialogAttributes,
} from './types';
import { NodeType } from '@rrweb/types';
import type {
serializedNode,
serializedNodeWithId,
serializedElementNodeWithId,
elementNode,
attributes,
mediaAttributes,
DataURLOptions,
} from '@rrweb/types';
import {
Mirror,
is2DCanvasBlank,
Expand Down
Loading

0 comments on commit 8f468aa

Please sign in to comment.