export const wrapEvent = function (type: T) { const orig = history[type]; return function (...args: Parameters) { const rv = orig.apply(history, args); const e = new CustomEvent(type, { detail: args, }); window.dispatchEvent(e); return rv; }; };