diff --git a/.changeset/large-files-give.md b/.changeset/large-files-give.md new file mode 100644 index 0000000000..4fe79ca168 --- /dev/null +++ b/.changeset/large-files-give.md @@ -0,0 +1,8 @@ +--- +"@amplitude/rrweb-all": patch +"@amplitude/rrdom-nodejs": patch +"@amplitude/rrdom": patch +"@amplitude/rrweb": patch +--- + +chore(rrweb): fix the dist files to properly map to typescript checks diff --git a/packages/all/test/cross-origin-iframe-packer.test.ts b/packages/all/test/cross-origin-iframe-packer.test.ts index d35e2cb83d..c9e171ae8e 100644 --- a/packages/all/test/cross-origin-iframe-packer.test.ts +++ b/packages/all/test/cross-origin-iframe-packer.test.ts @@ -17,7 +17,7 @@ import * as fs from 'fs'; import * as path from 'path'; import type * as puppeteer from 'puppeteer'; import type { recordOptions } from '@amplitude/rrweb'; -import type {} from'@amplitude/rrweb-types'; +import type {} from '@amplitude/rrweb-types'; import { EventType } from '@amplitude/rrweb-types'; import { assertSnapshot, diff --git a/packages/rrdom-nodejs/src/document-nodejs.ts b/packages/rrdom-nodejs/src/document-nodejs.ts index 01a37108ee..c4aa828b53 100644 --- a/packages/rrdom-nodejs/src/document-nodejs.ts +++ b/packages/rrdom-nodejs/src/document-nodejs.ts @@ -390,4 +390,4 @@ interface RRElementTagNameMap { } type RRElementType = - K extends keyof RRElementTagNameMap ? RRElementTagNameMap[K] : RRElement; \ No newline at end of file + K extends keyof RRElementTagNameMap ? RRElementTagNameMap[K] : RRElement; diff --git a/packages/rrdom-nodejs/test/document-nodejs.test.ts b/packages/rrdom-nodejs/test/document-nodejs.test.ts index 10c87c1705..1c43210f0a 100644 --- a/packages/rrdom-nodejs/test/document-nodejs.test.ts +++ b/packages/rrdom-nodejs/test/document-nodejs.test.ts @@ -545,4 +545,4 @@ describe('RRDocument for nodejs environment', () => { function getHtml(fileName: string) { const filePath = path.resolve(__dirname, `../../rrdom/test/html/${fileName}`); return fs.readFileSync(filePath, 'utf8'); -} \ No newline at end of file +} diff --git a/packages/rrdom/src/diff.ts b/packages/rrdom/src/diff.ts index fec3ba4722..403c8f85df 100644 --- a/packages/rrdom/src/diff.ts +++ b/packages/rrdom/src/diff.ts @@ -1,6 +1,6 @@ import { Mirror as NodeMirror, - NodeType as RRNodeType, + NodeType as NodeType_2, type elementNode, } from '@amplitude/rrweb-snapshot'; import type { @@ -148,7 +148,7 @@ function diffBeforeUpdatingChildren( oldTree = calibratedOldTree; } switch (newTree.RRNodeType) { - case RRNodeType.Document: { + case NodeType_2.Document: { /** * Special cases for updating the document node: * Case 1: If the oldTree is the content document of an iframe element and its content (HTML, HEAD, and BODY) is automatically mounted by browsers, we need to remove them to avoid unexpected behaviors. e.g. Selector matches may be case insensitive. @@ -166,7 +166,7 @@ function diffBeforeUpdatingChildren( } break; } - case RRNodeType.Element: { + case NodeType_2.Element: { const oldElement = oldTree as HTMLElement; const newRRElement = newTree as IRRElement; switch (newRRElement.tagName) { @@ -219,12 +219,12 @@ function diffAfterUpdatingChildren( replayer: ReplayerHandler, ) { switch (newTree.RRNodeType) { - case RRNodeType.Document: { + case NodeType_2.Document: { const scrollData = (newTree as RRDocument).scrollData; scrollData && replayer.applyScroll(scrollData, true); break; } - case RRNodeType.Element: { + case NodeType_2.Element: { const oldElement = oldTree as HTMLElement; const newRRElement = newTree as RRElement; newRRElement.scrollData && @@ -312,9 +312,9 @@ function diffAfterUpdatingChildren( } break; } - case RRNodeType.Text: - case RRNodeType.Comment: - case RRNodeType.CDATA: { + case NodeType_2.Text: + case NodeType_2.Comment: + case NodeType_2.CDATA: { if ( oldTree.textContent !== (newTree as IRRText | IRRComment | IRRCDATASection).data @@ -536,17 +536,17 @@ export function createOrGetNode( if (nodeId > -1) node = domMirror.getNode(nodeId); if (node !== null && sameNodeType(node, rrNode)) return node; switch (rrNode.RRNodeType) { - case RRNodeType.Document: + case NodeType_2.Document: node = new Document(); break; - case RRNodeType.DocumentType: + case NodeType_2.DocumentType: node = document.implementation.createDocumentType( (rrNode as IRRDocumentType).name, (rrNode as IRRDocumentType).publicId, (rrNode as IRRDocumentType).systemId, ); break; - case RRNodeType.Element: { + case NodeType_2.Element: { let tagName = (rrNode as IRRElement).tagName.toLowerCase(); tagName = SVGTagMap[tagName] || tagName; if (sn && 'isSVG' in sn && sn?.isSVG) { @@ -554,13 +554,13 @@ export function createOrGetNode( } else node = document.createElement((rrNode as IRRElement).tagName); break; } - case RRNodeType.Text: + case NodeType_2.Text: node = document.createTextNode((rrNode as IRRText).data); break; - case RRNodeType.Comment: + case NodeType_2.Comment: node = document.createComment((rrNode as IRRComment).data); break; - case RRNodeType.CDATA: + case NodeType_2.CDATA: node = document.createCDATASection((rrNode as IRRCDATASection).data); break; } diff --git a/packages/rrdom/src/document.ts b/packages/rrdom/src/document.ts index 79ad0319f1..a959daa197 100644 --- a/packages/rrdom/src/document.ts +++ b/packages/rrdom/src/document.ts @@ -1,4 +1,4 @@ -import { NodeType as RRNodeType } from '@amplitude/rrweb-snapshot'; +import { NodeType as NodeType_2 } from '@amplitude/rrweb-snapshot'; import { camelize, parseCSSText, toCSSText } from './style'; export interface IRRNode { parentElement: IRRNode | null; @@ -10,7 +10,7 @@ export interface IRRNode { // corresponding nodeType value of standard HTML Node readonly nodeType: number; readonly nodeName: string; // https://dom.spec.whatwg.org/#dom-node-nodename - readonly RRNodeType: RRNodeType; + readonly RRNodeType: NodeType_2; firstChild: IRRNode | null; @@ -140,7 +140,7 @@ export abstract class BaseRRNode implements IRRNode { // corresponding nodeType value of standard HTML Node public readonly nodeType!: number; public readonly nodeName!: string; - public readonly RRNodeType!: RRNodeType; + public readonly RRNodeType!: NodeType_2; // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any constructor(..._args: any[]) { @@ -199,7 +199,7 @@ export class BaseRRDocument extends BaseRRNode implements IRRDocument { public readonly nodeType: number = NodeType.DOCUMENT_NODE; public readonly nodeName = '#document' as const; public readonly compatMode: 'BackCompat' | 'CSS1Compat' = 'CSS1Compat'; - public readonly RRNodeType = RRNodeType.Document; + public readonly RRNodeType = NodeType_2.Document; public textContent: string | null = null; // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -212,7 +212,7 @@ export class BaseRRDocument extends BaseRRNode implements IRRDocument { return ( (this.childNodes.find( (node) => - node.RRNodeType === RRNodeType.Element && + node.RRNodeType === NodeType_2.Element && (node as IRRElement).tagName === 'HTML', ) as IRRElement) || null ); @@ -222,7 +222,7 @@ export class BaseRRDocument extends BaseRRNode implements IRRDocument { return ( (this.documentElement?.childNodes.find( (node) => - node.RRNodeType === RRNodeType.Element && + node.RRNodeType === NodeType_2.Element && (node as IRRElement).tagName === 'BODY', ) as IRRElement) || null ); @@ -232,7 +232,7 @@ export class BaseRRDocument extends BaseRRNode implements IRRDocument { return ( (this.documentElement?.childNodes.find( (node) => - node.RRNodeType === RRNodeType.Element && + node.RRNodeType === NodeType_2.Element && (node as IRRElement).tagName === 'HEAD', ) as IRRElement) || null ); @@ -249,13 +249,13 @@ export class BaseRRDocument extends BaseRRNode implements IRRDocument { public appendChild(newChild: IRRNode): IRRNode { const nodeType = newChild.RRNodeType; if ( - nodeType === RRNodeType.Element || - nodeType === RRNodeType.DocumentType + nodeType === NodeType_2.Element || + nodeType === NodeType_2.DocumentType ) { if (this.childNodes.some((s) => s.RRNodeType === nodeType)) { throw new Error( `RRDomException: Failed to execute 'appendChild' on 'RRNode': Only one ${ - nodeType === RRNodeType.Element ? 'RRElement' : 'RRDoctype' + nodeType === NodeType_2.Element ? 'RRElement' : 'RRDoctype' } on RRDocument allowed.`, ); } @@ -269,13 +269,13 @@ export class BaseRRDocument extends BaseRRNode implements IRRDocument { public insertBefore(newChild: IRRNode, refChild: IRRNode | null): IRRNode { const nodeType = newChild.RRNodeType; if ( - nodeType === RRNodeType.Element || - nodeType === RRNodeType.DocumentType + nodeType === NodeType_2.Element || + nodeType === NodeType_2.DocumentType ) { if (this.childNodes.some((s) => s.RRNodeType === nodeType)) { throw new Error( `RRDomException: Failed to execute 'insertBefore' on 'RRNode': Only one ${ - nodeType === RRNodeType.Element ? 'RRElement' : 'RRDoctype' + nodeType === NodeType_2.Element ? 'RRElement' : 'RRDoctype' } on RRDocument allowed.`, ); } @@ -380,7 +380,7 @@ export class BaseRRDocument extends BaseRRNode implements IRRDocument { export class BaseRRDocumentType extends BaseRRNode implements IRRDocumentType { public readonly nodeType: number = NodeType.DOCUMENT_TYPE_NODE; - public readonly RRNodeType = RRNodeType.DocumentType; + public readonly RRNodeType = NodeType_2.DocumentType; declare readonly nodeName: string; public readonly name: string; public readonly publicId: string; @@ -402,7 +402,7 @@ export class BaseRRDocumentType extends BaseRRNode implements IRRDocumentType { export class BaseRRElement extends BaseRRNode implements IRRElement { public readonly nodeType: number = NodeType.ELEMENT_NODE; - public readonly RRNodeType = RRNodeType.Element; + public readonly RRNodeType = NodeType_2.Element; declare readonly nodeName: string; public tagName: string; public attributes: Record = {}; @@ -575,7 +575,7 @@ export class BaseRRDialogElement extends BaseRRElement { export class BaseRRText extends BaseRRNode implements IRRText { public readonly nodeType: number = NodeType.TEXT_NODE; public readonly nodeName = '#text' as const; - public readonly RRNodeType = RRNodeType.Text; + public readonly RRNodeType = NodeType_2.Text; public data: string; constructor(data: string) { @@ -599,7 +599,7 @@ export class BaseRRText extends BaseRRNode implements IRRText { export class BaseRRComment extends BaseRRNode implements IRRComment { public readonly nodeType: number = NodeType.COMMENT_NODE; public readonly nodeName = '#comment' as const; - public readonly RRNodeType = RRNodeType.Comment; + public readonly RRNodeType = NodeType_2.Comment; public data: string; constructor(data: string) { @@ -623,7 +623,7 @@ export class BaseRRComment extends BaseRRNode implements IRRComment { export class BaseRRCDATASection extends BaseRRNode implements IRRCDATASection { public readonly nodeName = '#cdata-section' as const; public readonly nodeType: number = NodeType.CDATA_SECTION_NODE; - public readonly RRNodeType = RRNodeType.CDATA; + public readonly RRNodeType = NodeType_2.CDATA; public data: string; constructor(data: string) { diff --git a/packages/rrdom/src/index.ts b/packages/rrdom/src/index.ts index ad07c158d2..81f04153d5 100644 --- a/packages/rrdom/src/index.ts +++ b/packages/rrdom/src/index.ts @@ -4,7 +4,7 @@ import type { serializedNodeWithId, } from '@amplitude/rrweb-snapshot'; import { - NodeType as RRNodeType, + NodeType as NodeType_2, createMirror as createNodeMirror, } from '@amplitude/rrweb-snapshot'; import type { @@ -415,13 +415,13 @@ export class Mirror implements IMirror { */ export function getDefaultSN(node: IRRNode, id: number): serializedNodeWithId { switch (node.RRNodeType) { - case RRNodeType.Document: + case NodeType_2.Document: return { id, type: node.RRNodeType, childNodes: [], }; - case RRNodeType.DocumentType: { + case NodeType_2.DocumentType: { const doctype = node as IRRDocumentType; return { id, @@ -431,7 +431,7 @@ export function getDefaultSN(node: IRRNode, id: number): serializedNodeWithId { systemId: doctype.systemId, }; } - case RRNodeType.Element: + case NodeType_2.Element: return { id, type: node.RRNodeType, @@ -439,19 +439,19 @@ export function getDefaultSN(node: IRRNode, id: number): serializedNodeWithId { attributes: {}, childNodes: [], }; - case RRNodeType.Text: + case NodeType_2.Text: return { id, type: node.RRNodeType, textContent: (node as IRRText).textContent || '', }; - case RRNodeType.Comment: + case NodeType_2.Comment: return { id, type: node.RRNodeType, textContent: (node as IRRComment).textContent || '', }; - case RRNodeType.CDATA: + case NodeType_2.CDATA: return { id, type: node.RRNodeType, @@ -471,7 +471,7 @@ export function printRRDom(rootNode: IRRNode, mirror: IMirror) { } function walk(node: IRRNode, mirror: IMirror, blankSpace: string) { let printText = `${blankSpace}${mirror.getId(node)} ${node.toString()}\n`; - if (node.RRNodeType === RRNodeType.Element) { + if (node.RRNodeType === NodeType_2.Element) { const element = node as IRRElement; if (element.shadowRoot) printText += walk(element.shadowRoot, mirror, blankSpace + ' '); diff --git a/packages/rrweb/src/record/index.ts b/packages/rrweb/src/record/index.ts index d0f4919004..54c34e4674 100644 --- a/packages/rrweb/src/record/index.ts +++ b/packages/rrweb/src/record/index.ts @@ -62,7 +62,7 @@ try { } const mirror = createMirror(); -function record( +export function record( options: recordOptions = {}, ): listenerHandler | undefined { const { diff --git a/packages/rrweb/src/replay/canvas/webgl.ts b/packages/rrweb/src/replay/canvas/webgl.ts index 2c452f5e86..9bec1f2fb6 100644 --- a/packages/rrweb/src/replay/canvas/webgl.ts +++ b/packages/rrweb/src/replay/canvas/webgl.ts @@ -1,4 +1,7 @@ -import { CanvasContext, type canvasMutationCommand } from '@amplitude/rrweb-types'; +import { + CanvasContext, + type canvasMutationCommand, +} from '@amplitude/rrweb-types'; import type { Replayer } from '../'; import { deserializeArg, variableListFor } from './deserialize-args'; diff --git a/packages/rrweb/src/utils.ts b/packages/rrweb/src/utils.ts index e1506ba934..15a0f414f8 100644 --- a/packages/rrweb/src/utils.ts +++ b/packages/rrweb/src/utils.ts @@ -1,5 +1,9 @@ import { RRNode, RRIFrameElement, BaseRRNode } from '@amplitude/rrdom'; -import type { IMirror, Mirror, SlimDOMOptions } from '@amplitude/rrweb-snapshot'; +import type { + IMirror, + Mirror, + SlimDOMOptions, +} from '@amplitude/rrweb-snapshot'; import { IGNORED_NODE, classMatchesRegex, diff --git a/packages/rrweb/test/replay/hover.test.ts b/packages/rrweb/test/replay/hover.test.ts index b62e1e7af2..0113ad663c 100644 --- a/packages/rrweb/test/replay/hover.test.ts +++ b/packages/rrweb/test/replay/hover.test.ts @@ -72,4 +72,4 @@ describe('replayer', function () { }); }); }); -}); \ No newline at end of file +}); diff --git a/packages/rrweb/test/replay/video.test.ts b/packages/rrweb/test/replay/video.test.ts index 942d61883f..b23996f350 100644 --- a/packages/rrweb/test/replay/video.test.ts +++ b/packages/rrweb/test/replay/video.test.ts @@ -262,4 +262,4 @@ describe('video', () => { `); expect(time).toBe(8); }); -}); \ No newline at end of file +}); diff --git a/packages/rrweb/test/rrdom.test.ts b/packages/rrweb/test/rrdom.test.ts index db22d46c40..08a57eb6cb 100644 --- a/packages/rrweb/test/rrdom.test.ts +++ b/packages/rrweb/test/rrdom.test.ts @@ -3,7 +3,10 @@ */ import { EventType, IncrementalSource, Replayer, eventWithTime } from '../src'; import { vi, type MockInstance } from 'vitest'; -import type { styleDeclarationData, styleSheetRuleData } from '@amplitude/rrweb-types'; +import type { + styleDeclarationData, + styleSheetRuleData, +} from '@amplitude/rrweb-types'; import { createMirror, Mirror as NodeMirror } from '@amplitude/rrweb-snapshot'; import type { ReplayerHandler } from '@amplitude/rrdom';