From 41a53cc440c5d42c834db70323a17f31607553a3 Mon Sep 17 00:00:00 2001 From: Jesse Wang Date: Fri, 18 Oct 2024 10:48:13 -0700 Subject: [PATCH] chore(rrweb): Fixed build issues --- .../test/cross-origin-iframe-packer.test.ts | 4 +- packages/all/test/utils.ts | 4 +- packages/packer/src/pack.ts | 2 +- .../package.json | 4 +- .../src/index.ts | 2 +- .../tsconfig.json | 6 ++- .../rrweb-plugin-console-record/src/index.ts | 2 +- .../test/html/index.ts | 4 +- .../rrweb-plugin-console-replay/src/index.ts | 4 +- .../src/index.ts | 4 +- packages/record/src/index.ts | 2 +- packages/replay/src/index.ts | 4 +- packages/rrdom-nodejs/src/document-nodejs.ts | 9 +++-- packages/rrdom-nodejs/src/polyfill.ts | 2 +- packages/rrdom-nodejs/test/polyfill.test.ts | 2 +- packages/rrweb/test/rrdom.test.ts | 6 +-- yarn.lock | 40 ------------------- 17 files changed, 33 insertions(+), 68 deletions(-) diff --git a/packages/all/test/cross-origin-iframe-packer.test.ts b/packages/all/test/cross-origin-iframe-packer.test.ts index c45eb59c82..b6b7d8801a 100644 --- a/packages/all/test/cross-origin-iframe-packer.test.ts +++ b/packages/all/test/cross-origin-iframe-packer.test.ts @@ -16,7 +16,7 @@ import { unpack } from '@amplitude/rrweb-packer'; import * as fs from 'fs'; import * as path from 'path'; import type * as puppeteer from 'puppeteer'; -import type { recordOptions } from 'rrweb'; +import type { recordOptions } from '@amplitude/rrweb'; import type {} from'@amplitude/rrweb-types'; import { EventType } from '@amplitude/rrweb-types'; import { @@ -57,7 +57,7 @@ async function injectRecordScript( options?: ExtraOptions, ) { await frame.addScriptTag({ - path: path.resolve(__dirname, '../dist/all.umd.cjs'), + path: path.resolve(__dirname, '../dist/rrweb-all.umd.cjs'), }); options = options || {}; await frame.evaluate((options) => { diff --git a/packages/all/test/utils.ts b/packages/all/test/utils.ts index 5f8aaab932..8e2398d151 100644 --- a/packages/all/test/utils.ts +++ b/packages/all/test/utils.ts @@ -1,4 +1,4 @@ -import { NodeType } from 'rrweb-snapshot'; +import { NodeType } from '@amplitude/rrweb-snapshot'; import { expect } from 'vitest'; import { EventType, @@ -8,7 +8,7 @@ import { mouseInteractionData, event, pluginEvent, -} from '@rrweb/types'; +} from '@amplitude/rrweb-types'; import * as puppeteer from 'puppeteer'; import * as path from 'path'; import * as http from 'http'; diff --git a/packages/packer/src/pack.ts b/packages/packer/src/pack.ts index dfe5bc2590..dfbbc54430 100644 --- a/packages/packer/src/pack.ts +++ b/packages/packer/src/pack.ts @@ -1,5 +1,5 @@ import { strFromU8, strToU8, zlibSync } from 'fflate'; -import type { PackFn } from '@rrweb/types'; +import type { PackFn } from '@amplitude/rrweb-types'; import { eventWithTimeAndPacker, MARK } from './base'; export const pack: PackFn = (event) => { diff --git a/packages/plugins/rrweb-plugin-canvas-webrtc-replay/package.json b/packages/plugins/rrweb-plugin-canvas-webrtc-replay/package.json index 766c17d788..42217c2718 100644 --- a/packages/plugins/rrweb-plugin-canvas-webrtc-replay/package.json +++ b/packages/plugins/rrweb-plugin-canvas-webrtc-replay/package.json @@ -43,12 +43,12 @@ }, "homepage": "https://github.com/rrweb-io/rrweb#readme", "devDependencies": { - "rrweb": "^2.0.0-alpha.24", + "@amplitude/rrweb": "^2.0.0-alpha.24", "typescript": "^4.7.3", "vite": "^5.2.8", "vite-plugin-dts": "^3.8.1" }, "peerDependencies": { - "rrweb": "^2.0.0-alpha.24" + "@amplitude/rrweb": "^2.0.0-alpha.24" } } diff --git a/packages/plugins/rrweb-plugin-canvas-webrtc-replay/src/index.ts b/packages/plugins/rrweb-plugin-canvas-webrtc-replay/src/index.ts index f6604ec4aa..f5a0913c72 100644 --- a/packages/plugins/rrweb-plugin-canvas-webrtc-replay/src/index.ts +++ b/packages/plugins/rrweb-plugin-canvas-webrtc-replay/src/index.ts @@ -1,7 +1,7 @@ import type { RRNode } from '@amplitude/rrdom'; import type { Mirror } from '@amplitude/rrweb-snapshot'; import SimplePeer from 'simple-peer-light'; -import type { ReplayPlugin, Replayer } from 'rrweb'; +import type { ReplayPlugin, Replayer } from '@amplitude/rrweb'; import type { WebRTCDataChannel } from './types'; // TODO: restrict callback to real nodes only, or make sure callback gets called when real node gets added to dom as well diff --git a/packages/plugins/rrweb-plugin-canvas-webrtc-replay/tsconfig.json b/packages/plugins/rrweb-plugin-canvas-webrtc-replay/tsconfig.json index b4e394756b..35189e4952 100644 --- a/packages/plugins/rrweb-plugin-canvas-webrtc-replay/tsconfig.json +++ b/packages/plugins/rrweb-plugin-canvas-webrtc-replay/tsconfig.json @@ -10,5 +10,9 @@ "rootDir": "src", "tsBuildInfoFile": "./tsconfig.tsbuildinfo" }, - "references": [] + "references": [ + { + "path": "../../rrweb" + } + ] } diff --git a/packages/plugins/rrweb-plugin-console-record/src/index.ts b/packages/plugins/rrweb-plugin-console-record/src/index.ts index 9918ffa74d..2545dd2e30 100644 --- a/packages/plugins/rrweb-plugin-console-record/src/index.ts +++ b/packages/plugins/rrweb-plugin-console-record/src/index.ts @@ -3,7 +3,7 @@ import type { RecordPlugin, listenerHandler, } from '@amplitude/rrweb-types'; -import { utils } from 'rrweb'; +import { utils } from '@amplitude/rrweb'; import { ErrorStackParser, StackFrame } from './error-stack-parser'; import { stringify } from './stringify'; diff --git a/packages/plugins/rrweb-plugin-console-record/test/html/index.ts b/packages/plugins/rrweb-plugin-console-record/test/html/index.ts index d701b7991e..00e3409431 100644 --- a/packages/plugins/rrweb-plugin-console-record/test/html/index.ts +++ b/packages/plugins/rrweb-plugin-console-record/test/html/index.ts @@ -1,5 +1,5 @@ -import type { eventWithTime } from '@rrweb/types'; -import { record } from 'rrweb'; +import type { eventWithTime } from '@amplitude/rrweb-types'; +import { record } from '@amplitude/rrweb'; import { getRecordConsolePlugin } from '../../src/index'; window.Date.now = () => new Date(Date.UTC(2018, 10, 15, 8)).valueOf(); diff --git a/packages/plugins/rrweb-plugin-console-replay/src/index.ts b/packages/plugins/rrweb-plugin-console-replay/src/index.ts index 0127524190..6ad875fe82 100644 --- a/packages/plugins/rrweb-plugin-console-replay/src/index.ts +++ b/packages/plugins/rrweb-plugin-console-replay/src/index.ts @@ -1,7 +1,7 @@ import type { eventWithTime } from '@amplitude/rrweb-types'; import { EventType, IncrementalSource } from '@amplitude/rrweb-types'; -import type { ReplayPlugin, Replayer } from 'rrweb'; -import { LogData, LogLevel, PLUGIN_NAME } from '@rrweb/rrweb-plugin-console-record'; +import type { ReplayPlugin, Replayer } from '@amplitude/rrweb'; +import { LogData, LogLevel, PLUGIN_NAME } from '@amplitude/rrweb-plugin-console-record'; /** * define an interface to replay log records diff --git a/packages/plugins/rrweb-plugin-sequential-id-replay/src/index.ts b/packages/plugins/rrweb-plugin-sequential-id-replay/src/index.ts index 0be8aab3c2..a997c5b5a6 100644 --- a/packages/plugins/rrweb-plugin-sequential-id-replay/src/index.ts +++ b/packages/plugins/rrweb-plugin-sequential-id-replay/src/index.ts @@ -1,6 +1,6 @@ import type { eventWithTime } from '@amplitude/rrweb-types'; -import type { ReplayPlugin } from 'rrweb'; -import type { SequentialIdOptions } from '@rrweb/rrweb-plugin-sequential-id-record'; +import type { ReplayPlugin } from '@amplitude/rrweb'; +import type { SequentialIdOptions } from '@amplitude/rrweb-plugin-sequential-id-record'; type Options = SequentialIdOptions & { warnOnMissingId: boolean; diff --git a/packages/record/src/index.ts b/packages/record/src/index.ts index c2820aa1d2..4ae55f1015 100644 --- a/packages/record/src/index.ts +++ b/packages/record/src/index.ts @@ -1,3 +1,3 @@ -import { record } from 'rrweb'; +import { record } from '@amplitude/rrweb'; export { record }; diff --git a/packages/replay/src/index.ts b/packages/replay/src/index.ts index 1df4de17e1..12a294bb59 100644 --- a/packages/replay/src/index.ts +++ b/packages/replay/src/index.ts @@ -3,7 +3,7 @@ import { type playerConfig, type PlayerMachineState, type SpeedMachineState, -} from 'rrweb'; -import 'rrweb/dist/style.css'; +} from '@amplitude/rrweb'; +import '@amplitude/rrweb/dist/style.css'; export { Replayer, playerConfig, PlayerMachineState, SpeedMachineState }; diff --git a/packages/rrdom-nodejs/src/document-nodejs.ts b/packages/rrdom-nodejs/src/document-nodejs.ts index b90b6f0fb9..79f26ba9cd 100644 --- a/packages/rrdom-nodejs/src/document-nodejs.ts +++ b/packages/rrdom-nodejs/src/document-nodejs.ts @@ -1,4 +1,7 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ +import { NodeType as RRNodeType } from '@amplitude/rrweb-snapshot'; +import type { NWSAPI } from 'nwsapi'; +import type { CSSStyleDeclaration as CSSStyleDeclarationType } from 'cssstyle'; import { BaseRRCDATASection, BaseRRComment, @@ -10,10 +13,8 @@ import { BaseRRText, ClassList, IRRDocument, + CSSStyleDeclaration, } from '@amplitude/rrdom'; -import { NodeType as RRNodeType } from '@amplitude/rrweb-snapshot'; -import type { CSSStyleDeclaration as CSSStyleDeclarationType } from 'cssstyle'; -import type { NWSAPI } from 'nwsapi'; // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-var-requires const nwsapi = require('nwsapi'); // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-var-requires @@ -389,4 +390,4 @@ interface RRElementTagNameMap { } type RRElementType = - K extends keyof RRElementTagNameMap ? RRElementTagNameMap[K] : RRElement; + K extends keyof RRElementTagNameMap ? RRElementTagNameMap[K] : RRElement; \ No newline at end of file diff --git a/packages/rrdom-nodejs/src/polyfill.ts b/packages/rrdom-nodejs/src/polyfill.ts index 19674611c6..635da6c189 100644 --- a/packages/rrdom-nodejs/src/polyfill.ts +++ b/packages/rrdom-nodejs/src/polyfill.ts @@ -1,4 +1,4 @@ -import { BaseRRNode } from 'rrdom'; +import { BaseRRNode } from '@amplitude/rrdom'; import { RRDocument } from './document-nodejs'; /** diff --git a/packages/rrdom-nodejs/test/polyfill.test.ts b/packages/rrdom-nodejs/test/polyfill.test.ts index 0e7f8cbcda..ef4ac93097 100644 --- a/packages/rrdom-nodejs/test/polyfill.test.ts +++ b/packages/rrdom-nodejs/test/polyfill.test.ts @@ -9,7 +9,7 @@ import { polyfillDocument, } from '../src/polyfill'; import { performance as nativePerformance } from 'perf_hooks'; -import { BaseRRNode } from 'rrdom'; +import { BaseRRNode } from '@amplitude/rrdom'; describe('polyfill for nodejs', () => { it('should polyfill performance api', () => { diff --git a/packages/rrweb/test/rrdom.test.ts b/packages/rrweb/test/rrdom.test.ts index 7ef0866aa6..db22d46c40 100644 --- a/packages/rrweb/test/rrdom.test.ts +++ b/packages/rrweb/test/rrdom.test.ts @@ -3,9 +3,9 @@ */ import { EventType, IncrementalSource, Replayer, eventWithTime } from '../src'; import { vi, type MockInstance } from 'vitest'; -import type { styleDeclarationData, styleSheetRuleData } from '@rrweb/types'; -import { createMirror, Mirror as NodeMirror } from 'rrweb-snapshot'; -import type { ReplayerHandler } from 'rrdom'; +import type { styleDeclarationData, styleSheetRuleData } from '@amplitude/rrweb-types'; +import { createMirror, Mirror as NodeMirror } from '@amplitude/rrweb-snapshot'; +import type { ReplayerHandler } from '@amplitude/rrdom'; describe('diff algorithm for rrdom', () => { let mirror: NodeMirror; diff --git a/yarn.lock b/yarn.lock index 5bc294757f..78b6467ddd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2654,18 +2654,6 @@ resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.14.1.tgz#299eee74b7d87e116083ac5b1ce8dd9434668294" integrity sha512-wQGI+LY/Py20zdUPq+XCem7JcPOyzIJBm3dli+56DJsQOHbnXZFEwgmnC6el1TPAfC8lBT3m+z69RmLykNUbew== -"@rrweb/types@^2.0.0-alpha.17": - version "2.0.0-alpha.17" - resolved "https://registry.yarnpkg.com/@rrweb/types/-/types-2.0.0-alpha.17.tgz#bf4af026e767022674892919692d59e766e9368e" - integrity sha512-AfDTVUuCyCaIG0lTSqYtrZqJX39ZEYzs4fYKnexhQ+id+kbZIpIJtaut5cto6dWZbB3SEe4fW0o90Po3LvTmfg== - dependencies: - rrweb-snapshot "^2.0.0-alpha.17" - -"@rrweb/utils@^2.0.0-alpha.17": - version "2.0.0-alpha.17" - resolved "https://registry.yarnpkg.com/@rrweb/utils/-/utils-2.0.0-alpha.17.tgz#d13a7326af0311e0f54551e223ace987608eaed5" - integrity sha512-HCsasPERBwOS9/LQeOytO2ETKTCqRj1wORBuxiy3t41hKhmi225DdrUPiWnyDdTQm1GdVbOymMRknJVPnZaSXw== - "@rushstack/node-core-library@4.0.2": version "4.0.2" resolved "https://registry.yarnpkg.com/@rushstack/node-core-library/-/node-core-library-4.0.2.tgz#e26854a3314b279d57e8abdb4acce7797d02f554" @@ -9735,34 +9723,6 @@ rollup@^4.13.0: "@rollup/rollup-win32-x64-msvc" "4.14.1" fsevents "~2.3.2" -rrdom@^2.0.0-alpha.17: - version "2.0.0-alpha.17" - resolved "https://registry.yarnpkg.com/rrdom/-/rrdom-2.0.0-alpha.17.tgz#c200f21a63bab341caea7f3f2f88d760aa045c3a" - integrity sha512-b6caDiNcFO96Opp7TGdcVd4OLGSXu5dJe+A0IDiAu8mk7OmhqZCSDlgQdTKmdO5wMf4zPsUTgb8H/aNvR3kDHA== - dependencies: - rrweb-snapshot "^2.0.0-alpha.17" - -rrweb-snapshot@^2.0.0-alpha.17: - version "2.0.0-alpha.17" - resolved "https://registry.yarnpkg.com/rrweb-snapshot/-/rrweb-snapshot-2.0.0-alpha.17.tgz#c4667cbca62530bcb98508e6c85c20f2b320f5ca" - integrity sha512-GBg5pV8LHOTbeVmH2VHLEFR0mc2QpQMzAvcoxEGfPNWgWHc8UvKCyq7pqN1vA+fDZ+yXXbixeO0kB2pzVvFCBw== - dependencies: - postcss "^8.4.38" - -rrweb@^2.0.0-alpha.24: - version "2.0.0-alpha.17" - resolved "https://registry.yarnpkg.com/rrweb/-/rrweb-2.0.0-alpha.17.tgz#de4d8bce18c0f184708b79edaa3c974a9f5b843f" - integrity sha512-GQxBkCC4r9XL2bwSdv7iIS49M3cEA8OtObVq0rrQ4GUT4+h7omucGQ4x7m5YN5Vq1oalStBaBlYqF7yRnfG3JA== - dependencies: - "@rrweb/types" "^2.0.0-alpha.17" - "@rrweb/utils" "^2.0.0-alpha.17" - "@types/css-font-loading-module" "0.0.7" - "@xstate/fsm" "^1.4.0" - base64-arraybuffer "^1.0.1" - mitt "^3.0.0" - rrdom "^2.0.0-alpha.17" - rrweb-snapshot "^2.0.0-alpha.17" - run-async@^2.4.0: version "2.4.1" resolved "https://registry.npmjs.org/run-async/-/run-async-2.4.1.tgz"