Skip to content

Commit 5a78938

Browse files
daibhineoghanmurrayJuice10
authored
chore: abstract types to shared package (#1593)
* chore: update types * small typing change * fix typing issue * typed node * add extra lint skip * add changeset --------- Co-authored-by: Eoghan Murray <[email protected]> Co-authored-by: Justin Halsall <[email protected]>
1 parent bd9eb70 commit 5a78938

36 files changed

+256
-250
lines changed

.changeset/soft-worms-tan.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
"@rrweb/all": patch
3+
"rrdom-nodejs": patch
4+
"rrdom": patch
5+
"rrweb-snapshot": major
6+
"rrweb": patch
7+
"@rrweb/rrweb-plugin-canvas-webrtc-record": patch
8+
---
9+
10+
`NodeType` enum was moved from rrweb-snapshot to @rrweb/types
11+
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`

packages/all/test/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { NodeType } from 'rrweb-snapshot';
21
import { expect } from 'vitest';
32
import {
3+
NodeType,
44
EventType,
55
IncrementalSource,
66
eventWithTime,

packages/plugins/rrweb-plugin-canvas-webrtc-record/src/index.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
import type { Mirror } from 'rrweb-snapshot';
21
import SimplePeer from 'simple-peer-light';
3-
import type { RecordPlugin, ICrossOriginIframeMirror } from '@rrweb/types';
2+
import type {
3+
RecordPlugin,
4+
ICrossOriginIframeMirror,
5+
IMirror,
6+
} from '@rrweb/types';
47
import type { WebRTCDataChannel } from './types';
58

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

2629
export class RRWebPluginCanvasWebRTCRecord {
2730
private peer: SimplePeer.Instance | null = null;
28-
private mirror: Mirror | undefined;
31+
private mirror: IMirror<Node> | undefined;
2932
private crossOriginIframeMirror: ICrossOriginIframeMirror | undefined;
3033
private streamMap: Map<number, MediaStream> = new Map();
3134
private incomingStreams = new Set<MediaStream>();

packages/rrdom-nodejs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,6 @@
5656
"cssstyle": "^2.3.0",
5757
"nwsapi": "2.2.0",
5858
"rrdom": "^2.0.0-alpha.17",
59-
"rrweb-snapshot": "^2.0.0-alpha.17"
59+
"@rrweb/types": "^2.0.0-alpha.17"
6060
}
6161
}

packages/rrdom-nodejs/src/document-nodejs.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
2-
import { NodeType as RRNodeType } from 'rrweb-snapshot';
1+
import { NodeType as RRNodeType } from '@rrweb/types';
32
import type { NWSAPI } from 'nwsapi';
43
import type { CSSStyleDeclaration as CSSStyleDeclarationType } from 'cssstyle';
54
import {
@@ -345,7 +344,7 @@ export class RRStyleElement extends RRElement {
345344
for (const child of this.childNodes)
346345
if (child.RRNodeType === RRNodeType.Text)
347346
result += (child as RRText).textContent;
348-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
347+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-assignment
349348
this._sheet = cssom.parse(result);
350349
}
351350
return this._sheet;

packages/rrdom-nodejs/test/document-nodejs.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import { describe, it, expect, beforeAll } from 'vitest';
55
import * as fs from 'fs';
66
import * as path from 'path';
7-
import { NodeType as RRNodeType } from 'rrweb-snapshot';
7+
import { NodeType as RRNodeType } from '@rrweb/types';
88
import {
99
RRCanvasElement,
1010
RRCDATASection,

packages/rrdom-nodejs/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"path": "../rrdom"
1111
},
1212
{
13-
"path": "../rrweb-snapshot"
13+
"path": "../types"
1414
}
1515
]
1616
}

packages/rrdom/src/diff.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
import {
2-
NodeType as RRNodeType,
3-
Mirror as NodeMirror,
4-
type elementNode,
5-
} from 'rrweb-snapshot';
1+
import { type Mirror as NodeMirror } from 'rrweb-snapshot';
2+
import { NodeType as RRNodeType } from '@rrweb/types';
63
import type {
74
canvasMutationData,
85
canvasEventWithTime,
6+
elementNode,
97
inputData,
108
scrollData,
119
styleDeclarationData,

packages/rrdom/src/document.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { NodeType as RRNodeType } from 'rrweb-snapshot';
1+
import { NodeType as RRNodeType } from '@rrweb/types';
22
import { parseCSSText, camelize, toCSSText } from './style';
33
export interface IRRNode {
44
parentElement: IRRNode | null;

packages/rrdom/src/index.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
import {
2-
NodeType as RRNodeType,
3-
createMirror as createNodeMirror,
4-
} from 'rrweb-snapshot';
1+
import { createMirror as createNodeMirror } from 'rrweb-snapshot';
2+
import type { Mirror as NodeMirror } from 'rrweb-snapshot';
3+
import { NodeType as RRNodeType } from '@rrweb/types';
54
import type {
6-
Mirror as NodeMirror,
75
IMirror,
86
serializedNodeWithId,
9-
} from 'rrweb-snapshot';
10-
import type {
117
canvasMutationData,
128
canvasEventWithTime,
139
inputData,

0 commit comments

Comments
 (0)