Skip to content

Commit d6e8288

Browse files
eoghanmurraygithub-actions[bot]
authored andcommitted
Apply formatting changes
1 parent 06d0dbe commit d6e8288

File tree

7 files changed

+83
-62
lines changed

7 files changed

+83
-62
lines changed

packages/record/src/index.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import { record, getWindowScroll, getWindowHeight, getWindowWidth } from 'rrweb';
2-
31
import {
4-
EventType,
5-
IncrementalSource,
6-
MouseInteractions,
7-
} from '@rrweb/types';
2+
record,
3+
getWindowScroll,
4+
getWindowHeight,
5+
getWindowWidth,
6+
} from 'rrweb';
87

8+
import { EventType, IncrementalSource, MouseInteractions } from '@rrweb/types';
99

10-
export {
10+
export {
1111
EventType,
1212
IncrementalSource,
1313
MouseInteractions,

packages/replay/src/index.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@ import {
66
} from 'rrweb';
77
import 'rrweb/dist/style.css';
88

9-
import {
10-
EventType,
11-
IncrementalSource,
12-
MouseInteractions,
13-
} from '@rrweb/types';
9+
import { EventType, IncrementalSource, MouseInteractions } from '@rrweb/types';
1410

1511
export {
1612
Replayer,

packages/rrweb-snapshot/test/utils.test.ts

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -366,34 +366,34 @@ describe('utils', () => {
366366
const picture = document.createElement('picture');
367367
const source = document.createElement('source');
368368
source.srcset = 'https://example.com/img1.png';
369-
369+
370370
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/source
371371
// "Not allowed if parent is a picture"
372372
source.src = 'https://example.com/img2.png';
373373

374374
const fallback_img = document.createElement('img');
375375
fallback_img.src = 'https://example.com/img3.png';
376-
376+
377377
picture.append(source);
378378
picture.append(fallback_img);
379-
379+
380380
expect(
381-
shouldCaptureAsset(source, 'srcset', source.srcset, { images: true }),
381+
shouldCaptureAsset(source, 'srcset', source.srcset, { images: true }),
382382
).toBe(true);
383383
expect(
384-
shouldCaptureAsset(source, 'src', source.srcset, { images: true }),
384+
shouldCaptureAsset(source, 'src', source.srcset, { images: true }),
385385
).toBe(false); // not allowed
386386
expect(
387387
shouldCaptureAsset(fallback_img, 'src', source.src, { images: true }),
388388
).toBe(true);
389389

390390
expect(
391-
shouldCaptureAsset(source, 'srcset', source.srcset, { images: false }),
391+
shouldCaptureAsset(source, 'srcset', source.srcset, { images: false }),
392392
).toBe(false);
393393
expect(
394394
shouldCaptureAsset(fallback_img, 'src', source.src, { images: false }),
395-
).toBe(false);
396-
});
395+
).toBe(false);
396+
});
397397

398398
it(`should correctly identify <source> child of a <video> element as capturable if captureAssets.video is true`, () => {
399399
const video = document.createElement('video');
@@ -403,19 +403,19 @@ describe('utils', () => {
403403
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/source
404404
// "Not allowed if parent is a audio or video"
405405
source.srcset = 'https://example.com/show2.mov';
406-
406+
407407
video.append(source);
408-
408+
409409
expect(
410-
shouldCaptureAsset(source, 'src', source.src, { video: true }),
410+
shouldCaptureAsset(source, 'src', source.src, { video: true }),
411411
).toBe(true);
412412
expect(
413-
shouldCaptureAsset(source, 'srcset', source.srcset, { video: true }),
414-
).toBe(false); // not allowed
415-
413+
shouldCaptureAsset(source, 'srcset', source.srcset, { video: true }),
414+
).toBe(false); // not allowed
415+
416416
expect(
417-
shouldCaptureAsset(source, 'src', source.src, { video: false }),
418-
).toBe(false); // false because of lack of origins
417+
shouldCaptureAsset(source, 'src', source.src, { video: false }),
418+
).toBe(false); // false because of lack of origins
419419
});
420420

