move browser related APIs into runtime

This commit is contained in:
Yanzhen Yu
2026-04-01 12:00:00 +08:00
parent 6010d62c60
commit 32c33f3ce8
3 changed files with 9 additions and 9 deletions

View File

@@ -314,12 +314,6 @@ function initViewportResizeObserver(
} }
const INPUT_TAGS = ['INPUT', 'TEXTAREA', 'SELECT']; const INPUT_TAGS = ['INPUT', 'TEXTAREA', 'SELECT'];
const HOOK_PROPERTIES: Array<[HTMLElement, string]> = [
[HTMLInputElement.prototype, 'value'],
[HTMLInputElement.prototype, 'checked'],
[HTMLSelectElement.prototype, 'value'],
[HTMLTextAreaElement.prototype, 'value'],
];
const lastInputValueMap: WeakMap<EventTarget, inputValue> = new WeakMap(); const lastInputValueMap: WeakMap<EventTarget, inputValue> = new WeakMap();
function initInputObserver( function initInputObserver(
cb: inputCallback, cb: inputCallback,
@@ -388,9 +382,15 @@ function initInputObserver(
HTMLInputElement.prototype, HTMLInputElement.prototype,
'value', 'value',
); );
const hookProperties: Array<[HTMLElement, string]> = [
[HTMLInputElement.prototype, 'value'],
[HTMLInputElement.prototype, 'checked'],
[HTMLSelectElement.prototype, 'value'],
[HTMLTextAreaElement.prototype, 'value'],
];
if (propertyDescriptor && propertyDescriptor.set) { if (propertyDescriptor && propertyDescriptor.set) {
handlers.push( handlers.push(
...HOOK_PROPERTIES.map(p => ...hookProperties.map(p =>
hookSetter<HTMLElement>(p[0], p[1], { hookSetter<HTMLElement>(p[0], p[1], {
set() { set() {
// mock to a normal event // mock to a normal event

View File

@@ -26,8 +26,6 @@ import './styles/style.css';
const SKIP_TIME_THRESHOLD = 10 * 1000; const SKIP_TIME_THRESHOLD = 10 * 1000;
const SKIP_TIME_INTERVAL = 5 * 1000; const SKIP_TIME_INTERVAL = 5 * 1000;
smoothscroll.polyfill();
// https://github.com/rollup/rollup/issues/1267#issuecomment-296395734 // https://github.com/rollup/rollup/issues/1267#issuecomment-296395734
// tslint:disable-next-line // tslint:disable-next-line
const mitt = (mittProxy as any).default || mittProxy; const mitt = (mittProxy as any).default || mittProxy;
@@ -75,6 +73,7 @@ export class Replayer {
this.config = Object.assign({}, defaultConfig, config); this.config = Object.assign({}, defaultConfig, config);
this.timer = new Timer(this.config); this.timer = new Timer(this.config);
smoothscroll.polyfill();
this.setupDom(); this.setupDom();
this.emitter.on('resize', this.handleResize as mitt.Handler); this.emitter.on('resize', this.handleResize as mitt.Handler);
} }

View File

@@ -267,4 +267,5 @@ export enum ReplayerEvents {
LoadStylesheetEnd = 'load-stylesheet-end', LoadStylesheetEnd = 'load-stylesheet-end',
SkipStart = 'skip-start', SkipStart = 'skip-start',
SkipEnd = 'skip-end', SkipEnd = 'skip-end',
MouseInteraction = 'mouse-interaction',
} }