@appsurify-testmap/rrweb-utils 2.1.0-alpha.7 → 2.1.1-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.cts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/rrweb-utils.cjs +40 -1
- package/dist/rrweb-utils.cjs.map +1 -1
- package/dist/rrweb-utils.js +40 -1
- package/dist/rrweb-utils.js.map +1 -1
- package/dist/rrweb-utils.umd.cjs +41 -1
- package/dist/rrweb-utils.umd.cjs.map +3 -3
- package/dist/rrweb-utils.umd.min.cjs +1 -1
- package/dist/rrweb-utils.umd.min.cjs.map +3 -3
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -23,9 +23,18 @@ declare const _default: {
|
|
|
23
23
|
querySelectorAll: typeof querySelectorAll;
|
|
24
24
|
mutationObserver: typeof mutationObserverCtor;
|
|
25
25
|
patch: typeof patch;
|
|
26
|
+
describeNode: typeof describeNode;
|
|
27
|
+
getElementVisibility: typeof getElementVisibility;
|
|
26
28
|
};
|
|
27
29
|
export default _default;
|
|
28
30
|
|
|
31
|
+
export declare function describeNode(el: Element): string;
|
|
32
|
+
|
|
33
|
+
export declare function getElementVisibility(el: Element): {
|
|
34
|
+
isVisible: boolean;
|
|
35
|
+
ratio: number;
|
|
36
|
+
};
|
|
37
|
+
|
|
29
38
|
export declare function getRootNode(n: Node): Node;
|
|
30
39
|
|
|
31
40
|
export declare function getUntaintedAccessor<K extends keyof BasePrototypeCache, T extends keyof BasePrototypeCache[K]>(key: K, instance: BasePrototypeCache[K], accessor: T): BasePrototypeCache[K][T];
|
package/dist/index.d.ts
CHANGED
|
@@ -23,9 +23,18 @@ declare const _default: {
|
|
|
23
23
|
querySelectorAll: typeof querySelectorAll;
|
|
24
24
|
mutationObserver: typeof mutationObserverCtor;
|
|
25
25
|
patch: typeof patch;
|
|
26
|
+
describeNode: typeof describeNode;
|
|
27
|
+
getElementVisibility: typeof getElementVisibility;
|
|
26
28
|
};
|
|
27
29
|
export default _default;
|
|
28
30
|
|
|
31
|
+
export declare function describeNode(el: Element): string;
|
|
32
|
+
|
|
33
|
+
export declare function getElementVisibility(el: Element): {
|
|
34
|
+
isVisible: boolean;
|
|
35
|
+
ratio: number;
|
|
36
|
+
};
|
|
37
|
+
|
|
29
38
|
export declare function getRootNode(n: Node): Node;
|
|
30
39
|
|
|
31
40
|
export declare function getUntaintedAccessor<K extends keyof BasePrototypeCache, T extends keyof BasePrototypeCache[K]>(key: K, instance: BasePrototypeCache[K], accessor: T): BasePrototypeCache[K][T];
|
package/dist/rrweb-utils.cjs
CHANGED
|
@@ -154,6 +154,41 @@ function patch(source, name, replacement) {
|
|
|
154
154
|
};
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
|
+
function describeNode(el) {
|
|
158
|
+
const tag = el.tagName.toLowerCase();
|
|
159
|
+
const id = el.id ? `#${el.id}` : "";
|
|
160
|
+
const classes = el.classList.length ? "." + Array.from(el.classList).join(".") : "";
|
|
161
|
+
return `${tag}${id}${classes}`;
|
|
162
|
+
}
|
|
163
|
+
function getElementVisibility(el) {
|
|
164
|
+
var _a, _b;
|
|
165
|
+
const win = ((_a = el.ownerDocument) == null ? void 0 : _a.defaultView) ?? window;
|
|
166
|
+
const rect = el.getBoundingClientRect();
|
|
167
|
+
const viewportWidth = win.innerWidth || win.document.documentElement.clientWidth || 0;
|
|
168
|
+
const viewportHeight = win.innerHeight || win.document.documentElement.clientHeight || 0;
|
|
169
|
+
const isRectVisible = rect.width > 0 && rect.height > 0 && rect.bottom > 0 && rect.right > 0 && rect.top < viewportHeight && rect.left < viewportWidth;
|
|
170
|
+
const style = (_b = win.getComputedStyle) == null ? void 0 : _b.call(win, el);
|
|
171
|
+
const isStyleVisible = !!style && style.display !== "none" && style.visibility !== "hidden" && (parseFloat(style.opacity) || 0) > 0;
|
|
172
|
+
const isVisible = isStyleVisible && isRectVisible;
|
|
173
|
+
let ratio = 0;
|
|
174
|
+
if (isVisible) {
|
|
175
|
+
const xOverlap = Math.max(
|
|
176
|
+
0,
|
|
177
|
+
Math.min(rect.right, viewportWidth) - Math.max(rect.left, 0)
|
|
178
|
+
);
|
|
179
|
+
const yOverlap = Math.max(
|
|
180
|
+
0,
|
|
181
|
+
Math.min(rect.bottom, viewportHeight) - Math.max(rect.top, 0)
|
|
182
|
+
);
|
|
183
|
+
const intersectionArea = xOverlap * yOverlap;
|
|
184
|
+
const elementArea = rect.width * rect.height;
|
|
185
|
+
ratio = elementArea > 0 ? intersectionArea / elementArea : 0;
|
|
186
|
+
}
|
|
187
|
+
return {
|
|
188
|
+
isVisible,
|
|
189
|
+
ratio
|
|
190
|
+
};
|
|
191
|
+
}
|
|
157
192
|
const index = {
|
|
158
193
|
childNodes,
|
|
159
194
|
parentNode,
|
|
@@ -167,11 +202,15 @@ const index = {
|
|
|
167
202
|
querySelector,
|
|
168
203
|
querySelectorAll,
|
|
169
204
|
mutationObserver: mutationObserverCtor,
|
|
170
|
-
patch
|
|
205
|
+
patch,
|
|
206
|
+
describeNode,
|
|
207
|
+
getElementVisibility
|
|
171
208
|
};
|
|
172
209
|
exports.childNodes = childNodes;
|
|
173
210
|
exports.contains = contains;
|
|
174
211
|
exports.default = index;
|
|
212
|
+
exports.describeNode = describeNode;
|
|
213
|
+
exports.getElementVisibility = getElementVisibility;
|
|
175
214
|
exports.getRootNode = getRootNode;
|
|
176
215
|
exports.getUntaintedAccessor = getUntaintedAccessor;
|
|
177
216
|
exports.getUntaintedMethod = getUntaintedMethod;
|
package/dist/rrweb-utils.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rrweb-utils.cjs","sources":["../src/index.ts"],"sourcesContent":["type PrototypeOwner = Node | ShadowRoot | MutationObserver | Element;\ntype TypeofPrototypeOwner =\n | typeof Node\n | typeof ShadowRoot\n | typeof MutationObserver\n | typeof Element;\n\ntype BasePrototypeCache = {\n Node: typeof Node.prototype;\n ShadowRoot: typeof ShadowRoot.prototype;\n MutationObserver: typeof MutationObserver.prototype;\n Element: typeof Element.prototype;\n};\n\nconst testableAccessors = {\n Node: ['childNodes', 'parentNode', 'parentElement', 'textContent'] as const,\n ShadowRoot: ['host', 'styleSheets'] as const,\n Element: ['shadowRoot', 'querySelector', 'querySelectorAll'] as const,\n MutationObserver: [] as const,\n} as const;\n\nconst testableMethods = {\n Node: ['contains', 'getRootNode'] as const,\n ShadowRoot: ['getSelection'],\n Element: [],\n MutationObserver: ['constructor'],\n} as const;\n\nconst untaintedBasePrototype: Partial<BasePrototypeCache> = {};\n\n/*\n When angular patches things - particularly the MutationObserver -\n they pass the `isNativeFunction` check\n That then causes performance issues\n because Angular's change detection\n doesn't like sharing a mutation observer\n Checking for the presence of the Zone object\n on global is a good-enough proxy for Angular\n to cover most cases\n (you can configure zone.js to have a different name\n on the global object and should then manually run rrweb\n outside the Zone)\n */\nexport const isAngularZonePresent = (): boolean => {\n return !!(globalThis as { Zone?: unknown }).Zone;\n};\n\nexport function getUntaintedPrototype<T extends keyof BasePrototypeCache>(\n key: T,\n): BasePrototypeCache[T] {\n if (untaintedBasePrototype[key])\n return untaintedBasePrototype[key] as BasePrototypeCache[T];\n\n const defaultObj = globalThis[key] as TypeofPrototypeOwner;\n const defaultPrototype = defaultObj.prototype as BasePrototypeCache[T];\n\n // use list of testable accessors to check if the prototype is tainted\n const accessorNames =\n key in testableAccessors ? testableAccessors[key] : undefined;\n const isUntaintedAccessors = Boolean(\n accessorNames &&\n // @ts-expect-error 2345\n accessorNames.every((accessor: keyof typeof defaultPrototype) =>\n Boolean(\n Object.getOwnPropertyDescriptor(defaultPrototype, accessor)\n ?.get?.toString()\n .includes('[native code]'),\n ),\n ),\n );\n\n const methodNames = key in testableMethods ? testableMethods[key] : undefined;\n const isUntaintedMethods = Boolean(\n methodNames &&\n methodNames.every(\n // @ts-expect-error 2345\n (method: keyof typeof defaultPrototype) =>\n typeof defaultPrototype[method] === 'function' &&\n defaultPrototype[method]?.toString().includes('[native code]'),\n ),\n );\n\n if (isUntaintedAccessors && isUntaintedMethods && !isAngularZonePresent()) {\n untaintedBasePrototype[key] = defaultObj.prototype as BasePrototypeCache[T];\n return defaultObj.prototype as BasePrototypeCache[T];\n }\n\n try {\n const iframeEl = document.createElement('iframe');\n document.body.appendChild(iframeEl);\n const win = iframeEl.contentWindow;\n if (!win) return defaultObj.prototype as BasePrototypeCache[T];\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n const untaintedObject = (win as any)[key]\n .prototype as BasePrototypeCache[T];\n // cleanup\n document.body.removeChild(iframeEl);\n\n if (!untaintedObject) return defaultPrototype;\n\n return (untaintedBasePrototype[key] = untaintedObject);\n } catch {\n return defaultPrototype;\n }\n}\n\nconst untaintedAccessorCache: Record<\n string,\n (this: PrototypeOwner, ...args: unknown[]) => unknown\n> = {};\n\nexport function getUntaintedAccessor<\n K extends keyof BasePrototypeCache,\n T extends keyof BasePrototypeCache[K],\n>(\n key: K,\n instance: BasePrototypeCache[K],\n accessor: T,\n): BasePrototypeCache[K][T] {\n const cacheKey = `${key}.${String(accessor)}`;\n if (untaintedAccessorCache[cacheKey])\n return untaintedAccessorCache[cacheKey].call(\n instance,\n ) as BasePrototypeCache[K][T];\n\n const untaintedPrototype = getUntaintedPrototype(key);\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const untaintedAccessor = Object.getOwnPropertyDescriptor(\n untaintedPrototype,\n accessor,\n )?.get;\n\n if (!untaintedAccessor) return instance[accessor];\n\n untaintedAccessorCache[cacheKey] = untaintedAccessor;\n\n return untaintedAccessor.call(instance) as BasePrototypeCache[K][T];\n}\n\ntype BaseMethod<K extends keyof BasePrototypeCache> = (\n this: BasePrototypeCache[K],\n ...args: unknown[]\n) => unknown;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst untaintedMethodCache: Record<string, BaseMethod<any>> = {};\nexport function getUntaintedMethod<\n K extends keyof BasePrototypeCache,\n T extends keyof BasePrototypeCache[K],\n>(\n key: K,\n instance: BasePrototypeCache[K],\n method: T,\n): BasePrototypeCache[K][T] {\n const cacheKey = `${key}.${String(method)}`;\n if (untaintedMethodCache[cacheKey])\n return untaintedMethodCache[cacheKey].bind(\n instance,\n ) as BasePrototypeCache[K][T];\n\n const untaintedPrototype = getUntaintedPrototype(key);\n const untaintedMethod = untaintedPrototype[method];\n\n if (typeof untaintedMethod !== 'function') return instance[method];\n\n untaintedMethodCache[cacheKey] = untaintedMethod as BaseMethod<K>;\n\n return untaintedMethod.bind(instance) as BasePrototypeCache[K][T];\n}\n\nexport function childNodes(n: Node): NodeListOf<Node> {\n return getUntaintedAccessor('Node', n, 'childNodes');\n}\n\nexport function parentNode(n: Node): ParentNode | null {\n return getUntaintedAccessor('Node', n, 'parentNode');\n}\n\nexport function parentElement(n: Node): HTMLElement | null {\n return getUntaintedAccessor('Node', n, 'parentElement');\n}\n\nexport function textContent(n: Node): string | null {\n return getUntaintedAccessor('Node', n, 'textContent');\n}\n\nexport function contains(n: Node, other: Node): boolean {\n return getUntaintedMethod('Node', n, 'contains')(other);\n}\n\nexport function getRootNode(n: Node): Node {\n return getUntaintedMethod('Node', n, 'getRootNode')();\n}\n\nexport function host(n: ShadowRoot): Element | null {\n if (!n || !('host' in n)) return null;\n return getUntaintedAccessor('ShadowRoot', n, 'host');\n}\n\nexport function styleSheets(n: ShadowRoot): StyleSheetList {\n return n.styleSheets;\n}\n\nexport function shadowRoot(n: Node): ShadowRoot | null {\n if (!n || !('shadowRoot' in n)) return null;\n return getUntaintedAccessor('Element', n as Element, 'shadowRoot');\n}\n\nexport function querySelector(n: Element, selectors: string): Element | null {\n return getUntaintedAccessor('Element', n, 'querySelector')(selectors);\n}\n\nexport function querySelectorAll(\n n: Element,\n selectors: string,\n): NodeListOf<Element> {\n return getUntaintedAccessor('Element', n, 'querySelectorAll')(selectors);\n}\n\nexport function mutationObserverCtor(): (typeof MutationObserver)['prototype']['constructor'] {\n return getUntaintedPrototype('MutationObserver').constructor;\n}\n\n// copy from https://github.com/getsentry/sentry-javascript/blob/b2109071975af8bf0316d3b5b38f519bdaf5dc15/packages/utils/src/object.ts\nexport function patch(\n source: { [key: string]: any },\n name: string,\n replacement: (...args: unknown[]) => unknown,\n): () => void {\n try {\n if (!(name in source)) {\n return () => {\n //\n };\n }\n\n const original = source[name] as () => unknown;\n const wrapped = replacement(original);\n\n // Make sure it's a function first, as we need to attach an empty prototype for `defineProperties` to work\n // otherwise it'll throw \"TypeError: Object.defineProperties called on non-object\"\n if (typeof wrapped === 'function') {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n wrapped.prototype = wrapped.prototype || {};\n Object.defineProperties(wrapped, {\n __rrweb_original__: {\n enumerable: false,\n value: original,\n },\n });\n }\n\n source[name] = wrapped;\n\n return () => {\n source[name] = original;\n };\n } catch {\n return () => {\n //\n };\n // This can throw if multiple fill happens on a global object like XMLHttpRequest\n // Fixes https://github.com/getsentry/sentry-javascript/issues/2043\n }\n}\n\nexport default {\n childNodes,\n parentNode,\n parentElement,\n textContent,\n contains,\n getRootNode,\n host,\n styleSheets,\n shadowRoot,\n querySelector,\n querySelectorAll,\n mutationObserver: mutationObserverCtor,\n patch,\n};\n"],"names":[],"mappings":";;AAcA,MAAM,oBAAoB;AAAA,EACxB,MAAM,CAAC,cAAc,cAAc,iBAAiB,aAAa;AAAA,EACjE,YAAY,CAAC,QAAQ,aAAa;AAAA,EAClC,SAAS,CAAC,cAAc,iBAAiB,kBAAkB;AAAA,EAC3D,kBAAkB,CAAC;AACrB;AAEA,MAAM,kBAAkB;AAAA,EACtB,MAAM,CAAC,YAAY,aAAa;AAAA,EAChC,YAAY,CAAC,cAAc;AAAA,EAC3B,SAAS,CAAC;AAAA,EACV,kBAAkB,CAAC,aAAa;AAClC;AAEA,MAAM,yBAAsD,CAAA;AAerD,MAAM,uBAAuB,MAAe;AAC1C,SAAA,CAAC,CAAE,WAAkC;AAC9C;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AEO,SAAS,YAAY,GAA+B;AACzD,SAAO,EAAE;AACX;AAEO,SAAS,WAAW,GAA4B;AACrD,MAAI,CAAC,KAAK,EAAE,gBAAgB,GAAW,QAAA;AAChC,SAAA,qBAAqB,WAAW,GAAc,YAAY;AACnE;AAEgB,SAAA,cAAc,GAAY,WAAmC;AAC3E,SAAO,qBAAqB,WAAW,GAAG,eAAe,EAAE,SAAS;AACtE;AAEgB,SAAA,iBACd,GACA,WACqB;AACrB,SAAO,qBAAqB,WAAW,GAAG,kBAAkB,EAAE,SAAS;AACzE;AAEO,SAAS,uBAA8E;AACrF,SAAA,sBAAsB,kBAAkB,EAAE;AACnD;AAGgB,SAAA,MACd,QACA,MACA,aACY;AACR,MAAA;AACE,QAAA,EAAE,QAAQ,SAAS;AACrB,aAAO,MAAM;AAAA,MAAA;AAAA,IAGf;AAEM,UAAA,WAAW,OAAO,IAAI;AACtB,UAAA,UAAU,YAAY,QAAQ;AAIhC,QAAA,OAAO,YAAY,YAAY;AAEzB,cAAA,YAAY,QAAQ,aAAa,CAAA;AACzC,aAAO,iBAAiB,SAAS;AAAA,QAC/B,oBAAoB;AAAA,UAClB,YAAY;AAAA,UACZ,OAAO;AAAA,QACT;AAAA,MAAA,CACD;AAAA,IACH;AAEA,WAAO,IAAI,IAAI;AAEf,WAAO,MAAM;AACX,aAAO,IAAI,IAAI;AAAA,IAAA;AAAA,EACjB,QACM;AACN,WAAO,MAAM;AAAA,IAAA;AAAA,EAKf;AACF;AAEA,MAAe,QAAA;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,kBAAkB;AAAA,EAClB;AACF;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"rrweb-utils.cjs","sources":["../src/index.ts"],"sourcesContent":["type PrototypeOwner = Node | ShadowRoot | MutationObserver | Element;\ntype TypeofPrototypeOwner =\n | typeof Node\n | typeof ShadowRoot\n | typeof MutationObserver\n | typeof Element;\n\ntype BasePrototypeCache = {\n Node: typeof Node.prototype;\n ShadowRoot: typeof ShadowRoot.prototype;\n MutationObserver: typeof MutationObserver.prototype;\n Element: typeof Element.prototype;\n};\n\nconst testableAccessors = {\n Node: ['childNodes', 'parentNode', 'parentElement', 'textContent'] as const,\n ShadowRoot: ['host', 'styleSheets'] as const,\n Element: ['shadowRoot', 'querySelector', 'querySelectorAll'] as const,\n MutationObserver: [] as const,\n} as const;\n\nconst testableMethods = {\n Node: ['contains', 'getRootNode'] as const,\n ShadowRoot: ['getSelection'],\n Element: [],\n MutationObserver: ['constructor'],\n} as const;\n\nconst untaintedBasePrototype: Partial<BasePrototypeCache> = {};\n\n/*\n When angular patches things - particularly the MutationObserver -\n they pass the `isNativeFunction` check\n That then causes performance issues\n because Angular's change detection\n doesn't like sharing a mutation observer\n Checking for the presence of the Zone object\n on global is a good-enough proxy for Angular\n to cover most cases\n (you can configure zone.js to have a different name\n on the global object and should then manually run rrweb\n outside the Zone)\n */\nexport const isAngularZonePresent = (): boolean => {\n return !!(globalThis as { Zone?: unknown }).Zone;\n};\n\nexport function getUntaintedPrototype<T extends keyof BasePrototypeCache>(\n key: T,\n): BasePrototypeCache[T] {\n if (untaintedBasePrototype[key])\n return untaintedBasePrototype[key] as BasePrototypeCache[T];\n\n const defaultObj = globalThis[key] as TypeofPrototypeOwner;\n const defaultPrototype = defaultObj.prototype as BasePrototypeCache[T];\n\n // use list of testable accessors to check if the prototype is tainted\n const accessorNames =\n key in testableAccessors ? testableAccessors[key] : undefined;\n const isUntaintedAccessors = Boolean(\n accessorNames &&\n // @ts-expect-error 2345\n accessorNames.every((accessor: keyof typeof defaultPrototype) =>\n Boolean(\n Object.getOwnPropertyDescriptor(defaultPrototype, accessor)\n ?.get?.toString()\n .includes('[native code]'),\n ),\n ),\n );\n\n const methodNames = key in testableMethods ? testableMethods[key] : undefined;\n const isUntaintedMethods = Boolean(\n methodNames &&\n methodNames.every(\n // @ts-expect-error 2345\n (method: keyof typeof defaultPrototype) =>\n typeof defaultPrototype[method] === 'function' &&\n defaultPrototype[method]?.toString().includes('[native code]'),\n ),\n );\n\n if (isUntaintedAccessors && isUntaintedMethods && !isAngularZonePresent()) {\n untaintedBasePrototype[key] = defaultObj.prototype as BasePrototypeCache[T];\n return defaultObj.prototype as BasePrototypeCache[T];\n }\n\n try {\n const iframeEl = document.createElement('iframe');\n document.body.appendChild(iframeEl);\n const win = iframeEl.contentWindow;\n if (!win) return defaultObj.prototype as BasePrototypeCache[T];\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n const untaintedObject = (win as any)[key]\n .prototype as BasePrototypeCache[T];\n // cleanup\n document.body.removeChild(iframeEl);\n\n if (!untaintedObject) return defaultPrototype;\n\n return (untaintedBasePrototype[key] = untaintedObject);\n } catch {\n return defaultPrototype;\n }\n}\n\nconst untaintedAccessorCache: Record<\n string,\n (this: PrototypeOwner, ...args: unknown[]) => unknown\n> = {};\n\nexport function getUntaintedAccessor<\n K extends keyof BasePrototypeCache,\n T extends keyof BasePrototypeCache[K],\n>(\n key: K,\n instance: BasePrototypeCache[K],\n accessor: T,\n): BasePrototypeCache[K][T] {\n const cacheKey = `${key}.${String(accessor)}`;\n if (untaintedAccessorCache[cacheKey])\n return untaintedAccessorCache[cacheKey].call(\n instance,\n ) as BasePrototypeCache[K][T];\n\n const untaintedPrototype = getUntaintedPrototype(key);\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const untaintedAccessor = Object.getOwnPropertyDescriptor(\n untaintedPrototype,\n accessor,\n )?.get;\n\n if (!untaintedAccessor) return instance[accessor];\n\n untaintedAccessorCache[cacheKey] = untaintedAccessor;\n\n return untaintedAccessor.call(instance) as BasePrototypeCache[K][T];\n}\n\ntype BaseMethod<K extends keyof BasePrototypeCache> = (\n this: BasePrototypeCache[K],\n ...args: unknown[]\n) => unknown;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst untaintedMethodCache: Record<string, BaseMethod<any>> = {};\nexport function getUntaintedMethod<\n K extends keyof BasePrototypeCache,\n T extends keyof BasePrototypeCache[K],\n>(\n key: K,\n instance: BasePrototypeCache[K],\n method: T,\n): BasePrototypeCache[K][T] {\n const cacheKey = `${key}.${String(method)}`;\n if (untaintedMethodCache[cacheKey])\n return untaintedMethodCache[cacheKey].bind(\n instance,\n ) as BasePrototypeCache[K][T];\n\n const untaintedPrototype = getUntaintedPrototype(key);\n const untaintedMethod = untaintedPrototype[method];\n\n if (typeof untaintedMethod !== 'function') return instance[method];\n\n untaintedMethodCache[cacheKey] = untaintedMethod as BaseMethod<K>;\n\n return untaintedMethod.bind(instance) as BasePrototypeCache[K][T];\n}\n\nexport function childNodes(n: Node): NodeListOf<Node> {\n return getUntaintedAccessor('Node', n, 'childNodes');\n}\n\nexport function parentNode(n: Node): ParentNode | null {\n return getUntaintedAccessor('Node', n, 'parentNode');\n}\n\nexport function parentElement(n: Node): HTMLElement | null {\n return getUntaintedAccessor('Node', n, 'parentElement');\n}\n\nexport function textContent(n: Node): string | null {\n return getUntaintedAccessor('Node', n, 'textContent');\n}\n\nexport function contains(n: Node, other: Node): boolean {\n return getUntaintedMethod('Node', n, 'contains')(other);\n}\n\nexport function getRootNode(n: Node): Node {\n return getUntaintedMethod('Node', n, 'getRootNode')();\n}\n\nexport function host(n: ShadowRoot): Element | null {\n if (!n || !('host' in n)) return null;\n return getUntaintedAccessor('ShadowRoot', n, 'host');\n}\n\nexport function styleSheets(n: ShadowRoot): StyleSheetList {\n return n.styleSheets;\n}\n\nexport function shadowRoot(n: Node): ShadowRoot | null {\n if (!n || !('shadowRoot' in n)) return null;\n return getUntaintedAccessor('Element', n as Element, 'shadowRoot');\n}\n\nexport function querySelector(n: Element, selectors: string): Element | null {\n return getUntaintedAccessor('Element', n, 'querySelector')(selectors);\n}\n\nexport function querySelectorAll(\n n: Element,\n selectors: string,\n): NodeListOf<Element> {\n return getUntaintedAccessor('Element', n, 'querySelectorAll')(selectors);\n}\n\nexport function mutationObserverCtor(): (typeof MutationObserver)['prototype']['constructor'] {\n return getUntaintedPrototype('MutationObserver').constructor;\n}\n\n// copy from https://github.com/getsentry/sentry-javascript/blob/b2109071975af8bf0316d3b5b38f519bdaf5dc15/packages/utils/src/object.ts\nexport function patch(\n source: { [key: string]: any },\n name: string,\n replacement: (...args: unknown[]) => unknown,\n): () => void {\n try {\n if (!(name in source)) {\n return () => {\n //\n };\n }\n\n const original = source[name] as () => unknown;\n const wrapped = replacement(original);\n\n // Make sure it's a function first, as we need to attach an empty prototype for `defineProperties` to work\n // otherwise it'll throw \"TypeError: Object.defineProperties called on non-object\"\n if (typeof wrapped === 'function') {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n wrapped.prototype = wrapped.prototype || {};\n Object.defineProperties(wrapped, {\n __rrweb_original__: {\n enumerable: false,\n value: original,\n },\n });\n }\n\n source[name] = wrapped;\n\n return () => {\n source[name] = original;\n };\n } catch {\n return () => {\n //\n };\n // This can throw if multiple fill happens on a global object like XMLHttpRequest\n // Fixes https://github.com/getsentry/sentry-javascript/issues/2043\n }\n}\n\nexport function describeNode(el: Element): string {\n const tag = el.tagName.toLowerCase();\n const id = el.id ? `#${el.id}` : '';\n const classes = el.classList.length\n ? '.' + Array.from(el.classList).join('.')\n : '';\n return `${tag}${id}${classes}`;\n}\n\nexport function getElementVisibility(el: Element): {\n isVisible: boolean;\n ratio: number;\n} {\n const win = el.ownerDocument?.defaultView ?? window;\n const rect = el.getBoundingClientRect();\n\n const viewportWidth =\n win.innerWidth || win.document.documentElement.clientWidth || 0;\n const viewportHeight =\n win.innerHeight || win.document.documentElement.clientHeight || 0;\n\n const isRectVisible =\n rect.width > 0 &&\n rect.height > 0 &&\n rect.bottom > 0 &&\n rect.right > 0 &&\n rect.top < viewportHeight &&\n rect.left < viewportWidth;\n\n const style = win.getComputedStyle?.(el);\n const isStyleVisible =\n !!style &&\n style.display !== 'none' &&\n style.visibility !== 'hidden' &&\n (parseFloat(style.opacity) || 0) > 0;\n\n const isVisible = isStyleVisible && isRectVisible;\n\n let ratio = 0;\n if (isVisible) {\n const xOverlap = Math.max(\n 0,\n Math.min(rect.right, viewportWidth) - Math.max(rect.left, 0),\n );\n const yOverlap = Math.max(\n 0,\n Math.min(rect.bottom, viewportHeight) - Math.max(rect.top, 0),\n );\n const intersectionArea = xOverlap * yOverlap;\n const elementArea = rect.width * rect.height;\n ratio = elementArea > 0 ? intersectionArea / elementArea : 0;\n }\n\n return {\n isVisible,\n ratio,\n };\n}\n\nexport default {\n childNodes,\n parentNode,\n parentElement,\n textContent,\n contains,\n getRootNode,\n host,\n styleSheets,\n shadowRoot,\n querySelector,\n querySelectorAll,\n mutationObserver: mutationObserverCtor,\n patch,\n describeNode,\n getElementVisibility,\n};\n"],"names":[],"mappings":";;AAcA,MAAM,oBAAoB;AAAA,EACxB,MAAM,CAAC,cAAc,cAAc,iBAAiB,aAAa;AAAA,EACjE,YAAY,CAAC,QAAQ,aAAa;AAAA,EAClC,SAAS,CAAC,cAAc,iBAAiB,kBAAkB;AAAA,EAC3D,kBAAkB,CAAC;AACrB;AAEA,MAAM,kBAAkB;AAAA,EACtB,MAAM,CAAC,YAAY,aAAa;AAAA,EAChC,YAAY,CAAC,cAAc;AAAA,EAC3B,SAAS,CAAC;AAAA,EACV,kBAAkB,CAAC,aAAa;AAClC;AAEA,MAAM,yBAAsD,CAAA;AAerD,MAAM,uBAAuB,MAAe;AAC1C,SAAA,CAAC,CAAE,WAAkC;AAC9C;AAEO,SAAS,sBACd,KACuB;AACvB,MAAI,uBAAuB,GAAG;AAC5B,WAAO,uBAAuB,GAAG;AAE7B,QAAA,aAAa,WAAW,GAAG;AACjC,QAAM,mBAAmB,WAAW;AAGpC,QAAM,gBACJ,OAAO,oBAAoB,kBAAkB,GAAG,IAAI;AACtD,QAAM,uBAAuB;AAAA,IAC3B;AAAA,IA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ACd,KAAK,QAAQ,KACb,KAAK,MAAM,kBACX,KAAK,OAAO;AAER,QAAA,SAAQ,SAAI,qBAAJ,6BAAuB;AACrC,QAAM,iBACJ,CAAC,CAAC,SACF,MAAM,YAAY,UAClB,MAAM,eAAe,aACpB,WAAW,MAAM,OAAO,KAAK,KAAK;AAErC,QAAM,YAAY,kBAAkB;AAEpC,MAAI,QAAQ;AACZ,MAAI,WAAW;AACb,UAAM,WAAW,KAAK;AAAA,MACpB;AAAA,MACA,KAAK,IAAI,KAAK,OAAO,aAAa,IAAI,KAAK,IAAI,KAAK,MAAM,CAAC;AAAA,IAAA;AAE7D,UAAM,WAAW,KAAK;AAAA,MACpB;AAAA,MACA,KAAK,IAAI,KAAK,QAAQ,cAAc,IAAI,KAAK,IAAI,KAAK,KAAK,CAAC;AAAA,IAAA;AAE9D,UAAM,mBAAmB,WAAW;AAC9B,UAAA,cAAc,KAAK,QAAQ,KAAK;AAC9B,YAAA,cAAc,IAAI,mBAAmB,cAAc;AAAA,EAC7D;AAEO,SAAA;AAAA,IACL;AAAA,IACA;AAAA,EAAA;AAEJ;AAEA,MAAe,QAAA;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,kBAAkB;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AACF;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/rrweb-utils.js
CHANGED
|
@@ -152,6 +152,41 @@ function patch(source, name, replacement) {
|
|
|
152
152
|
};
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
|
+
function describeNode(el) {
|
|
156
|
+
const tag = el.tagName.toLowerCase();
|
|
157
|
+
const id = el.id ? `#${el.id}` : "";
|
|
158
|
+
const classes = el.classList.length ? "." + Array.from(el.classList).join(".") : "";
|
|
159
|
+
return `${tag}${id}${classes}`;
|
|
160
|
+
}
|
|
161
|
+
function getElementVisibility(el) {
|
|
162
|
+
var _a, _b;
|
|
163
|
+
const win = ((_a = el.ownerDocument) == null ? void 0 : _a.defaultView) ?? window;
|
|
164
|
+
const rect = el.getBoundingClientRect();
|
|
165
|
+
const viewportWidth = win.innerWidth || win.document.documentElement.clientWidth || 0;
|
|
166
|
+
const viewportHeight = win.innerHeight || win.document.documentElement.clientHeight || 0;
|
|
167
|
+
const isRectVisible = rect.width > 0 && rect.height > 0 && rect.bottom > 0 && rect.right > 0 && rect.top < viewportHeight && rect.left < viewportWidth;
|
|
168
|
+
const style = (_b = win.getComputedStyle) == null ? void 0 : _b.call(win, el);
|
|
169
|
+
const isStyleVisible = !!style && style.display !== "none" && style.visibility !== "hidden" && (parseFloat(style.opacity) || 0) > 0;
|
|
170
|
+
const isVisible = isStyleVisible && isRectVisible;
|
|
171
|
+
let ratio = 0;
|
|
172
|
+
if (isVisible) {
|
|
173
|
+
const xOverlap = Math.max(
|
|
174
|
+
0,
|
|
175
|
+
Math.min(rect.right, viewportWidth) - Math.max(rect.left, 0)
|
|
176
|
+
);
|
|
177
|
+
const yOverlap = Math.max(
|
|
178
|
+
0,
|
|
179
|
+
Math.min(rect.bottom, viewportHeight) - Math.max(rect.top, 0)
|
|
180
|
+
);
|
|
181
|
+
const intersectionArea = xOverlap * yOverlap;
|
|
182
|
+
const elementArea = rect.width * rect.height;
|
|
183
|
+
ratio = elementArea > 0 ? intersectionArea / elementArea : 0;
|
|
184
|
+
}
|
|
185
|
+
return {
|
|
186
|
+
isVisible,
|
|
187
|
+
ratio
|
|
188
|
+
};
|
|
189
|
+
}
|
|
155
190
|
const index = {
|
|
156
191
|
childNodes,
|
|
157
192
|
parentNode,
|
|
@@ -165,12 +200,16 @@ const index = {
|
|
|
165
200
|
querySelector,
|
|
166
201
|
querySelectorAll,
|
|
167
202
|
mutationObserver: mutationObserverCtor,
|
|
168
|
-
patch
|
|
203
|
+
patch,
|
|
204
|
+
describeNode,
|
|
205
|
+
getElementVisibility
|
|
169
206
|
};
|
|
170
207
|
export {
|
|
171
208
|
childNodes,
|
|
172
209
|
contains,
|
|
173
210
|
index as default,
|
|
211
|
+
describeNode,
|
|
212
|
+
getElementVisibility,
|
|
174
213
|
getRootNode,
|
|
175
214
|
getUntaintedAccessor,
|
|
176
215
|
getUntaintedMethod,
|
package/dist/rrweb-utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rrweb-utils.js","sources":["../src/index.ts"],"sourcesContent":["type PrototypeOwner = Node | ShadowRoot | MutationObserver | Element;\ntype TypeofPrototypeOwner =\n | typeof Node\n | typeof ShadowRoot\n | typeof MutationObserver\n | typeof Element;\n\ntype BasePrototypeCache = {\n Node: typeof Node.prototype;\n ShadowRoot: typeof ShadowRoot.prototype;\n MutationObserver: typeof MutationObserver.prototype;\n Element: typeof Element.prototype;\n};\n\nconst testableAccessors = {\n Node: ['childNodes', 'parentNode', 'parentElement', 'textContent'] as const,\n ShadowRoot: ['host', 'styleSheets'] as const,\n Element: ['shadowRoot', 'querySelector', 'querySelectorAll'] as const,\n MutationObserver: [] as const,\n} as const;\n\nconst testableMethods = {\n Node: ['contains', 'getRootNode'] as const,\n ShadowRoot: ['getSelection'],\n Element: [],\n MutationObserver: ['constructor'],\n} as const;\n\nconst untaintedBasePrototype: Partial<BasePrototypeCache> = {};\n\n/*\n When angular patches things - particularly the MutationObserver -\n they pass the `isNativeFunction` check\n That then causes performance issues\n because Angular's change detection\n doesn't like sharing a mutation observer\n Checking for the presence of the Zone object\n on global is a good-enough proxy for Angular\n to cover most cases\n (you can configure zone.js to have a different name\n on the global object and should then manually run rrweb\n outside the Zone)\n */\nexport const isAngularZonePresent = (): boolean => {\n return !!(globalThis as { Zone?: unknown }).Zone;\n};\n\nexport function getUntaintedPrototype<T extends keyof BasePrototypeCache>(\n key: T,\n): BasePrototypeCache[T] {\n if (untaintedBasePrototype[key])\n return untaintedBasePrototype[key] as BasePrototypeCache[T];\n\n const defaultObj = globalThis[key] as TypeofPrototypeOwner;\n const defaultPrototype = defaultObj.prototype as BasePrototypeCache[T];\n\n // use list of testable accessors to check if the prototype is tainted\n const accessorNames =\n key in testableAccessors ? testableAccessors[key] : undefined;\n const isUntaintedAccessors = Boolean(\n accessorNames &&\n // @ts-expect-error 2345\n accessorNames.every((accessor: keyof typeof defaultPrototype) =>\n Boolean(\n Object.getOwnPropertyDescriptor(defaultPrototype, accessor)\n ?.get?.toString()\n .includes('[native code]'),\n ),\n ),\n );\n\n const methodNames = key in testableMethods ? testableMethods[key] : undefined;\n const isUntaintedMethods = Boolean(\n methodNames &&\n methodNames.every(\n // @ts-expect-error 2345\n (method: keyof typeof defaultPrototype) =>\n typeof defaultPrototype[method] === 'function' &&\n defaultPrototype[method]?.toString().includes('[native code]'),\n ),\n );\n\n if (isUntaintedAccessors && isUntaintedMethods && !isAngularZonePresent()) {\n untaintedBasePrototype[key] = defaultObj.prototype as BasePrototypeCache[T];\n return defaultObj.prototype as BasePrototypeCache[T];\n }\n\n try {\n const iframeEl = document.createElement('iframe');\n document.body.appendChild(iframeEl);\n const win = iframeEl.contentWindow;\n if (!win) return defaultObj.prototype as BasePrototypeCache[T];\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n const untaintedObject = (win as any)[key]\n .prototype as BasePrototypeCache[T];\n // cleanup\n document.body.removeChild(iframeEl);\n\n if (!untaintedObject) return defaultPrototype;\n\n return (untaintedBasePrototype[key] = untaintedObject);\n } catch {\n return defaultPrototype;\n }\n}\n\nconst untaintedAccessorCache: Record<\n string,\n (this: PrototypeOwner, ...args: unknown[]) => unknown\n> = {};\n\nexport function getUntaintedAccessor<\n K extends keyof BasePrototypeCache,\n T extends keyof BasePrototypeCache[K],\n>(\n key: K,\n instance: BasePrototypeCache[K],\n accessor: T,\n): BasePrototypeCache[K][T] {\n const cacheKey = `${key}.${String(accessor)}`;\n if (untaintedAccessorCache[cacheKey])\n return untaintedAccessorCache[cacheKey].call(\n instance,\n ) as BasePrototypeCache[K][T];\n\n const untaintedPrototype = getUntaintedPrototype(key);\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const untaintedAccessor = Object.getOwnPropertyDescriptor(\n untaintedPrototype,\n accessor,\n )?.get;\n\n if (!untaintedAccessor) return instance[accessor];\n\n untaintedAccessorCache[cacheKey] = untaintedAccessor;\n\n return untaintedAccessor.call(instance) as BasePrototypeCache[K][T];\n}\n\ntype BaseMethod<K extends keyof BasePrototypeCache> = (\n this: BasePrototypeCache[K],\n ...args: unknown[]\n) => unknown;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst untaintedMethodCache: Record<string, BaseMethod<any>> = {};\nexport function getUntaintedMethod<\n K extends keyof BasePrototypeCache,\n T extends keyof BasePrototypeCache[K],\n>(\n key: K,\n instance: BasePrototypeCache[K],\n method: T,\n): BasePrototypeCache[K][T] {\n const cacheKey = `${key}.${String(method)}`;\n if (untaintedMethodCache[cacheKey])\n return untaintedMethodCache[cacheKey].bind(\n instance,\n ) as BasePrototypeCache[K][T];\n\n const untaintedPrototype = getUntaintedPrototype(key);\n const untaintedMethod = untaintedPrototype[method];\n\n if (typeof untaintedMethod !== 'function') return instance[method];\n\n untaintedMethodCache[cacheKey] = untaintedMethod as BaseMethod<K>;\n\n return untaintedMethod.bind(instance) as BasePrototypeCache[K][T];\n}\n\nexport function childNodes(n: Node): NodeListOf<Node> {\n return getUntaintedAccessor('Node', n, 'childNodes');\n}\n\nexport function parentNode(n: Node): ParentNode | null {\n return getUntaintedAccessor('Node', n, 'parentNode');\n}\n\nexport function parentElement(n: Node): HTMLElement | null {\n return getUntaintedAccessor('Node', n, 'parentElement');\n}\n\nexport function textContent(n: Node): string | null {\n return getUntaintedAccessor('Node', n, 'textContent');\n}\n\nexport function contains(n: Node, other: Node): boolean {\n return getUntaintedMethod('Node', n, 'contains')(other);\n}\n\nexport function getRootNode(n: Node): Node {\n return getUntaintedMethod('Node', n, 'getRootNode')();\n}\n\nexport function host(n: ShadowRoot): Element | null {\n if (!n || !('host' in n)) return null;\n return getUntaintedAccessor('ShadowRoot', n, 'host');\n}\n\nexport function styleSheets(n: ShadowRoot): StyleSheetList {\n return n.styleSheets;\n}\n\nexport function shadowRoot(n: Node): ShadowRoot | null {\n if (!n || !('shadowRoot' in n)) return null;\n return getUntaintedAccessor('Element', n as Element, 'shadowRoot');\n}\n\nexport function querySelector(n: Element, selectors: string): Element | null {\n return getUntaintedAccessor('Element', n, 'querySelector')(selectors);\n}\n\nexport function querySelectorAll(\n n: Element,\n selectors: string,\n): NodeListOf<Element> {\n return getUntaintedAccessor('Element', n, 'querySelectorAll')(selectors);\n}\n\nexport function mutationObserverCtor(): (typeof MutationObserver)['prototype']['constructor'] {\n return getUntaintedPrototype('MutationObserver').constructor;\n}\n\n// copy from https://github.com/getsentry/sentry-javascript/blob/b2109071975af8bf0316d3b5b38f519bdaf5dc15/packages/utils/src/object.ts\nexport function patch(\n source: { [key: string]: any },\n name: string,\n replacement: (...args: unknown[]) => unknown,\n): () => void {\n try {\n if (!(name in source)) {\n return () => {\n //\n };\n }\n\n const original = source[name] as () => unknown;\n const wrapped = replacement(original);\n\n // Make sure it's a function first, as we need to attach an empty prototype for `defineProperties` to work\n // otherwise it'll throw \"TypeError: Object.defineProperties called on non-object\"\n if (typeof wrapped === 'function') {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n wrapped.prototype = wrapped.prototype || {};\n Object.defineProperties(wrapped, {\n __rrweb_original__: {\n enumerable: false,\n value: original,\n },\n });\n }\n\n source[name] = wrapped;\n\n return () => {\n source[name] = original;\n };\n } catch {\n return () => {\n //\n };\n // This can throw if multiple fill happens on a global object like XMLHttpRequest\n // Fixes https://github.com/getsentry/sentry-javascript/issues/2043\n }\n}\n\nexport default {\n childNodes,\n parentNode,\n parentElement,\n textContent,\n contains,\n getRootNode,\n host,\n styleSheets,\n shadowRoot,\n querySelector,\n querySelectorAll,\n mutationObserver: mutationObserverCtor,\n patch,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AAA,CACD;AAAA,IACH;AAEA,WAAO,IAAI,IAAI;AAEf,WAAO,MAAM;AACX,aAAO,IAAI,IAAI;AAAA,IAAA;AAAA,EACjB,QACM;AACN,WAAO,MAAM;AAAA,IAAA;AAAA,EAKf;AACF;AAEA,MAAe,QAAA;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,kBAAkB;AAAA,EAClB;AACF;"}
|
|
1
|
+
{"version":3,"file":"rrweb-utils.js","sources":["../src/index.ts"],"sourcesContent":["type PrototypeOwner = Node | ShadowRoot | MutationObserver | Element;\ntype TypeofPrototypeOwner =\n | typeof Node\n | typeof ShadowRoot\n | typeof MutationObserver\n | typeof Element;\n\ntype BasePrototypeCache = {\n Node: typeof Node.prototype;\n ShadowRoot: typeof ShadowRoot.prototype;\n MutationObserver: typeof MutationObserver.prototype;\n Element: typeof Element.prototype;\n};\n\nconst testableAccessors = {\n Node: ['childNodes', 'parentNode', 'parentElement', 'textContent'] as const,\n ShadowRoot: ['host', 'styleSheets'] as const,\n Element: ['shadowRoot', 'querySelector', 'querySelectorAll'] as const,\n MutationObserver: [] as const,\n} as const;\n\nconst testableMethods = {\n Node: ['contains', 'getRootNode'] as const,\n ShadowRoot: ['getSelection'],\n Element: [],\n MutationObserver: ['constructor'],\n} as const;\n\nconst untaintedBasePrototype: Partial<BasePrototypeCache> = {};\n\n/*\n When angular patches things - particularly the MutationObserver -\n they pass the `isNativeFunction` check\n That then causes performance issues\n because Angular's change detection\n doesn't like sharing a mutation observer\n Checking for the presence of the Zone object\n on global is a good-enough proxy for Angular\n to cover most cases\n (you can configure zone.js to have a different name\n on the global object and should then manually run rrweb\n outside the Zone)\n */\nexport const isAngularZonePresent = (): boolean => {\n return !!(globalThis as { Zone?: unknown }).Zone;\n};\n\nexport function getUntaintedPrototype<T extends keyof BasePrototypeCache>(\n key: T,\n): BasePrototypeCache[T] {\n if (untaintedBasePrototype[key])\n return untaintedBasePrototype[key] as BasePrototypeCache[T];\n\n const defaultObj = globalThis[key] as TypeofPrototypeOwner;\n const defaultPrototype = defaultObj.prototype as BasePrototypeCache[T];\n\n // use list of testable accessors to check if the prototype is tainted\n const accessorNames =\n key in testableAccessors ? testableAccessors[key] : undefined;\n const isUntaintedAccessors = Boolean(\n accessorNames &&\n // @ts-expect-error 2345\n accessorNames.every((accessor: keyof typeof defaultPrototype) =>\n Boolean(\n Object.getOwnPropertyDescriptor(defaultPrototype, accessor)\n ?.get?.toString()\n .includes('[native code]'),\n ),\n ),\n );\n\n const methodNames = key in testableMethods ? testableMethods[key] : undefined;\n const isUntaintedMethods = Boolean(\n methodNames &&\n methodNames.every(\n // @ts-expect-error 2345\n (method: keyof typeof defaultPrototype) =>\n typeof defaultPrototype[method] === 'function' &&\n defaultPrototype[method]?.toString().includes('[native code]'),\n ),\n );\n\n if (isUntaintedAccessors && isUntaintedMethods && !isAngularZonePresent()) {\n untaintedBasePrototype[key] = defaultObj.prototype as BasePrototypeCache[T];\n return defaultObj.prototype as BasePrototypeCache[T];\n }\n\n try {\n const iframeEl = document.createElement('iframe');\n document.body.appendChild(iframeEl);\n const win = iframeEl.contentWindow;\n if (!win) return defaultObj.prototype as BasePrototypeCache[T];\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n const untaintedObject = (win as any)[key]\n .prototype as BasePrototypeCache[T];\n // cleanup\n document.body.removeChild(iframeEl);\n\n if (!untaintedObject) return defaultPrototype;\n\n return (untaintedBasePrototype[key] = untaintedObject);\n } catch {\n return defaultPrototype;\n }\n}\n\nconst untaintedAccessorCache: Record<\n string,\n (this: PrototypeOwner, ...args: unknown[]) => unknown\n> = {};\n\nexport function getUntaintedAccessor<\n K extends keyof BasePrototypeCache,\n T extends keyof BasePrototypeCache[K],\n>(\n key: K,\n instance: BasePrototypeCache[K],\n accessor: T,\n): BasePrototypeCache[K][T] {\n const cacheKey = `${key}.${String(accessor)}`;\n if (untaintedAccessorCache[cacheKey])\n return untaintedAccessorCache[cacheKey].call(\n instance,\n ) as BasePrototypeCache[K][T];\n\n const untaintedPrototype = getUntaintedPrototype(key);\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const untaintedAccessor = Object.getOwnPropertyDescriptor(\n untaintedPrototype,\n accessor,\n )?.get;\n\n if (!untaintedAccessor) return instance[accessor];\n\n untaintedAccessorCache[cacheKey] = untaintedAccessor;\n\n return untaintedAccessor.call(instance) as BasePrototypeCache[K][T];\n}\n\ntype BaseMethod<K extends keyof BasePrototypeCache> = (\n this: BasePrototypeCache[K],\n ...args: unknown[]\n) => unknown;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst untaintedMethodCache: Record<string, BaseMethod<any>> = {};\nexport function getUntaintedMethod<\n K extends keyof BasePrototypeCache,\n T extends keyof BasePrototypeCache[K],\n>(\n key: K,\n instance: BasePrototypeCache[K],\n method: T,\n): BasePrototypeCache[K][T] {\n const cacheKey = `${key}.${String(method)}`;\n if (untaintedMethodCache[cacheKey])\n return untaintedMethodCache[cacheKey].bind(\n instance,\n ) as BasePrototypeCache[K][T];\n\n const untaintedPrototype = getUntaintedPrototype(key);\n const untaintedMethod = untaintedPrototype[method];\n\n if (typeof untaintedMethod !== 'function') return instance[method];\n\n untaintedMethodCache[cacheKey] = untaintedMethod as BaseMethod<K>;\n\n return untaintedMethod.bind(instance) as BasePrototypeCache[K][T];\n}\n\nexport function childNodes(n: Node): NodeListOf<Node> {\n return getUntaintedAccessor('Node', n, 'childNodes');\n}\n\nexport function parentNode(n: Node): ParentNode | null {\n return getUntaintedAccessor('Node', n, 'parentNode');\n}\n\nexport function parentElement(n: Node): HTMLElement | null {\n return getUntaintedAccessor('Node', n, 'parentElement');\n}\n\nexport function textContent(n: Node): string | null {\n return getUntaintedAccessor('Node', n, 'textContent');\n}\n\nexport function contains(n: Node, other: Node): boolean {\n return getUntaintedMethod('Node', n, 'contains')(other);\n}\n\nexport function getRootNode(n: Node): Node {\n return getUntaintedMethod('Node', n, 'getRootNode')();\n}\n\nexport function host(n: ShadowRoot): Element | null {\n if (!n || !('host' in n)) return null;\n return getUntaintedAccessor('ShadowRoot', n, 'host');\n}\n\nexport function styleSheets(n: ShadowRoot): StyleSheetList {\n return n.styleSheets;\n}\n\nexport function shadowRoot(n: Node): ShadowRoot | null {\n if (!n || !('shadowRoot' in n)) return null;\n return getUntaintedAccessor('Element', n as Element, 'shadowRoot');\n}\n\nexport function querySelector(n: Element, selectors: string): Element | null {\n return getUntaintedAccessor('Element', n, 'querySelector')(selectors);\n}\n\nexport function querySelectorAll(\n n: Element,\n selectors: string,\n): NodeListOf<Element> {\n return getUntaintedAccessor('Element', n, 'querySelectorAll')(selectors);\n}\n\nexport function mutationObserverCtor(): (typeof MutationObserver)['prototype']['constructor'] {\n return getUntaintedPrototype('MutationObserver').constructor;\n}\n\n// copy from https://github.com/getsentry/sentry-javascript/blob/b2109071975af8bf0316d3b5b38f519bdaf5dc15/packages/utils/src/object.ts\nexport function patch(\n source: { [key: string]: any },\n name: string,\n replacement: (...args: unknown[]) => unknown,\n): () => void {\n try {\n if (!(name in source)) {\n return () => {\n //\n };\n }\n\n const original = source[name] as () => unknown;\n const wrapped = replacement(original);\n\n // Make sure it's a function first, as we need to attach an empty prototype for `defineProperties` to work\n // otherwise it'll throw \"TypeError: Object.defineProperties called on non-object\"\n if (typeof wrapped === 'function') {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n wrapped.prototype = wrapped.prototype || {};\n Object.defineProperties(wrapped, {\n __rrweb_original__: {\n enumerable: false,\n value: original,\n },\n });\n }\n\n source[name] = wrapped;\n\n return () => {\n source[name] = original;\n };\n } catch {\n return () => {\n //\n };\n // This can throw if multiple fill happens on a global object like XMLHttpRequest\n // Fixes https://github.com/getsentry/sentry-javascript/issues/2043\n }\n}\n\nexport function describeNode(el: Element): string {\n const tag = el.tagName.toLowerCase();\n const id = el.id ? `#${el.id}` : '';\n const classes = el.classList.length\n ? '.' + Array.from(el.classList).join('.')\n : '';\n return `${tag}${id}${classes}`;\n}\n\nexport function getElementVisibility(el: Element): {\n isVisible: boolean;\n ratio: number;\n} {\n const win = el.ownerDocument?.defaultView ?? window;\n const rect = el.getBoundingClientRect();\n\n const viewportWidth =\n win.innerWidth || win.document.documentElement.clientWidth || 0;\n const viewportHeight =\n win.innerHeight || win.document.documentElement.clientHeight || 0;\n\n const isRectVisible =\n rect.width > 0 &&\n rect.height > 0 &&\n rect.bottom > 0 &&\n rect.right > 0 &&\n rect.top < viewportHeight &&\n rect.left < viewportWidth;\n\n const style = win.getComputedStyle?.(el);\n const isStyleVisible =\n !!style &&\n style.display !== 'none' &&\n style.visibility !== 'hidden' &&\n (parseFloat(style.opacity) || 0) > 0;\n\n const isVisible = isStyleVisible && isRectVisible;\n\n let ratio = 0;\n if (isVisible) {\n const xOverlap = Math.max(\n 0,\n Math.min(rect.right, viewportWidth) - Math.max(rect.left, 0),\n );\n const yOverlap = Math.max(\n 0,\n Math.min(rect.bottom, viewportHeight) - Math.max(rect.top, 0),\n );\n const intersectionArea = xOverlap * yOverlap;\n const elementArea = rect.width * rect.height;\n ratio = elementArea > 0 ? intersectionArea / elementArea : 0;\n }\n\n return {\n isVisible,\n ratio,\n };\n}\n\nexport default {\n childNodes,\n parentNode,\n parentElement,\n textContent,\n contains,\n getRootNode,\n host,\n styleSheets,\n shadowRoot,\n querySelector,\n querySelectorAll,\n mutationObserver: mutationObserverCtor,\n patch,\n describeNode,\n getElementVisibility,\n};\n"],"names":[],"mappings":"AAcA,MAAM,oBAAoB;AAAA,EACxB,MAAM,CAAC,cAAc,cAAc,iBAAiB,aAAa;AAAA,EACjE,YAAY,CAAC,QAAQ,aAAa;AAAA,EAClC,SAAS,CAAC,cAAc,iBAAiB,kBAAkB;AAAA,EAC3D,kBAAkB,CAAC;AACrB;AAEA,MAAM,kBAAkB;AAAA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,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,kBAAkB;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AACF;"}
|
package/dist/rrweb-utils.umd.cjs
CHANGED
|
@@ -167,6 +167,42 @@ function patch(source, name, replacement) {
|
|
|
167
167
|
};
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
|
+
function describeNode(el) {
|
|
171
|
+
const tag = el.tagName.toLowerCase();
|
|
172
|
+
const id = el.id ? `#${el.id}` : "";
|
|
173
|
+
const classes = el.classList.length ? "." + Array.from(el.classList).join(".") : "";
|
|
174
|
+
return `${tag}${id}${classes}`;
|
|
175
|
+
}
|
|
176
|
+
function getElementVisibility(el) {
|
|
177
|
+
var _a2;
|
|
178
|
+
var _a, _b;
|
|
179
|
+
const win = (_a2 = (_a = el.ownerDocument) == null ? void 0 : _a.defaultView) != null ? _a2 : window;
|
|
180
|
+
const rect = el.getBoundingClientRect();
|
|
181
|
+
const viewportWidth = win.innerWidth || win.document.documentElement.clientWidth || 0;
|
|
182
|
+
const viewportHeight = win.innerHeight || win.document.documentElement.clientHeight || 0;
|
|
183
|
+
const isRectVisible = rect.width > 0 && rect.height > 0 && rect.bottom > 0 && rect.right > 0 && rect.top < viewportHeight && rect.left < viewportWidth;
|
|
184
|
+
const style = (_b = win.getComputedStyle) == null ? void 0 : _b.call(win, el);
|
|
185
|
+
const isStyleVisible = !!style && style.display !== "none" && style.visibility !== "hidden" && (parseFloat(style.opacity) || 0) > 0;
|
|
186
|
+
const isVisible = isStyleVisible && isRectVisible;
|
|
187
|
+
let ratio = 0;
|
|
188
|
+
if (isVisible) {
|
|
189
|
+
const xOverlap = Math.max(
|
|
190
|
+
0,
|
|
191
|
+
Math.min(rect.right, viewportWidth) - Math.max(rect.left, 0)
|
|
192
|
+
);
|
|
193
|
+
const yOverlap = Math.max(
|
|
194
|
+
0,
|
|
195
|
+
Math.min(rect.bottom, viewportHeight) - Math.max(rect.top, 0)
|
|
196
|
+
);
|
|
197
|
+
const intersectionArea = xOverlap * yOverlap;
|
|
198
|
+
const elementArea = rect.width * rect.height;
|
|
199
|
+
ratio = elementArea > 0 ? intersectionArea / elementArea : 0;
|
|
200
|
+
}
|
|
201
|
+
return {
|
|
202
|
+
isVisible,
|
|
203
|
+
ratio
|
|
204
|
+
};
|
|
205
|
+
}
|
|
170
206
|
const index = {
|
|
171
207
|
childNodes,
|
|
172
208
|
parentNode,
|
|
@@ -180,11 +216,15 @@ const index = {
|
|
|
180
216
|
querySelector,
|
|
181
217
|
querySelectorAll,
|
|
182
218
|
mutationObserver: mutationObserverCtor,
|
|
183
|
-
patch
|
|
219
|
+
patch,
|
|
220
|
+
describeNode,
|
|
221
|
+
getElementVisibility
|
|
184
222
|
};
|
|
185
223
|
exports.childNodes = childNodes;
|
|
186
224
|
exports.contains = contains;
|
|
187
225
|
exports.default = index;
|
|
226
|
+
exports.describeNode = describeNode;
|
|
227
|
+
exports.getElementVisibility = getElementVisibility;
|
|
188
228
|
exports.getRootNode = getRootNode;
|
|
189
229
|
exports.getUntaintedAccessor = getUntaintedAccessor;
|
|
190
230
|
exports.getUntaintedMethod = getUntaintedMethod;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["type PrototypeOwner = Node | ShadowRoot | MutationObserver | Element;\ntype TypeofPrototypeOwner =\n | typeof Node\n | typeof ShadowRoot\n | typeof MutationObserver\n | typeof Element;\n\ntype BasePrototypeCache = {\n Node: typeof Node.prototype;\n ShadowRoot: typeof ShadowRoot.prototype;\n MutationObserver: typeof MutationObserver.prototype;\n Element: typeof Element.prototype;\n};\n\nconst testableAccessors = {\n Node: ['childNodes', 'parentNode', 'parentElement', 'textContent'] as const,\n ShadowRoot: ['host', 'styleSheets'] as const,\n Element: ['shadowRoot', 'querySelector', 'querySelectorAll'] as const,\n MutationObserver: [] as const,\n} as const;\n\nconst testableMethods = {\n Node: ['contains', 'getRootNode'] as const,\n ShadowRoot: ['getSelection'],\n Element: [],\n MutationObserver: ['constructor'],\n} as const;\n\nconst untaintedBasePrototype: Partial<BasePrototypeCache> = {};\n\n/*\n When angular patches things - particularly the MutationObserver -\n they pass the `isNativeFunction` check\n That then causes performance issues\n because Angular's change detection\n doesn't like sharing a mutation observer\n Checking for the presence of the Zone object\n on global is a good-enough proxy for Angular\n to cover most cases\n (you can configure zone.js to have a different name\n on the global object and should then manually run rrweb\n outside the Zone)\n */\nexport const isAngularZonePresent = (): boolean => {\n return !!(globalThis as { Zone?: unknown }).Zone;\n};\n\nexport function getUntaintedPrototype<T extends keyof BasePrototypeCache>(\n key: T,\n): BasePrototypeCache[T] {\n if (untaintedBasePrototype[key])\n return untaintedBasePrototype[key] as BasePrototypeCache[T];\n\n const defaultObj = globalThis[key] as TypeofPrototypeOwner;\n const defaultPrototype = defaultObj.prototype as BasePrototypeCache[T];\n\n // use list of testable accessors to check if the prototype is tainted\n const accessorNames =\n key in testableAccessors ? testableAccessors[key] : undefined;\n const isUntaintedAccessors = Boolean(\n accessorNames &&\n // @ts-expect-error 2345\n accessorNames.every((accessor: keyof typeof defaultPrototype) =>\n Boolean(\n Object.getOwnPropertyDescriptor(defaultPrototype, accessor)\n ?.get?.toString()\n .includes('[native code]'),\n ),\n ),\n );\n\n const methodNames = key in testableMethods ? testableMethods[key] : undefined;\n const isUntaintedMethods = Boolean(\n methodNames &&\n methodNames.every(\n // @ts-expect-error 2345\n (method: keyof typeof defaultPrototype) =>\n typeof defaultPrototype[method] === 'function' &&\n defaultPrototype[method]?.toString().includes('[native code]'),\n ),\n );\n\n if (isUntaintedAccessors && isUntaintedMethods && !isAngularZonePresent()) {\n untaintedBasePrototype[key] = defaultObj.prototype as BasePrototypeCache[T];\n return defaultObj.prototype as BasePrototypeCache[T];\n }\n\n try {\n const iframeEl = document.createElement('iframe');\n document.body.appendChild(iframeEl);\n const win = iframeEl.contentWindow;\n if (!win) return defaultObj.prototype as BasePrototypeCache[T];\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n const untaintedObject = (win as any)[key]\n .prototype as BasePrototypeCache[T];\n // cleanup\n document.body.removeChild(iframeEl);\n\n if (!untaintedObject) return defaultPrototype;\n\n return (untaintedBasePrototype[key] = untaintedObject);\n } catch {\n return defaultPrototype;\n }\n}\n\nconst untaintedAccessorCache: Record<\n string,\n (this: PrototypeOwner, ...args: unknown[]) => unknown\n> = {};\n\nexport function getUntaintedAccessor<\n K extends keyof BasePrototypeCache,\n T extends keyof BasePrototypeCache[K],\n>(\n key: K,\n instance: BasePrototypeCache[K],\n accessor: T,\n): BasePrototypeCache[K][T] {\n const cacheKey = `${key}.${String(accessor)}`;\n if (untaintedAccessorCache[cacheKey])\n return untaintedAccessorCache[cacheKey].call(\n instance,\n ) as BasePrototypeCache[K][T];\n\n const untaintedPrototype = getUntaintedPrototype(key);\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const untaintedAccessor = Object.getOwnPropertyDescriptor(\n untaintedPrototype,\n accessor,\n )?.get;\n\n if (!untaintedAccessor) return instance[accessor];\n\n untaintedAccessorCache[cacheKey] = untaintedAccessor;\n\n return untaintedAccessor.call(instance) as BasePrototypeCache[K][T];\n}\n\ntype BaseMethod<K extends keyof BasePrototypeCache> = (\n this: BasePrototypeCache[K],\n ...args: unknown[]\n) => unknown;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst untaintedMethodCache: Record<string, BaseMethod<any>> = {};\nexport function getUntaintedMethod<\n K extends keyof BasePrototypeCache,\n T extends keyof BasePrototypeCache[K],\n>(\n key: K,\n instance: BasePrototypeCache[K],\n method: T,\n): BasePrototypeCache[K][T] {\n const cacheKey = `${key}.${String(method)}`;\n if (untaintedMethodCache[cacheKey])\n return untaintedMethodCache[cacheKey].bind(\n instance,\n ) as BasePrototypeCache[K][T];\n\n const untaintedPrototype = getUntaintedPrototype(key);\n const untaintedMethod = untaintedPrototype[method];\n\n if (typeof untaintedMethod !== 'function') return instance[method];\n\n untaintedMethodCache[cacheKey] = untaintedMethod as BaseMethod<K>;\n\n return untaintedMethod.bind(instance) as BasePrototypeCache[K][T];\n}\n\nexport function childNodes(n: Node): NodeListOf<Node> {\n return getUntaintedAccessor('Node', n, 'childNodes');\n}\n\nexport function parentNode(n: Node): ParentNode | null {\n return getUntaintedAccessor('Node', n, 'parentNode');\n}\n\nexport function parentElement(n: Node): HTMLElement | null {\n return getUntaintedAccessor('Node', n, 'parentElement');\n}\n\nexport function textContent(n: Node): string | null {\n return getUntaintedAccessor('Node', n, 'textContent');\n}\n\nexport function contains(n: Node, other: Node): boolean {\n return getUntaintedMethod('Node', n, 'contains')(other);\n}\n\nexport function getRootNode(n: Node): Node {\n return getUntaintedMethod('Node', n, 'getRootNode')();\n}\n\nexport function host(n: ShadowRoot): Element | null {\n if (!n || !('host' in n)) return null;\n return getUntaintedAccessor('ShadowRoot', n, 'host');\n}\n\nexport function styleSheets(n: ShadowRoot): StyleSheetList {\n return n.styleSheets;\n}\n\nexport function shadowRoot(n: Node): ShadowRoot | null {\n if (!n || !('shadowRoot' in n)) return null;\n return getUntaintedAccessor('Element', n as Element, 'shadowRoot');\n}\n\nexport function querySelector(n: Element, selectors: string): Element | null {\n return getUntaintedAccessor('Element', n, 'querySelector')(selectors);\n}\n\nexport function querySelectorAll(\n n: Element,\n selectors: string,\n): NodeListOf<Element> {\n return getUntaintedAccessor('Element', n, 'querySelectorAll')(selectors);\n}\n\nexport function mutationObserverCtor(): (typeof MutationObserver)['prototype']['constructor'] {\n return getUntaintedPrototype('MutationObserver').constructor;\n}\n\n// copy from https://github.com/getsentry/sentry-javascript/blob/b2109071975af8bf0316d3b5b38f519bdaf5dc15/packages/utils/src/object.ts\nexport function patch(\n source: { [key: string]: any },\n name: string,\n replacement: (...args: unknown[]) => unknown,\n): () => void {\n try {\n if (!(name in source)) {\n return () => {\n //\n };\n }\n\n const original = source[name] as () => unknown;\n const wrapped = replacement(original);\n\n // Make sure it's a function first, as we need to attach an empty prototype for `defineProperties` to work\n // otherwise it'll throw \"TypeError: Object.defineProperties called on non-object\"\n if (typeof wrapped === 'function') {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n wrapped.prototype = wrapped.prototype || {};\n Object.defineProperties(wrapped, {\n __rrweb_original__: {\n enumerable: false,\n value: original,\n },\n });\n }\n\n source[name] = wrapped;\n\n return () => {\n source[name] = original;\n };\n } catch {\n return () => {\n //\n };\n // This can throw if multiple fill happens on a global object like XMLHttpRequest\n // Fixes https://github.com/getsentry/sentry-javascript/issues/2043\n }\n}\n\nexport default {\n childNodes,\n parentNode,\n parentElement,\n textContent,\n contains,\n getRootNode,\n host,\n styleSheets,\n shadowRoot,\n querySelector,\n querySelectorAll,\n mutationObserver: mutationObserverCtor,\n patch,\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;AAcA,MAAM,oBAAoB;EACxB,MAAM,CAAC,cAAc,cAAc,iBAAiB,aAAa;EACjE,YAAY,CAAC,QAAQ,aAAa;EAClC,SAAS,CAAC,cAAc,iBAAiB,kBAAkB;EAC3D,kBAAkB,CAAC;AACrB;AAEA,MAAM,kBAAkB;EACtB,MAAM,CAAC,YAAY,aAAa;EAChC,YAAY,CAAC,cAAc;EAC3B,SAAS,CAAC;EACV,kBAAkB,CAAC,aAAa;AAClC;AAEA,MAAM,yBAAsD,CAAA;AAerD,MAAM,uBAAuB,MAAe;AAC1C,SAAA,CAAC,CAAE,WAAkC;AAC9C;AAEO,SAAS,sBACd,KACuB;AACvB,MAAI,uBAAuB,GAAG;AAC5B,WAAO,uBAAuB,GAAG;AAE7B,QAAA,aAAa,WAAW,GAAG;AACjC,QAAM,mBAAmB,WAAW;AAGpC,QAAM,gBACJ,OAAO,oBAAoB,kBAAkB,GAAG,IAAI;AACtD,QAAM,uBAAuB;IAC3B;IAEE,cAAc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tE;AAEgB,SAAA,iBACd,GACA,WACqB;AACrB,SAAO,qBAAqB,WAAW,GAAG,kBAAkB,EAAE,SAAS;AACzE;AAEO,SAAS,uBAA8E;AACrF,SAAA,sBAAsB,kBAAkB,EAAE;AACnD;AAGgB,SAAA,MACd,QACA,MACA,aACY;AACR,MAAA;AACE,QAAA,EAAE,QAAQ,SAAS;AACrB,aAAO,MAAM;MAAA;IAGf;AAEM,UAAA,WAAW,OAAO,IAAI;AACtB,UAAA,UAAU,YAAY,QAAQ;AAIhC,QAAA,OAAO,YAAY,YAAY;AAEzB,cAAA,YAAY,QAAQ,aAAa,CAAA;AACzC,aAAO,iBAAiB,SAAS;QAC/B,oBAAoB;UAClB,YAAY;UACZ,OAAO;QACT;MAAA,CACD;IACH;AAEA,WAAO,IAAI,IAAI;AAEf,WAAO,MAAM;AACX,aAAO,IAAI,IAAI;IAAA;EACjB,SACM;AACN,WAAO,MAAM;IAAA;EAKf;AACF;AAEA,MAAe,QAAA;EACb;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,kBAAkB;EAClB;AACF
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["type PrototypeOwner = Node | ShadowRoot | MutationObserver | Element;\ntype TypeofPrototypeOwner =\n | typeof Node\n | typeof ShadowRoot\n | typeof MutationObserver\n | typeof Element;\n\ntype BasePrototypeCache = {\n Node: typeof Node.prototype;\n ShadowRoot: typeof ShadowRoot.prototype;\n MutationObserver: typeof MutationObserver.prototype;\n Element: typeof Element.prototype;\n};\n\nconst testableAccessors = {\n Node: ['childNodes', 'parentNode', 'parentElement', 'textContent'] as const,\n ShadowRoot: ['host', 'styleSheets'] as const,\n Element: ['shadowRoot', 'querySelector', 'querySelectorAll'] as const,\n MutationObserver: [] as const,\n} as const;\n\nconst testableMethods = {\n Node: ['contains', 'getRootNode'] as const,\n ShadowRoot: ['getSelection'],\n Element: [],\n MutationObserver: ['constructor'],\n} as const;\n\nconst untaintedBasePrototype: Partial<BasePrototypeCache> = {};\n\n/*\n When angular patches things - particularly the MutationObserver -\n they pass the `isNativeFunction` check\n That then causes performance issues\n because Angular's change detection\n doesn't like sharing a mutation observer\n Checking for the presence of the Zone object\n on global is a good-enough proxy for Angular\n to cover most cases\n (you can configure zone.js to have a different name\n on the global object and should then manually run rrweb\n outside the Zone)\n */\nexport const isAngularZonePresent = (): boolean => {\n return !!(globalThis as { Zone?: unknown }).Zone;\n};\n\nexport function getUntaintedPrototype<T extends keyof BasePrototypeCache>(\n key: T,\n): BasePrototypeCache[T] {\n if (untaintedBasePrototype[key])\n return untaintedBasePrototype[key] as BasePrototypeCache[T];\n\n const defaultObj = globalThis[key] as TypeofPrototypeOwner;\n const defaultPrototype = defaultObj.prototype as BasePrototypeCache[T];\n\n // use list of testable accessors to check if the prototype is tainted\n const accessorNames =\n key in testableAccessors ? testableAccessors[key] : undefined;\n const isUntaintedAccessors = Boolean(\n accessorNames &&\n // @ts-expect-error 2345\n accessorNames.every((accessor: keyof typeof defaultPrototype) =>\n Boolean(\n Object.getOwnPropertyDescriptor(defaultPrototype, accessor)\n ?.get?.toString()\n .includes('[native code]'),\n ),\n ),\n );\n\n const methodNames = key in testableMethods ? testableMethods[key] : undefined;\n const isUntaintedMethods = Boolean(\n methodNames &&\n methodNames.every(\n // @ts-expect-error 2345\n (method: keyof typeof defaultPrototype) =>\n typeof defaultPrototype[method] === 'function' &&\n defaultPrototype[method]?.toString().includes('[native code]'),\n ),\n );\n\n if (isUntaintedAccessors && isUntaintedMethods && !isAngularZonePresent()) {\n untaintedBasePrototype[key] = defaultObj.prototype as BasePrototypeCache[T];\n return defaultObj.prototype as BasePrototypeCache[T];\n }\n\n try {\n const iframeEl = document.createElement('iframe');\n document.body.appendChild(iframeEl);\n const win = iframeEl.contentWindow;\n if (!win) return defaultObj.prototype as BasePrototypeCache[T];\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n const untaintedObject = (win as any)[key]\n .prototype as BasePrototypeCache[T];\n // cleanup\n document.body.removeChild(iframeEl);\n\n if (!untaintedObject) return defaultPrototype;\n\n return (untaintedBasePrototype[key] = untaintedObject);\n } catch {\n return defaultPrototype;\n }\n}\n\nconst untaintedAccessorCache: Record<\n string,\n (this: PrototypeOwner, ...args: unknown[]) => unknown\n> = {};\n\nexport function getUntaintedAccessor<\n K extends keyof BasePrototypeCache,\n T extends keyof BasePrototypeCache[K],\n>(\n key: K,\n instance: BasePrototypeCache[K],\n accessor: T,\n): BasePrototypeCache[K][T] {\n const cacheKey = `${key}.${String(accessor)}`;\n if (untaintedAccessorCache[cacheKey])\n return untaintedAccessorCache[cacheKey].call(\n instance,\n ) as BasePrototypeCache[K][T];\n\n const untaintedPrototype = getUntaintedPrototype(key);\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const untaintedAccessor = Object.getOwnPropertyDescriptor(\n untaintedPrototype,\n accessor,\n )?.get;\n\n if (!untaintedAccessor) return instance[accessor];\n\n untaintedAccessorCache[cacheKey] = untaintedAccessor;\n\n return untaintedAccessor.call(instance) as BasePrototypeCache[K][T];\n}\n\ntype BaseMethod<K extends keyof BasePrototypeCache> = (\n this: BasePrototypeCache[K],\n ...args: unknown[]\n) => unknown;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst untaintedMethodCache: Record<string, BaseMethod<any>> = {};\nexport function getUntaintedMethod<\n K extends keyof BasePrototypeCache,\n T extends keyof BasePrototypeCache[K],\n>(\n key: K,\n instance: BasePrototypeCache[K],\n method: T,\n): BasePrototypeCache[K][T] {\n const cacheKey = `${key}.${String(method)}`;\n if (untaintedMethodCache[cacheKey])\n return untaintedMethodCache[cacheKey].bind(\n instance,\n ) as BasePrototypeCache[K][T];\n\n const untaintedPrototype = getUntaintedPrototype(key);\n const untaintedMethod = untaintedPrototype[method];\n\n if (typeof untaintedMethod !== 'function') return instance[method];\n\n untaintedMethodCache[cacheKey] = untaintedMethod as BaseMethod<K>;\n\n return untaintedMethod.bind(instance) as BasePrototypeCache[K][T];\n}\n\nexport function childNodes(n: Node): NodeListOf<Node> {\n return getUntaintedAccessor('Node', n, 'childNodes');\n}\n\nexport function parentNode(n: Node): ParentNode | null {\n return getUntaintedAccessor('Node', n, 'parentNode');\n}\n\nexport function parentElement(n: Node): HTMLElement | null {\n return getUntaintedAccessor('Node', n, 'parentElement');\n}\n\nexport function textContent(n: Node): string | null {\n return getUntaintedAccessor('Node', n, 'textContent');\n}\n\nexport function contains(n: Node, other: Node): boolean {\n return getUntaintedMethod('Node', n, 'contains')(other);\n}\n\nexport function getRootNode(n: Node): Node {\n return getUntaintedMethod('Node', n, 'getRootNode')();\n}\n\nexport function host(n: ShadowRoot): Element | null {\n if (!n || !('host' in n)) return null;\n return getUntaintedAccessor('ShadowRoot', n, 'host');\n}\n\nexport function styleSheets(n: ShadowRoot): StyleSheetList {\n return n.styleSheets;\n}\n\nexport function shadowRoot(n: Node): ShadowRoot | null {\n if (!n || !('shadowRoot' in n)) return null;\n return getUntaintedAccessor('Element', n as Element, 'shadowRoot');\n}\n\nexport function querySelector(n: Element, selectors: string): Element | null {\n return getUntaintedAccessor('Element', n, 'querySelector')(selectors);\n}\n\nexport function querySelectorAll(\n n: Element,\n selectors: string,\n): NodeListOf<Element> {\n return getUntaintedAccessor('Element', n, 'querySelectorAll')(selectors);\n}\n\nexport function mutationObserverCtor(): (typeof MutationObserver)['prototype']['constructor'] {\n return getUntaintedPrototype('MutationObserver').constructor;\n}\n\n// copy from https://github.com/getsentry/sentry-javascript/blob/b2109071975af8bf0316d3b5b38f519bdaf5dc15/packages/utils/src/object.ts\nexport function patch(\n source: { [key: string]: any },\n name: string,\n replacement: (...args: unknown[]) => unknown,\n): () => void {\n try {\n if (!(name in source)) {\n return () => {\n //\n };\n }\n\n const original = source[name] as () => unknown;\n const wrapped = replacement(original);\n\n // Make sure it's a function first, as we need to attach an empty prototype for `defineProperties` to work\n // otherwise it'll throw \"TypeError: Object.defineProperties called on non-object\"\n if (typeof wrapped === 'function') {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n wrapped.prototype = wrapped.prototype || {};\n Object.defineProperties(wrapped, {\n __rrweb_original__: {\n enumerable: false,\n value: original,\n },\n });\n }\n\n source[name] = wrapped;\n\n return () => {\n source[name] = original;\n };\n } catch {\n return () => {\n //\n };\n // This can throw if multiple fill happens on a global object like XMLHttpRequest\n // Fixes https://github.com/getsentry/sentry-javascript/issues/2043\n }\n}\n\nexport function describeNode(el: Element): string {\n const tag = el.tagName.toLowerCase();\n const id = el.id ? `#${el.id}` : '';\n const classes = el.classList.length\n ? '.' + Array.from(el.classList).join('.')\n : '';\n return `${tag}${id}${classes}`;\n}\n\nexport function getElementVisibility(el: Element): {\n isVisible: boolean;\n ratio: number;\n} {\n const win = el.ownerDocument?.defaultView ?? window;\n const rect = el.getBoundingClientRect();\n\n const viewportWidth =\n win.innerWidth || win.document.documentElement.clientWidth || 0;\n const viewportHeight =\n win.innerHeight || win.document.documentElement.clientHeight || 0;\n\n const isRectVisible =\n rect.width > 0 &&\n rect.height > 0 &&\n rect.bottom > 0 &&\n rect.right > 0 &&\n rect.top < viewportHeight &&\n rect.left < viewportWidth;\n\n const style = win.getComputedStyle?.(el);\n const isStyleVisible =\n !!style &&\n style.display !== 'none' &&\n style.visibility !== 'hidden' &&\n (parseFloat(style.opacity) || 0) > 0;\n\n const isVisible = isStyleVisible && isRectVisible;\n\n let ratio = 0;\n if (isVisible) {\n const xOverlap = Math.max(\n 0,\n Math.min(rect.right, viewportWidth) - Math.max(rect.left, 0),\n );\n const yOverlap = Math.max(\n 0,\n Math.min(rect.bottom, viewportHeight) - Math.max(rect.top, 0),\n );\n const intersectionArea = xOverlap * yOverlap;\n const elementArea = rect.width * rect.height;\n ratio = elementArea > 0 ? intersectionArea / elementArea : 0;\n }\n\n return {\n isVisible,\n ratio,\n };\n}\n\nexport default {\n childNodes,\n parentNode,\n parentElement,\n textContent,\n contains,\n getRootNode,\n host,\n styleSheets,\n shadowRoot,\n querySelector,\n querySelectorAll,\n mutationObserver: mutationObserverCtor,\n patch,\n describeNode,\n getElementVisibility,\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;AAcA,MAAM,oBAAoB;EACxB,MAAM,CAAC,cAAc,cAAc,iBAAiB,aAAa;EACjE,YAAY,CAAC,QAAQ,aAAa;EAClC,SAAS,CAAC,cAAc,iBAAiB,kBAAkB;EAC3D,kBAAkB,CAAC;AACrB;AAEA,MAAM,kBAAkB;EACtB,MAAM,CAAC,YAAY,aAAa;EAChC,YAAY,CAAC,cAAc;EAC3B,SAAS,CAAC;EACV,kBAAkB,CAAC,aAAa;AAClC;AAEA,MAAM,yBAAsD,CAAA;AAerD,MAAM,uBAAuB,MAAe;AAC1C,SAAA,CAAC,CAAE,WAAkC;AAC9C;AAEO,SAAS,sBACd,KACuB;AACvB,MAAI,uBAAuB,GAAG;AAC5B,WAAO,uBAAuB,GAAG;AAE7B,QAAA,aAAa,WAAW,GAAG;AACjC,QAAM,mBAAmB,WAAW;AAGpC,QAAM,gBACJ,OAAO,oBAAoB,kBAAkB,GAAG,IAAI;AACtD,QAAM,uBAAuB;IAC3B;IAEE,cAAc;MAAM,CAAC,aACnB;;AAAA,eAAA;WACE,MAAA,KAAA,OAAO,yBAAyB,kBAAkB,QAAQ,MAA1D,OAAA,SAAA,GACI,QADJ,OAAA,SAAA,GACS,SAAA,EACN,SAAS,eAAA;QACd;MAAA;IACF;EAAA;AAGJ,QAAM,cAAc,OAAO,kBAAkB,gBAAgB,GAAG,IAAI;AACpE,QAAM,qBAAqB;IACzB,eACE,YAAY;;MAEV,CAAC,WACC;;AAAA,eAAA,OAAO,iBAAiB,MAAM,MAAM,gBACpC,KAAA,iBAAiB,MAAM,MAAvB,OAAA,SAAA,GAA0B,SAAA,EAAW,SAAS,eAAA;MAAA;IAClD;EAAA;AAGJ,MAAI,wBAAwB,sBAAsB,CAAC,qBAAA,GAAwB;AAClD,2BAAA,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BAAmB,WAAW;AAC9B,UAAA,cAAc,KAAK,QAAQ,KAAK;AAC9B,YAAA,cAAc,IAAI,mBAAmB,cAAc;EAC7D;AAEO,SAAA;IACL;IACA;EAAA;AAEJ;AAEA,MAAe,QAAA;EACb;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,kBAAkB;EAClB;EACA;EACA;AACF;;;;;;;;;;;;;;;;;;;;;",
|
|
6
|
+
"names": ["_a"]
|
|
7
7
|
}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
}(this, () => {
|
|
12
12
|
var exports = {};
|
|
13
13
|
var module = { exports };
|
|
14
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
14
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const N={Node:["childNodes","parentNode","parentElement","textContent"],ShadowRoot:["host","styleSheets"],Element:["shadowRoot","querySelector","querySelectorAll"],MutationObserver:[]},S={Node:["contains","getRootNode"],ShadowRoot:["getSelection"],Element:[],MutationObserver:["constructor"]},d={},w=()=>!!globalThis.Zone;function h(t){if(d[t])return d[t];const e=globalThis[t],r=e.prototype,o=t in N?N[t]:void 0,n=!!(o&&o.every(s=>{var i,u;return!!((u=(i=Object.getOwnPropertyDescriptor(r,s))==null?void 0:i.get)!=null&&u.toString().includes("[native code]"))})),c=t in S?S[t]:void 0,l=!!(c&&c.every(s=>{var i;return typeof r[s]=="function"&&((i=r[s])==null?void 0:i.toString().includes("[native code]"))}));if(n&&l&&!w())return d[t]=e.prototype,e.prototype;try{const s=document.createElement("iframe");document.body.appendChild(s);const i=s.contentWindow;if(!i)return e.prototype;const u=i[t].prototype;return document.body.removeChild(s),u?d[t]=u:r}catch(s){return r}}const p={};function a(t,e,r){var o;const n=`${t}.${String(r)}`;if(p[n])return p[n].call(e);const c=h(t),l=(o=Object.getOwnPropertyDescriptor(c,r))==null?void 0:o.get;return l?(p[n]=l,l.call(e)):e[r]}const f={};function g(t,e,r){const o=`${t}.${String(r)}`;if(f[o])return f[o].bind(e);const c=h(t)[r];return typeof c!="function"?e[r]:(f[o]=c,c.bind(e))}function M(t){return a("Node",t,"childNodes")}function O(t){return a("Node",t,"parentNode")}function A(t){return a("Node",t,"parentElement")}function E(t){return a("Node",t,"textContent")}function R(t,e){return g("Node",t,"contains")(e)}function C(t){return g("Node",t,"getRootNode")()}function P(t){return!t||!("host"in t)?null:a("ShadowRoot",t,"host")}function _(t){return t.styleSheets}function x(t){return!t||!("shadowRoot"in t)?null:a("Element",t,"shadowRoot")}function q(t,e){return a("Element",t,"querySelector")(e)}function U(t,e){return a("Element",t,"querySelectorAll")(e)}function $(){return h("MutationObserver").constructor}function j(t,e,r){try{if(!(e in t))return()=>{};const o=t[e],n=r(o);return typeof n=="function"&&(n.prototype=n.prototype||{},Object.defineProperties(n,{__rrweb_original__:{enumerable:!1,value:o}})),t[e]=n,()=>{t[e]=o}}catch(o){return()=>{}}}function V(t){const e=t.tagName.toLowerCase(),r=t.id?`#${t.id}`:"",o=t.classList.length?"."+Array.from(t.classList).join("."):"";return`${e}${r}${o}`}function B(t){var b;var e,r;const o=(b=(e=t.ownerDocument)==null?void 0:e.defaultView)!=null?b:window,n=t.getBoundingClientRect(),c=o.innerWidth||o.document.documentElement.clientWidth||0,l=o.innerHeight||o.document.documentElement.clientHeight||0,s=n.width>0&&n.height>0&&n.bottom>0&&n.right>0&&n.top<l&&n.left<c,i=(r=o.getComputedStyle)==null?void 0:r.call(o,t),y=!!i&&i.display!=="none"&&i.visibility!=="hidden"&&(parseFloat(i.opacity)||0)>0&&s;let m=0;if(y){const W=Math.max(0,Math.min(n.right,c)-Math.max(n.left,0)),D=Math.max(0,Math.min(n.bottom,l)-Math.max(n.top,0)),H=W*D,v=n.width*n.height;m=v>0?H/v:0}return{isVisible:y,ratio:m}}const L={childNodes:M,parentNode:O,parentElement:A,textContent:E,contains:R,getRootNode:C,host:P,styleSheets:_,shadowRoot:x,querySelector:q,querySelectorAll:U,mutationObserver:$,patch:j,describeNode:V,getElementVisibility:B};exports.childNodes=M;exports.contains=R;exports.default=L;exports.describeNode=V;exports.getElementVisibility=B;exports.getRootNode=C;exports.getUntaintedAccessor=a;exports.getUntaintedMethod=g;exports.getUntaintedPrototype=h;exports.host=P;exports.isAngularZonePresent=w;exports.mutationObserverCtor=$;exports.parentElement=A;exports.parentNode=O;exports.patch=j;exports.querySelector=q;exports.querySelectorAll=U;exports.shadowRoot=x;exports.styleSheets=_;exports.textContent=E;
|
|
15
15
|
if (typeof module.exports == "object" && typeof exports == "object") {
|
|
16
16
|
var __cp = (to, from, except, desc) => {
|
|
17
17
|
if ((from && typeof from === "object") || typeof from === "function") {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["type PrototypeOwner = Node | ShadowRoot | MutationObserver | Element;\ntype TypeofPrototypeOwner =\n | typeof Node\n | typeof ShadowRoot\n | typeof MutationObserver\n | typeof Element;\n\ntype BasePrototypeCache = {\n Node: typeof Node.prototype;\n ShadowRoot: typeof ShadowRoot.prototype;\n MutationObserver: typeof MutationObserver.prototype;\n Element: typeof Element.prototype;\n};\n\nconst testableAccessors = {\n Node: ['childNodes', 'parentNode', 'parentElement', 'textContent'] as const,\n ShadowRoot: ['host', 'styleSheets'] as const,\n Element: ['shadowRoot', 'querySelector', 'querySelectorAll'] as const,\n MutationObserver: [] as const,\n} as const;\n\nconst testableMethods = {\n Node: ['contains', 'getRootNode'] as const,\n ShadowRoot: ['getSelection'],\n Element: [],\n MutationObserver: ['constructor'],\n} as const;\n\nconst untaintedBasePrototype: Partial<BasePrototypeCache> = {};\n\n/*\n When angular patches things - particularly the MutationObserver -\n they pass the `isNativeFunction` check\n That then causes performance issues\n because Angular's change detection\n doesn't like sharing a mutation observer\n Checking for the presence of the Zone object\n on global is a good-enough proxy for Angular\n to cover most cases\n (you can configure zone.js to have a different name\n on the global object and should then manually run rrweb\n outside the Zone)\n */\nexport const isAngularZonePresent = (): boolean => {\n return !!(globalThis as { Zone?: unknown }).Zone;\n};\n\nexport function getUntaintedPrototype<T extends keyof BasePrototypeCache>(\n key: T,\n): BasePrototypeCache[T] {\n if (untaintedBasePrototype[key])\n return untaintedBasePrototype[key] as BasePrototypeCache[T];\n\n const defaultObj = globalThis[key] as TypeofPrototypeOwner;\n const defaultPrototype = defaultObj.prototype as BasePrototypeCache[T];\n\n // use list of testable accessors to check if the prototype is tainted\n const accessorNames =\n key in testableAccessors ? testableAccessors[key] : undefined;\n const isUntaintedAccessors = Boolean(\n accessorNames &&\n // @ts-expect-error 2345\n accessorNames.every((accessor: keyof typeof defaultPrototype) =>\n Boolean(\n Object.getOwnPropertyDescriptor(defaultPrototype, accessor)\n ?.get?.toString()\n .includes('[native code]'),\n ),\n ),\n );\n\n const methodNames = key in testableMethods ? testableMethods[key] : undefined;\n const isUntaintedMethods = Boolean(\n methodNames &&\n methodNames.every(\n // @ts-expect-error 2345\n (method: keyof typeof defaultPrototype) =>\n typeof defaultPrototype[method] === 'function' &&\n defaultPrototype[method]?.toString().includes('[native code]'),\n ),\n );\n\n if (isUntaintedAccessors && isUntaintedMethods && !isAngularZonePresent()) {\n untaintedBasePrototype[key] = defaultObj.prototype as BasePrototypeCache[T];\n return defaultObj.prototype as BasePrototypeCache[T];\n }\n\n try {\n const iframeEl = document.createElement('iframe');\n document.body.appendChild(iframeEl);\n const win = iframeEl.contentWindow;\n if (!win) return defaultObj.prototype as BasePrototypeCache[T];\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n const untaintedObject = (win as any)[key]\n .prototype as BasePrototypeCache[T];\n // cleanup\n document.body.removeChild(iframeEl);\n\n if (!untaintedObject) return defaultPrototype;\n\n return (untaintedBasePrototype[key] = untaintedObject);\n } catch {\n return defaultPrototype;\n }\n}\n\nconst untaintedAccessorCache: Record<\n string,\n (this: PrototypeOwner, ...args: unknown[]) => unknown\n> = {};\n\nexport function getUntaintedAccessor<\n K extends keyof BasePrototypeCache,\n T extends keyof BasePrototypeCache[K],\n>(\n key: K,\n instance: BasePrototypeCache[K],\n accessor: T,\n): BasePrototypeCache[K][T] {\n const cacheKey = `${key}.${String(accessor)}`;\n if (untaintedAccessorCache[cacheKey])\n return untaintedAccessorCache[cacheKey].call(\n instance,\n ) as BasePrototypeCache[K][T];\n\n const untaintedPrototype = getUntaintedPrototype(key);\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const untaintedAccessor = Object.getOwnPropertyDescriptor(\n untaintedPrototype,\n accessor,\n )?.get;\n\n if (!untaintedAccessor) return instance[accessor];\n\n untaintedAccessorCache[cacheKey] = untaintedAccessor;\n\n return untaintedAccessor.call(instance) as BasePrototypeCache[K][T];\n}\n\ntype BaseMethod<K extends keyof BasePrototypeCache> = (\n this: BasePrototypeCache[K],\n ...args: unknown[]\n) => unknown;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst untaintedMethodCache: Record<string, BaseMethod<any>> = {};\nexport function getUntaintedMethod<\n K extends keyof BasePrototypeCache,\n T extends keyof BasePrototypeCache[K],\n>(\n key: K,\n instance: BasePrototypeCache[K],\n method: T,\n): BasePrototypeCache[K][T] {\n const cacheKey = `${key}.${String(method)}`;\n if (untaintedMethodCache[cacheKey])\n return untaintedMethodCache[cacheKey].bind(\n instance,\n ) as BasePrototypeCache[K][T];\n\n const untaintedPrototype = getUntaintedPrototype(key);\n const untaintedMethod = untaintedPrototype[method];\n\n if (typeof untaintedMethod !== 'function') return instance[method];\n\n untaintedMethodCache[cacheKey] = untaintedMethod as BaseMethod<K>;\n\n return untaintedMethod.bind(instance) as BasePrototypeCache[K][T];\n}\n\nexport function childNodes(n: Node): NodeListOf<Node> {\n return getUntaintedAccessor('Node', n, 'childNodes');\n}\n\nexport function parentNode(n: Node): ParentNode | null {\n return getUntaintedAccessor('Node', n, 'parentNode');\n}\n\nexport function parentElement(n: Node): HTMLElement | null {\n return getUntaintedAccessor('Node', n, 'parentElement');\n}\n\nexport function textContent(n: Node): string | null {\n return getUntaintedAccessor('Node', n, 'textContent');\n}\n\nexport function contains(n: Node, other: Node): boolean {\n return getUntaintedMethod('Node', n, 'contains')(other);\n}\n\nexport function getRootNode(n: Node): Node {\n return getUntaintedMethod('Node', n, 'getRootNode')();\n}\n\nexport function host(n: ShadowRoot): Element | null {\n if (!n || !('host' in n)) return null;\n return getUntaintedAccessor('ShadowRoot', n, 'host');\n}\n\nexport function styleSheets(n: ShadowRoot): StyleSheetList {\n return n.styleSheets;\n}\n\nexport function shadowRoot(n: Node): ShadowRoot | null {\n if (!n || !('shadowRoot' in n)) return null;\n return getUntaintedAccessor('Element', n as Element, 'shadowRoot');\n}\n\nexport function querySelector(n: Element, selectors: string): Element | null {\n return getUntaintedAccessor('Element', n, 'querySelector')(selectors);\n}\n\nexport function querySelectorAll(\n n: Element,\n selectors: string,\n): NodeListOf<Element> {\n return getUntaintedAccessor('Element', n, 'querySelectorAll')(selectors);\n}\n\nexport function mutationObserverCtor(): (typeof MutationObserver)['prototype']['constructor'] {\n return getUntaintedPrototype('MutationObserver').constructor;\n}\n\n// copy from https://github.com/getsentry/sentry-javascript/blob/b2109071975af8bf0316d3b5b38f519bdaf5dc15/packages/utils/src/object.ts\nexport function patch(\n source: { [key: string]: any },\n name: string,\n replacement: (...args: unknown[]) => unknown,\n): () => void {\n try {\n if (!(name in source)) {\n return () => {\n //\n };\n }\n\n const original = source[name] as () => unknown;\n const wrapped = replacement(original);\n\n // Make sure it's a function first, as we need to attach an empty prototype for `defineProperties` to work\n // otherwise it'll throw \"TypeError: Object.defineProperties called on non-object\"\n if (typeof wrapped === 'function') {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n wrapped.prototype = wrapped.prototype || {};\n Object.defineProperties(wrapped, {\n __rrweb_original__: {\n enumerable: false,\n value: original,\n },\n });\n }\n\n source[name] = wrapped;\n\n return () => {\n source[name] = original;\n };\n } catch {\n return () => {\n //\n };\n // This can throw if multiple fill happens on a global object like XMLHttpRequest\n // Fixes https://github.com/getsentry/sentry-javascript/issues/2043\n }\n}\n\nexport default {\n childNodes,\n parentNode,\n parentElement,\n textContent,\n contains,\n getRootNode,\n host,\n styleSheets,\n shadowRoot,\n querySelector,\n querySelectorAll,\n mutationObserver: mutationObserverCtor,\n patch,\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;4GAcA,MAAMA,EAAoB,CACxB,KAAM,CAAC,aAAc,aAAc,gBAAiB,aAAa,EACjE,WAAY,CAAC,OAAQ,aAAa,EAClC,QAAS,CAAC,aAAc,gBAAiB,kBAAkB,EAC3D,iBAAkB,CAAC,CACrB,EAEMC,EAAkB,CACtB,KAAM,CAAC,WAAY,aAAa,EAChC,WAAY,CAAC,cAAc,EAC3B,QAAS,CAAC,EACV,iBAAkB,CAAC,aAAa,CAClC,EAEMC,EAAsD,CAAA,EAe/CC,EAAuB,IAC3B,CAAC,CAAE,WAAkC,KAGvC,SAASC,EACdC,EACuB,CACvB,GAAIH,EAAuBG,CAAG,EAC5B,OAAOH,EAAuBG,CAAG,EAE7B,MAAAC,EAAa,WAAWD,CAAG,EAC3BE,EAAmBD,EAAW,UAG9BE,EACJH,KAAOL,EAAoBA,EAAkBK,CAAG,EAAI,OAChDI,EAAuB,GAC3BD,GAEEA,EAAc,MAAOE,GACnB,SAAA,MAAA,IACEC,GAAAC,EAAA,OAAO,yBAAyBL,EAAkBG,CAAQ,IAA1D,KAAA,OAAAE,EACI,MADJ,MAAAD,EACS,SAAA,EACN,SAAS,eAAA,EACd,CACF,GAGEE,EAAcR,KAAOJ,EAAkBA,EAAgBI,CAAG,EAAI,OAC9DS,EAAqB,GACzBD,GACEA,EAAY,MAETE,GACC,OAAA,OAAA,OAAOR,EAAiBQ,CAAM,GAAM,cACpCH,EAAAL,EAAiBQ,CAAM,IAAvB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A,EAAQ,WAAa,CAAA,EACzC,OAAO,iBAAiBA,EAAS,CAC/B,mBAAoB,CAClB,WAAY,GACZ,MAAOD,CACT,CAAA,CACD,GAGHH,EAAOC,CAAI,EAAIG,EAER,IAAM,CACXJ,EAAOC,CAAI,EAAIE,CAAA,CACjB,OACM7B,EAAA,CACN,MAAO,IAAM,CAAA,CAKf,CACF,
|
|
6
|
-
"names": ["testableAccessors", "testableMethods", "untaintedBasePrototype", "isAngularZonePresent", "getUntaintedPrototype", "key", "defaultObj", "defaultPrototype", "accessorNames", "isUntaintedAccessors", "accessor", "_b", "_a", "methodNames", "isUntaintedMethods", "method", "iframeEl", "win", "untaintedObject", "e", "untaintedAccessorCache", "getUntaintedAccessor", "instance", "cacheKey", "untaintedPrototype", "untaintedAccessor", "untaintedMethodCache", "getUntaintedMethod", "untaintedMethod", "childNodes", "n", "parentNode", "parentElement", "textContent", "contains", "other", "getRootNode", "host", "styleSheets", "shadowRoot", "querySelector", "selectors", "querySelectorAll", "mutationObserverCtor", "patch", "source", "name", "replacement", "original", "wrapped", "index"]
|
|
4
|
+
"sourcesContent": ["type PrototypeOwner = Node | ShadowRoot | MutationObserver | Element;\ntype TypeofPrototypeOwner =\n | typeof Node\n | typeof ShadowRoot\n | typeof MutationObserver\n | typeof Element;\n\ntype BasePrototypeCache = {\n Node: typeof Node.prototype;\n ShadowRoot: typeof ShadowRoot.prototype;\n MutationObserver: typeof MutationObserver.prototype;\n Element: typeof Element.prototype;\n};\n\nconst testableAccessors = {\n Node: ['childNodes', 'parentNode', 'parentElement', 'textContent'] as const,\n ShadowRoot: ['host', 'styleSheets'] as const,\n Element: ['shadowRoot', 'querySelector', 'querySelectorAll'] as const,\n MutationObserver: [] as const,\n} as const;\n\nconst testableMethods = {\n Node: ['contains', 'getRootNode'] as const,\n ShadowRoot: ['getSelection'],\n Element: [],\n MutationObserver: ['constructor'],\n} as const;\n\nconst untaintedBasePrototype: Partial<BasePrototypeCache> = {};\n\n/*\n When angular patches things - particularly the MutationObserver -\n they pass the `isNativeFunction` check\n That then causes performance issues\n because Angular's change detection\n doesn't like sharing a mutation observer\n Checking for the presence of the Zone object\n on global is a good-enough proxy for Angular\n to cover most cases\n (you can configure zone.js to have a different name\n on the global object and should then manually run rrweb\n outside the Zone)\n */\nexport const isAngularZonePresent = (): boolean => {\n return !!(globalThis as { Zone?: unknown }).Zone;\n};\n\nexport function getUntaintedPrototype<T extends keyof BasePrototypeCache>(\n key: T,\n): BasePrototypeCache[T] {\n if (untaintedBasePrototype[key])\n return untaintedBasePrototype[key] as BasePrototypeCache[T];\n\n const defaultObj = globalThis[key] as TypeofPrototypeOwner;\n const defaultPrototype = defaultObj.prototype as BasePrototypeCache[T];\n\n // use list of testable accessors to check if the prototype is tainted\n const accessorNames =\n key in testableAccessors ? testableAccessors[key] : undefined;\n const isUntaintedAccessors = Boolean(\n accessorNames &&\n // @ts-expect-error 2345\n accessorNames.every((accessor: keyof typeof defaultPrototype) =>\n Boolean(\n Object.getOwnPropertyDescriptor(defaultPrototype, accessor)\n ?.get?.toString()\n .includes('[native code]'),\n ),\n ),\n );\n\n const methodNames = key in testableMethods ? testableMethods[key] : undefined;\n const isUntaintedMethods = Boolean(\n methodNames &&\n methodNames.every(\n // @ts-expect-error 2345\n (method: keyof typeof defaultPrototype) =>\n typeof defaultPrototype[method] === 'function' &&\n defaultPrototype[method]?.toString().includes('[native code]'),\n ),\n );\n\n if (isUntaintedAccessors && isUntaintedMethods && !isAngularZonePresent()) {\n untaintedBasePrototype[key] = defaultObj.prototype as BasePrototypeCache[T];\n return defaultObj.prototype as BasePrototypeCache[T];\n }\n\n try {\n const iframeEl = document.createElement('iframe');\n document.body.appendChild(iframeEl);\n const win = iframeEl.contentWindow;\n if (!win) return defaultObj.prototype as BasePrototypeCache[T];\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n const untaintedObject = (win as any)[key]\n .prototype as BasePrototypeCache[T];\n // cleanup\n document.body.removeChild(iframeEl);\n\n if (!untaintedObject) return defaultPrototype;\n\n return (untaintedBasePrototype[key] = untaintedObject);\n } catch {\n return defaultPrototype;\n }\n}\n\nconst untaintedAccessorCache: Record<\n string,\n (this: PrototypeOwner, ...args: unknown[]) => unknown\n> = {};\n\nexport function getUntaintedAccessor<\n K extends keyof BasePrototypeCache,\n T extends keyof BasePrototypeCache[K],\n>(\n key: K,\n instance: BasePrototypeCache[K],\n accessor: T,\n): BasePrototypeCache[K][T] {\n const cacheKey = `${key}.${String(accessor)}`;\n if (untaintedAccessorCache[cacheKey])\n return untaintedAccessorCache[cacheKey].call(\n instance,\n ) as BasePrototypeCache[K][T];\n\n const untaintedPrototype = getUntaintedPrototype(key);\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const untaintedAccessor = Object.getOwnPropertyDescriptor(\n untaintedPrototype,\n accessor,\n )?.get;\n\n if (!untaintedAccessor) return instance[accessor];\n\n untaintedAccessorCache[cacheKey] = untaintedAccessor;\n\n return untaintedAccessor.call(instance) as BasePrototypeCache[K][T];\n}\n\ntype BaseMethod<K extends keyof BasePrototypeCache> = (\n this: BasePrototypeCache[K],\n ...args: unknown[]\n) => unknown;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst untaintedMethodCache: Record<string, BaseMethod<any>> = {};\nexport function getUntaintedMethod<\n K extends keyof BasePrototypeCache,\n T extends keyof BasePrototypeCache[K],\n>(\n key: K,\n instance: BasePrototypeCache[K],\n method: T,\n): BasePrototypeCache[K][T] {\n const cacheKey = `${key}.${String(method)}`;\n if (untaintedMethodCache[cacheKey])\n return untaintedMethodCache[cacheKey].bind(\n instance,\n ) as BasePrototypeCache[K][T];\n\n const untaintedPrototype = getUntaintedPrototype(key);\n const untaintedMethod = untaintedPrototype[method];\n\n if (typeof untaintedMethod !== 'function') return instance[method];\n\n untaintedMethodCache[cacheKey] = untaintedMethod as BaseMethod<K>;\n\n return untaintedMethod.bind(instance) as BasePrototypeCache[K][T];\n}\n\nexport function childNodes(n: Node): NodeListOf<Node> {\n return getUntaintedAccessor('Node', n, 'childNodes');\n}\n\nexport function parentNode(n: Node): ParentNode | null {\n return getUntaintedAccessor('Node', n, 'parentNode');\n}\n\nexport function parentElement(n: Node): HTMLElement | null {\n return getUntaintedAccessor('Node', n, 'parentElement');\n}\n\nexport function textContent(n: Node): string | null {\n return getUntaintedAccessor('Node', n, 'textContent');\n}\n\nexport function contains(n: Node, other: Node): boolean {\n return getUntaintedMethod('Node', n, 'contains')(other);\n}\n\nexport function getRootNode(n: Node): Node {\n return getUntaintedMethod('Node', n, 'getRootNode')();\n}\n\nexport function host(n: ShadowRoot): Element | null {\n if (!n || !('host' in n)) return null;\n return getUntaintedAccessor('ShadowRoot', n, 'host');\n}\n\nexport function styleSheets(n: ShadowRoot): StyleSheetList {\n return n.styleSheets;\n}\n\nexport function shadowRoot(n: Node): ShadowRoot | null {\n if (!n || !('shadowRoot' in n)) return null;\n return getUntaintedAccessor('Element', n as Element, 'shadowRoot');\n}\n\nexport function querySelector(n: Element, selectors: string): Element | null {\n return getUntaintedAccessor('Element', n, 'querySelector')(selectors);\n}\n\nexport function querySelectorAll(\n n: Element,\n selectors: string,\n): NodeListOf<Element> {\n return getUntaintedAccessor('Element', n, 'querySelectorAll')(selectors);\n}\n\nexport function mutationObserverCtor(): (typeof MutationObserver)['prototype']['constructor'] {\n return getUntaintedPrototype('MutationObserver').constructor;\n}\n\n// copy from https://github.com/getsentry/sentry-javascript/blob/b2109071975af8bf0316d3b5b38f519bdaf5dc15/packages/utils/src/object.ts\nexport function patch(\n source: { [key: string]: any },\n name: string,\n replacement: (...args: unknown[]) => unknown,\n): () => void {\n try {\n if (!(name in source)) {\n return () => {\n //\n };\n }\n\n const original = source[name] as () => unknown;\n const wrapped = replacement(original);\n\n // Make sure it's a function first, as we need to attach an empty prototype for `defineProperties` to work\n // otherwise it'll throw \"TypeError: Object.defineProperties called on non-object\"\n if (typeof wrapped === 'function') {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n wrapped.prototype = wrapped.prototype || {};\n Object.defineProperties(wrapped, {\n __rrweb_original__: {\n enumerable: false,\n value: original,\n },\n });\n }\n\n source[name] = wrapped;\n\n return () => {\n source[name] = original;\n };\n } catch {\n return () => {\n //\n };\n // This can throw if multiple fill happens on a global object like XMLHttpRequest\n // Fixes https://github.com/getsentry/sentry-javascript/issues/2043\n }\n}\n\nexport function describeNode(el: Element): string {\n const tag = el.tagName.toLowerCase();\n const id = el.id ? `#${el.id}` : '';\n const classes = el.classList.length\n ? '.' + Array.from(el.classList).join('.')\n : '';\n return `${tag}${id}${classes}`;\n}\n\nexport function getElementVisibility(el: Element): {\n isVisible: boolean;\n ratio: number;\n} {\n const win = el.ownerDocument?.defaultView ?? window;\n const rect = el.getBoundingClientRect();\n\n const viewportWidth =\n win.innerWidth || win.document.documentElement.clientWidth || 0;\n const viewportHeight =\n win.innerHeight || win.document.documentElement.clientHeight || 0;\n\n const isRectVisible =\n rect.width > 0 &&\n rect.height > 0 &&\n rect.bottom > 0 &&\n rect.right > 0 &&\n rect.top < viewportHeight &&\n rect.left < viewportWidth;\n\n const style = win.getComputedStyle?.(el);\n const isStyleVisible =\n !!style &&\n style.display !== 'none' &&\n style.visibility !== 'hidden' &&\n (parseFloat(style.opacity) || 0) > 0;\n\n const isVisible = isStyleVisible && isRectVisible;\n\n let ratio = 0;\n if (isVisible) {\n const xOverlap = Math.max(\n 0,\n Math.min(rect.right, viewportWidth) - Math.max(rect.left, 0),\n );\n const yOverlap = Math.max(\n 0,\n Math.min(rect.bottom, viewportHeight) - Math.max(rect.top, 0),\n );\n const intersectionArea = xOverlap * yOverlap;\n const elementArea = rect.width * rect.height;\n ratio = elementArea > 0 ? intersectionArea / elementArea : 0;\n }\n\n return {\n isVisible,\n ratio,\n };\n}\n\nexport default {\n childNodes,\n parentNode,\n parentElement,\n textContent,\n contains,\n getRootNode,\n host,\n styleSheets,\n shadowRoot,\n querySelector,\n querySelect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A,CAEJ,CAEA,MAAeK,EAAA,CACb,WAAAtC,EACA,WAAAE,EACA,cAAAC,EACA,YAAAC,EACA,SAAAC,EACA,YAAAE,EACA,KAAAC,EACA,YAAAC,EACA,WAAAC,EACA,cAAAC,EACA,iBAAAE,EACA,iBAAkBC,EAClB,MAAAC,EACA,aAAAM,EACA,qBAAAK,CACF",
|
|
6
|
+
"names": ["testableAccessors", "testableMethods", "untaintedBasePrototype", "isAngularZonePresent", "getUntaintedPrototype", "key", "defaultObj", "defaultPrototype", "accessorNames", "isUntaintedAccessors", "accessor", "_b", "_a", "methodNames", "isUntaintedMethods", "method", "iframeEl", "win", "untaintedObject", "e", "untaintedAccessorCache", "getUntaintedAccessor", "instance", "cacheKey", "untaintedPrototype", "untaintedAccessor", "untaintedMethodCache", "getUntaintedMethod", "untaintedMethod", "childNodes", "n", "parentNode", "parentElement", "textContent", "contains", "other", "getRootNode", "host", "styleSheets", "shadowRoot", "querySelector", "selectors", "querySelectorAll", "mutationObserverCtor", "patch", "source", "name", "replacement", "original", "wrapped", "describeNode", "el", "tag", "id", "classes", "getElementVisibility", "rect", "viewportWidth", "viewportHeight", "isRectVisible", "style", "isVisible", "ratio", "xOverlap", "yOverlap", "intersectionArea", "elementArea", "index"]
|
|
7
7
|
}
|