421421
it(`should correctly identify <source> child of a <audio> element as capturable if captureAssets.audio is true`, () => {
@@ -426,21 +426,21 @@ describe('utils', () => {
426426
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/source
427427
// "Not allowed if parent is a audio or video"
428428
source.srcset = 'https://example.com/recording2.mp3';
429-
429+
430430
audio.append(source);
431-
431+
432432
expect(
433-
shouldCaptureAsset(source, 'src', source.src, { audio: true }),
433+
shouldCaptureAsset(source, 'src', source.src, { audio: true }),
434434
).toBe(true);
435435
expect(
436-
shouldCaptureAsset(source, 'srcset', source.srcset, { audio: true }),
437-
).toBe(false); // not allowed
438-
436+
shouldCaptureAsset(source, 'srcset', source.srcset, { audio: true }),
437+
).toBe(false); // not allowed
438+
439439
expect(
440-
shouldCaptureAsset(source, 'src', source.src, { audio: false }),
440+
shouldCaptureAsset(source, 'src', source.src, { audio: false }),
441441
).toBe(false);
442442
});
443-
443+
444444
it(`should correctly identify <link href rel="stylesheet"> as capturable if inlineStylesheet == 'all'`, () => {
445445
const element = document.createElement('link');
446446
element.setAttribute('rel', 'StyleSheet');

packages/rrweb/src/record/observer.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,10 @@ function initMouseInteractionObserver({
482482
}
483483
if (!significantEl) {
484484
significantEl = htarget;
485-
} else if (htarget !== significantEl && htarget.contains(significantEl)) {
485+
} else if (
486+
htarget !== significantEl &&
487+
htarget.contains(significantEl)
488+
) {
486489
emissionEvent = {
487490
...emissionEvent,
488491
sigTargetInternal: true,

packages/rrweb/src/replay/index.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1909,22 +1909,35 @@ export class Replayer {
19091909
attributeName.substring('rr_captured_'.length),
19101910
value,
19111911
);
1912-
} else if (attributeName === 'rr_onErrorSrc' || attributeName === 'rr_onErrorSrcset') {
1912+
} else if (
1913+
attributeName === 'rr_onErrorSrc' ||
1914+
attributeName === 'rr_onErrorSrcset'
1915+
) {
19131916
// pass
19141917
} else {
1915-
if (targetEl.tagName === 'IMG' && attributeName === 'src' && mutation.attributes['rr_onErrorSrc']) {
1918+
if (
1919+
targetEl.tagName === 'IMG' &&
1920+
attributeName === 'src' &&
1921+
mutation.attributes['rr_onErrorSrc']
1922+
) {
19161923
// set onerror before setting src
1917-
const rr_onErrorSrc = mutation.attributes['rr_onErrorSrc'] as string;
1924+
const rr_onErrorSrc = mutation.attributes[
1925+
'rr_onErrorSrc'
1926+
] as string;
19181927
let rr_onErrorSrcset: string | false = false;
19191928
if (mutation.attributes['rr_onErrorSrcset']) {
1920-
rr_onErrorSrcset = mutation.attributes['rr_onErrorSrcset'] as string;
1929+
rr_onErrorSrcset = mutation.attributes[
1930+
'rr_onErrorSrcset'
1931+
] as string;
19211932
}
19221933
const img = targetEl as HTMLImageElement;
19231934
const cacheValue = errorSrcCache.get(value);
19241935
if (cacheValue) {
19251936
value = cacheValue;
19261937
if (mutation.attributes['srcset']) {
1927-
const srcsetCache = errorSrcCache.get(mutation.attributes['srcset'] as string);
1938+
const srcsetCache = errorSrcCache.get(
1939+
mutation.attributes['srcset'] as string,
1940+
);
19281941
if (srcsetCache) {
19291942
img.srcset = srcsetCache;
19301943
}

packages/rrweb/test/record/mutation.test.ts

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ describe('mutation', () => {
132132
});
133133

134134
it('add root first', async () => {
135-
await setup('mutation.html');
135+
await setup('mutation.html');
136136
await page.evaluate(() => {
137137
const d1 = document.createElement('div');
138138
d1.id = 'd1';
@@ -279,7 +279,7 @@ describe('mutation', () => {
279279

280280
it('siblings added in idleCallback', async () => {
281281
await setup('mutation.html');
282-
await page.evaluate(() => {
282+
await page.evaluate(() => {
283283
document.body.childNodes.forEach((cn) => document.body.removeChild(cn)); // clear out text nodes created by server
284284
document.body.prepend(document.createElement('div'));
285285
requestAnimationFrame(() => {
@@ -294,16 +294,16 @@ describe('mutation', () => {
294294
);
295295
await assertSnapshot(mutations, true);
296296
});
297-
297+
298298
it('ignored firstchild comment already there', async () => {
299299
await setup('mutation-already-there.html');
300300
await page.evaluate(() => {
301301
const siblingDiv = document.createElement('div');
302302
document.getElementById('with-comment').append(siblingDiv);
303303
});
304304
await waitForRAF(page);
305-
const mutations = events.filter(
306-
(e) => [EventType.IncrementalSnapshot, EventType.FullSnapshot].includes(e.type),
305+
const mutations = events.filter((e) =>
306+
[EventType.IncrementalSnapshot, EventType.FullSnapshot].includes(e.type),
307307
);
308308
await assertSnapshot(mutations, true);
309309
});
@@ -313,12 +313,14 @@ describe('mutation', () => {
313313
await page.evaluate(() => {
314314
const siblingDiv = document.createElement('div');
315315
const siblingDiv2 = document.createElement('div');
316-
document.getElementById('with-comment').insertAdjacentElement('afterbegin', siblingDiv);
316+
document
317+
.getElementById('with-comment')
318+
.insertAdjacentElement('afterbegin', siblingDiv);
317319
document.getElementById('with-comment').append(siblingDiv2);
318320
});
319321
await waitForRAF(page);
320-
const mutations = events.filter(
321-
(e) => [EventType.IncrementalSnapshot, EventType.FullSnapshot].includes(e.type)
322+
const mutations = events.filter((e) =>
323+
[EventType.IncrementalSnapshot, EventType.FullSnapshot].includes(e.type),
322324
);
323325
await assertSnapshot(mutations, true);
324326
});
@@ -327,11 +329,13 @@ describe('mutation', () => {
327329
await setup('mutation-already-there.html');
328330
await page.evaluate(() => {
329331
const siblingDiv = document.createElement('div');
330-
document.getElementById('with-comment').insertAdjacentElement('afterbegin', siblingDiv);
332+
document
333+
.getElementById('with-comment')
334+
.insertAdjacentElement('afterbegin', siblingDiv);
331335
});
332336
await waitForRAF(page);
333-
const mutations = events.filter(
334-
(e) => [EventType.IncrementalSnapshot, EventType.FullSnapshot].includes(e.type)
337+
const mutations = events.filter((e) =>
338+
[EventType.IncrementalSnapshot, EventType.FullSnapshot].includes(e.type),
335339
);
336340
await assertSnapshot(mutations, true);
337341
});
@@ -347,8 +351,8 @@ describe('mutation', () => {
347351
d1.append(siblingDiv);
348352
});
349353
await waitForRAF(page);
350-
const mutations = events.filter(
351-
(e) => [EventType.IncrementalSnapshot, EventType.FullSnapshot].includes(e.type)
354+
const mutations = events.filter((e) =>
355+
[EventType.IncrementalSnapshot, EventType.FullSnapshot].includes(e.type),
352356
);
353357
await assertSnapshot(mutations, true);
354358
});
@@ -366,8 +370,8 @@ describe('mutation', () => {
366370
d1.append(siblingDiv2);
367371
});
368372
await waitForRAF(page);
369-
const mutations = events.filter(
370-
(e) => [EventType.IncrementalSnapshot, EventType.FullSnapshot].includes(e.type)
373+
const mutations = events.filter((e) =>
374+
[EventType.IncrementalSnapshot, EventType.FullSnapshot].includes(e.type),
371375
);
372376
await assertSnapshot(mutations, true);
373377
});
@@ -383,10 +387,9 @@ describe('mutation', () => {
383387
d1.insertAdjacentElement('afterbegin', siblingDiv);
384388
});
385389
await waitForRAF(page);
386-
const mutations = events.filter(
387-
(e) => [EventType.IncrementalSnapshot, EventType.FullSnapshot].includes(e.type)
390+
const mutations = events.filter((e) =>
391+
[EventType.IncrementalSnapshot, EventType.FullSnapshot].includes(e.type),
388392
);
389393
await assertSnapshot(mutations, true);
390394
});
391-
392395
});

vite.config.default.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ function minifyAndUMDPlugin({
6161
isCss: false,
6262
outDir,
6363
});
64-
copyFileSync(outUmd, `${outputFilePath.replace('/dist/', '/umd/')}.js`);
64+
copyFileSync(
65+
outUmd,
66+
`${outputFilePath.replace('/dist/', '/umd/')}.js`,
67+
);
6568
const outUmdMin = `${outputFilePath}.umd.min.cjs`;
6669
await buildFile({
6770
name,
@@ -71,7 +74,10 @@ function minifyAndUMDPlugin({
7174
isCss: false,
7275
outDir,
7376
});
74-
copyFileSync(outUmdMin, `${outputFilePath.replace('/dist/', '/umd/')}.min.js`);
77+
copyFileSync(
78+
outUmdMin,
79+
`${outputFilePath.replace('/dist/', '/umd/')}.min.js`,
80+
);
7581
}
7682
}
7783
}

0 commit comments

Comments
 (0)