Chore: Move most types from rrweb to @rrweb/types package (#1031)

* Chore: Add move most types from rrweb to @rrweb/types package

* Split off type imports

* Split off type import to its own line

* Get vite to generate type definitions

* Apply formatting changes

* noEmit not allowed in tsconfig, moved it to build step

* Align version of @rrweb/types with main rrweb package

Based on @mark-fenng's comments https://github.com/rrweb-io/rrweb/pull/1031/files#r1002298176

* Move up keywords
This commit is contained in:
Justin Halsall
2026-04-01 12:00:00 +08:00
committed by GitHub
parent 96ba547e72
commit 905ac51afb
69 changed files with 1307 additions and 712 deletions

View File

@@ -10,7 +10,8 @@ import {
generateRecordSnippet,
ISuite,
} from '../utils';
import type { recordOptions, eventWithTime } from '../../src/types';
import type { recordOptions } from '../../src/types';
import type { eventWithTime } from '@rrweb/types';
import { toMatchImageSnapshot } from 'jest-image-snapshot';
expect.extend({ toMatchImageSnapshot });

View File

@@ -1,4 +1,5 @@
import { EventType, eventWithTime, IncrementalSource } from '../../src/types';
import { EventType, IncrementalSource } from '@rrweb/types';
import type { eventWithTime } from '@rrweb/types';
const now = Date.now();
const events: eventWithTime[] = [

View File

@@ -1,4 +1,5 @@
import { EventType, eventWithTime, IncrementalSource } from '../../src/types';
import { EventType, IncrementalSource } from '@rrweb/types';
import type { eventWithTime } from '@rrweb/types';
const now = Date.now();

View File

@@ -1,4 +1,5 @@
import { EventType, eventWithTime, IncrementalSource } from '../../src/types';
import { EventType, IncrementalSource } from '@rrweb/types';
import type { eventWithTime } from '@rrweb/types';
const now = Date.now();

View File

@@ -1,4 +1,5 @@
import { EventType, eventWithTime, IncrementalSource } from '../../src/types';
import { EventType, IncrementalSource } from '@rrweb/types';
import type { eventWithTime } from '@rrweb/types';
const now = Date.now();

View File

@@ -1,4 +1,5 @@
import { EventType, eventWithTime, IncrementalSource } from '../../src/types';
import { EventType, IncrementalSource } from '@rrweb/types';
import type { eventWithTime } from '@rrweb/types';
const now = Date.now();
const events: eventWithTime[] = [

View File

@@ -1,4 +1,5 @@
import { EventType, eventWithTime, IncrementalSource } from '../../src/types';
import { EventType, IncrementalSource } from '@rrweb/types';
import type { eventWithTime } from '@rrweb/types';
const now = Date.now();
const events: eventWithTime[] = [

View File

@@ -1,4 +1,5 @@
import { EventType, eventWithTime, IncrementalSource } from '../../src/types';
import { EventType, IncrementalSource } from '@rrweb/types';
import type { eventWithTime } from '@rrweb/types';
const now = Date.now();
const events: eventWithTime[] = [

View File

@@ -1,4 +1,5 @@
import { EventType, eventWithTime, IncrementalSource } from '../../src/types';
import { EventType, IncrementalSource } from '@rrweb/types';
import type { eventWithTime } from '@rrweb/types';
const now = Date.now();

View File

@@ -1,4 +1,5 @@
import { EventType, eventWithTime, IncrementalSource } from '../../src/types';
import { EventType, IncrementalSource } from '@rrweb/types';
import type { eventWithTime } from '@rrweb/types';
const now = Date.now();

View File

@@ -1,4 +1,5 @@
import { EventType, eventWithTime, IncrementalSource } from '../../src/types';
import { EventType, IncrementalSource } from '@rrweb/types';
import type { eventWithTime } from '@rrweb/types';
const now = Date.now();
const events: eventWithTime[] = [

View File

@@ -1,4 +1,5 @@
import { EventType, eventWithTime, IncrementalSource } from '../../src/types';
import { EventType, IncrementalSource } from '@rrweb/types';
import type { eventWithTime } from '@rrweb/types';
const now = Date.now();
const events: eventWithTime[] = [

View File

@@ -11,12 +11,8 @@ import {
generateRecordSnippet,
ISuite,
} from './utils';
import {
recordOptions,
eventWithTime,
EventType,
RecordPlugin,
} from '../src/types';
import type { recordOptions } from '../src/types';
import { eventWithTime, EventType, RecordPlugin } from '@rrweb/types';
import { visitSnapshot, NodeType } from 'rrweb-snapshot';
describe('record integration tests', function (this: ISuite) {

View File

@@ -1,6 +1,6 @@
import { discardPriorSnapshots } from '../src/replay/machine';
import { sampleEvents } from './utils';
import { EventType } from '../src/types';
import { EventType } from '@rrweb/types';
const events = sampleEvents.filter(
(e) => ![EventType.DomContentLoaded, EventType.Load].includes(e.type),

View File

@@ -1,5 +1,5 @@
import { pack, unpack } from '../src/packer';
import { eventWithTime, EventType } from '../src/types';
import { eventWithTime, EventType } from '@rrweb/types';
import { MARK } from '../src/packer/base';
const event: eventWithTime = {

View File

@@ -2,15 +2,15 @@ import * as fs from 'fs';
import * as path from 'path';
import type * as puppeteer from 'puppeteer';
import 'construct-style-sheets-polyfill';
import type { recordOptions } from '../src/types';
import {
recordOptions,
listenerHandler,
eventWithTime,
EventType,
IncrementalSource,
styleSheetRuleData,
selectionData,
} from '../src/types';
} from '@rrweb/types';
import { assertSnapshot, launchPuppeteer, waitForRAF } from './utils';
interface ISuite {

View File

@@ -1,14 +1,14 @@
import * as fs from 'fs';
import * as path from 'path';
import type * as puppeteer from 'puppeteer';
import type { recordOptions } from '../../src/types';
import {
recordOptions,
listenerHandler,
eventWithTime,
EventType,
IncrementalSource,
CanvasContext,
} from '../../src/types';
} from '@rrweb/types';
import {
assertSnapshot,
launchPuppeteer,

View File

@@ -11,7 +11,7 @@ import {
IncrementalSource,
EventType,
eventWithTime,
} from '../../src/types';
} from '@rrweb/types';
let replayer: Replayer;

View File

@@ -6,7 +6,7 @@ import { polyfillWebGLGlobals } from '../utils';
polyfillWebGLGlobals();
import webglMutation from '../../src/replay/canvas/webgl';
import { CanvasContext } from '../../src/types';
import { CanvasContext } from '@rrweb/types';
import { variableListFor } from '../../src/replay/canvas/deserialize-args';
let canvas: HTMLCanvasElement;

View File

@@ -7,8 +7,8 @@ import {
Optional,
mouseInteractionData,
event,
recordOptions,
} from '../src/types';
} from '@rrweb/types';
import type { recordOptions } from '../src/types';
import * as puppeteer from 'puppeteer';
import { format } from 'prettier';
import * as path from 'path';