rrdom-nodejs
Advanced tools
+117
| import { BaseRRCDATASection } from 'rrdom'; | ||
| import { BaseRRComment } from 'rrdom'; | ||
| import { BaseRRDocument } from 'rrdom'; | ||
| import { BaseRRDocumentType } from 'rrdom'; | ||
| import { BaseRRElement } from 'rrdom'; | ||
| import { BaseRRMediaElement } from 'rrdom'; | ||
| import { BaseRRNode } from 'rrdom'; | ||
| import { BaseRRText } from 'rrdom'; | ||
| import { CSSStyleDeclaration as CSSStyleDeclaration_2 } from 'rrdom'; | ||
| import { IRRDocument } from 'rrdom'; | ||
| import { IRRNode } from 'rrdom'; | ||
| import { NWSAPI } from 'nwsapi'; | ||
| export declare class RRCanvasElement extends RRElement { | ||
| getContext(): CanvasRenderingContext2D | null; | ||
| } | ||
| export declare class RRCDATASection extends BaseRRCDATASection { | ||
| readonly nodeName: "#cdata-section"; | ||
| } | ||
| export declare class RRComment extends BaseRRComment { | ||
| readonly nodeName: "#comment"; | ||
| } | ||
| export declare class RRDocument extends BaseRRDocument implements IRRDocument { | ||
| readonly nodeName: "#document"; | ||
| private _nwsapi; | ||
| get nwsapi(): NWSAPI; | ||
| get documentElement(): RRElement | null; | ||
| get body(): RRElement | null; | ||
| get head(): RRElement | null; | ||
| get implementation(): RRDocument; | ||
| get firstElementChild(): RRElement | null; | ||
| appendChild(childNode: BaseRRNode): IRRNode; | ||
| insertBefore(newChild: BaseRRNode, refChild: BaseRRNode | null): IRRNode; | ||
| querySelectorAll(selectors: string): BaseRRNode[]; | ||
| getElementsByTagName(tagName: string): RRElement[]; | ||
| getElementsByClassName(className: string): RRElement[]; | ||
| getElementById(elementId: string): RRElement | null; | ||
| createDocument(_namespace: string | null, _qualifiedName: string | null, _doctype?: DocumentType | null): RRDocument; | ||
| createDocumentType(qualifiedName: string, publicId: string, systemId: string): RRDocumentType; | ||
| createElement<K extends keyof HTMLElementTagNameMap>(tagName: K): RRElementType<K>; | ||
| createElement(tagName: string): RRElement; | ||
| createElementNS(_namespaceURI: string, qualifiedName: string): RRElement | RRMediaElement | RRCanvasElement | RRIFrameElement | RRImageElement | RRStyleElement; | ||
| createComment(data: string): RRComment; | ||
| createCDATASection(data: string): RRCDATASection; | ||
| createTextNode(data: string): RRText; | ||
| } | ||
| export declare class RRDocumentType extends BaseRRDocumentType { | ||
| } | ||
| export declare class RRElement extends BaseRRElement { | ||
| private _style; | ||
| constructor(tagName: string); | ||
| get style(): CSSStyleDeclaration_2; | ||
| attachShadow(_init: ShadowRootInit): RRElement; | ||
| appendChild(newChild: BaseRRNode): BaseRRNode; | ||
| insertBefore(newChild: BaseRRNode, refChild: BaseRRNode | null): BaseRRNode; | ||
| getAttribute(name: string): string | null; | ||
| setAttribute(name: string, attribute: string): void; | ||
| removeAttribute(name: string): void; | ||
| get firstElementChild(): RRElement | null; | ||
| get nextElementSibling(): RRElement | null; | ||
| querySelectorAll(selectors: string): BaseRRNode[]; | ||
| getElementById(elementId: string): RRElement | null; | ||
| getElementsByClassName(className: string): RRElement[]; | ||
| getElementsByTagName(tagName: string): RRElement[]; | ||
| } | ||
| declare interface RRElementTagNameMap { | ||
| audio: RRMediaElement; | ||
| canvas: RRCanvasElement; | ||
| iframe: RRIFrameElement; | ||
| img: RRImageElement; | ||
| style: RRStyleElement; | ||
| video: RRMediaElement; | ||
| } | ||
| declare type RRElementType<K extends keyof HTMLElementTagNameMap> = K extends keyof RRElementTagNameMap ? RRElementTagNameMap[K] : RRElement; | ||
| export declare class RRIFrameElement extends RRElement { | ||
| width: string; | ||
| height: string; | ||
| src: string; | ||
| contentDocument: RRDocument; | ||
| contentWindow: RRWindow; | ||
| constructor(tagName: string); | ||
| } | ||
| export declare class RRImageElement extends RRElement { | ||
| src: string; | ||
| width: number; | ||
| height: number; | ||
| onload: ((this: GlobalEventHandlers, ev: Event) => unknown) | null; | ||
| } | ||
| export declare class RRMediaElement extends BaseRRMediaElement { | ||
| } | ||
| export declare class RRStyleElement extends RRElement { | ||
| private _sheet; | ||
| get sheet(): CSSStyleSheet | null; | ||
| } | ||
| export declare class RRText extends BaseRRText { | ||
| readonly nodeName: "#text"; | ||
| } | ||
| export declare class RRWindow { | ||
| scrollLeft: number; | ||
| scrollTop: number; | ||
| scrollTo(options?: ScrollToOptions): void; | ||
| } | ||
| export { } |
+117
| import { BaseRRCDATASection } from 'rrdom'; | ||
| import { BaseRRComment } from 'rrdom'; | ||
| import { BaseRRDocument } from 'rrdom'; | ||
| import { BaseRRDocumentType } from 'rrdom'; | ||
| import { BaseRRElement } from 'rrdom'; | ||
| import { BaseRRMediaElement } from 'rrdom'; | ||
| import { BaseRRNode } from 'rrdom'; | ||
| import { BaseRRText } from 'rrdom'; | ||
| import { CSSStyleDeclaration as CSSStyleDeclaration_2 } from 'rrdom'; | ||
| import { IRRDocument } from 'rrdom'; | ||
| import { IRRNode } from 'rrdom'; | ||
| import { NWSAPI } from 'nwsapi'; | ||
| export declare class RRCanvasElement extends RRElement { | ||
| getContext(): CanvasRenderingContext2D | null; | ||
| } | ||
| export declare class RRCDATASection extends BaseRRCDATASection { | ||
| readonly nodeName: "#cdata-section"; | ||
| } | ||
| export declare class RRComment extends BaseRRComment { | ||
| readonly nodeName: "#comment"; | ||
| } | ||
| export declare class RRDocument extends BaseRRDocument implements IRRDocument { | ||
| readonly nodeName: "#document"; | ||
| private _nwsapi; | ||
| get nwsapi(): NWSAPI; | ||
| get documentElement(): RRElement | null; | ||
| get body(): RRElement | null; | ||
| get head(): RRElement | null; | ||
| get implementation(): RRDocument; | ||
| get firstElementChild(): RRElement | null; | ||
| appendChild(childNode: BaseRRNode): IRRNode; | ||
| insertBefore(newChild: BaseRRNode, refChild: BaseRRNode | null): IRRNode; | ||
| querySelectorAll(selectors: string): BaseRRNode[]; | ||
| getElementsByTagName(tagName: string): RRElement[]; | ||
| getElementsByClassName(className: string): RRElement[]; | ||
| getElementById(elementId: string): RRElement | null; | ||
| createDocument(_namespace: string | null, _qualifiedName: string | null, _doctype?: DocumentType | null): RRDocument; | ||
| createDocumentType(qualifiedName: string, publicId: string, systemId: string): RRDocumentType; | ||
| createElement<K extends keyof HTMLElementTagNameMap>(tagName: K): RRElementType<K>; | ||
| createElement(tagName: string): RRElement; | ||
| createElementNS(_namespaceURI: string, qualifiedName: string): RRElement | RRMediaElement | RRCanvasElement | RRIFrameElement | RRImageElement | RRStyleElement; | ||
| createComment(data: string): RRComment; | ||
| createCDATASection(data: string): RRCDATASection; | ||
| createTextNode(data: string): RRText; | ||
| } | ||
| export declare class RRDocumentType extends BaseRRDocumentType { | ||
| } | ||
| export declare class RRElement extends BaseRRElement { | ||
| private _style; | ||
| constructor(tagName: string); | ||
| get style(): CSSStyleDeclaration_2; | ||
| attachShadow(_init: ShadowRootInit): RRElement; | ||
| appendChild(newChild: BaseRRNode): BaseRRNode; | ||
| insertBefore(newChild: BaseRRNode, refChild: BaseRRNode | null): BaseRRNode; | ||
| getAttribute(name: string): string | null; | ||
| setAttribute(name: string, attribute: string): void; | ||
| removeAttribute(name: string): void; | ||
| get firstElementChild(): RRElement | null; | ||
| get nextElementSibling(): RRElement | null; | ||
| querySelectorAll(selectors: string): BaseRRNode[]; | ||
| getElementById(elementId: string): RRElement | null; | ||
| getElementsByClassName(className: string): RRElement[]; | ||
| getElementsByTagName(tagName: string): RRElement[]; | ||
| } | ||
| declare interface RRElementTagNameMap { | ||
| audio: RRMediaElement; | ||
| canvas: RRCanvasElement; | ||
| iframe: RRIFrameElement; | ||
| img: RRImageElement; | ||
| style: RRStyleElement; | ||
| video: RRMediaElement; | ||
| } | ||
| declare type RRElementType<K extends keyof HTMLElementTagNameMap> = K extends keyof RRElementTagNameMap ? RRElementTagNameMap[K] : RRElement; | ||
| export declare class RRIFrameElement extends RRElement { | ||
| width: string; | ||
| height: string; | ||
| src: string; | ||
| contentDocument: RRDocument; | ||
| contentWindow: RRWindow; | ||
| constructor(tagName: string); | ||
| } | ||
| export declare class RRImageElement extends RRElement { | ||
| src: string; | ||
| width: number; | ||
| height: number; | ||
| onload: ((this: GlobalEventHandlers, ev: Event) => unknown) | null; | ||
| } | ||
| export declare class RRMediaElement extends BaseRRMediaElement { | ||
| } | ||
| export declare class RRStyleElement extends RRElement { | ||
| private _sheet; | ||
| get sheet(): CSSStyleSheet | null; | ||
| } | ||
| export declare class RRText extends BaseRRText { | ||
| readonly nodeName: "#text"; | ||
| } | ||
| export declare class RRWindow { | ||
| scrollLeft: number; | ||
| scrollTop: number; | ||
| scrollTo(options?: ScrollToOptions): void; | ||
| } | ||
| export { } |
| "use strict"; | ||
| var __defProp = Object.defineProperty; | ||
| var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; | ||
| var __publicField = (obj, key, value) => { | ||
| __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); | ||
| return value; | ||
| }; | ||
| Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); | ||
| var __defProp2 = Object.defineProperty; | ||
| var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; | ||
| var __publicField2 = (obj, key, value) => { | ||
| __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value); | ||
| return value; | ||
| }; | ||
| var NodeType$1 = /* @__PURE__ */ ((NodeType2) => { | ||
| NodeType2[NodeType2["Document"] = 0] = "Document"; | ||
| NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType"; | ||
| NodeType2[NodeType2["Element"] = 2] = "Element"; | ||
| NodeType2[NodeType2["Text"] = 3] = "Text"; | ||
| NodeType2[NodeType2["CDATA"] = 4] = "CDATA"; | ||
| NodeType2[NodeType2["Comment"] = 5] = "Comment"; | ||
| return NodeType2; | ||
| })(NodeType$1 || {}); | ||
| function parseCSSText(cssText) { | ||
| const res = {}; | ||
| const listDelimiter = /;(?![^(]*\))/g; | ||
| const propertyDelimiter = /:(.+)/; | ||
| const comment = /\/\*.*?\*\//g; | ||
| cssText.replace(comment, "").split(listDelimiter).forEach(function(item) { | ||
| if (item) { | ||
| const tmp = item.split(propertyDelimiter); | ||
| tmp.length > 1 && (res[camelize(tmp[0].trim())] = tmp[1].trim()); | ||
| } | ||
| }); | ||
| return res; | ||
| } | ||
| function toCSSText(style) { | ||
| const properties = []; | ||
| for (const name in style) { | ||
| const value = style[name]; | ||
| if (typeof value !== "string") | ||
| continue; | ||
| const normalizedName = hyphenate(name); | ||
| properties.push(`${normalizedName}: ${value};`); | ||
| } | ||
| return properties.join(" "); | ||
| } | ||
| const camelizeRE = /-([a-z])/g; | ||
| const CUSTOM_PROPERTY_REGEX = /^--[a-zA-Z0-9-]+$/; | ||
| const camelize = (str) => { | ||
| if (CUSTOM_PROPERTY_REGEX.test(str)) | ||
| return str; | ||
| return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : ""); | ||
| }; | ||
| const hyphenateRE = /\B([A-Z])/g; | ||
| const hyphenate = (str) => { | ||
| return str.replace(hyphenateRE, "-$1").toLowerCase(); | ||
| }; | ||
| class BaseRRNode { | ||
| // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any | ||
| constructor(..._args) { | ||
| __publicField2(this, "parentElement", null); | ||
| __publicField2(this, "parentNode", null); | ||
| __publicField2(this, "ownerDocument"); | ||
| __publicField2(this, "firstChild", null); | ||
| __publicField2(this, "lastChild", null); | ||
| __publicField2(this, "previousSibling", null); | ||
| __publicField2(this, "nextSibling", null); | ||
| __publicField2(this, "ELEMENT_NODE", 1); | ||
| __publicField2(this, "TEXT_NODE", 3); | ||
| __publicField2(this, "nodeType"); | ||
| __publicField2(this, "nodeName"); | ||
| __publicField2(this, "RRNodeType"); | ||
| } | ||
| get childNodes() { | ||
| const childNodes = []; | ||
| let childIterator = this.firstChild; | ||
| while (childIterator) { | ||
| childNodes.push(childIterator); | ||
| childIterator = childIterator.nextSibling; | ||
| } | ||
| return childNodes; | ||
| } | ||
| contains(node) { | ||
| if (!(node instanceof BaseRRNode)) | ||
| return false; | ||
| else if (node.ownerDocument !== this.ownerDocument) | ||
| return false; | ||
| else if (node === this) | ||
| return true; | ||
| while (node.parentNode) { | ||
| if (node.parentNode === this) | ||
| return true; | ||
| node = node.parentNode; | ||
| } | ||
| return false; | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
| appendChild(_newChild) { | ||
| throw new Error( | ||
| `RRDomException: Failed to execute 'appendChild' on 'RRNode': This RRNode type does not support this method.` | ||
| ); | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
| insertBefore(_newChild, _refChild) { | ||
| throw new Error( | ||
| `RRDomException: Failed to execute 'insertBefore' on 'RRNode': This RRNode type does not support this method.` | ||
| ); | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
| removeChild(_node) { | ||
| throw new Error( | ||
| `RRDomException: Failed to execute 'removeChild' on 'RRNode': This RRNode type does not support this method.` | ||
| ); | ||
| } | ||
| toString() { | ||
| return "RRNode"; | ||
| } | ||
| } | ||
| class BaseRRDocument extends BaseRRNode { | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| constructor(...args) { | ||
| super(args); | ||
| __publicField2(this, "nodeType", 9); | ||
| __publicField2(this, "nodeName", "#document"); | ||
| __publicField2(this, "compatMode", "CSS1Compat"); | ||
| __publicField2(this, "RRNodeType", NodeType$1.Document); | ||
| __publicField2(this, "textContent", null); | ||
| this.ownerDocument = this; | ||
| } | ||
| get documentElement() { | ||
| return this.childNodes.find( | ||
| (node) => node.RRNodeType === NodeType$1.Element && node.tagName === "HTML" | ||
| ) || null; | ||
| } | ||
| get body() { | ||
| var _a; | ||
| return ((_a = this.documentElement) == null ? void 0 : _a.childNodes.find( | ||
| (node) => node.RRNodeType === NodeType$1.Element && node.tagName === "BODY" | ||
| )) || null; | ||
| } | ||
| get head() { | ||
| var _a; | ||
| return ((_a = this.documentElement) == null ? void 0 : _a.childNodes.find( | ||
| (node) => node.RRNodeType === NodeType$1.Element && node.tagName === "HEAD" | ||
| )) || null; | ||
| } | ||
| get implementation() { | ||
| return this; | ||
| } | ||
| get firstElementChild() { | ||
| return this.documentElement; | ||
| } | ||
| appendChild(newChild) { | ||
| const nodeType = newChild.RRNodeType; | ||
| if (nodeType === NodeType$1.Element || nodeType === NodeType$1.DocumentType) { | ||
| if (this.childNodes.some((s) => s.RRNodeType === nodeType)) { | ||
| throw new Error( | ||
| `RRDomException: Failed to execute 'appendChild' on 'RRNode': Only one ${nodeType === NodeType$1.Element ? "RRElement" : "RRDoctype"} on RRDocument allowed.` | ||
| ); | ||
| } | ||
| } | ||
| const child = appendChild(this, newChild); | ||
| child.parentElement = null; | ||
| return child; | ||
| } | ||
| insertBefore(newChild, refChild) { | ||
| const nodeType = newChild.RRNodeType; | ||
| if (nodeType === NodeType$1.Element || nodeType === NodeType$1.DocumentType) { | ||
| if (this.childNodes.some((s) => s.RRNodeType === nodeType)) { | ||
| throw new Error( | ||
| `RRDomException: Failed to execute 'insertBefore' on 'RRNode': Only one ${nodeType === NodeType$1.Element ? "RRElement" : "RRDoctype"} on RRDocument allowed.` | ||
| ); | ||
| } | ||
| } | ||
| const child = insertBefore(this, newChild, refChild); | ||
| child.parentElement = null; | ||
| return child; | ||
| } | ||
| removeChild(node) { | ||
| return removeChild(this, node); | ||
| } | ||
| open() { | ||
| this.firstChild = null; | ||
| this.lastChild = null; | ||
| } | ||
| close() { | ||
| } | ||
| /** | ||
| * Adhoc implementation for setting xhtml namespace in rebuilt.ts (rrweb-snapshot). | ||
| * There are two lines used this function: | ||
| * 1. doc.write('\<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""\>') | ||
| * 2. doc.write('\<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" ""\>') | ||
| */ | ||
| write(content) { | ||
| let publicId; | ||
| if (content === '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">') | ||
| publicId = "-//W3C//DTD XHTML 1.0 Transitional//EN"; | ||
| else if (content === '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "">') | ||
| publicId = "-//W3C//DTD HTML 4.0 Transitional//EN"; | ||
| if (publicId) { | ||
| const doctype = this.createDocumentType("html", publicId, ""); | ||
| this.open(); | ||
| this.appendChild(doctype); | ||
| } | ||
| } | ||
| createDocument(_namespace, _qualifiedName, _doctype) { | ||
| return new BaseRRDocument(); | ||
| } | ||
| createDocumentType(qualifiedName, publicId, systemId) { | ||
| const doctype = new BaseRRDocumentType(qualifiedName, publicId, systemId); | ||
| doctype.ownerDocument = this; | ||
| return doctype; | ||
| } | ||
| createElement(tagName) { | ||
| const element = new BaseRRElement(tagName); | ||
| element.ownerDocument = this; | ||
| return element; | ||
| } | ||
| createElementNS(_namespaceURI, qualifiedName) { | ||
| return this.createElement(qualifiedName); | ||
| } | ||
| createTextNode(data) { | ||
| const text = new BaseRRText(data); | ||
| text.ownerDocument = this; | ||
| return text; | ||
| } | ||
| createComment(data) { | ||
| const comment = new BaseRRComment(data); | ||
| comment.ownerDocument = this; | ||
| return comment; | ||
| } | ||
| createCDATASection(data) { | ||
| const CDATASection = new BaseRRCDATASection(data); | ||
| CDATASection.ownerDocument = this; | ||
| return CDATASection; | ||
| } | ||
| toString() { | ||
| return "RRDocument"; | ||
| } | ||
| } | ||
| class BaseRRDocumentType extends BaseRRNode { | ||
| constructor(qualifiedName, publicId, systemId) { | ||
| super(); | ||
| __publicField2(this, "nodeType", 10); | ||
| __publicField2(this, "RRNodeType", NodeType$1.DocumentType); | ||
| __publicField2(this, "name"); | ||
| __publicField2(this, "publicId"); | ||
| __publicField2(this, "systemId"); | ||
| __publicField2(this, "textContent", null); | ||
| this.name = qualifiedName; | ||
| this.publicId = publicId; | ||
| this.systemId = systemId; | ||
| this.nodeName = qualifiedName; | ||
| } | ||
| toString() { | ||
| return "RRDocumentType"; | ||
| } | ||
| } | ||
| class BaseRRElement extends BaseRRNode { | ||
| constructor(tagName) { | ||
| super(); | ||
| __publicField2(this, "nodeType", 1); | ||
| __publicField2(this, "RRNodeType", NodeType$1.Element); | ||
| __publicField2(this, "tagName"); | ||
| __publicField2(this, "attributes", {}); | ||
| __publicField2(this, "shadowRoot", null); | ||
| __publicField2(this, "scrollLeft"); | ||
| __publicField2(this, "scrollTop"); | ||
| this.tagName = tagName.toUpperCase(); | ||
| this.nodeName = tagName.toUpperCase(); | ||
| } | ||
| get textContent() { | ||
| let result = ""; | ||
| this.childNodes.forEach((node) => result += node.textContent); | ||
| return result; | ||
| } | ||
| set textContent(textContent) { | ||
| this.firstChild = null; | ||
| this.lastChild = null; | ||
| this.appendChild(this.ownerDocument.createTextNode(textContent)); | ||
| } | ||
| get classList() { | ||
| return new ClassList( | ||
| this.attributes.class, | ||
| (newClassName) => { | ||
| this.attributes.class = newClassName; | ||
| } | ||
| ); | ||
| } | ||
| get id() { | ||
| return this.attributes.id || ""; | ||
| } | ||
| get className() { | ||
| return this.attributes.class || ""; | ||
| } | ||
| get style() { | ||
| const style = this.attributes.style ? parseCSSText(this.attributes.style) : {}; | ||
| const hyphenateRE2 = /\B([A-Z])/g; | ||
| style.setProperty = (name, value, priority) => { | ||
| if (hyphenateRE2.test(name)) | ||
| return; | ||
| const normalizedName = camelize(name); | ||
| if (!value) | ||
| delete style[normalizedName]; | ||
| else | ||
| style[normalizedName] = value; | ||
| if (priority === "important") | ||
| style[normalizedName] += " !important"; | ||
| this.attributes.style = toCSSText(style); | ||
| }; | ||
| style.removeProperty = (name) => { | ||
| if (hyphenateRE2.test(name)) | ||
| return ""; | ||
| const normalizedName = camelize(name); | ||
| const value = style[normalizedName] || ""; | ||
| delete style[normalizedName]; | ||
| this.attributes.style = toCSSText(style); | ||
| return value; | ||
| }; | ||
| return style; | ||
| } | ||
| getAttribute(name) { | ||
| return this.attributes[name] || null; | ||
| } | ||
| setAttribute(name, attribute) { | ||
| this.attributes[name] = attribute; | ||
| } | ||
| setAttributeNS(_namespace, qualifiedName, value) { | ||
| this.setAttribute(qualifiedName, value); | ||
| } | ||
| removeAttribute(name) { | ||
| delete this.attributes[name]; | ||
| } | ||
| appendChild(newChild) { | ||
| return appendChild(this, newChild); | ||
| } | ||
| insertBefore(newChild, refChild) { | ||
| return insertBefore(this, newChild, refChild); | ||
| } | ||
| removeChild(node) { | ||
| return removeChild(this, node); | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
| attachShadow(_init) { | ||
| const shadowRoot = this.ownerDocument.createElement("SHADOWROOT"); | ||
| this.shadowRoot = shadowRoot; | ||
| return shadowRoot; | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
| dispatchEvent(_event) { | ||
| return true; | ||
| } | ||
| toString() { | ||
| let attributeString = ""; | ||
| for (const attribute in this.attributes) { | ||
| attributeString += `${attribute}="${this.attributes[attribute]}" `; | ||
| } | ||
| return `${this.tagName} ${attributeString}`; | ||
| } | ||
| } | ||
| class BaseRRMediaElement extends BaseRRElement { | ||
| constructor() { | ||
| super(...arguments); | ||
| __publicField2(this, "currentTime"); | ||
| __publicField2(this, "volume"); | ||
| __publicField2(this, "paused"); | ||
| __publicField2(this, "muted"); | ||
| __publicField2(this, "playbackRate"); | ||
| __publicField2(this, "loop"); | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
| attachShadow(_init) { | ||
| throw new Error( | ||
| `RRDomException: Failed to execute 'attachShadow' on 'RRElement': This RRElement does not support attachShadow` | ||
| ); | ||
| } | ||
| play() { | ||
| this.paused = false; | ||
| } | ||
| pause() { | ||
| this.paused = true; | ||
| } | ||
| } | ||
| class BaseRRText extends BaseRRNode { | ||
| constructor(data) { | ||
| super(); | ||
| __publicField2(this, "nodeType", 3); | ||
| __publicField2(this, "nodeName", "#text"); | ||
| __publicField2(this, "RRNodeType", NodeType$1.Text); | ||
| __publicField2(this, "data"); | ||
| this.data = data; | ||
| } | ||
| get textContent() { | ||
| return this.data; | ||
| } | ||
| set textContent(textContent) { | ||
| this.data = textContent; | ||
| } | ||
| toString() { | ||
| return `RRText text=${JSON.stringify(this.data)}`; | ||
| } | ||
| } | ||
| class BaseRRComment extends BaseRRNode { | ||
| constructor(data) { | ||
| super(); | ||
| __publicField2(this, "nodeType", 8); | ||
| __publicField2(this, "nodeName", "#comment"); | ||
| __publicField2(this, "RRNodeType", NodeType$1.Comment); | ||
| __publicField2(this, "data"); | ||
| this.data = data; | ||
| } | ||
| get textContent() { | ||
| return this.data; | ||
| } | ||
| set textContent(textContent) { | ||
| this.data = textContent; | ||
| } | ||
| toString() { | ||
| return `RRComment text=${JSON.stringify(this.data)}`; | ||
| } | ||
| } | ||
| class BaseRRCDATASection extends BaseRRNode { | ||
| constructor(data) { | ||
| super(); | ||
| __publicField2(this, "nodeName", "#cdata-section"); | ||
| __publicField2(this, "nodeType", 4); | ||
| __publicField2(this, "RRNodeType", NodeType$1.CDATA); | ||
| __publicField2(this, "data"); | ||
| this.data = data; | ||
| } | ||
| get textContent() { | ||
| return this.data; | ||
| } | ||
| set textContent(textContent) { | ||
| this.data = textContent; | ||
| } | ||
| toString() { | ||
| return `RRCDATASection data=${JSON.stringify(this.data)}`; | ||
| } | ||
| } | ||
| class ClassList { | ||
| constructor(classText, onChange) { | ||
| __publicField2(this, "onChange"); | ||
| __publicField2(this, "classes", []); | ||
| __publicField2(this, "add", (...classNames) => { | ||
| for (const item of classNames) { | ||
| const className = String(item); | ||
| if (this.classes.indexOf(className) >= 0) | ||
| continue; | ||
| this.classes.push(className); | ||
| } | ||
| this.onChange && this.onChange(this.classes.join(" ")); | ||
| }); | ||
| __publicField2(this, "remove", (...classNames) => { | ||
| this.classes = this.classes.filter( | ||
| (item) => classNames.indexOf(item) === -1 | ||
| ); | ||
| this.onChange && this.onChange(this.classes.join(" ")); | ||
| }); | ||
| if (classText) { | ||
| const classes = classText.trim().split(/\s+/); | ||
| this.classes.push(...classes); | ||
| } | ||
| this.onChange = onChange; | ||
| } | ||
| } | ||
| function appendChild(parent, newChild) { | ||
| if (newChild.parentNode) | ||
| newChild.parentNode.removeChild(newChild); | ||
| if (parent.lastChild) { | ||
| parent.lastChild.nextSibling = newChild; | ||
| newChild.previousSibling = parent.lastChild; | ||
| } else { | ||
| parent.firstChild = newChild; | ||
| newChild.previousSibling = null; | ||
| } | ||
| parent.lastChild = newChild; | ||
| newChild.nextSibling = null; | ||
| newChild.parentNode = parent; | ||
| newChild.parentElement = parent; | ||
| newChild.ownerDocument = parent.ownerDocument; | ||
| return newChild; | ||
| } | ||
| function insertBefore(parent, newChild, refChild) { | ||
| if (!refChild) | ||
| return appendChild(parent, newChild); | ||
| if (refChild.parentNode !== parent) | ||
| throw new Error( | ||
| "Failed to execute 'insertBefore' on 'RRNode': The RRNode before which the new node is to be inserted is not a child of this RRNode." | ||
| ); | ||
| if (newChild === refChild) | ||
| return newChild; | ||
| if (newChild.parentNode) | ||
| newChild.parentNode.removeChild(newChild); | ||
| newChild.previousSibling = refChild.previousSibling; | ||
| refChild.previousSibling = newChild; | ||
| newChild.nextSibling = refChild; | ||
| if (newChild.previousSibling) | ||
| newChild.previousSibling.nextSibling = newChild; | ||
| else | ||
| parent.firstChild = newChild; | ||
| newChild.parentElement = parent; | ||
| newChild.parentNode = parent; | ||
| newChild.ownerDocument = parent.ownerDocument; | ||
| return newChild; | ||
| } | ||
| function removeChild(parent, child) { | ||
| if (child.parentNode !== parent) | ||
| throw new Error( | ||
| "Failed to execute 'removeChild' on 'RRNode': The RRNode to be removed is not a child of this RRNode." | ||
| ); | ||
| if (child.previousSibling) | ||
| child.previousSibling.nextSibling = child.nextSibling; | ||
| else | ||
| parent.firstChild = child.nextSibling; | ||
| if (child.nextSibling) | ||
| child.nextSibling.previousSibling = child.previousSibling; | ||
| else | ||
| parent.lastChild = child.previousSibling; | ||
| child.previousSibling = null; | ||
| child.nextSibling = null; | ||
| child.parentElement = null; | ||
| child.parentNode = null; | ||
| return child; | ||
| } | ||
| var NodeType = /* @__PURE__ */ ((NodeType2) => { | ||
| NodeType2[NodeType2["Document"] = 0] = "Document"; | ||
| NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType"; | ||
| NodeType2[NodeType2["Element"] = 2] = "Element"; | ||
| NodeType2[NodeType2["Text"] = 3] = "Text"; | ||
| NodeType2[NodeType2["CDATA"] = 4] = "CDATA"; | ||
| NodeType2[NodeType2["Comment"] = 5] = "Comment"; | ||
| return NodeType2; | ||
| })(NodeType || {}); | ||
| const nwsapi = require("nwsapi"); | ||
| const cssom = require("cssom"); | ||
| const cssstyle = require("cssstyle"); | ||
| class RRWindow { | ||
| constructor() { | ||
| __publicField(this, "scrollLeft", 0); | ||
| __publicField(this, "scrollTop", 0); | ||
| } | ||
| scrollTo(options) { | ||
| if (!options) | ||
| return; | ||
| if (typeof options.left === "number") | ||
| this.scrollLeft = options.left; | ||
| if (typeof options.top === "number") | ||
| this.scrollTop = options.top; | ||
| } | ||
| } | ||
| class RRDocument extends BaseRRDocument { | ||
| constructor() { | ||
| super(...arguments); | ||
| __publicField(this, "nodeName", "#document"); | ||
| __publicField(this, "_nwsapi"); | ||
| } | ||
| get nwsapi() { | ||
| if (!this._nwsapi) { | ||
| this._nwsapi = nwsapi({ | ||
| document: this, | ||
| DOMException: null | ||
| }); | ||
| this._nwsapi.configure({ | ||
| LOGERRORS: false, | ||
| IDS_DUPES: true, | ||
| MIXEDCASE: true | ||
| }); | ||
| } | ||
| return this._nwsapi; | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
| // @ts-ignore | ||
| get documentElement() { | ||
| return super.documentElement; | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
| // @ts-ignore | ||
| get body() { | ||
| return super.body; | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
| // @ts-ignore | ||
| get head() { | ||
| return super.head; | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
| // @ts-ignore | ||
| get implementation() { | ||
| return this; | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
| // @ts-ignore | ||
| get firstElementChild() { | ||
| return this.documentElement; | ||
| } | ||
| appendChild(childNode) { | ||
| return super.appendChild(childNode); | ||
| } | ||
| insertBefore(newChild, refChild) { | ||
| return super.insertBefore(newChild, refChild); | ||
| } | ||
| querySelectorAll(selectors) { | ||
| return this.nwsapi.select(selectors); | ||
| } | ||
| getElementsByTagName(tagName) { | ||
| if (this.documentElement) | ||
| return this.documentElement.getElementsByTagName(tagName); | ||
| return []; | ||
| } | ||
| getElementsByClassName(className) { | ||
| if (this.documentElement) | ||
| return this.documentElement.getElementsByClassName(className); | ||
| return []; | ||
| } | ||
| getElementById(elementId) { | ||
| if (this.documentElement) | ||
| return this.documentElement.getElementById(elementId); | ||
| return null; | ||
| } | ||
| createDocument(_namespace, _qualifiedName, _doctype) { | ||
| return new RRDocument(); | ||
| } | ||
| createDocumentType(qualifiedName, publicId, systemId) { | ||
| const documentTypeNode = new RRDocumentType( | ||
| qualifiedName, | ||
| publicId, | ||
| systemId | ||
| ); | ||
| documentTypeNode.ownerDocument = this; | ||
| return documentTypeNode; | ||
| } | ||
| createElement(tagName) { | ||
| const upperTagName = tagName.toUpperCase(); | ||
| let element; | ||
| switch (upperTagName) { | ||
| case "AUDIO": | ||
| case "VIDEO": | ||
| element = new RRMediaElement(upperTagName); | ||
| break; | ||
| case "IFRAME": | ||
| element = new RRIFrameElement(upperTagName); | ||
| break; | ||
| case "IMG": | ||
| element = new RRImageElement(upperTagName); | ||
| break; | ||
| case "CANVAS": | ||
| element = new RRCanvasElement(upperTagName); | ||
| break; | ||
| case "STYLE": | ||
| element = new RRStyleElement(upperTagName); | ||
| break; | ||
| default: | ||
| element = new RRElement(upperTagName); | ||
| break; | ||
| } | ||
| element.ownerDocument = this; | ||
| return element; | ||
| } | ||
| createElementNS(_namespaceURI, qualifiedName) { | ||
| return this.createElement(qualifiedName); | ||
| } | ||
| createComment(data) { | ||
| const commentNode = new RRComment(data); | ||
| commentNode.ownerDocument = this; | ||
| return commentNode; | ||
| } | ||
| createCDATASection(data) { | ||
| const sectionNode = new RRCDATASection(data); | ||
| sectionNode.ownerDocument = this; | ||
| return sectionNode; | ||
| } | ||
| createTextNode(data) { | ||
| const textNode = new RRText(data); | ||
| textNode.ownerDocument = this; | ||
| return textNode; | ||
| } | ||
| } | ||
| class RRDocumentType extends BaseRRDocumentType { | ||
| } | ||
| class RRElement extends BaseRRElement { | ||
| constructor(tagName) { | ||
| super(tagName); | ||
| __publicField(this, "_style"); | ||
| this._style = new cssstyle.CSSStyleDeclaration(); | ||
| const style = this._style; | ||
| Object.defineProperty(this.attributes, "style", { | ||
| get() { | ||
| return style.cssText; | ||
| }, | ||
| set(cssText) { | ||
| style.cssText = cssText; | ||
| } | ||
| }); | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
| // @ts-ignore | ||
| get style() { | ||
| return this._style; | ||
| } | ||
| attachShadow(_init) { | ||
| return super.attachShadow(_init); | ||
| } | ||
| appendChild(newChild) { | ||
| return super.appendChild(newChild); | ||
| } | ||
| insertBefore(newChild, refChild) { | ||
| return super.insertBefore(newChild, refChild); | ||
| } | ||
| getAttribute(name) { | ||
| const upperName = name && name.toLowerCase(); | ||
| if (upperName in this.attributes) | ||
| return this.attributes[upperName]; | ||
| return null; | ||
| } | ||
| setAttribute(name, attribute) { | ||
| this.attributes[name.toLowerCase()] = attribute; | ||
| } | ||
| removeAttribute(name) { | ||
| delete this.attributes[name.toLowerCase()]; | ||
| } | ||
| get firstElementChild() { | ||
| for (const child of this.childNodes) | ||
| if (child.RRNodeType === NodeType.Element) | ||
| return child; | ||
| return null; | ||
| } | ||
| get nextElementSibling() { | ||
| const parentNode = this.parentNode; | ||
| if (!parentNode) | ||
| return null; | ||
| const siblings = parentNode.childNodes; | ||
| const index = siblings.indexOf(this); | ||
| for (let i = index + 1; i < siblings.length; i++) | ||
| if (siblings[i] instanceof RRElement) | ||
| return siblings[i]; | ||
| return null; | ||
| } | ||
| querySelectorAll(selectors) { | ||
| const result = []; | ||
| if (this.ownerDocument !== null) { | ||
| this.ownerDocument.nwsapi.select( | ||
| selectors, | ||
| this, | ||
| (element) => { | ||
| if (element !== this) | ||
| result.push(element); | ||
| } | ||
| ); | ||
| } | ||
| return result; | ||
| } | ||
| getElementById(elementId) { | ||
| if (this.id === elementId) | ||
| return this; | ||
| for (const child of this.childNodes) { | ||
| if (child instanceof RRElement) { | ||
| const result = child.getElementById(elementId); | ||
| if (result !== null) | ||
| return result; | ||
| } | ||
| } | ||
| return null; | ||
| } | ||
| getElementsByClassName(className) { | ||
| let elements = []; | ||
| const queryClassList = new ClassList(className); | ||
| if (this instanceof RRElement && queryClassList.classes.filter( | ||
| (queriedClassName) => this.classList.classes.some((name) => name === queriedClassName) | ||
| ).length == queryClassList.classes.length) | ||
| elements.push(this); | ||
| for (const child of this.childNodes) { | ||
| if (child instanceof RRElement) | ||
| elements = elements.concat(child.getElementsByClassName(className)); | ||
| } | ||
| return elements; | ||
| } | ||
| getElementsByTagName(tagName) { | ||
| let elements = []; | ||
| const normalizedTagName = tagName.toUpperCase(); | ||
| if (this instanceof RRElement && this.tagName === normalizedTagName) | ||
| elements.push(this); | ||
| for (const child of this.childNodes) { | ||
| if (child instanceof RRElement) | ||
| elements = elements.concat(child.getElementsByTagName(tagName)); | ||
| } | ||
| return elements; | ||
| } | ||
| } | ||
| class RRImageElement extends RRElement { | ||
| constructor() { | ||
| super(...arguments); | ||
| __publicField(this, "src", ""); | ||
| __publicField(this, "width", 0); | ||
| __publicField(this, "height", 0); | ||
| __publicField(this, "onload", null); | ||
| } | ||
| } | ||
| class RRMediaElement extends BaseRRMediaElement { | ||
| } | ||
| class RRCanvasElement extends RRElement { | ||
| /** | ||
| * This is just a dummy implementation to prevent rrweb replayer from drawing mouse tail. If further analysis of canvas is needed, we may implement it with node-canvas. | ||
| */ | ||
| getContext() { | ||
| return null; | ||
| } | ||
| } | ||
| class RRStyleElement extends RRElement { | ||
| constructor() { | ||
| super(...arguments); | ||
| __publicField(this, "_sheet", null); | ||
| } | ||
| get sheet() { | ||
| if (!this._sheet) { | ||
| let result = ""; | ||
| for (const child of this.childNodes) | ||
| if (child.RRNodeType === NodeType.Text) | ||
| result += child.textContent; | ||
| this._sheet = cssom.parse(result); | ||
| } | ||
| return this._sheet; | ||
| } | ||
| } | ||
| class RRIFrameElement extends RRElement { | ||
| constructor(tagName) { | ||
| super(tagName); | ||
| __publicField(this, "width", ""); | ||
| __publicField(this, "height", ""); | ||
| __publicField(this, "src", ""); | ||
| __publicField(this, "contentDocument", new RRDocument()); | ||
| __publicField(this, "contentWindow", new RRWindow()); | ||
| const htmlElement = this.contentDocument.createElement("HTML"); | ||
| this.contentDocument.appendChild(htmlElement); | ||
| htmlElement.appendChild(this.contentDocument.createElement("HEAD")); | ||
| htmlElement.appendChild(this.contentDocument.createElement("BODY")); | ||
| } | ||
| } | ||
| class RRText extends BaseRRText { | ||
| constructor() { | ||
| super(...arguments); | ||
| __publicField(this, "nodeName", "#text"); | ||
| } | ||
| } | ||
| class RRComment extends BaseRRComment { | ||
| constructor() { | ||
| super(...arguments); | ||
| __publicField(this, "nodeName", "#comment"); | ||
| } | ||
| } | ||
| class RRCDATASection extends BaseRRCDATASection { | ||
| constructor() { | ||
| super(...arguments); | ||
| __publicField(this, "nodeName", "#cdata-section"); | ||
| } | ||
| } | ||
| function polyfillPerformance() { | ||
| if (typeof window !== "undefined" || "performance" in global) | ||
| return; | ||
| const performance = require("perf_hooks").performance; | ||
| global.performance = performance; | ||
| } | ||
| function polyfillRAF() { | ||
| if (typeof window !== "undefined" || "requestAnimationFrame" in global) | ||
| return; | ||
| const FPS = 60, INTERVAL = 1e3 / FPS; | ||
| let timeoutHandle = null, rafCount = 0, requests = /* @__PURE__ */ Object.create(null); | ||
| function onFrameTimer() { | ||
| const currentRequests = requests; | ||
| requests = /* @__PURE__ */ Object.create(null); | ||
| timeoutHandle = null; | ||
| Object.keys(currentRequests).forEach(function(id) { | ||
| const request = currentRequests[id]; | ||
| if (request) | ||
| request(Date.now()); | ||
| }); | ||
| } | ||
| function requestAnimationFrame(callback) { | ||
| const cbHandle = ++rafCount; | ||
| requests[cbHandle] = callback; | ||
| if (timeoutHandle === null) | ||
| timeoutHandle = setTimeout(onFrameTimer, INTERVAL); | ||
| return cbHandle; | ||
| } | ||
| function cancelAnimationFrame(handleId) { | ||
| delete requests[handleId]; | ||
| if (Object.keys(requests).length === 0 && timeoutHandle !== null) { | ||
| clearTimeout(timeoutHandle); | ||
| timeoutHandle = null; | ||
| } | ||
| } | ||
| global.requestAnimationFrame = requestAnimationFrame; | ||
| global.cancelAnimationFrame = cancelAnimationFrame; | ||
| } | ||
| function polyfillEvent() { | ||
| if (typeof Event !== "undefined") | ||
| return; | ||
| global.Event = function() { | ||
| }; | ||
| } | ||
| function polyfillNode() { | ||
| if (typeof Node !== "undefined") | ||
| return; | ||
| global.Node = BaseRRNode; | ||
| } | ||
| function polyfillDocument() { | ||
| if (typeof document !== "undefined") | ||
| return; | ||
| const rrdom = new RRDocument(); | ||
| (() => { | ||
| var _a, _b; | ||
| rrdom.appendChild(rrdom.createElement("html")); | ||
| (_a = rrdom.documentElement) == null ? void 0 : _a.appendChild(rrdom.createElement("head")); | ||
| (_b = rrdom.documentElement) == null ? void 0 : _b.appendChild(rrdom.createElement("body")); | ||
| })(); | ||
| global.document = rrdom; | ||
| } | ||
| polyfillPerformance(); | ||
| polyfillRAF(); | ||
| polyfillEvent(); | ||
| polyfillNode(); | ||
| polyfillDocument(); | ||
| exports.RRCDATASection = RRCDATASection; | ||
| exports.RRCanvasElement = RRCanvasElement; | ||
| exports.RRComment = RRComment; | ||
| exports.RRDocument = RRDocument; | ||
| exports.RRDocumentType = RRDocumentType; | ||
| exports.RRElement = RRElement; | ||
| exports.RRIFrameElement = RRIFrameElement; | ||
| exports.RRImageElement = RRImageElement; | ||
| exports.RRMediaElement = RRMediaElement; | ||
| exports.RRStyleElement = RRStyleElement; | ||
| exports.RRText = RRText; | ||
| exports.RRWindow = RRWindow; | ||
| //# sourceMappingURL=rrdom-nodejs.cjs.map |
Sorry, the diff of this file is too big to display
| var __defProp = Object.defineProperty; | ||
| var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; | ||
| var __publicField = (obj, key, value) => { | ||
| __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); | ||
| return value; | ||
| }; | ||
| var __defProp2 = Object.defineProperty; | ||
| var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; | ||
| var __publicField2 = (obj, key, value) => { | ||
| __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value); | ||
| return value; | ||
| }; | ||
| var NodeType$1 = /* @__PURE__ */ ((NodeType2) => { | ||
| NodeType2[NodeType2["Document"] = 0] = "Document"; | ||
| NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType"; | ||
| NodeType2[NodeType2["Element"] = 2] = "Element"; | ||
| NodeType2[NodeType2["Text"] = 3] = "Text"; | ||
| NodeType2[NodeType2["CDATA"] = 4] = "CDATA"; | ||
| NodeType2[NodeType2["Comment"] = 5] = "Comment"; | ||
| return NodeType2; | ||
| })(NodeType$1 || {}); | ||
| function parseCSSText(cssText) { | ||
| const res = {}; | ||
| const listDelimiter = /;(?![^(]*\))/g; | ||
| const propertyDelimiter = /:(.+)/; | ||
| const comment = /\/\*.*?\*\//g; | ||
| cssText.replace(comment, "").split(listDelimiter).forEach(function(item) { | ||
| if (item) { | ||
| const tmp = item.split(propertyDelimiter); | ||
| tmp.length > 1 && (res[camelize(tmp[0].trim())] = tmp[1].trim()); | ||
| } | ||
| }); | ||
| return res; | ||
| } | ||
| function toCSSText(style) { | ||
| const properties = []; | ||
| for (const name in style) { | ||
| const value = style[name]; | ||
| if (typeof value !== "string") | ||
| continue; | ||
| const normalizedName = hyphenate(name); | ||
| properties.push(`${normalizedName}: ${value};`); | ||
| } | ||
| return properties.join(" "); | ||
| } | ||
| const camelizeRE = /-([a-z])/g; | ||
| const CUSTOM_PROPERTY_REGEX = /^--[a-zA-Z0-9-]+$/; | ||
| const camelize = (str) => { | ||
| if (CUSTOM_PROPERTY_REGEX.test(str)) | ||
| return str; | ||
| return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : ""); | ||
| }; | ||
| const hyphenateRE = /\B([A-Z])/g; | ||
| const hyphenate = (str) => { | ||
| return str.replace(hyphenateRE, "-$1").toLowerCase(); | ||
| }; | ||
| class BaseRRNode { | ||
| // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any | ||
| constructor(..._args) { | ||
| __publicField2(this, "parentElement", null); | ||
| __publicField2(this, "parentNode", null); | ||
| __publicField2(this, "ownerDocument"); | ||
| __publicField2(this, "firstChild", null); | ||
| __publicField2(this, "lastChild", null); | ||
| __publicField2(this, "previousSibling", null); | ||
| __publicField2(this, "nextSibling", null); | ||
| __publicField2(this, "ELEMENT_NODE", 1); | ||
| __publicField2(this, "TEXT_NODE", 3); | ||
| __publicField2(this, "nodeType"); | ||
| __publicField2(this, "nodeName"); | ||
| __publicField2(this, "RRNodeType"); | ||
| } | ||
| get childNodes() { | ||
| const childNodes = []; | ||
| let childIterator = this.firstChild; | ||
| while (childIterator) { | ||
| childNodes.push(childIterator); | ||
| childIterator = childIterator.nextSibling; | ||
| } | ||
| return childNodes; | ||
| } | ||
| contains(node) { | ||
| if (!(node instanceof BaseRRNode)) | ||
| return false; | ||
| else if (node.ownerDocument !== this.ownerDocument) | ||
| return false; | ||
| else if (node === this) | ||
| return true; | ||
| while (node.parentNode) { | ||
| if (node.parentNode === this) | ||
| return true; | ||
| node = node.parentNode; | ||
| } | ||
| return false; | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
| appendChild(_newChild) { | ||
| throw new Error( | ||
| `RRDomException: Failed to execute 'appendChild' on 'RRNode': This RRNode type does not support this method.` | ||
| ); | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
| insertBefore(_newChild, _refChild) { | ||
| throw new Error( | ||
| `RRDomException: Failed to execute 'insertBefore' on 'RRNode': This RRNode type does not support this method.` | ||
| ); | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
| removeChild(_node) { | ||
| throw new Error( | ||
| `RRDomException: Failed to execute 'removeChild' on 'RRNode': This RRNode type does not support this method.` | ||
| ); | ||
| } | ||
| toString() { | ||
| return "RRNode"; | ||
| } | ||
| } | ||
| class BaseRRDocument extends BaseRRNode { | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| constructor(...args) { | ||
| super(args); | ||
| __publicField2(this, "nodeType", 9); | ||
| __publicField2(this, "nodeName", "#document"); | ||
| __publicField2(this, "compatMode", "CSS1Compat"); | ||
| __publicField2(this, "RRNodeType", NodeType$1.Document); | ||
| __publicField2(this, "textContent", null); | ||
| this.ownerDocument = this; | ||
| } | ||
| get documentElement() { | ||
| return this.childNodes.find( | ||
| (node) => node.RRNodeType === NodeType$1.Element && node.tagName === "HTML" | ||
| ) || null; | ||
| } | ||
| get body() { | ||
| var _a; | ||
| return ((_a = this.documentElement) == null ? void 0 : _a.childNodes.find( | ||
| (node) => node.RRNodeType === NodeType$1.Element && node.tagName === "BODY" | ||
| )) || null; | ||
| } | ||
| get head() { | ||
| var _a; | ||
| return ((_a = this.documentElement) == null ? void 0 : _a.childNodes.find( | ||
| (node) => node.RRNodeType === NodeType$1.Element && node.tagName === "HEAD" | ||
| )) || null; | ||
| } | ||
| get implementation() { | ||
| return this; | ||
| } | ||
| get firstElementChild() { | ||
| return this.documentElement; | ||
| } | ||
| appendChild(newChild) { | ||
| const nodeType = newChild.RRNodeType; | ||
| if (nodeType === NodeType$1.Element || nodeType === NodeType$1.DocumentType) { | ||
| if (this.childNodes.some((s) => s.RRNodeType === nodeType)) { | ||
| throw new Error( | ||
| `RRDomException: Failed to execute 'appendChild' on 'RRNode': Only one ${nodeType === NodeType$1.Element ? "RRElement" : "RRDoctype"} on RRDocument allowed.` | ||
| ); | ||
| } | ||
| } | ||
| const child = appendChild(this, newChild); | ||
| child.parentElement = null; | ||
| return child; | ||
| } | ||
| insertBefore(newChild, refChild) { | ||
| const nodeType = newChild.RRNodeType; | ||
| if (nodeType === NodeType$1.Element || nodeType === NodeType$1.DocumentType) { | ||
| if (this.childNodes.some((s) => s.RRNodeType === nodeType)) { | ||
| throw new Error( | ||
| `RRDomException: Failed to execute 'insertBefore' on 'RRNode': Only one ${nodeType === NodeType$1.Element ? "RRElement" : "RRDoctype"} on RRDocument allowed.` | ||
| ); | ||
| } | ||
| } | ||
| const child = insertBefore(this, newChild, refChild); | ||
| child.parentElement = null; | ||
| return child; | ||
| } | ||
| removeChild(node) { | ||
| return removeChild(this, node); | ||
| } | ||
| open() { | ||
| this.firstChild = null; | ||
| this.lastChild = null; | ||
| } | ||
| close() { | ||
| } | ||
| /** | ||
| * Adhoc implementation for setting xhtml namespace in rebuilt.ts (rrweb-snapshot). | ||
| * There are two lines used this function: | ||
| * 1. doc.write('\<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""\>') | ||
| * 2. doc.write('\<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" ""\>') | ||
| */ | ||
| write(content) { | ||
| let publicId; | ||
| if (content === '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">') | ||
| publicId = "-//W3C//DTD XHTML 1.0 Transitional//EN"; | ||
| else if (content === '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "">') | ||
| publicId = "-//W3C//DTD HTML 4.0 Transitional//EN"; | ||
| if (publicId) { | ||
| const doctype = this.createDocumentType("html", publicId, ""); | ||
| this.open(); | ||
| this.appendChild(doctype); | ||
| } | ||
| } | ||
| createDocument(_namespace, _qualifiedName, _doctype) { | ||
| return new BaseRRDocument(); | ||
| } | ||
| createDocumentType(qualifiedName, publicId, systemId) { | ||
| const doctype = new BaseRRDocumentType(qualifiedName, publicId, systemId); | ||
| doctype.ownerDocument = this; | ||
| return doctype; | ||
| } | ||
| createElement(tagName) { | ||
| const element = new BaseRRElement(tagName); | ||
| element.ownerDocument = this; | ||
| return element; | ||
| } | ||
| createElementNS(_namespaceURI, qualifiedName) { | ||
| return this.createElement(qualifiedName); | ||
| } | ||
| createTextNode(data) { | ||
| const text = new BaseRRText(data); | ||
| text.ownerDocument = this; | ||
| return text; | ||
| } | ||
| createComment(data) { | ||
| const comment = new BaseRRComment(data); | ||
| comment.ownerDocument = this; | ||
| return comment; | ||
| } | ||
| createCDATASection(data) { | ||
| const CDATASection = new BaseRRCDATASection(data); | ||
| CDATASection.ownerDocument = this; | ||
| return CDATASection; | ||
| } | ||
| toString() { | ||
| return "RRDocument"; | ||
| } | ||
| } | ||
| class BaseRRDocumentType extends BaseRRNode { | ||
| constructor(qualifiedName, publicId, systemId) { | ||
| super(); | ||
| __publicField2(this, "nodeType", 10); | ||
| __publicField2(this, "RRNodeType", NodeType$1.DocumentType); | ||
| __publicField2(this, "name"); | ||
| __publicField2(this, "publicId"); | ||
| __publicField2(this, "systemId"); | ||
| __publicField2(this, "textContent", null); | ||
| this.name = qualifiedName; | ||
| this.publicId = publicId; | ||
| this.systemId = systemId; | ||
| this.nodeName = qualifiedName; | ||
| } | ||
| toString() { | ||
| return "RRDocumentType"; | ||
| } | ||
| } | ||
| class BaseRRElement extends BaseRRNode { | ||
| constructor(tagName) { | ||
| super(); | ||
| __publicField2(this, "nodeType", 1); | ||
| __publicField2(this, "RRNodeType", NodeType$1.Element); | ||
| __publicField2(this, "tagName"); | ||
| __publicField2(this, "attributes", {}); | ||
| __publicField2(this, "shadowRoot", null); | ||
| __publicField2(this, "scrollLeft"); | ||
| __publicField2(this, "scrollTop"); | ||
| this.tagName = tagName.toUpperCase(); | ||
| this.nodeName = tagName.toUpperCase(); | ||
| } | ||
| get textContent() { | ||
| let result = ""; | ||
| this.childNodes.forEach((node) => result += node.textContent); | ||
| return result; | ||
| } | ||
| set textContent(textContent) { | ||
| this.firstChild = null; | ||
| this.lastChild = null; | ||
| this.appendChild(this.ownerDocument.createTextNode(textContent)); | ||
| } | ||
| get classList() { | ||
| return new ClassList( | ||
| this.attributes.class, | ||
| (newClassName) => { | ||
| this.attributes.class = newClassName; | ||
| } | ||
| ); | ||
| } | ||
| get id() { | ||
| return this.attributes.id || ""; | ||
| } | ||
| get className() { | ||
| return this.attributes.class || ""; | ||
| } | ||
| get style() { | ||
| const style = this.attributes.style ? parseCSSText(this.attributes.style) : {}; | ||
| const hyphenateRE2 = /\B([A-Z])/g; | ||
| style.setProperty = (name, value, priority) => { | ||
| if (hyphenateRE2.test(name)) | ||
| return; | ||
| const normalizedName = camelize(name); | ||
| if (!value) | ||
| delete style[normalizedName]; | ||
| else | ||
| style[normalizedName] = value; | ||
| if (priority === "important") | ||
| style[normalizedName] += " !important"; | ||
| this.attributes.style = toCSSText(style); | ||
| }; | ||
| style.removeProperty = (name) => { | ||
| if (hyphenateRE2.test(name)) | ||
| return ""; | ||
| const normalizedName = camelize(name); | ||
| const value = style[normalizedName] || ""; | ||
| delete style[normalizedName]; | ||
| this.attributes.style = toCSSText(style); | ||
| return value; | ||
| }; | ||
| return style; | ||
| } | ||
| getAttribute(name) { | ||
| return this.attributes[name] || null; | ||
| } | ||
| setAttribute(name, attribute) { | ||
| this.attributes[name] = attribute; | ||
| } | ||
| setAttributeNS(_namespace, qualifiedName, value) { | ||
| this.setAttribute(qualifiedName, value); | ||
| } | ||
| removeAttribute(name) { | ||
| delete this.attributes[name]; | ||
| } | ||
| appendChild(newChild) { | ||
| return appendChild(this, newChild); | ||
| } | ||
| insertBefore(newChild, refChild) { | ||
| return insertBefore(this, newChild, refChild); | ||
| } | ||
| removeChild(node) { | ||
| return removeChild(this, node); | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
| attachShadow(_init) { | ||
| const shadowRoot = this.ownerDocument.createElement("SHADOWROOT"); | ||
| this.shadowRoot = shadowRoot; | ||
| return shadowRoot; | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
| dispatchEvent(_event) { | ||
| return true; | ||
| } | ||
| toString() { | ||
| let attributeString = ""; | ||
| for (const attribute in this.attributes) { | ||
| attributeString += `${attribute}="${this.attributes[attribute]}" `; | ||
| } | ||
| return `${this.tagName} ${attributeString}`; | ||
| } | ||
| } | ||
| class BaseRRMediaElement extends BaseRRElement { | ||
| constructor() { | ||
| super(...arguments); | ||
| __publicField2(this, "currentTime"); | ||
| __publicField2(this, "volume"); | ||
| __publicField2(this, "paused"); | ||
| __publicField2(this, "muted"); | ||
| __publicField2(this, "playbackRate"); | ||
| __publicField2(this, "loop"); | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
| attachShadow(_init) { | ||
| throw new Error( | ||
| `RRDomException: Failed to execute 'attachShadow' on 'RRElement': This RRElement does not support attachShadow` | ||
| ); | ||
| } | ||
| play() { | ||
| this.paused = false; | ||
| } | ||
| pause() { | ||
| this.paused = true; | ||
| } | ||
| } | ||
| class BaseRRText extends BaseRRNode { | ||
| constructor(data) { | ||
| super(); | ||
| __publicField2(this, "nodeType", 3); | ||
| __publicField2(this, "nodeName", "#text"); | ||
| __publicField2(this, "RRNodeType", NodeType$1.Text); | ||
| __publicField2(this, "data"); | ||
| this.data = data; | ||
| } | ||
| get textContent() { | ||
| return this.data; | ||
| } | ||
| set textContent(textContent) { | ||
| this.data = textContent; | ||
| } | ||
| toString() { | ||
| return `RRText text=${JSON.stringify(this.data)}`; | ||
| } | ||
| } | ||
| class BaseRRComment extends BaseRRNode { | ||
| constructor(data) { | ||
| super(); | ||
| __publicField2(this, "nodeType", 8); | ||
| __publicField2(this, "nodeName", "#comment"); | ||
| __publicField2(this, "RRNodeType", NodeType$1.Comment); | ||
| __publicField2(this, "data"); | ||
| this.data = data; | ||
| } | ||
| get textContent() { | ||
| return this.data; | ||
| } | ||
| set textContent(textContent) { | ||
| this.data = textContent; | ||
| } | ||
| toString() { | ||
| return `RRComment text=${JSON.stringify(this.data)}`; | ||
| } | ||
| } | ||
| class BaseRRCDATASection extends BaseRRNode { | ||
| constructor(data) { | ||
| super(); | ||
| __publicField2(this, "nodeName", "#cdata-section"); | ||
| __publicField2(this, "nodeType", 4); | ||
| __publicField2(this, "RRNodeType", NodeType$1.CDATA); | ||
| __publicField2(this, "data"); | ||
| this.data = data; | ||
| } | ||
| get textContent() { | ||
| return this.data; | ||
| } | ||
| set textContent(textContent) { | ||
| this.data = textContent; | ||
| } | ||
| toString() { | ||
| return `RRCDATASection data=${JSON.stringify(this.data)}`; | ||
| } | ||
| } | ||
| class ClassList { | ||
| constructor(classText, onChange) { | ||
| __publicField2(this, "onChange"); | ||
| __publicField2(this, "classes", []); | ||
| __publicField2(this, "add", (...classNames) => { | ||
| for (const item of classNames) { | ||
| const className = String(item); | ||
| if (this.classes.indexOf(className) >= 0) | ||
| continue; | ||
| this.classes.push(className); | ||
| } | ||
| this.onChange && this.onChange(this.classes.join(" ")); | ||
| }); | ||
| __publicField2(this, "remove", (...classNames) => { | ||
| this.classes = this.classes.filter( | ||
| (item) => classNames.indexOf(item) === -1 | ||
| ); | ||
| this.onChange && this.onChange(this.classes.join(" ")); | ||
| }); | ||
| if (classText) { | ||
| const classes = classText.trim().split(/\s+/); | ||
| this.classes.push(...classes); | ||
| } | ||
| this.onChange = onChange; | ||
| } | ||
| } | ||
| function appendChild(parent, newChild) { | ||
| if (newChild.parentNode) | ||
| newChild.parentNode.removeChild(newChild); | ||
| if (parent.lastChild) { | ||
| parent.lastChild.nextSibling = newChild; | ||
| newChild.previousSibling = parent.lastChild; | ||
| } else { | ||
| parent.firstChild = newChild; | ||
| newChild.previousSibling = null; | ||
| } | ||
| parent.lastChild = newChild; | ||
| newChild.nextSibling = null; | ||
| newChild.parentNode = parent; | ||
| newChild.parentElement = parent; | ||
| newChild.ownerDocument = parent.ownerDocument; | ||
| return newChild; | ||
| } | ||
| function insertBefore(parent, newChild, refChild) { | ||
| if (!refChild) | ||
| return appendChild(parent, newChild); | ||
| if (refChild.parentNode !== parent) | ||
| throw new Error( | ||
| "Failed to execute 'insertBefore' on 'RRNode': The RRNode before which the new node is to be inserted is not a child of this RRNode." | ||
| ); | ||
| if (newChild === refChild) | ||
| return newChild; | ||
| if (newChild.parentNode) | ||
| newChild.parentNode.removeChild(newChild); | ||
| newChild.previousSibling = refChild.previousSibling; | ||
| refChild.previousSibling = newChild; | ||
| newChild.nextSibling = refChild; | ||
| if (newChild.previousSibling) | ||
| newChild.previousSibling.nextSibling = newChild; | ||
| else | ||
| parent.firstChild = newChild; | ||
| newChild.parentElement = parent; | ||
| newChild.parentNode = parent; | ||
| newChild.ownerDocument = parent.ownerDocument; | ||
| return newChild; | ||
| } | ||
| function removeChild(parent, child) { | ||
| if (child.parentNode !== parent) | ||
| throw new Error( | ||
| "Failed to execute 'removeChild' on 'RRNode': The RRNode to be removed is not a child of this RRNode." | ||
| ); | ||
| if (child.previousSibling) | ||
| child.previousSibling.nextSibling = child.nextSibling; | ||
| else | ||
| parent.firstChild = child.nextSibling; | ||
| if (child.nextSibling) | ||
| child.nextSibling.previousSibling = child.previousSibling; | ||
| else | ||
| parent.lastChild = child.previousSibling; | ||
| child.previousSibling = null; | ||
| child.nextSibling = null; | ||
| child.parentElement = null; | ||
| child.parentNode = null; | ||
| return child; | ||
| } | ||
| var NodeType = /* @__PURE__ */ ((NodeType2) => { | ||
| NodeType2[NodeType2["Document"] = 0] = "Document"; | ||
| NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType"; | ||
| NodeType2[NodeType2["Element"] = 2] = "Element"; | ||
| NodeType2[NodeType2["Text"] = 3] = "Text"; | ||
| NodeType2[NodeType2["CDATA"] = 4] = "CDATA"; | ||
| NodeType2[NodeType2["Comment"] = 5] = "Comment"; | ||
| return NodeType2; | ||
| })(NodeType || {}); | ||
| const nwsapi = require("nwsapi"); | ||
| const cssom = require("cssom"); | ||
| const cssstyle = require("cssstyle"); | ||
| class RRWindow { | ||
| constructor() { | ||
| __publicField(this, "scrollLeft", 0); | ||
| __publicField(this, "scrollTop", 0); | ||
| } | ||
| scrollTo(options) { | ||
| if (!options) | ||
| return; | ||
| if (typeof options.left === "number") | ||
| this.scrollLeft = options.left; | ||
| if (typeof options.top === "number") | ||
| this.scrollTop = options.top; | ||
| } | ||
| } | ||
| class RRDocument extends BaseRRDocument { | ||
| constructor() { | ||
| super(...arguments); | ||
| __publicField(this, "nodeName", "#document"); | ||
| __publicField(this, "_nwsapi"); | ||
| } | ||
| get nwsapi() { | ||
| if (!this._nwsapi) { | ||
| this._nwsapi = nwsapi({ | ||
| document: this, | ||
| DOMException: null | ||
| }); | ||
| this._nwsapi.configure({ | ||
| LOGERRORS: false, | ||
| IDS_DUPES: true, | ||
| MIXEDCASE: true | ||
| }); | ||
| } | ||
| return this._nwsapi; | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
| // @ts-ignore | ||
| get documentElement() { | ||
| return super.documentElement; | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
| // @ts-ignore | ||
| get body() { | ||
| return super.body; | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
| // @ts-ignore | ||
| get head() { | ||
| return super.head; | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
| // @ts-ignore | ||
| get implementation() { | ||
| return this; | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
| // @ts-ignore | ||
| get firstElementChild() { | ||
| return this.documentElement; | ||
| } | ||
| appendChild(childNode) { | ||
| return super.appendChild(childNode); | ||
| } | ||
| insertBefore(newChild, refChild) { | ||
| return super.insertBefore(newChild, refChild); | ||
| } | ||
| querySelectorAll(selectors) { | ||
| return this.nwsapi.select(selectors); | ||
| } | ||
| getElementsByTagName(tagName) { | ||
| if (this.documentElement) | ||
| return this.documentElement.getElementsByTagName(tagName); | ||
| return []; | ||
| } | ||
| getElementsByClassName(className) { | ||
| if (this.documentElement) | ||
| return this.documentElement.getElementsByClassName(className); | ||
| return []; | ||
| } | ||
| getElementById(elementId) { | ||
| if (this.documentElement) | ||
| return this.documentElement.getElementById(elementId); | ||
| return null; | ||
| } | ||
| createDocument(_namespace, _qualifiedName, _doctype) { | ||
| return new RRDocument(); | ||
| } | ||
| createDocumentType(qualifiedName, publicId, systemId) { | ||
| const documentTypeNode = new RRDocumentType( | ||
| qualifiedName, | ||
| publicId, | ||
| systemId | ||
| ); | ||
| documentTypeNode.ownerDocument = this; | ||
| return documentTypeNode; | ||
| } | ||
| createElement(tagName) { | ||
| const upperTagName = tagName.toUpperCase(); | ||
| let element; | ||
| switch (upperTagName) { | ||
| case "AUDIO": | ||
| case "VIDEO": | ||
| element = new RRMediaElement(upperTagName); | ||
| break; | ||
| case "IFRAME": | ||
| element = new RRIFrameElement(upperTagName); | ||
| break; | ||
| case "IMG": | ||
| element = new RRImageElement(upperTagName); | ||
| break; | ||
| case "CANVAS": | ||
| element = new RRCanvasElement(upperTagName); | ||
| break; | ||
| case "STYLE": | ||
| element = new RRStyleElement(upperTagName); | ||
| break; | ||
| default: | ||
| element = new RRElement(upperTagName); | ||
| break; | ||
| } | ||
| element.ownerDocument = this; | ||
| return element; | ||
| } | ||
| createElementNS(_namespaceURI, qualifiedName) { | ||
| return this.createElement(qualifiedName); | ||
| } | ||
| createComment(data) { | ||
| const commentNode = new RRComment(data); | ||
| commentNode.ownerDocument = this; | ||
| return commentNode; | ||
| } | ||
| createCDATASection(data) { | ||
| const sectionNode = new RRCDATASection(data); | ||
| sectionNode.ownerDocument = this; | ||
| return sectionNode; | ||
| } | ||
| createTextNode(data) { | ||
| const textNode = new RRText(data); | ||
| textNode.ownerDocument = this; | ||
| return textNode; | ||
| } | ||
| } | ||
| class RRDocumentType extends BaseRRDocumentType { | ||
| } | ||
| class RRElement extends BaseRRElement { | ||
| constructor(tagName) { | ||
| super(tagName); | ||
| __publicField(this, "_style"); | ||
| this._style = new cssstyle.CSSStyleDeclaration(); | ||
| const style = this._style; | ||
| Object.defineProperty(this.attributes, "style", { | ||
| get() { | ||
| return style.cssText; | ||
| }, | ||
| set(cssText) { | ||
| style.cssText = cssText; | ||
| } | ||
| }); | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
| // @ts-ignore | ||
| get style() { | ||
| return this._style; | ||
| } | ||
| attachShadow(_init) { | ||
| return super.attachShadow(_init); | ||
| } | ||
| appendChild(newChild) { | ||
| return super.appendChild(newChild); | ||
| } | ||
| insertBefore(newChild, refChild) { | ||
| return super.insertBefore(newChild, refChild); | ||
| } | ||
| getAttribute(name) { | ||
| const upperName = name && name.toLowerCase(); | ||
| if (upperName in this.attributes) | ||
| return this.attributes[upperName]; | ||
| return null; | ||
| } | ||
| setAttribute(name, attribute) { | ||
| this.attributes[name.toLowerCase()] = attribute; | ||
| } | ||
| removeAttribute(name) { | ||
| delete this.attributes[name.toLowerCase()]; | ||
| } | ||
| get firstElementChild() { | ||
| for (const child of this.childNodes) | ||
| if (child.RRNodeType === NodeType.Element) | ||
| return child; | ||
| return null; | ||
| } | ||
| get nextElementSibling() { | ||
| const parentNode = this.parentNode; | ||
| if (!parentNode) | ||
| return null; | ||
| const siblings = parentNode.childNodes; | ||
| const index = siblings.indexOf(this); | ||
| for (let i = index + 1; i < siblings.length; i++) | ||
| if (siblings[i] instanceof RRElement) | ||
| return siblings[i]; | ||
| return null; | ||
| } | ||
| querySelectorAll(selectors) { | ||
| const result = []; | ||
| if (this.ownerDocument !== null) { | ||
| this.ownerDocument.nwsapi.select( | ||
| selectors, | ||
| this, | ||
| (element) => { | ||
| if (element !== this) | ||
| result.push(element); | ||
| } | ||
| ); | ||
| } | ||
| return result; | ||
| } | ||
| getElementById(elementId) { | ||
| if (this.id === elementId) | ||
| return this; | ||
| for (const child of this.childNodes) { | ||
| if (child instanceof RRElement) { | ||
| const result = child.getElementById(elementId); | ||
| if (result !== null) | ||
| return result; | ||
| } | ||
| } | ||
| return null; | ||
| } | ||
| getElementsByClassName(className) { | ||
| let elements = []; | ||
| const queryClassList = new ClassList(className); | ||
| if (this instanceof RRElement && queryClassList.classes.filter( | ||
| (queriedClassName) => this.classList.classes.some((name) => name === queriedClassName) | ||
| ).length == queryClassList.classes.length) | ||
| elements.push(this); | ||
| for (const child of this.childNodes) { | ||
| if (child instanceof RRElement) | ||
| elements = elements.concat(child.getElementsByClassName(className)); | ||
| } | ||
| return elements; | ||
| } | ||
| getElementsByTagName(tagName) { | ||
| let elements = []; | ||
| const normalizedTagName = tagName.toUpperCase(); | ||
| if (this instanceof RRElement && this.tagName === normalizedTagName) | ||
| elements.push(this); | ||
| for (const child of this.childNodes) { | ||
| if (child instanceof RRElement) | ||
| elements = elements.concat(child.getElementsByTagName(tagName)); | ||
| } | ||
| return elements; | ||
| } | ||
| } | ||
| class RRImageElement extends RRElement { | ||
| constructor() { | ||
| super(...arguments); | ||
| __publicField(this, "src", ""); | ||
| __publicField(this, "width", 0); | ||
| __publicField(this, "height", 0); | ||
| __publicField(this, "onload", null); | ||
| } | ||
| } | ||
| class RRMediaElement extends BaseRRMediaElement { | ||
| } | ||
| class RRCanvasElement extends RRElement { | ||
| /** | ||
| * This is just a dummy implementation to prevent rrweb replayer from drawing mouse tail. If further analysis of canvas is needed, we may implement it with node-canvas. | ||
| */ | ||
| getContext() { | ||
| return null; | ||
| } | ||
| } | ||
| class RRStyleElement extends RRElement { | ||
| constructor() { | ||
| super(...arguments); | ||
| __publicField(this, "_sheet", null); | ||
| } | ||
| get sheet() { | ||
| if (!this._sheet) { | ||
| let result = ""; | ||
| for (const child of this.childNodes) | ||
| if (child.RRNodeType === NodeType.Text) | ||
| result += child.textContent; | ||
| this._sheet = cssom.parse(result); | ||
| } | ||
| return this._sheet; | ||
| } | ||
| } | ||
| class RRIFrameElement extends RRElement { | ||
| constructor(tagName) { | ||
| super(tagName); | ||
| __publicField(this, "width", ""); | ||
| __publicField(this, "height", ""); | ||
| __publicField(this, "src", ""); | ||
| __publicField(this, "contentDocument", new RRDocument()); | ||
| __publicField(this, "contentWindow", new RRWindow()); | ||
| const htmlElement = this.contentDocument.createElement("HTML"); | ||
| this.contentDocument.appendChild(htmlElement); | ||
| htmlElement.appendChild(this.contentDocument.createElement("HEAD")); | ||
| htmlElement.appendChild(this.contentDocument.createElement("BODY")); | ||
| } | ||
| } | ||
| class RRText extends BaseRRText { | ||
| constructor() { | ||
| super(...arguments); | ||
| __publicField(this, "nodeName", "#text"); | ||
| } | ||
| } | ||
| class RRComment extends BaseRRComment { | ||
| constructor() { | ||
| super(...arguments); | ||
| __publicField(this, "nodeName", "#comment"); | ||
| } | ||
| } | ||
| class RRCDATASection extends BaseRRCDATASection { | ||
| constructor() { | ||
| super(...arguments); | ||
| __publicField(this, "nodeName", "#cdata-section"); | ||
| } | ||
| } | ||
| function polyfillPerformance() { | ||
| if (typeof window !== "undefined" || "performance" in global) | ||
| return; | ||
| const performance = require("perf_hooks").performance; | ||
| global.performance = performance; | ||
| } | ||
| function polyfillRAF() { | ||
| if (typeof window !== "undefined" || "requestAnimationFrame" in global) | ||
| return; | ||
| const FPS = 60, INTERVAL = 1e3 / FPS; | ||
| let timeoutHandle = null, rafCount = 0, requests = /* @__PURE__ */ Object.create(null); | ||
| function onFrameTimer() { | ||
| const currentRequests = requests; | ||
| requests = /* @__PURE__ */ Object.create(null); | ||
| timeoutHandle = null; | ||
| Object.keys(currentRequests).forEach(function(id) { | ||
| const request = currentRequests[id]; | ||
| if (request) | ||
| request(Date.now()); | ||
| }); | ||
| } | ||
| function requestAnimationFrame(callback) { | ||
| const cbHandle = ++rafCount; | ||
| requests[cbHandle] = callback; | ||
| if (timeoutHandle === null) | ||
| timeoutHandle = setTimeout(onFrameTimer, INTERVAL); | ||
| return cbHandle; | ||
| } | ||
| function cancelAnimationFrame(handleId) { | ||
| delete requests[handleId]; | ||
| if (Object.keys(requests).length === 0 && timeoutHandle !== null) { | ||
| clearTimeout(timeoutHandle); | ||
| timeoutHandle = null; | ||
| } | ||
| } | ||
| global.requestAnimationFrame = requestAnimationFrame; | ||
| global.cancelAnimationFrame = cancelAnimationFrame; | ||
| } | ||
| function polyfillEvent() { | ||
| if (typeof Event !== "undefined") | ||
| return; | ||
| global.Event = function() { | ||
| }; | ||
| } | ||
| function polyfillNode() { | ||
| if (typeof Node !== "undefined") | ||
| return; | ||
| global.Node = BaseRRNode; | ||
| } | ||
| function polyfillDocument() { | ||
| if (typeof document !== "undefined") | ||
| return; | ||
| const rrdom = new RRDocument(); | ||
| (() => { | ||
| var _a, _b; | ||
| rrdom.appendChild(rrdom.createElement("html")); | ||
| (_a = rrdom.documentElement) == null ? void 0 : _a.appendChild(rrdom.createElement("head")); | ||
| (_b = rrdom.documentElement) == null ? void 0 : _b.appendChild(rrdom.createElement("body")); | ||
| })(); | ||
| global.document = rrdom; | ||
| } | ||
| polyfillPerformance(); | ||
| polyfillRAF(); | ||
| polyfillEvent(); | ||
| polyfillNode(); | ||
| polyfillDocument(); | ||
| export { | ||
| RRCDATASection, | ||
| RRCanvasElement, | ||
| RRComment, | ||
| RRDocument, | ||
| RRDocumentType, | ||
| RRElement, | ||
| RRIFrameElement, | ||
| RRImageElement, | ||
| RRMediaElement, | ||
| RRStyleElement, | ||
| RRText, | ||
| RRWindow | ||
| }; | ||
| //# sourceMappingURL=rrdom-nodejs.js.map |
Sorry, the diff of this file is too big to display
| (function (g, f) { | ||
| if ("object" == typeof exports && "object" == typeof module) { | ||
| module.exports = f(); | ||
| } else if ("function" == typeof define && define.amd) { | ||
| define("rrdomNodejs", [], f); | ||
| } else if ("object" == typeof exports) { | ||
| exports["rrdomNodejs"] = f(); | ||
| } else { | ||
| g["rrdomNodejs"] = f(); | ||
| } | ||
| }(this, () => { | ||
| var exports = {}; | ||
| var module = { exports }; | ||
| "use strict"; | ||
| var __defProp = Object.defineProperty; | ||
| var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; | ||
| var __publicField = (obj, key, value) => { | ||
| __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); | ||
| return value; | ||
| }; | ||
| Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); | ||
| var __defProp2 = Object.defineProperty; | ||
| var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; | ||
| var __publicField2 = (obj, key, value) => { | ||
| __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value); | ||
| return value; | ||
| }; | ||
| var NodeType$1 = /* @__PURE__ */ ((NodeType2) => { | ||
| NodeType2[NodeType2["Document"] = 0] = "Document"; | ||
| NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType"; | ||
| NodeType2[NodeType2["Element"] = 2] = "Element"; | ||
| NodeType2[NodeType2["Text"] = 3] = "Text"; | ||
| NodeType2[NodeType2["CDATA"] = 4] = "CDATA"; | ||
| NodeType2[NodeType2["Comment"] = 5] = "Comment"; | ||
| return NodeType2; | ||
| })(NodeType$1 || {}); | ||
| function parseCSSText(cssText) { | ||
| const res = {}; | ||
| const listDelimiter = /;(?![^(]*\))/g; | ||
| const propertyDelimiter = /:(.+)/; | ||
| const comment = /\/\*.*?\*\//g; | ||
| cssText.replace(comment, "").split(listDelimiter).forEach(function(item) { | ||
| if (item) { | ||
| const tmp = item.split(propertyDelimiter); | ||
| tmp.length > 1 && (res[camelize(tmp[0].trim())] = tmp[1].trim()); | ||
| } | ||
| }); | ||
| return res; | ||
| } | ||
| function toCSSText(style) { | ||
| const properties = []; | ||
| for (const name in style) { | ||
| const value = style[name]; | ||
| if (typeof value !== "string") | ||
| continue; | ||
| const normalizedName = hyphenate(name); | ||
| properties.push(`${normalizedName}: ${value};`); | ||
| } | ||
| return properties.join(" "); | ||
| } | ||
| const camelizeRE = /-([a-z])/g; | ||
| const CUSTOM_PROPERTY_REGEX = /^--[a-zA-Z0-9-]+$/; | ||
| const camelize = (str) => { | ||
| if (CUSTOM_PROPERTY_REGEX.test(str)) | ||
| return str; | ||
| return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : ""); | ||
| }; | ||
| const hyphenateRE = /\B([A-Z])/g; | ||
| const hyphenate = (str) => { | ||
| return str.replace(hyphenateRE, "-$1").toLowerCase(); | ||
| }; | ||
| class BaseRRNode { | ||
| // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any | ||
| constructor(..._args) { | ||
| __publicField2(this, "parentElement", null); | ||
| __publicField2(this, "parentNode", null); | ||
| __publicField2(this, "ownerDocument"); | ||
| __publicField2(this, "firstChild", null); | ||
| __publicField2(this, "lastChild", null); | ||
| __publicField2(this, "previousSibling", null); | ||
| __publicField2(this, "nextSibling", null); | ||
| __publicField2(this, "ELEMENT_NODE", 1); | ||
| __publicField2(this, "TEXT_NODE", 3); | ||
| __publicField2(this, "nodeType"); | ||
| __publicField2(this, "nodeName"); | ||
| __publicField2(this, "RRNodeType"); | ||
| } | ||
| get childNodes() { | ||
| const childNodes = []; | ||
| let childIterator = this.firstChild; | ||
| while (childIterator) { | ||
| childNodes.push(childIterator); | ||
| childIterator = childIterator.nextSibling; | ||
| } | ||
| return childNodes; | ||
| } | ||
| contains(node) { | ||
| if (!(node instanceof BaseRRNode)) | ||
| return false; | ||
| else if (node.ownerDocument !== this.ownerDocument) | ||
| return false; | ||
| else if (node === this) | ||
| return true; | ||
| while (node.parentNode) { | ||
| if (node.parentNode === this) | ||
| return true; | ||
| node = node.parentNode; | ||
| } | ||
| return false; | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
| appendChild(_newChild) { | ||
| throw new Error( | ||
| `RRDomException: Failed to execute 'appendChild' on 'RRNode': This RRNode type does not support this method.` | ||
| ); | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
| insertBefore(_newChild, _refChild) { | ||
| throw new Error( | ||
| `RRDomException: Failed to execute 'insertBefore' on 'RRNode': This RRNode type does not support this method.` | ||
| ); | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
| removeChild(_node) { | ||
| throw new Error( | ||
| `RRDomException: Failed to execute 'removeChild' on 'RRNode': This RRNode type does not support this method.` | ||
| ); | ||
| } | ||
| toString() { | ||
| return "RRNode"; | ||
| } | ||
| } | ||
| class BaseRRDocument extends BaseRRNode { | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| constructor(...args) { | ||
| super(args); | ||
| __publicField2(this, "nodeType", 9); | ||
| __publicField2(this, "nodeName", "#document"); | ||
| __publicField2(this, "compatMode", "CSS1Compat"); | ||
| __publicField2(this, "RRNodeType", NodeType$1.Document); | ||
| __publicField2(this, "textContent", null); | ||
| this.ownerDocument = this; | ||
| } | ||
| get documentElement() { | ||
| return this.childNodes.find( | ||
| (node) => node.RRNodeType === NodeType$1.Element && node.tagName === "HTML" | ||
| ) || null; | ||
| } | ||
| get body() { | ||
| var _a; | ||
| return ((_a = this.documentElement) == null ? void 0 : _a.childNodes.find( | ||
| (node) => node.RRNodeType === NodeType$1.Element && node.tagName === "BODY" | ||
| )) || null; | ||
| } | ||
| get head() { | ||
| var _a; | ||
| return ((_a = this.documentElement) == null ? void 0 : _a.childNodes.find( | ||
| (node) => node.RRNodeType === NodeType$1.Element && node.tagName === "HEAD" | ||
| )) || null; | ||
| } | ||
| get implementation() { | ||
| return this; | ||
| } | ||
| get firstElementChild() { | ||
| return this.documentElement; | ||
| } | ||
| appendChild(newChild) { | ||
| const nodeType = newChild.RRNodeType; | ||
| if (nodeType === NodeType$1.Element || nodeType === NodeType$1.DocumentType) { | ||
| if (this.childNodes.some((s) => s.RRNodeType === nodeType)) { | ||
| throw new Error( | ||
| `RRDomException: Failed to execute 'appendChild' on 'RRNode': Only one ${nodeType === NodeType$1.Element ? "RRElement" : "RRDoctype"} on RRDocument allowed.` | ||
| ); | ||
| } | ||
| } | ||
| const child = appendChild(this, newChild); | ||
| child.parentElement = null; | ||
| return child; | ||
| } | ||
| insertBefore(newChild, refChild) { | ||
| const nodeType = newChild.RRNodeType; | ||
| if (nodeType === NodeType$1.Element || nodeType === NodeType$1.DocumentType) { | ||
| if (this.childNodes.some((s) => s.RRNodeType === nodeType)) { | ||
| throw new Error( | ||
| `RRDomException: Failed to execute 'insertBefore' on 'RRNode': Only one ${nodeType === NodeType$1.Element ? "RRElement" : "RRDoctype"} on RRDocument allowed.` | ||
| ); | ||
| } | ||
| } | ||
| const child = insertBefore(this, newChild, refChild); | ||
| child.parentElement = null; | ||
| return child; | ||
| } | ||
| removeChild(node) { | ||
| return removeChild(this, node); | ||
| } | ||
| open() { | ||
| this.firstChild = null; | ||
| this.lastChild = null; | ||
| } | ||
| close() { | ||
| } | ||
| /** | ||
| * Adhoc implementation for setting xhtml namespace in rebuilt.ts (rrweb-snapshot). | ||
| * There are two lines used this function: | ||
| * 1. doc.write('\<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""\>') | ||
| * 2. doc.write('\<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" ""\>') | ||
| */ | ||
| write(content) { | ||
| let publicId; | ||
| if (content === '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">') | ||
| publicId = "-//W3C//DTD XHTML 1.0 Transitional//EN"; | ||
| else if (content === '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "">') | ||
| publicId = "-//W3C//DTD HTML 4.0 Transitional//EN"; | ||
| if (publicId) { | ||
| const doctype = this.createDocumentType("html", publicId, ""); | ||
| this.open(); | ||
| this.appendChild(doctype); | ||
| } | ||
| } | ||
| createDocument(_namespace, _qualifiedName, _doctype) { | ||
| return new BaseRRDocument(); | ||
| } | ||
| createDocumentType(qualifiedName, publicId, systemId) { | ||
| const doctype = new BaseRRDocumentType(qualifiedName, publicId, systemId); | ||
| doctype.ownerDocument = this; | ||
| return doctype; | ||
| } | ||
| createElement(tagName) { | ||
| const element = new BaseRRElement(tagName); | ||
| element.ownerDocument = this; | ||
| return element; | ||
| } | ||
| createElementNS(_namespaceURI, qualifiedName) { | ||
| return this.createElement(qualifiedName); | ||
| } | ||
| createTextNode(data) { | ||
| const text = new BaseRRText(data); | ||
| text.ownerDocument = this; | ||
| return text; | ||
| } | ||
| createComment(data) { | ||
| const comment = new BaseRRComment(data); | ||
| comment.ownerDocument = this; | ||
| return comment; | ||
| } | ||
| createCDATASection(data) { | ||
| const CDATASection = new BaseRRCDATASection(data); | ||
| CDATASection.ownerDocument = this; | ||
| return CDATASection; | ||
| } | ||
| toString() { | ||
| return "RRDocument"; | ||
| } | ||
| } | ||
| class BaseRRDocumentType extends BaseRRNode { | ||
| constructor(qualifiedName, publicId, systemId) { | ||
| super(); | ||
| __publicField2(this, "nodeType", 10); | ||
| __publicField2(this, "RRNodeType", NodeType$1.DocumentType); | ||
| __publicField2(this, "name"); | ||
| __publicField2(this, "publicId"); | ||
| __publicField2(this, "systemId"); | ||
| __publicField2(this, "textContent", null); | ||
| this.name = qualifiedName; | ||
| this.publicId = publicId; | ||
| this.systemId = systemId; | ||
| this.nodeName = qualifiedName; | ||
| } | ||
| toString() { | ||
| return "RRDocumentType"; | ||
| } | ||
| } | ||
| class BaseRRElement extends BaseRRNode { | ||
| constructor(tagName) { | ||
| super(); | ||
| __publicField2(this, "nodeType", 1); | ||
| __publicField2(this, "RRNodeType", NodeType$1.Element); | ||
| __publicField2(this, "tagName"); | ||
| __publicField2(this, "attributes", {}); | ||
| __publicField2(this, "shadowRoot", null); | ||
| __publicField2(this, "scrollLeft"); | ||
| __publicField2(this, "scrollTop"); | ||
| this.tagName = tagName.toUpperCase(); | ||
| this.nodeName = tagName.toUpperCase(); | ||
| } | ||
| get textContent() { | ||
| let result = ""; | ||
| this.childNodes.forEach((node) => result += node.textContent); | ||
| return result; | ||
| } | ||
| set textContent(textContent) { | ||
| this.firstChild = null; | ||
| this.lastChild = null; | ||
| this.appendChild(this.ownerDocument.createTextNode(textContent)); | ||
| } | ||
| get classList() { | ||
| return new ClassList( | ||
| this.attributes.class, | ||
| (newClassName) => { | ||
| this.attributes.class = newClassName; | ||
| } | ||
| ); | ||
| } | ||
| get id() { | ||
| return this.attributes.id || ""; | ||
| } | ||
| get className() { | ||
| return this.attributes.class || ""; | ||
| } | ||
| get style() { | ||
| const style = this.attributes.style ? parseCSSText(this.attributes.style) : {}; | ||
| const hyphenateRE2 = /\B([A-Z])/g; | ||
| style.setProperty = (name, value, priority) => { | ||
| if (hyphenateRE2.test(name)) | ||
| return; | ||
| const normalizedName = camelize(name); | ||
| if (!value) | ||
| delete style[normalizedName]; | ||
| else | ||
| style[normalizedName] = value; | ||
| if (priority === "important") | ||
| style[normalizedName] += " !important"; | ||
| this.attributes.style = toCSSText(style); | ||
| }; | ||
| style.removeProperty = (name) => { | ||
| if (hyphenateRE2.test(name)) | ||
| return ""; | ||
| const normalizedName = camelize(name); | ||
| const value = style[normalizedName] || ""; | ||
| delete style[normalizedName]; | ||
| this.attributes.style = toCSSText(style); | ||
| return value; | ||
| }; | ||
| return style; | ||
| } | ||
| getAttribute(name) { | ||
| return this.attributes[name] || null; | ||
| } | ||
| setAttribute(name, attribute) { | ||
| this.attributes[name] = attribute; | ||
| } | ||
| setAttributeNS(_namespace, qualifiedName, value) { | ||
| this.setAttribute(qualifiedName, value); | ||
| } | ||
| removeAttribute(name) { | ||
| delete this.attributes[name]; | ||
| } | ||
| appendChild(newChild) { | ||
| return appendChild(this, newChild); | ||
| } | ||
| insertBefore(newChild, refChild) { | ||
| return insertBefore(this, newChild, refChild); | ||
| } | ||
| removeChild(node) { | ||
| return removeChild(this, node); | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
| attachShadow(_init) { | ||
| const shadowRoot = this.ownerDocument.createElement("SHADOWROOT"); | ||
| this.shadowRoot = shadowRoot; | ||
| return shadowRoot; | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
| dispatchEvent(_event) { | ||
| return true; | ||
| } | ||
| toString() { | ||
| let attributeString = ""; | ||
| for (const attribute in this.attributes) { | ||
| attributeString += `${attribute}="${this.attributes[attribute]}" `; | ||
| } | ||
| return `${this.tagName} ${attributeString}`; | ||
| } | ||
| } | ||
| class BaseRRMediaElement extends BaseRRElement { | ||
| constructor() { | ||
| super(...arguments); | ||
| __publicField2(this, "currentTime"); | ||
| __publicField2(this, "volume"); | ||
| __publicField2(this, "paused"); | ||
| __publicField2(this, "muted"); | ||
| __publicField2(this, "playbackRate"); | ||
| __publicField2(this, "loop"); | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
| attachShadow(_init) { | ||
| throw new Error( | ||
| `RRDomException: Failed to execute 'attachShadow' on 'RRElement': This RRElement does not support attachShadow` | ||
| ); | ||
| } | ||
| play() { | ||
| this.paused = false; | ||
| } | ||
| pause() { | ||
| this.paused = true; | ||
| } | ||
| } | ||
| class BaseRRText extends BaseRRNode { | ||
| constructor(data) { | ||
| super(); | ||
| __publicField2(this, "nodeType", 3); | ||
| __publicField2(this, "nodeName", "#text"); | ||
| __publicField2(this, "RRNodeType", NodeType$1.Text); | ||
| __publicField2(this, "data"); | ||
| this.data = data; | ||
| } | ||
| get textContent() { | ||
| return this.data; | ||
| } | ||
| set textContent(textContent) { | ||
| this.data = textContent; | ||
| } | ||
| toString() { | ||
| return `RRText text=${JSON.stringify(this.data)}`; | ||
| } | ||
| } | ||
| class BaseRRComment extends BaseRRNode { | ||
| constructor(data) { | ||
| super(); | ||
| __publicField2(this, "nodeType", 8); | ||
| __publicField2(this, "nodeName", "#comment"); | ||
| __publicField2(this, "RRNodeType", NodeType$1.Comment); | ||
| __publicField2(this, "data"); | ||
| this.data = data; | ||
| } | ||
| get textContent() { | ||
| return this.data; | ||
| } | ||
| set textContent(textContent) { | ||
| this.data = textContent; | ||
| } | ||
| toString() { | ||
| return `RRComment text=${JSON.stringify(this.data)}`; | ||
| } | ||
| } | ||
| class BaseRRCDATASection extends BaseRRNode { | ||
| constructor(data) { | ||
| super(); | ||
| __publicField2(this, "nodeName", "#cdata-section"); | ||
| __publicField2(this, "nodeType", 4); | ||
| __publicField2(this, "RRNodeType", NodeType$1.CDATA); | ||
| __publicField2(this, "data"); | ||
| this.data = data; | ||
| } | ||
| get textContent() { | ||
| return this.data; | ||
| } | ||
| set textContent(textContent) { | ||
| this.data = textContent; | ||
| } | ||
| toString() { | ||
| return `RRCDATASection data=${JSON.stringify(this.data)}`; | ||
| } | ||
| } | ||
| class ClassList { | ||
| constructor(classText, onChange) { | ||
| __publicField2(this, "onChange"); | ||
| __publicField2(this, "classes", []); | ||
| __publicField2(this, "add", (...classNames) => { | ||
| for (const item of classNames) { | ||
| const className = String(item); | ||
| if (this.classes.indexOf(className) >= 0) | ||
| continue; | ||
| this.classes.push(className); | ||
| } | ||
| this.onChange && this.onChange(this.classes.join(" ")); | ||
| }); | ||
| __publicField2(this, "remove", (...classNames) => { | ||
| this.classes = this.classes.filter( | ||
| (item) => classNames.indexOf(item) === -1 | ||
| ); | ||
| this.onChange && this.onChange(this.classes.join(" ")); | ||
| }); | ||
| if (classText) { | ||
| const classes = classText.trim().split(/\s+/); | ||
| this.classes.push(...classes); | ||
| } | ||
| this.onChange = onChange; | ||
| } | ||
| } | ||
| function appendChild(parent, newChild) { | ||
| if (newChild.parentNode) | ||
| newChild.parentNode.removeChild(newChild); | ||
| if (parent.lastChild) { | ||
| parent.lastChild.nextSibling = newChild; | ||
| newChild.previousSibling = parent.lastChild; | ||
| } else { | ||
| parent.firstChild = newChild; | ||
| newChild.previousSibling = null; | ||
| } | ||
| parent.lastChild = newChild; | ||
| newChild.nextSibling = null; | ||
| newChild.parentNode = parent; | ||
| newChild.parentElement = parent; | ||
| newChild.ownerDocument = parent.ownerDocument; | ||
| return newChild; | ||
| } | ||
| function insertBefore(parent, newChild, refChild) { | ||
| if (!refChild) | ||
| return appendChild(parent, newChild); | ||
| if (refChild.parentNode !== parent) | ||
| throw new Error( | ||
| "Failed to execute 'insertBefore' on 'RRNode': The RRNode before which the new node is to be inserted is not a child of this RRNode." | ||
| ); | ||
| if (newChild === refChild) | ||
| return newChild; | ||
| if (newChild.parentNode) | ||
| newChild.parentNode.removeChild(newChild); | ||
| newChild.previousSibling = refChild.previousSibling; | ||
| refChild.previousSibling = newChild; | ||
| newChild.nextSibling = refChild; | ||
| if (newChild.previousSibling) | ||
| newChild.previousSibling.nextSibling = newChild; | ||
| else | ||
| parent.firstChild = newChild; | ||
| newChild.parentElement = parent; | ||
| newChild.parentNode = parent; | ||
| newChild.ownerDocument = parent.ownerDocument; | ||
| return newChild; | ||
| } | ||
| function removeChild(parent, child) { | ||
| if (child.parentNode !== parent) | ||
| throw new Error( | ||
| "Failed to execute 'removeChild' on 'RRNode': The RRNode to be removed is not a child of this RRNode." | ||
| ); | ||
| if (child.previousSibling) | ||
| child.previousSibling.nextSibling = child.nextSibling; | ||
| else | ||
| parent.firstChild = child.nextSibling; | ||
| if (child.nextSibling) | ||
| child.nextSibling.previousSibling = child.previousSibling; | ||
| else | ||
| parent.lastChild = child.previousSibling; | ||
| child.previousSibling = null; | ||
| child.nextSibling = null; | ||
| child.parentElement = null; | ||
| child.parentNode = null; | ||
| return child; | ||
| } | ||
| var NodeType = /* @__PURE__ */ ((NodeType2) => { | ||
| NodeType2[NodeType2["Document"] = 0] = "Document"; | ||
| NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType"; | ||
| NodeType2[NodeType2["Element"] = 2] = "Element"; | ||
| NodeType2[NodeType2["Text"] = 3] = "Text"; | ||
| NodeType2[NodeType2["CDATA"] = 4] = "CDATA"; | ||
| NodeType2[NodeType2["Comment"] = 5] = "Comment"; | ||
| return NodeType2; | ||
| })(NodeType || {}); | ||
| const nwsapi = require("nwsapi"); | ||
| const cssom = require("cssom"); | ||
| const cssstyle = require("cssstyle"); | ||
| class RRWindow { | ||
| constructor() { | ||
| __publicField(this, "scrollLeft", 0); | ||
| __publicField(this, "scrollTop", 0); | ||
| } | ||
| scrollTo(options) { | ||
| if (!options) | ||
| return; | ||
| if (typeof options.left === "number") | ||
| this.scrollLeft = options.left; | ||
| if (typeof options.top === "number") | ||
| this.scrollTop = options.top; | ||
| } | ||
| } | ||
| class RRDocument extends BaseRRDocument { | ||
| constructor() { | ||
| super(...arguments); | ||
| __publicField(this, "nodeName", "#document"); | ||
| __publicField(this, "_nwsapi"); | ||
| } | ||
| get nwsapi() { | ||
| if (!this._nwsapi) { | ||
| this._nwsapi = nwsapi({ | ||
| document: this, | ||
| DOMException: null | ||
| }); | ||
| this._nwsapi.configure({ | ||
| LOGERRORS: false, | ||
| IDS_DUPES: true, | ||
| MIXEDCASE: true | ||
| }); | ||
| } | ||
| return this._nwsapi; | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
| // @ts-ignore | ||
| get documentElement() { | ||
| return super.documentElement; | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
| // @ts-ignore | ||
| get body() { | ||
| return super.body; | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
| // @ts-ignore | ||
| get head() { | ||
| return super.head; | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
| // @ts-ignore | ||
| get implementation() { | ||
| return this; | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
| // @ts-ignore | ||
| get firstElementChild() { | ||
| return this.documentElement; | ||
| } | ||
| appendChild(childNode) { | ||
| return super.appendChild(childNode); | ||
| } | ||
| insertBefore(newChild, refChild) { | ||
| return super.insertBefore(newChild, refChild); | ||
| } | ||
| querySelectorAll(selectors) { | ||
| return this.nwsapi.select(selectors); | ||
| } | ||
| getElementsByTagName(tagName) { | ||
| if (this.documentElement) | ||
| return this.documentElement.getElementsByTagName(tagName); | ||
| return []; | ||
| } | ||
| getElementsByClassName(className) { | ||
| if (this.documentElement) | ||
| return this.documentElement.getElementsByClassName(className); | ||
| return []; | ||
| } | ||
| getElementById(elementId) { | ||
| if (this.documentElement) | ||
| return this.documentElement.getElementById(elementId); | ||
| return null; | ||
| } | ||
| createDocument(_namespace, _qualifiedName, _doctype) { | ||
| return new RRDocument(); | ||
| } | ||
| createDocumentType(qualifiedName, publicId, systemId) { | ||
| const documentTypeNode = new RRDocumentType( | ||
| qualifiedName, | ||
| publicId, | ||
| systemId | ||
| ); | ||
| documentTypeNode.ownerDocument = this; | ||
| return documentTypeNode; | ||
| } | ||
| createElement(tagName) { | ||
| const upperTagName = tagName.toUpperCase(); | ||
| let element; | ||
| switch (upperTagName) { | ||
| case "AUDIO": | ||
| case "VIDEO": | ||
| element = new RRMediaElement(upperTagName); | ||
| break; | ||
| case "IFRAME": | ||
| element = new RRIFrameElement(upperTagName); | ||
| break; | ||
| case "IMG": | ||
| element = new RRImageElement(upperTagName); | ||
| break; | ||
| case "CANVAS": | ||
| element = new RRCanvasElement(upperTagName); | ||
| break; | ||
| case "STYLE": | ||
| element = new RRStyleElement(upperTagName); | ||
| break; | ||
| default: | ||
| element = new RRElement(upperTagName); | ||
| break; | ||
| } | ||
| element.ownerDocument = this; | ||
| return element; | ||
| } | ||
| createElementNS(_namespaceURI, qualifiedName) { | ||
| return this.createElement(qualifiedName); | ||
| } | ||
| createComment(data) { | ||
| const commentNode = new RRComment(data); | ||
| commentNode.ownerDocument = this; | ||
| return commentNode; | ||
| } | ||
| createCDATASection(data) { | ||
| const sectionNode = new RRCDATASection(data); | ||
| sectionNode.ownerDocument = this; | ||
| return sectionNode; | ||
| } | ||
| createTextNode(data) { | ||
| const textNode = new RRText(data); | ||
| textNode.ownerDocument = this; | ||
| return textNode; | ||
| } | ||
| } | ||
| class RRDocumentType extends BaseRRDocumentType { | ||
| } | ||
| class RRElement extends BaseRRElement { | ||
| constructor(tagName) { | ||
| super(tagName); | ||
| __publicField(this, "_style"); | ||
| this._style = new cssstyle.CSSStyleDeclaration(); | ||
| const style = this._style; | ||
| Object.defineProperty(this.attributes, "style", { | ||
| get() { | ||
| return style.cssText; | ||
| }, | ||
| set(cssText) { | ||
| style.cssText = cssText; | ||
| } | ||
| }); | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
| // @ts-ignore | ||
| get style() { | ||
| return this._style; | ||
| } | ||
| attachShadow(_init) { | ||
| return super.attachShadow(_init); | ||
| } | ||
| appendChild(newChild) { | ||
| return super.appendChild(newChild); | ||
| } | ||
| insertBefore(newChild, refChild) { | ||
| return super.insertBefore(newChild, refChild); | ||
| } | ||
| getAttribute(name) { | ||
| const upperName = name && name.toLowerCase(); | ||
| if (upperName in this.attributes) | ||
| return this.attributes[upperName]; | ||
| return null; | ||
| } | ||
| setAttribute(name, attribute) { | ||
| this.attributes[name.toLowerCase()] = attribute; | ||
| } | ||
| removeAttribute(name) { | ||
| delete this.attributes[name.toLowerCase()]; | ||
| } | ||
| get firstElementChild() { | ||
| for (const child of this.childNodes) | ||
| if (child.RRNodeType === NodeType.Element) | ||
| return child; | ||
| return null; | ||
| } | ||
| get nextElementSibling() { | ||
| const parentNode = this.parentNode; | ||
| if (!parentNode) | ||
| return null; | ||
| const siblings = parentNode.childNodes; | ||
| const index = siblings.indexOf(this); | ||
| for (let i = index + 1; i < siblings.length; i++) | ||
| if (siblings[i] instanceof RRElement) | ||
| return siblings[i]; | ||
| return null; | ||
| } | ||
| querySelectorAll(selectors) { | ||
| const result = []; | ||
| if (this.ownerDocument !== null) { | ||
| this.ownerDocument.nwsapi.select( | ||
| selectors, | ||
| this, | ||
| (element) => { | ||
| if (element !== this) | ||
| result.push(element); | ||
| } | ||
| ); | ||
| } | ||
| return result; | ||
| } | ||
| getElementById(elementId) { | ||
| if (this.id === elementId) | ||
| return this; | ||
| for (const child of this.childNodes) { | ||
| if (child instanceof RRElement) { | ||
| const result = child.getElementById(elementId); | ||
| if (result !== null) | ||
| return result; | ||
| } | ||
| } | ||
| return null; | ||
| } | ||
| getElementsByClassName(className) { | ||
| let elements = []; | ||
| const queryClassList = new ClassList(className); | ||
| if (this instanceof RRElement && queryClassList.classes.filter( | ||
| (queriedClassName) => this.classList.classes.some((name) => name === queriedClassName) | ||
| ).length == queryClassList.classes.length) | ||
| elements.push(this); | ||
| for (const child of this.childNodes) { | ||
| if (child instanceof RRElement) | ||
| elements = elements.concat(child.getElementsByClassName(className)); | ||
| } | ||
| return elements; | ||
| } | ||
| getElementsByTagName(tagName) { | ||
| let elements = []; | ||
| const normalizedTagName = tagName.toUpperCase(); | ||
| if (this instanceof RRElement && this.tagName === normalizedTagName) | ||
| elements.push(this); | ||
| for (const child of this.childNodes) { | ||
| if (child instanceof RRElement) | ||
| elements = elements.concat(child.getElementsByTagName(tagName)); | ||
| } | ||
| return elements; | ||
| } | ||
| } | ||
| class RRImageElement extends RRElement { | ||
| constructor() { | ||
| super(...arguments); | ||
| __publicField(this, "src", ""); | ||
| __publicField(this, "width", 0); | ||
| __publicField(this, "height", 0); | ||
| __publicField(this, "onload", null); | ||
| } | ||
| } | ||
| class RRMediaElement extends BaseRRMediaElement { | ||
| } | ||
| class RRCanvasElement extends RRElement { | ||
| /** | ||
| * This is just a dummy implementation to prevent rrweb replayer from drawing mouse tail. If further analysis of canvas is needed, we may implement it with node-canvas. | ||
| */ | ||
| getContext() { | ||
| return null; | ||
| } | ||
| } | ||
| class RRStyleElement extends RRElement { | ||
| constructor() { | ||
| super(...arguments); | ||
| __publicField(this, "_sheet", null); | ||
| } | ||
| get sheet() { | ||
| if (!this._sheet) { | ||
| let result = ""; | ||
| for (const child of this.childNodes) | ||
| if (child.RRNodeType === NodeType.Text) | ||
| result += child.textContent; | ||
| this._sheet = cssom.parse(result); | ||
| } | ||
| return this._sheet; | ||
| } | ||
| } | ||
| class RRIFrameElement extends RRElement { | ||
| constructor(tagName) { | ||
| super(tagName); | ||
| __publicField(this, "width", ""); | ||
| __publicField(this, "height", ""); | ||
| __publicField(this, "src", ""); | ||
| __publicField(this, "contentDocument", new RRDocument()); | ||
| __publicField(this, "contentWindow", new RRWindow()); | ||
| const htmlElement = this.contentDocument.createElement("HTML"); | ||
| this.contentDocument.appendChild(htmlElement); | ||
| htmlElement.appendChild(this.contentDocument.createElement("HEAD")); | ||
| htmlElement.appendChild(this.contentDocument.createElement("BODY")); | ||
| } | ||
| } | ||
| class RRText extends BaseRRText { | ||
| constructor() { | ||
| super(...arguments); | ||
| __publicField(this, "nodeName", "#text"); | ||
| } | ||
| } | ||
| class RRComment extends BaseRRComment { | ||
| constructor() { | ||
| super(...arguments); | ||
| __publicField(this, "nodeName", "#comment"); | ||
| } | ||
| } | ||
| class RRCDATASection extends BaseRRCDATASection { | ||
| constructor() { | ||
| super(...arguments); | ||
| __publicField(this, "nodeName", "#cdata-section"); | ||
| } | ||
| } | ||
| function polyfillPerformance() { | ||
| if (typeof window !== "undefined" || "performance" in global) | ||
| return; | ||
| const performance = require("perf_hooks").performance; | ||
| global.performance = performance; | ||
| } | ||
| function polyfillRAF() { | ||
| if (typeof window !== "undefined" || "requestAnimationFrame" in global) | ||
| return; | ||
| const FPS = 60, INTERVAL = 1e3 / FPS; | ||
| let timeoutHandle = null, rafCount = 0, requests = /* @__PURE__ */ Object.create(null); | ||
| function onFrameTimer() { | ||
| const currentRequests = requests; | ||
| requests = /* @__PURE__ */ Object.create(null); | ||
| timeoutHandle = null; | ||
| Object.keys(currentRequests).forEach(function(id) { | ||
| const request = currentRequests[id]; | ||
| if (request) | ||
| request(Date.now()); | ||
| }); | ||
| } | ||
| function requestAnimationFrame(callback) { | ||
| const cbHandle = ++rafCount; | ||
| requests[cbHandle] = callback; | ||
| if (timeoutHandle === null) | ||
| timeoutHandle = setTimeout(onFrameTimer, INTERVAL); | ||
| return cbHandle; | ||
| } | ||
| function cancelAnimationFrame(handleId) { | ||
| delete requests[handleId]; | ||
| if (Object.keys(requests).length === 0 && timeoutHandle !== null) { | ||
| clearTimeout(timeoutHandle); | ||
| timeoutHandle = null; | ||
| } | ||
| } | ||
| global.requestAnimationFrame = requestAnimationFrame; | ||
| global.cancelAnimationFrame = cancelAnimationFrame; | ||
| } | ||
| function polyfillEvent() { | ||
| if (typeof Event !== "undefined") | ||
| return; | ||
| global.Event = function() { | ||
| }; | ||
| } | ||
| function polyfillNode() { | ||
| if (typeof Node !== "undefined") | ||
| return; | ||
| global.Node = BaseRRNode; | ||
| } | ||
| function polyfillDocument() { | ||
| if (typeof document !== "undefined") | ||
| return; | ||
| const rrdom = new RRDocument(); | ||
| (() => { | ||
| var _a, _b; | ||
| rrdom.appendChild(rrdom.createElement("html")); | ||
| (_a = rrdom.documentElement) == null ? void 0 : _a.appendChild(rrdom.createElement("head")); | ||
| (_b = rrdom.documentElement) == null ? void 0 : _b.appendChild(rrdom.createElement("body")); | ||
| })(); | ||
| global.document = rrdom; | ||
| } | ||
| polyfillPerformance(); | ||
| polyfillRAF(); | ||
| polyfillEvent(); | ||
| polyfillNode(); | ||
| polyfillDocument(); | ||
| exports.RRCDATASection = RRCDATASection; | ||
| exports.RRCanvasElement = RRCanvasElement; | ||
| exports.RRComment = RRComment; | ||
| exports.RRDocument = RRDocument; | ||
| exports.RRDocumentType = RRDocumentType; | ||
| exports.RRElement = RRElement; | ||
| exports.RRIFrameElement = RRIFrameElement; | ||
| exports.RRImageElement = RRImageElement; | ||
| exports.RRMediaElement = RRMediaElement; | ||
| exports.RRStyleElement = RRStyleElement; | ||
| exports.RRText = RRText; | ||
| exports.RRWindow = RRWindow; | ||
| if (typeof module.exports == "object" && typeof exports == "object") { | ||
| var __cp = (to, from, except, desc) => { | ||
| if ((from && typeof from === "object") || typeof from === "function") { | ||
| for (let key of Object.getOwnPropertyNames(from)) { | ||
| if (!Object.prototype.hasOwnProperty.call(to, key) && key !== except) | ||
| Object.defineProperty(to, key, { | ||
| get: () => from[key], | ||
| enumerable: !(desc = Object.getOwnPropertyDescriptor(from, key)) || desc.enumerable, | ||
| }); | ||
| } | ||
| } | ||
| return to; | ||
| }; | ||
| module.exports = __cp(module.exports, exports); | ||
| } | ||
| return module.exports; | ||
| })) | ||
| //# sourceMappingURL=rrdom-nodejs.umd.cjs.map |
Sorry, the diff of this file is too big to display
| (function (g, f) { | ||
| if ("object" == typeof exports && "object" == typeof module) { | ||
| module.exports = f(); | ||
| } else if ("function" == typeof define && define.amd) { | ||
| define("rrdomNodejs", [], f); | ||
| } else if ("object" == typeof exports) { | ||
| exports["rrdomNodejs"] = f(); | ||
| } else { | ||
| g["rrdomNodejs"] = f(); | ||
| } | ||
| }(this, () => { | ||
| var exports = {}; | ||
| var module = { exports }; | ||
| "use strict";var U=Object.defineProperty,H=(n,e,t)=>e in n?U(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,o=(n,e,t)=>(H(n,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var z=Object.defineProperty,W=(n,e,t)=>e in n?z(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,r=(n,e,t)=>(W(n,typeof e!="symbol"?e+"":e,t),t),l=(n=>(n[n.Document=0]="Document",n[n.DocumentType=1]="DocumentType",n[n.Element=2]="Element",n[n.Text=3]="Text",n[n.CDATA=4]="CDATA",n[n.Comment=5]="Comment",n))(l||{});function j(n){const e={},t=/;(?![^(]*\))/g,s=/:(.+)/,i=/\/\*.*?\*\//g;return n.replace(i,"").split(t).forEach(function(a){if(a){const c=a.split(s);c.length>1&&(e[f(c[0].trim())]=c[1].trim())}}),e}function N(n){const e=[];for(const t in n){const s=n[t];if(typeof s!="string")continue;const i=J(t);e.push(`${i}: ${s};`)}return e.join(" ")}const Y=/-([a-z])/g,X=/^--[a-zA-Z0-9-]+$/,f=n=>X.test(n)?n:n.replace(Y,(e,t)=>t?t.toUpperCase():""),G=/\B([A-Z])/g,J=n=>n.replace(G,"-$1").toLowerCase();class h{constructor(...e){r(this,"parentElement",null),r(this,"parentNode",null),r(this,"ownerDocument"),r(this,"firstChild",null),r(this,"lastChild",null),r(this,"previousSibling",null),r(this,"nextSibling",null),r(this,"ELEMENT_NODE",1),r(this,"TEXT_NODE",3),r(this,"nodeType"),r(this,"nodeName"),r(this,"RRNodeType")}get childNodes(){const e=[];let t=this.firstChild;for(;t;)e.push(t),t=t.nextSibling;return e}contains(e){if(e instanceof h){if(e.ownerDocument!==this.ownerDocument)return!1;if(e===this)return!0}else return!1;for(;e.parentNode;){if(e.parentNode===this)return!0;e=e.parentNode}return!1}appendChild(e){throw new Error("RRDomException: Failed to execute 'appendChild' on 'RRNode': This RRNode type does not support this method.")}insertBefore(e,t){throw new Error("RRDomException: Failed to execute 'insertBefore' on 'RRNode': This RRNode type does not support this method.")}removeChild(e){throw new Error("RRDomException: Failed to execute 'removeChild' on 'RRNode': This RRNode type does not support this method.")}toString(){return"RRNode"}}class R extends h{constructor(...e){super(e),r(this,"nodeType",9),r(this,"nodeName","#document"),r(this,"compatMode","CSS1Compat"),r(this,"RRNodeType",l.Document),r(this,"textContent",null),this.ownerDocument=this}get documentElement(){return this.childNodes.find(e=>e.RRNodeType===l.Element&&e.tagName==="HTML")||null}get body(){var e;return((e=this.documentElement)==null?void 0:e.childNodes.find(t=>t.RRNodeType===l.Element&&t.tagName==="BODY"))||null}get head(){var e;return((e=this.documentElement)==null?void 0:e.childNodes.find(t=>t.RRNodeType===l.Element&&t.tagName==="HEAD"))||null}get implementation(){return this}get firstElementChild(){return this.documentElement}appendChild(e){const t=e.RRNodeType;if((t===l.Element||t===l.DocumentType)&&this.childNodes.some(i=>i.RRNodeType===t))throw new Error(`RRDomException: Failed to execute 'appendChild' on 'RRNode': Only one ${t===l.Element?"RRElement":"RRDoctype"} on RRDocument allowed.`);const s=E(this,e);return s.parentElement=null,s}insertBefore(e,t){const s=e.RRNodeType;if((s===l.Element||s===l.DocumentType)&&this.childNodes.some(a=>a.RRNodeType===s))throw new Error(`RRDomException: Failed to execute 'insertBefore' on 'RRNode': Only one ${s===l.Element?"RRElement":"RRDoctype"} on RRDocument allowed.`);const i=w(this,e,t);return i.parentElement=null,i}removeChild(e){return A(this,e)}open(){this.firstChild=null,this.lastChild=null}close(){}write(e){let t;if(e==='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">'?t="-//W3C//DTD XHTML 1.0 Transitional//EN":e==='<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "">'&&(t="-//W3C//DTD HTML 4.0 Transitional//EN"),t){const s=this.createDocumentType("html",t,"");this.open(),this.appendChild(s)}}createDocument(e,t,s){return new R}createDocumentType(e,t,s){const i=new y(e,t,s);return i.ownerDocument=this,i}createElement(e){const t=new g(e);return t.ownerDocument=this,t}createElementNS(e,t){return this.createElement(t)}createTextNode(e){const t=new T(e);return t.ownerDocument=this,t}createComment(e){const t=new C(e);return t.ownerDocument=this,t}createCDATASection(e){const t=new x(e);return t.ownerDocument=this,t}toString(){return"RRDocument"}}class y extends h{constructor(e,t,s){super(),r(this,"nodeType",10),r(this,"RRNodeType",l.DocumentType),r(this,"name"),r(this,"publicId"),r(this,"systemId"),r(this,"textContent",null),this.name=e,this.publicId=t,this.systemId=s,this.nodeName=e}toString(){return"RRDocumentType"}}class g extends h{constructor(e){super(),r(this,"nodeType",1),r(this,"RRNodeType",l.Element),r(this,"tagName"),r(this,"attributes",{}),r(this,"shadowRoot",null),r(this,"scrollLeft"),r(this,"scrollTop"),this.tagName=e.toUpperCase(),this.nodeName=e.toUpperCase()}get textContent(){let e="";return this.childNodes.forEach(t=>e+=t.textContent),e}set textContent(e){this.firstChild=null,this.lastChild=null,this.appendChild(this.ownerDocument.createTextNode(e))}get classList(){return new S(this.attributes.class,e=>{this.attributes.class=e})}get id(){return this.attributes.id||""}get className(){return this.attributes.class||""}get style(){const e=this.attributes.style?j(this.attributes.style):{},t=/\B([A-Z])/g;return e.setProperty=(s,i,a)=>{if(t.test(s))return;const c=f(s);i?e[c]=i:delete e[c],a==="important"&&(e[c]+=" !important"),this.attributes.style=N(e)},e.removeProperty=s=>{if(t.test(s))return"";const i=f(s),a=e[i]||"";return delete e[i],this.attributes.style=N(e),a},e}getAttribute(e){return this.attributes[e]||null}setAttribute(e,t){this.attributes[e]=t}setAttributeNS(e,t,s){this.setAttribute(t,s)}removeAttribute(e){delete this.attributes[e]}appendChild(e){return E(this,e)}insertBefore(e,t){return w(this,e,t)}removeChild(e){return A(this,e)}attachShadow(e){const t=this.ownerDocument.createElement("SHADOWROOT");return this.shadowRoot=t,t}dispatchEvent(e){return!0}toString(){let e="";for(const t in this.attributes)e+=`${t}="${this.attributes[t]}" `;return`${this.tagName} ${e}`}}class V extends g{constructor(){super(...arguments),r(this,"currentTime"),r(this,"volume"),r(this,"paused"),r(this,"muted"),r(this,"playbackRate"),r(this,"loop")}attachShadow(e){throw new Error("RRDomException: Failed to execute 'attachShadow' on 'RRElement': This RRElement does not support attachShadow")}play(){this.paused=!1}pause(){this.paused=!0}}class T extends h{constructor(e){super(),r(this,"nodeType",3),r(this,"nodeName","#text"),r(this,"RRNodeType",l.Text),r(this,"data"),this.data=e}get textContent(){return this.data}set textContent(e){this.data=e}toString(){return`RRText text=${JSON.stringify(this.data)}`}}class C extends h{constructor(e){super(),r(this,"nodeType",8),r(this,"nodeName","#comment"),r(this,"RRNodeType",l.Comment),r(this,"data"),this.data=e}get textContent(){return this.data}set textContent(e){this.data=e}toString(){return`RRComment text=${JSON.stringify(this.data)}`}}class x extends h{constructor(e){super(),r(this,"nodeName","#cdata-section"),r(this,"nodeType",4),r(this,"RRNodeType",l.CDATA),r(this,"data"),this.data=e}get textContent(){return this.data}set textContent(e){this.data=e}toString(){return`RRCDATASection data=${JSON.stringify(this.data)}`}}class S{constructor(e,t){if(r(this,"onChange"),r(this,"classes",[]),r(this,"add",(...s)=>{for(const i of s){const a=String(i);this.classes.indexOf(a)>=0||this.classes.push(a)}this.onChange&&this.onChange(this.classes.join(" "))}),r(this,"remove",(...s)=>{this.classes=this.classes.filter(i=>s.indexOf(i)===-1),this.onChange&&this.onChange(this.classes.join(" "))}),e){const s=e.trim().split(/\s+/);this.classes.push(...s)}this.onChange=t}}function E(n,e){return e.parentNode&&e.parentNode.removeChild(e),n.lastChild?(n.lastChild.nextSibling=e,e.previousSibling=n.lastChild):(n.firstChild=e,e.previousSibling=null),n.lastChild=e,e.nextSibling=null,e.parentNode=n,e.parentElement=n,e.ownerDocument=n.ownerDocument,e}function w(n,e,t){if(!t)return E(n,e);if(t.parentNode!==n)throw new Error("Failed to execute 'insertBefore' on 'RRNode': The RRNode before which the new node is to be inserted is not a child of this RRNode.");return e===t||(e.parentNode&&e.parentNode.removeChild(e),e.previousSibling=t.previousSibling,t.previousSibling=e,e.nextSibling=t,e.previousSibling?e.previousSibling.nextSibling=e:n.firstChild=e,e.parentElement=n,e.parentNode=n,e.ownerDocument=n.ownerDocument),e}function A(n,e){if(e.parentNode!==n)throw new Error("Failed to execute 'removeChild' on 'RRNode': The RRNode to be removed is not a child of this RRNode.");return e.previousSibling?e.previousSibling.nextSibling=e.nextSibling:n.firstChild=e.nextSibling,e.nextSibling?e.nextSibling.previousSibling=e.previousSibling:n.lastChild=e.previousSibling,e.previousSibling=null,e.nextSibling=null,e.parentElement=null,e.parentNode=null,e}var b=(n=>(n[n.Document=0]="Document",n[n.DocumentType=1]="DocumentType",n[n.Element=2]="Element",n[n.Text=3]="Text",n[n.CDATA=4]="CDATA",n[n.Comment=5]="Comment",n))(b||{});const Z=require("nwsapi"),k=require("cssom"),K=require("cssstyle");class v{constructor(){o(this,"scrollLeft",0),o(this,"scrollTop",0)}scrollTo(e){e&&(typeof e.left=="number"&&(this.scrollLeft=e.left),typeof e.top=="number"&&(this.scrollTop=e.top))}}class d extends R{constructor(){super(...arguments),o(this,"nodeName","#document"),o(this,"_nwsapi")}get nwsapi(){return this._nwsapi||(this._nwsapi=Z({document:this,DOMException:null}),this._nwsapi.configure({LOGERRORS:!1,IDS_DUPES:!0,MIXEDCASE:!0})),this._nwsapi}get documentElement(){return super.documentElement}get body(){return super.body}get head(){return super.head}get implementation(){return this}get firstElementChild(){return this.documentElement}appendChild(e){return super.appendChild(e)}insertBefore(e,t){return super.insertBefore(e,t)}querySelectorAll(e){return this.nwsapi.select(e)}getElementsByTagName(e){return this.documentElement?this.documentElement.getElementsByTagName(e):[]}getElementsByClassName(e){return this.documentElement?this.documentElement.getElementsByClassName(e):[]}getElementById(e){return this.documentElement?this.documentElement.getElementById(e):null}createDocument(e,t,s){return new d}createDocumentType(e,t,s){const i=new _(e,t,s);return i.ownerDocument=this,i}createElement(e){const t=e.toUpperCase();let s;switch(t){case"AUDIO":case"VIDEO":s=new O(t);break;case"IFRAME":s=new F(t);break;case"IMG":s=new B(t);break;case"CANVAS":s=new I(t);break;case"STYLE":s=new L(t);break;default:s=new u(t);break}return s.ownerDocument=this,s}createElementNS(e,t){return this.createElement(t)}createComment(e){const t=new M(e);return t.ownerDocument=this,t}createCDATASection(e){const t=new q(e);return t.ownerDocument=this,t}createTextNode(e){const t=new P(e);return t.ownerDocument=this,t}}class _ extends y{}class u extends g{constructor(e){super(e),o(this,"_style"),this._style=new K.CSSStyleDeclaration;const t=this._style;Object.defineProperty(this.attributes,"style",{get(){return t.cssText},set(s){t.cssText=s}})}get style(){return this._style}attachShadow(e){return super.attachShadow(e)}appendChild(e){return super.appendChild(e)}insertBefore(e,t){return super.insertBefore(e,t)}getAttribute(e){const t=e&&e.toLowerCase();return t in this.attributes?this.attributes[t]:null}setAttribute(e,t){this.attributes[e.toLowerCase()]=t}removeAttribute(e){delete this.attributes[e.toLowerCase()]}get firstElementChild(){for(const e of this.childNodes)if(e.RRNodeType===b.Element)return e;return null}get nextElementSibling(){const e=this.parentNode;if(!e)return null;const t=e.childNodes,s=t.indexOf(this);for(let i=s+1;i<t.length;i++)if(t[i]instanceof u)return t[i];return null}querySelectorAll(e){const t=[];return this.ownerDocument!==null&&this.ownerDocument.nwsapi.select(e,this,s=>{s!==this&&t.push(s)}),t}getElementById(e){if(this.id===e)return this;for(const t of this.childNodes)if(t instanceof u){const s=t.getElementById(e);if(s!==null)return s}return null}getElementsByClassName(e){let t=[];const s=new S(e);this instanceof u&&s.classes.filter(i=>this.classList.classes.some(a=>a===i)).length==s.classes.length&&t.push(this);for(const i of this.childNodes)i instanceof u&&(t=t.concat(i.getElementsByClassName(e)));return t}getElementsByTagName(e){let t=[];const s=e.toUpperCase();this instanceof u&&this.tagName===s&&t.push(this);for(const i of this.childNodes)i instanceof u&&(t=t.concat(i.getElementsByTagName(e)));return t}}class B extends u{constructor(){super(...arguments),o(this,"src",""),o(this,"width",0),o(this,"height",0),o(this,"onload",null)}}class O extends V{}class I extends u{getContext(){return null}}class L extends u{constructor(){super(...arguments),o(this,"_sheet",null)}get sheet(){if(!this._sheet){let e="";for(const t of this.childNodes)t.RRNodeType===b.Text&&(e+=t.textContent);this._sheet=k.parse(e)}return this._sheet}}class F extends u{constructor(e){super(e),o(this,"width",""),o(this,"height",""),o(this,"src",""),o(this,"contentDocument",new d),o(this,"contentWindow",new v);const t=this.contentDocument.createElement("HTML");this.contentDocument.appendChild(t),t.appendChild(this.contentDocument.createElement("HEAD")),t.appendChild(this.contentDocument.createElement("BODY"))}}class P extends T{constructor(){super(...arguments),o(this,"nodeName","#text")}}class M extends C{constructor(){super(...arguments),o(this,"nodeName","#comment")}}class q extends x{constructor(){super(...arguments),o(this,"nodeName","#cdata-section")}}function Q(){if(typeof window!="undefined"||"performance"in global)return;const n=require("perf_hooks").performance;global.performance=n}function ee(){if(typeof window!="undefined"||"requestAnimationFrame"in global)return;const n=60,e=1e3/n;let t=null,s=0,i=Object.create(null);function a(){const m=i;i=Object.create(null),t=null,Object.keys(m).forEach(function(p){const D=m[p];D&&D(Date.now())})}function c(m){const p=++s;return i[p]=m,t===null&&(t=setTimeout(a,e)),p}function $(m){delete i[m],Object.keys(i).length===0&&t!==null&&(clearTimeout(t),t=null)}global.requestAnimationFrame=c,global.cancelAnimationFrame=$}function te(){typeof Event=="undefined"&&(global.Event=function(){})}function ne(){typeof Node=="undefined"&&(global.Node=h)}function se(){if(typeof document!="undefined")return;const n=new d;(()=>{var e,t;n.appendChild(n.createElement("html")),(e=n.documentElement)==null||e.appendChild(n.createElement("head")),(t=n.documentElement)==null||t.appendChild(n.createElement("body"))})(),global.document=n}Q();ee();te();ne();se();exports.RRCDATASection=q;exports.RRCanvasElement=I;exports.RRComment=M;exports.RRDocument=d;exports.RRDocumentType=_;exports.RRElement=u;exports.RRIFrameElement=F;exports.RRImageElement=B;exports.RRMediaElement=O;exports.RRStyleElement=L;exports.RRText=P;exports.RRWindow=v; | ||
| if (typeof module.exports == "object" && typeof exports == "object") { | ||
| var __cp = (to, from, except, desc) => { | ||
| if ((from && typeof from === "object") || typeof from === "function") { | ||
| for (let key of Object.getOwnPropertyNames(from)) { | ||
| if (!Object.prototype.hasOwnProperty.call(to, key) && key !== except) | ||
| Object.defineProperty(to, key, { | ||
| get: () => from[key], | ||
| enumerable: !(desc = Object.getOwnPropertyDescriptor(from, key)) || desc.enumerable, | ||
| }); | ||
| } | ||
| } | ||
| return to; | ||
| }; | ||
| module.exports = __cp(module.exports, exports); | ||
| } | ||
| return module.exports; | ||
| })) | ||
| //# sourceMappingURL=rrdom-nodejs.umd.min.cjs.map |
Sorry, the diff of this file is too big to display
+179
| # rrdom-nodejs | ||
| `rrdom-nodejs` is a Node.js implementation of the [`rrdom`](../rrdom/) library. It allows you to replay and inspect recorded user interactions with `rrweb` in a Node.js environment. | ||
| See the [guide](../../guide.md) for more info on rrweb. | ||
| ## Sponsors | ||
| [Become a sponsor](https://opencollective.com/rrweb#sponsor) and get your logo on our README on Github with a link to your site. | ||
| ### Gold Sponsors 🥇 | ||
| <div dir="auto"> | ||
| <a href="https://opencollective.com/rrweb/tiers/gold-sponsor/0/website?requireActive=false" target="_blank"><img src="https://opencollective.com/rrweb/tiers/gold-sponsor/0/avatar.svg?requireActive=false&avatarHeight=225" alt="sponsor"></a> | ||
| <a href="https://opencollective.com/rrweb/tiers/gold-sponsor/1/website?requireActive=false" target="_blank"><img src="https://opencollective.com/rrweb/tiers/gold-sponsor/1/avatar.svg?requireActive=false&avatarHeight=225" alt="sponsor"></a> | ||
| <a href="https://opencollective.com/rrweb/tiers/gold-sponsor/2/website?requireActive=false" target="_blank"><img src="https://opencollective.com/rrweb/tiers/gold-sponsor/2/avatar.svg?requireActive=false&avatarHeight=225" alt="sponsor"></a> | ||
| <a href="https://opencollective.com/rrweb/tiers/gold-sponsor/3/website?requireActive=false" target="_blank"><img src="https://opencollective.com/rrweb/tiers/gold-sponsor/3/avatar.svg?requireActive=false&avatarHeight=225" alt="sponsor"></a> | ||
| <a href="https://opencollective.com/rrweb/tiers/gold-sponsor/4/website?requireActive=false" target="_blank"><img src="https://opencollective.com/rrweb/tiers/gold-sponsor/4/avatar.svg?requireActive=false&avatarHeight=225" alt="sponsor"></a> | ||
| <a href="https://opencollective.com/rrweb/tiers/gold-sponsor/5/website?requireActive=false" target="_blank"><img src="https://opencollective.com/rrweb/tiers/gold-sponsor/5/avatar.svg?requireActive=false&avatarHeight=225" alt="sponsor"></a> | ||
| <a href="https://opencollective.com/rrweb/tiers/gold-sponsor/6/website?requireActive=false" target="_blank"><img src="https://opencollective.com/rrweb/tiers/gold-sponsor/6/avatar.svg?requireActive=false&avatarHeight=225" alt="sponsor"></a> | ||
| </div> | ||
| ### Silver Sponsors 🥈 | ||
| <div dir="auto"> | ||
| <a href="https://opencollective.com/rrweb/tiers/silver-sponsor/0/website?requireActive=false" target="_blank"><img src="https://opencollective.com/rrweb/tiers/silver-sponsor/0/avatar.svg?requireActive=false&avatarHeight=158" alt="sponsor"></a> | ||
| <a href="https://opencollective.com/rrweb/tiers/silver-sponsor/1/website?requireActive=false" target="_blank"><img src="https://opencollective.com/rrweb/tiers/silver-sponsor/1/avatar.svg?requireActive=false&avatarHeight=158" alt="sponsor"></a> | ||
| <a href="https://opencollective.com/rrweb/tiers/silver-sponsor/2/website?requireActive=false" target="_blank"><img src="https://opencollective.com/rrweb/tiers/silver-sponsor/2/avatar.svg?requireActive=false&avatarHeight=158" alt="sponsor"></a> | ||
| <a href="https://opencollective.com/rrweb/tiers/silver-sponsor/3/website?requireActive=false" target="_blank"><img src="https://opencollective.com/rrweb/tiers/silver-sponsor/3/avatar.svg?requireActive=false&avatarHeight=158" alt="sponsor"></a> | ||
| <a href="https://opencollective.com/rrweb/tiers/silver-sponsor/4/website?requireActive=false" target="_blank"><img src="https://opencollective.com/rrweb/tiers/silver-sponsor/4/avatar.svg?requireActive=false&avatarHeight=158" alt="sponsor"></a> | ||
| <a href="https://opencollective.com/rrweb/tiers/silver-sponsor/5/website?requireActive=false" target="_blank"><img src="https://opencollective.com/rrweb/tiers/silver-sponsor/5/avatar.svg?requireActive=false&avatarHeight=158" alt="sponsor"></a> | ||
| <a href="https://opencollective.com/rrweb/tiers/silver-sponsor/6/website?requireActive=false" target="_blank"><img src="https://opencollective.com/rrweb/tiers/silver-sponsor/6/avatar.svg?requireActive=false&avatarHeight=158" alt="sponsor"></a> | ||
| </div> | ||
| ### Bronze Sponsors 🥉 | ||
| <div dir="auto"> | ||
| <a href="https://opencollective.com/rrweb/tiers/sponsors/0/website?requireActive=false" target="_blank"><img src="https://opencollective.com/rrweb/tiers/sponsors/0/avatar.svg?requireActive=false&avatarHeight=70" alt="sponsor"></a> | ||
| <a href="https://opencollective.com/rrweb/tiers/sponsors/1/website?requireActive=false" target="_blank"><img src="https://opencollective.com/rrweb/tiers/sponsors/1/avatar.svg?requireActive=false&avatarHeight=70" alt="sponsor"></a> | ||
| <a href="https://opencollective.com/rrweb/tiers/sponsors/2/website?requireActive=false" target="_blank"><img src="https://opencollective.com/rrweb/tiers/sponsors/2/avatar.svg?requireActive=false&avatarHeight=70" alt="sponsor"></a> | ||
| <a href="https://opencollective.com/rrweb/tiers/sponsors/3/website?requireActive=false" target="_blank"><img src="https://opencollective.com/rrweb/tiers/sponsors/3/avatar.svg?requireActive=false&avatarHeight=70" alt="sponsor"></a> | ||
| <a href="https://opencollective.com/rrweb/tiers/sponsors/4/website?requireActive=false" target="_blank"><img src="https://opencollective.com/rrweb/tiers/sponsors/4/avatar.svg?requireActive=false&avatarHeight=70" alt="sponsor"></a> | ||
| <a href="https://opencollective.com/rrweb/tiers/sponsors/5/website?requireActive=false" target="_blank"><img src="https://opencollective.com/rrweb/tiers/sponsors/5/avatar.svg?requireActive=false&avatarHeight=70" alt="sponsor"></a> | ||
| <a href="https://opencollective.com/rrweb/tiers/sponsors/6/website?requireActive=false" target="_blank"><img src="https://opencollective.com/rrweb/tiers/sponsors/6/avatar.svg?requireActive=false&avatarHeight=70" alt="sponsor"></a> | ||
| <a href="https://opencollective.com/rrweb/tiers/sponsors/7/website?requireActive=false" target="_blank"><img src="https://opencollective.com/rrweb/tiers/sponsors/7/avatar.svg?requireActive=false&avatarHeight=70" alt="sponsor"></a> | ||
| <a href="https://opencollective.com/rrweb/tiers/sponsors/8/website?requireActive=false" target="_blank"><img src="https://opencollective.com/rrweb/tiers/sponsors/8/avatar.svg?requireActive=false&avatarHeight=70" alt="sponsor"></a> | ||
| </div> | ||
| ### Backers | ||
| <a href="https://opencollective.com/rrweb#sponsor" rel="nofollow"><img src="https://opencollective.com/rrweb/tiers/backers.svg?avatarHeight=36"></a> | ||
| ## Core Team Members | ||
| <table> | ||
| <tr> | ||
| <td align="center"> | ||
| <a href="https://github.com/Yuyz0112"> | ||
| <img | ||
| src="https://avatars.githubusercontent.com/u/13651389?s=100" | ||
| width="100px;" | ||
| alt="" | ||
| /> | ||
| <br /><sub><b>Yuyz0112</b></sub> | ||
| <br /><br /> | ||
| </a> | ||
| </td> | ||
| <td align="center"> | ||
| <a href="https://github.com/YunFeng0817"> | ||
| <img | ||
| src="https://avatars.githubusercontent.com/u/27533910?s=100" | ||
| width="100px;" | ||
| alt="" | ||
| /> | ||
| <br /><sub><b>Yun Feng</b></sub> | ||
| <br /><br /> | ||
| </a> | ||
| </td> | ||
| <td align="center"> | ||
| <a href="https://github.com/eoghanmurray"> | ||
| <img | ||
| src="https://avatars.githubusercontent.com/u/156780?s=100" | ||
| width="100px;" | ||
| alt="" | ||
| /> | ||
| <br /><sub><b>eoghanmurray</b></sub> | ||
| <br /><br /> | ||
| </a> | ||
| </td> | ||
| <td align="center"> | ||
| <a href="https://github.com/Juice10"> | ||
| <img | ||
| src="https://avatars.githubusercontent.com/u/4106?s=100" | ||
| width="100px;" | ||
| alt="" | ||
| /> | ||
| <br /><sub><b>Juice10</b></sub> | ||
| <br /><sub>open for rrweb consulting</sub> | ||
| </a> | ||
| </td> | ||
| </tr> | ||
| </table> | ||
| ## Who's using rrweb? | ||
| <table> | ||
| <tr> | ||
| <td align="center"> | ||
| <a href="http://www.smartx.com/" target="_blank"> | ||
| <img width="195px" src="https://www.rrweb.io/logos/smartx.png"> | ||
| </a> | ||
| </td> | ||
| <td align="center"> | ||
| <a href="https://posthog.com?utm_source=rrweb&utm_medium=sponsorship&utm_campaign=open-source-sponsorship" target="_blank"> | ||
| <img width="195px" src="https://www.rrweb.io/logos/posthog.png"> | ||
| </a> | ||
| </td> | ||
| <td align="center"> | ||
| <a href="https://statcounter.com/session-replay/" target="_blank"> | ||
| <img width="195px" src="https://statcounter.com/images/logo-statcounter-arc-blue.svg"> | ||
| </a> | ||
| </td> | ||
| <td align="center"> | ||
| <a href="https://recordonce.com/" target="_blank"> | ||
| <img width="195px" alt="Smart screen recording for SaaS" src="https://uploads-ssl.webflow.com/5f3d133183156245630d4446/5f3d1940abe8db8612c23521_Record-Once-logo-554x80px.svg"> | ||
| </a> | ||
| </td> | ||
| </tr> | ||
| <tr> | ||
| <td align="center"> | ||
| <a href="https://cux.io" target="_blank"> | ||
| <img style="padding: 8px" alt="The first ever UX automation tool" width="195px" src="https://cux.io/cux-logo.svg"> | ||
| </a> | ||
| </td> | ||
| <td align="center"> | ||
| <a href="https://remsupp.com" target="_blank"> | ||
| <img style="padding: 8px" alt="Remote Access & Co-Browsing" width="195px" src="https://remsupp.com/images/logo.png"> | ||
| </a> | ||
| </td> | ||
| <td align="center"> | ||
| <a href="https://highlight.io" target="_blank"> | ||
| <img style="padding: 8px" alt="The open source, fullstack Monitoring Platform." width="195px" src="https://github.com/highlight/highlight/raw/main/highlight.io/public/images/logo.png"> | ||
| </a> | ||
| </td> | ||
| <td align="center"> | ||
| <a href="https://analyzee.io" target="_blank"> | ||
| <img style="padding: 8px" alt="Comprehensive data analytics platform that empowers businesses to gain valuable insights and make data-driven decisions." width="195px" src="https://cdn.analyzee.io/assets/analyzee-logo.png"> | ||
| </a> | ||
| </td> | ||
| </tr> | ||
| <tr> | ||
| <td align="center"> | ||
| <a href="https://requestly.io" target="_blank"> | ||
| <img style="padding: 8px" alt="Intercept, Modify, Record & Replay HTTP Requests." width="195px" src="https://github.com/requestly/requestly/assets/16779465/652552db-c867-44cb-9bb5-94a2026e04ca"> | ||
| </a> | ||
| </td> | ||
| <td align="center"> | ||
| <a href="https://gleap.io" target="_blank"> | ||
| <img style="padding: 8px" alt="In-app bug reporting & customer feedback platform." width="195px" src="https://assets-global.website-files.com/6506f3f29c68b1724807619d/6506f56010237164c6306591_GleapLogo.svg"> | ||
| </a> | ||
| </td> | ||
| <td align="center"> | ||
| <a href="https://uxwizz.com" target="_blank"> | ||
| <img style="padding: 8px" alt="Self-hosted website analytics with heatmaps and session recordings." width="195px" src="https://github.com/UXWizz/public-files/raw/main/assets/logo.png"> | ||
| </a> | ||
| </td> | ||
| <td align="center"> | ||
| <a href="https://www.howdygo.com" target="_blank"> | ||
| <img style="padding: 8px" alt="Interactive product demos for small marketing teams" width="195px" src="https://assets-global.website-files.com/650afb446f1dd5bd410f00cc/650b2cec6188ff54dd9b01e1_Logo.svg"> | ||
| </a> | ||
| </td> | ||
| </tr> | ||
| </table> |
+30
-23
| { | ||
| "name": "rrdom-nodejs", | ||
| "version": "2.0.0-alpha.14", | ||
| "version": "2.0.0-alpha.15", | ||
| "scripts": { | ||
| "dev": "rollup -c -w", | ||
| "bundle": "rollup --config", | ||
| "bundle:es-only": "cross-env ES_ONLY=true rollup --config", | ||
| "dev": "vite build --watch", | ||
| "build": "tsc -noEmit && vite build", | ||
| "check-types": "tsc -noEmit", | ||
| "test": "jest", | ||
| "prepublish": "npm run bundle", | ||
| "test": "vitest run", | ||
| "test:watch": "vitest watch", | ||
| "prepublish": "npm run build", | ||
| "lint": "yarn eslint src/**/*.ts" | ||
@@ -18,17 +18,26 @@ }, | ||
| "license": "MIT", | ||
| "main": "lib/rrdom-nodejs.cjs", | ||
| "module": "es/rrdom-nodejs.js", | ||
| "typings": "es", | ||
| "type": "module", | ||
| "main": "./dist/rrdom-nodejs.umd.cjs", | ||
| "module": "./dist/rrdom-nodejs.js", | ||
| "unpkg": "./dist/rrdom-nodejs.umd.cjs", | ||
| "typings": "dist/index.d.ts", | ||
| "exports": { | ||
| ".": { | ||
| "import": { | ||
| "types": "./dist/index.d.ts", | ||
| "default": "./dist/rrdom-nodejs.js" | ||
| }, | ||
| "require": { | ||
| "types": "./dist/index.d.cts", | ||
| "default": "./dist/rrdom-nodejs.umd.cjs" | ||
| } | ||
| } | ||
| }, | ||
| "files": [ | ||
| "dist", | ||
| "lib", | ||
| "es", | ||
| "typings" | ||
| "package.json" | ||
| ], | ||
| "devDependencies": { | ||
| "@rollup/plugin-commonjs": "^20.0.0", | ||
| "@rollup/plugin-node-resolve": "^13.0.4", | ||
| "@types/cssom": "^0.4.1", | ||
| "@types/cssstyle": "^2.2.1", | ||
| "@types/jest": "^27.4.1", | ||
| "@types/nwsapi": "^2.2.2", | ||
@@ -40,9 +49,7 @@ "@types/puppeteer": "^5.4.4", | ||
| "eslint": "^8.15.0", | ||
| "jest": "^27.5.1", | ||
| "puppeteer": "^9.1.1", | ||
| "rollup": "^2.56.3", | ||
| "rollup-plugin-terser": "^7.0.2", | ||
| "rollup-plugin-typescript2": "^0.31.2", | ||
| "rollup-plugin-web-worker-loader": "^1.6.1", | ||
| "ts-jest": "^27.1.3" | ||
| "vite": "^5.2.8", | ||
| "vite-plugin-dts": "^3.8.1", | ||
| "vitest": "^1.4.0", | ||
| "typescript": "^4.7.3" | ||
| }, | ||
@@ -53,4 +60,4 @@ "dependencies": { | ||
| "nwsapi": "^2.2.0", | ||
| "rrdom": "^2.0.0-alpha.14", | ||
| "rrweb-snapshot": "^2.0.0-alpha.14" | ||
| "rrdom": "^2.0.0-alpha.15", | ||
| "rrweb-snapshot": "^2.0.0-alpha.15" | ||
| }, | ||
@@ -57,0 +64,0 @@ "browserslist": [ |
| import { NodeType as RRNodeType } from 'rrweb-snapshot'; | ||
| import type { NWSAPI } from 'nwsapi'; | ||
| import { BaseRRNode, ClassList, IRRDocument, CSSStyleDeclaration } from 'rrdom'; | ||
| export declare class RRNode extends BaseRRNode { | ||
| } | ||
| export declare class RRWindow { | ||
| scrollLeft: number; | ||
| scrollTop: number; | ||
| scrollTo(options?: ScrollToOptions): void; | ||
| } | ||
| declare const RRDocument_base: (new (...args: any[]) => { | ||
| readonly nodeType: number; | ||
| readonly nodeName: "#document"; | ||
| readonly compatMode: "BackCompat" | "CSS1Compat"; | ||
| readonly RRNodeType: RRNodeType.Document; | ||
| readonly documentElement: import("rrdom").IRRElement | null; | ||
| readonly body: import("rrdom").IRRElement | null; | ||
| readonly head: import("rrdom").IRRElement | null; | ||
| readonly implementation: IRRDocument; | ||
| readonly firstElementChild: import("rrdom").IRRElement | null; | ||
| appendChild(newChild: import("rrdom").IRRNode): import("rrdom").IRRNode; | ||
| insertBefore(newChild: import("rrdom").IRRNode, refChild: import("rrdom").IRRNode | null): import("rrdom").IRRNode; | ||
| removeChild(node: import("rrdom").IRRNode): import("rrdom").IRRNode; | ||
| open(): void; | ||
| close(): void; | ||
| write(content: string): void; | ||
| createDocument(_namespace: string | null, _qualifiedName: string | null, _doctype?: DocumentType | null | undefined): IRRDocument; | ||
| createDocumentType(qualifiedName: string, publicId: string, systemId: string): import("rrdom").IRRDocumentType; | ||
| createElement(tagName: string): import("rrdom").IRRElement; | ||
| createElementNS(_namespaceURI: string, qualifiedName: string): import("rrdom").IRRElement; | ||
| createTextNode(data: string): import("rrdom").IRRText; | ||
| createComment(data: string): import("rrdom").IRRComment; | ||
| createCDATASection(data: string): import("rrdom").IRRCDATASection; | ||
| toString(): string; | ||
| parentElement: import("rrdom").IRRNode | null; | ||
| parentNode: import("rrdom").IRRNode | null; | ||
| ownerDocument: IRRDocument; | ||
| readonly childNodes: import("rrdom").IRRNode[]; | ||
| readonly ELEMENT_NODE: number; | ||
| readonly TEXT_NODE: number; | ||
| firstChild: import("rrdom").IRRNode | null; | ||
| lastChild: import("rrdom").IRRNode | null; | ||
| previousSibling: import("rrdom").IRRNode | null; | ||
| nextSibling: import("rrdom").IRRNode | null; | ||
| textContent: string | null; | ||
| contains(node: import("rrdom").IRRNode): boolean; | ||
| }) & typeof RRNode; | ||
| export declare class RRDocument extends RRDocument_base implements IRRDocument { | ||
| readonly nodeName: '#document'; | ||
| private _nwsapi; | ||
| get nwsapi(): NWSAPI; | ||
| get documentElement(): RRElement | null; | ||
| get body(): RRElement | null; | ||
| get head(): RRElement | null; | ||
| get implementation(): RRDocument; | ||
| get firstElementChild(): RRElement | null; | ||
| appendChild(childNode: RRNode): import("rrdom").IRRNode; | ||
| insertBefore(newChild: RRNode, refChild: RRNode | null): import("rrdom").IRRNode; | ||
| querySelectorAll(selectors: string): RRNode[]; | ||
| getElementsByTagName(tagName: string): RRElement[]; | ||
| getElementsByClassName(className: string): RRElement[]; | ||
| getElementById(elementId: string): RRElement | null; | ||
| createDocument(_namespace: string | null, _qualifiedName: string | null, _doctype?: DocumentType | null): RRDocument; | ||
| createDocumentType(qualifiedName: string, publicId: string, systemId: string): RRDocumentType; | ||
| createElement<K extends keyof HTMLElementTagNameMap>(tagName: K): RRElementType<K>; | ||
| createElement(tagName: string): RRElement; | ||
| createElementNS(_namespaceURI: string, qualifiedName: string): RRElement | RRMediaElement | RRCanvasElement | RRIFrameElement | RRImageElement | RRStyleElement; | ||
| createComment(data: string): RRComment; | ||
| createCDATASection(data: string): RRCDATASection; | ||
| createTextNode(data: string): RRText; | ||
| } | ||
| declare const RRDocumentType_base: (new (qualifiedName: string, publicId: string, systemId: string) => { | ||
| readonly nodeType: number; | ||
| readonly RRNodeType: RRNodeType.DocumentType; | ||
| readonly nodeName: string; | ||
| readonly name: string; | ||
| readonly publicId: string; | ||
| readonly systemId: string; | ||
| toString(): string; | ||
| parentElement: import("rrdom").IRRNode | null; | ||
| parentNode: import("rrdom").IRRNode | null; | ||
| ownerDocument: IRRDocument; | ||
| readonly childNodes: import("rrdom").IRRNode[]; | ||
| readonly ELEMENT_NODE: number; | ||
| readonly TEXT_NODE: number; | ||
| firstChild: import("rrdom").IRRNode | null; | ||
| lastChild: import("rrdom").IRRNode | null; | ||
| previousSibling: import("rrdom").IRRNode | null; | ||
| nextSibling: import("rrdom").IRRNode | null; | ||
| textContent: string | null; | ||
| contains(node: import("rrdom").IRRNode): boolean; | ||
| appendChild(newChild: import("rrdom").IRRNode): import("rrdom").IRRNode; | ||
| insertBefore(newChild: import("rrdom").IRRNode, refChild: import("rrdom").IRRNode | null): import("rrdom").IRRNode; | ||
| removeChild(node: import("rrdom").IRRNode): import("rrdom").IRRNode; | ||
| }) & typeof RRNode; | ||
| export declare class RRDocumentType extends RRDocumentType_base { | ||
| } | ||
| declare const RRElement_base: (new (tagName: string) => { | ||
| readonly nodeType: number; | ||
| readonly RRNodeType: RRNodeType.Element; | ||
| readonly nodeName: string; | ||
| tagName: string; | ||
| attributes: Record<string, string>; | ||
| shadowRoot: import("rrdom").IRRElement | null; | ||
| scrollLeft?: number | undefined; | ||
| scrollTop?: number | undefined; | ||
| textContent: string; | ||
| readonly classList: ClassList; | ||
| readonly id: string; | ||
| readonly className: string; | ||
| readonly style: CSSStyleDeclaration; | ||
| getAttribute(name: string): string | null; | ||
| setAttribute(name: string, attribute: string): void; | ||
| setAttributeNS(_namespace: string | null, qualifiedName: string, value: string): void; | ||
| removeAttribute(name: string): void; | ||
| appendChild(newChild: import("rrdom").IRRNode): import("rrdom").IRRNode; | ||
| insertBefore(newChild: import("rrdom").IRRNode, refChild: import("rrdom").IRRNode | null): import("rrdom").IRRNode; | ||
| removeChild(node: import("rrdom").IRRNode): import("rrdom").IRRNode; | ||
| attachShadow(_init: ShadowRootInit): import("rrdom").IRRElement; | ||
| dispatchEvent(_event: Event): boolean; | ||
| toString(): string; | ||
| parentElement: import("rrdom").IRRNode | null; | ||
| parentNode: import("rrdom").IRRNode | null; | ||
| ownerDocument: IRRDocument; | ||
| readonly childNodes: import("rrdom").IRRNode[]; | ||
| readonly ELEMENT_NODE: number; | ||
| readonly TEXT_NODE: number; | ||
| firstChild: import("rrdom").IRRNode | null; | ||
| lastChild: import("rrdom").IRRNode | null; | ||
| previousSibling: import("rrdom").IRRNode | null; | ||
| nextSibling: import("rrdom").IRRNode | null; | ||
| contains(node: import("rrdom").IRRNode): boolean; | ||
| }) & typeof RRNode; | ||
| export declare class RRElement extends RRElement_base { | ||
| private _style; | ||
| constructor(tagName: string); | ||
| get style(): CSSStyleDeclaration; | ||
| attachShadow(_init: ShadowRootInit): RRElement; | ||
| appendChild(newChild: RRNode): RRNode; | ||
| insertBefore(newChild: RRNode, refChild: RRNode | null): RRNode; | ||
| getAttribute(name: string): string | null; | ||
| setAttribute(name: string, attribute: string): void; | ||
| removeAttribute(name: string): void; | ||
| get firstElementChild(): RRElement | null; | ||
| get nextElementSibling(): RRElement | null; | ||
| querySelectorAll(selectors: string): RRNode[]; | ||
| getElementById(elementId: string): RRElement | null; | ||
| getElementsByClassName(className: string): RRElement[]; | ||
| getElementsByTagName(tagName: string): RRElement[]; | ||
| } | ||
| export declare class RRImageElement extends RRElement { | ||
| src: string; | ||
| width: number; | ||
| height: number; | ||
| onload: ((this: GlobalEventHandlers, ev: Event) => unknown) | null; | ||
| } | ||
| declare const RRMediaElement_base: (new (...args: any[]) => { | ||
| currentTime?: number | undefined; | ||
| volume?: number | undefined; | ||
| paused?: boolean | undefined; | ||
| muted?: boolean | undefined; | ||
| playbackRate?: number | undefined; | ||
| loop?: boolean | undefined; | ||
| attachShadow(_init: ShadowRootInit): import("rrdom").IRRElement; | ||
| play(): void; | ||
| pause(): void; | ||
| tagName: string; | ||
| attributes: Record<string, string>; | ||
| shadowRoot: import("rrdom").IRRElement | null; | ||
| scrollLeft?: number | undefined; | ||
| scrollTop?: number | undefined; | ||
| id: string; | ||
| className: string; | ||
| classList: ClassList; | ||
| style: CSSStyleDeclaration; | ||
| getAttribute(name: string): string | null; | ||
| setAttribute(name: string, attribute: string): void; | ||
| setAttributeNS(namespace: string | null, qualifiedName: string, value: string): void; | ||
| removeAttribute(name: string): void; | ||
| dispatchEvent(event: Event): boolean; | ||
| parentElement: import("rrdom").IRRNode | null; | ||
| parentNode: import("rrdom").IRRNode | null; | ||
| ownerDocument: IRRDocument; | ||
| readonly childNodes: import("rrdom").IRRNode[]; | ||
| readonly ELEMENT_NODE: number; | ||
| readonly TEXT_NODE: number; | ||
| readonly nodeType: number; | ||
| readonly nodeName: string; | ||
| readonly RRNodeType: RRNodeType; | ||
| firstChild: import("rrdom").IRRNode | null; | ||
| lastChild: import("rrdom").IRRNode | null; | ||
| previousSibling: import("rrdom").IRRNode | null; | ||
| nextSibling: import("rrdom").IRRNode | null; | ||
| textContent: string | null; | ||
| contains(node: import("rrdom").IRRNode): boolean; | ||
| appendChild(newChild: import("rrdom").IRRNode): import("rrdom").IRRNode; | ||
| insertBefore(newChild: import("rrdom").IRRNode, refChild: import("rrdom").IRRNode | null): import("rrdom").IRRNode; | ||
| removeChild(node: import("rrdom").IRRNode): import("rrdom").IRRNode; | ||
| toString(): string; | ||
| }) & typeof RRElement; | ||
| export declare class RRMediaElement extends RRMediaElement_base { | ||
| } | ||
| export declare class RRCanvasElement extends RRElement { | ||
| getContext(): CanvasRenderingContext2D | null; | ||
| } | ||
| export declare class RRStyleElement extends RRElement { | ||
| private _sheet; | ||
| get sheet(): CSSStyleSheet | null; | ||
| } | ||
| export declare class RRIFrameElement extends RRElement { | ||
| width: string; | ||
| height: string; | ||
| src: string; | ||
| contentDocument: RRDocument; | ||
| contentWindow: RRWindow; | ||
| constructor(tagName: string); | ||
| } | ||
| declare const RRText_base: (new (data: string) => { | ||
| readonly nodeType: number; | ||
| readonly nodeName: "#text"; | ||
| readonly RRNodeType: RRNodeType.Text; | ||
| data: string; | ||
| textContent: string; | ||
| toString(): string; | ||
| parentElement: import("rrdom").IRRNode | null; | ||
| parentNode: import("rrdom").IRRNode | null; | ||
| ownerDocument: IRRDocument; | ||
| readonly childNodes: import("rrdom").IRRNode[]; | ||
| readonly ELEMENT_NODE: number; | ||
| readonly TEXT_NODE: number; | ||
| firstChild: import("rrdom").IRRNode | null; | ||
| lastChild: import("rrdom").IRRNode | null; | ||
| previousSibling: import("rrdom").IRRNode | null; | ||
| nextSibling: import("rrdom").IRRNode | null; | ||
| contains(node: import("rrdom").IRRNode): boolean; | ||
| appendChild(newChild: import("rrdom").IRRNode): import("rrdom").IRRNode; | ||
| insertBefore(newChild: import("rrdom").IRRNode, refChild: import("rrdom").IRRNode | null): import("rrdom").IRRNode; | ||
| removeChild(node: import("rrdom").IRRNode): import("rrdom").IRRNode; | ||
| }) & typeof RRNode; | ||
| export declare class RRText extends RRText_base { | ||
| readonly nodeName: '#text'; | ||
| } | ||
| declare const RRComment_base: (new (data: string) => { | ||
| readonly nodeType: number; | ||
| readonly nodeName: "#comment"; | ||
| readonly RRNodeType: RRNodeType.Comment; | ||
| data: string; | ||
| textContent: string; | ||
| toString(): string; | ||
| parentElement: import("rrdom").IRRNode | null; | ||
| parentNode: import("rrdom").IRRNode | null; | ||
| ownerDocument: IRRDocument; | ||
| readonly childNodes: import("rrdom").IRRNode[]; | ||
| readonly ELEMENT_NODE: number; | ||
| readonly TEXT_NODE: number; | ||
| firstChild: import("rrdom").IRRNode | null; | ||
| lastChild: import("rrdom").IRRNode | null; | ||
| previousSibling: import("rrdom").IRRNode | null; | ||
| nextSibling: import("rrdom").IRRNode | null; | ||
| contains(node: import("rrdom").IRRNode): boolean; | ||
| appendChild(newChild: import("rrdom").IRRNode): import("rrdom").IRRNode; | ||
| insertBefore(newChild: import("rrdom").IRRNode, refChild: import("rrdom").IRRNode | null): import("rrdom").IRRNode; | ||
| removeChild(node: import("rrdom").IRRNode): import("rrdom").IRRNode; | ||
| }) & typeof RRNode; | ||
| export declare class RRComment extends RRComment_base { | ||
| readonly nodeName: '#comment'; | ||
| } | ||
| declare const RRCDATASection_base: (new (data: string) => { | ||
| readonly nodeName: "#cdata-section"; | ||
| readonly nodeType: number; | ||
| readonly RRNodeType: RRNodeType.CDATA; | ||
| data: string; | ||
| textContent: string; | ||
| toString(): string; | ||
| parentElement: import("rrdom").IRRNode | null; | ||
| parentNode: import("rrdom").IRRNode | null; | ||
| ownerDocument: IRRDocument; | ||
| readonly childNodes: import("rrdom").IRRNode[]; | ||
| readonly ELEMENT_NODE: number; | ||
| readonly TEXT_NODE: number; | ||
| firstChild: import("rrdom").IRRNode | null; | ||
| lastChild: import("rrdom").IRRNode | null; | ||
| previousSibling: import("rrdom").IRRNode | null; | ||
| nextSibling: import("rrdom").IRRNode | null; | ||
| contains(node: import("rrdom").IRRNode): boolean; | ||
| appendChild(newChild: import("rrdom").IRRNode): import("rrdom").IRRNode; | ||
| insertBefore(newChild: import("rrdom").IRRNode, refChild: import("rrdom").IRRNode | null): import("rrdom").IRRNode; | ||
| removeChild(node: import("rrdom").IRRNode): import("rrdom").IRRNode; | ||
| }) & typeof RRNode; | ||
| export declare class RRCDATASection extends RRCDATASection_base { | ||
| readonly nodeName: '#cdata-section'; | ||
| } | ||
| interface RRElementTagNameMap { | ||
| audio: RRMediaElement; | ||
| canvas: RRCanvasElement; | ||
| iframe: RRIFrameElement; | ||
| img: RRImageElement; | ||
| style: RRStyleElement; | ||
| video: RRMediaElement; | ||
| } | ||
| type RRElementType<K extends keyof HTMLElementTagNameMap> = K extends keyof RRElementTagNameMap ? RRElementTagNameMap[K] : RRElement; | ||
| export {}; |
| var NodeType$2; | ||
| (function (NodeType) { | ||
| NodeType[NodeType["Document"] = 0] = "Document"; | ||
| NodeType[NodeType["DocumentType"] = 1] = "DocumentType"; | ||
| NodeType[NodeType["Element"] = 2] = "Element"; | ||
| NodeType[NodeType["Text"] = 3] = "Text"; | ||
| NodeType[NodeType["CDATA"] = 4] = "CDATA"; | ||
| NodeType[NodeType["Comment"] = 5] = "Comment"; | ||
| })(NodeType$2 || (NodeType$2 = {})); | ||
| var NodeType$1; | ||
| (function (NodeType) { | ||
| NodeType[NodeType["Document"] = 0] = "Document"; | ||
| NodeType[NodeType["DocumentType"] = 1] = "DocumentType"; | ||
| NodeType[NodeType["Element"] = 2] = "Element"; | ||
| NodeType[NodeType["Text"] = 3] = "Text"; | ||
| NodeType[NodeType["CDATA"] = 4] = "CDATA"; | ||
| NodeType[NodeType["Comment"] = 5] = "Comment"; | ||
| })(NodeType$1 || (NodeType$1 = {})); | ||
| function parseCSSText(cssText) { | ||
| const res = {}; | ||
| const listDelimiter = /;(?![^(]*\))/g; | ||
| const propertyDelimiter = /:(.+)/; | ||
| const comment = /\/\*.*?\*\//g; | ||
| cssText | ||
| .replace(comment, '') | ||
| .split(listDelimiter) | ||
| .forEach(function (item) { | ||
| if (item) { | ||
| const tmp = item.split(propertyDelimiter); | ||
| tmp.length > 1 && (res[camelize(tmp[0].trim())] = tmp[1].trim()); | ||
| } | ||
| }); | ||
| return res; | ||
| } | ||
| function toCSSText(style) { | ||
| const properties = []; | ||
| for (const name in style) { | ||
| const value = style[name]; | ||
| if (typeof value !== 'string') | ||
| continue; | ||
| const normalizedName = hyphenate(name); | ||
| properties.push(`${normalizedName}: ${value};`); | ||
| } | ||
| return properties.join(' '); | ||
| } | ||
| const camelizeRE = /-([a-z])/g; | ||
| const CUSTOM_PROPERTY_REGEX = /^--[a-zA-Z0-9-]+$/; | ||
| const camelize = (str) => { | ||
| if (CUSTOM_PROPERTY_REGEX.test(str)) | ||
| return str; | ||
| return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : '')); | ||
| }; | ||
| const hyphenateRE = /\B([A-Z])/g; | ||
| const hyphenate = (str) => { | ||
| return str.replace(hyphenateRE, '-$1').toLowerCase(); | ||
| }; | ||
| class BaseRRNode { | ||
| constructor(..._args) { | ||
| this.parentElement = null; | ||
| this.parentNode = null; | ||
| this.firstChild = null; | ||
| this.lastChild = null; | ||
| this.previousSibling = null; | ||
| this.nextSibling = null; | ||
| this.ELEMENT_NODE = NodeType.ELEMENT_NODE; | ||
| this.TEXT_NODE = NodeType.TEXT_NODE; | ||
| } | ||
| get childNodes() { | ||
| const childNodes = []; | ||
| let childIterator = this.firstChild; | ||
| while (childIterator) { | ||
| childNodes.push(childIterator); | ||
| childIterator = childIterator.nextSibling; | ||
| } | ||
| return childNodes; | ||
| } | ||
| contains(node) { | ||
| if (!(node instanceof BaseRRNode)) | ||
| return false; | ||
| else if (node.ownerDocument !== this.ownerDocument) | ||
| return false; | ||
| else if (node === this) | ||
| return true; | ||
| while (node.parentNode) { | ||
| if (node.parentNode === this) | ||
| return true; | ||
| node = node.parentNode; | ||
| } | ||
| return false; | ||
| } | ||
| appendChild(_newChild) { | ||
| throw new Error(`RRDomException: Failed to execute 'appendChild' on 'RRNode': This RRNode type does not support this method.`); | ||
| } | ||
| insertBefore(_newChild, _refChild) { | ||
| throw new Error(`RRDomException: Failed to execute 'insertBefore' on 'RRNode': This RRNode type does not support this method.`); | ||
| } | ||
| removeChild(_node) { | ||
| throw new Error(`RRDomException: Failed to execute 'removeChild' on 'RRNode': This RRNode type does not support this method.`); | ||
| } | ||
| toString() { | ||
| return 'RRNode'; | ||
| } | ||
| } | ||
| function BaseRRDocumentImpl(RRNodeClass) { | ||
| return class BaseRRDocument extends RRNodeClass { | ||
| constructor(...args) { | ||
| super(args); | ||
| this.nodeType = NodeType.DOCUMENT_NODE; | ||
| this.nodeName = '#document'; | ||
| this.compatMode = 'CSS1Compat'; | ||
| this.RRNodeType = NodeType$1.Document; | ||
| this.textContent = null; | ||
| this.ownerDocument = this; | ||
| } | ||
| get documentElement() { | ||
| return (this.childNodes.find((node) => node.RRNodeType === NodeType$1.Element && | ||
| node.tagName === 'HTML') || null); | ||
| } | ||
| get body() { | ||
| var _a; | ||
| return (((_a = this.documentElement) === null || _a === void 0 ? void 0 : _a.childNodes.find((node) => node.RRNodeType === NodeType$1.Element && | ||
| node.tagName === 'BODY')) || null); | ||
| } | ||
| get head() { | ||
| var _a; | ||
| return (((_a = this.documentElement) === null || _a === void 0 ? void 0 : _a.childNodes.find((node) => node.RRNodeType === NodeType$1.Element && | ||
| node.tagName === 'HEAD')) || null); | ||
| } | ||
| get implementation() { | ||
| return this; | ||
| } | ||
| get firstElementChild() { | ||
| return this.documentElement; | ||
| } | ||
| appendChild(newChild) { | ||
| const nodeType = newChild.RRNodeType; | ||
| if (nodeType === NodeType$1.Element || | ||
| nodeType === NodeType$1.DocumentType) { | ||
| if (this.childNodes.some((s) => s.RRNodeType === nodeType)) { | ||
| throw new Error(`RRDomException: Failed to execute 'appendChild' on 'RRNode': Only one ${nodeType === NodeType$1.Element ? 'RRElement' : 'RRDoctype'} on RRDocument allowed.`); | ||
| } | ||
| } | ||
| const child = appendChild(this, newChild); | ||
| child.parentElement = null; | ||
| return child; | ||
| } | ||
| insertBefore(newChild, refChild) { | ||
| const nodeType = newChild.RRNodeType; | ||
| if (nodeType === NodeType$1.Element || | ||
| nodeType === NodeType$1.DocumentType) { | ||
| if (this.childNodes.some((s) => s.RRNodeType === nodeType)) { | ||
| throw new Error(`RRDomException: Failed to execute 'insertBefore' on 'RRNode': Only one ${nodeType === NodeType$1.Element ? 'RRElement' : 'RRDoctype'} on RRDocument allowed.`); | ||
| } | ||
| } | ||
| const child = insertBefore(this, newChild, refChild); | ||
| child.parentElement = null; | ||
| return child; | ||
| } | ||
| removeChild(node) { | ||
| return removeChild(this, node); | ||
| } | ||
| open() { | ||
| this.firstChild = null; | ||
| this.lastChild = null; | ||
| } | ||
| close() { | ||
| } | ||
| write(content) { | ||
| let publicId; | ||
| if (content === | ||
| '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">') | ||
| publicId = '-//W3C//DTD XHTML 1.0 Transitional//EN'; | ||
| else if (content === | ||
| '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "">') | ||
| publicId = '-//W3C//DTD HTML 4.0 Transitional//EN'; | ||
| if (publicId) { | ||
| const doctype = this.createDocumentType('html', publicId, ''); | ||
| this.open(); | ||
| this.appendChild(doctype); | ||
| } | ||
| } | ||
| createDocument(_namespace, _qualifiedName, _doctype) { | ||
| return new BaseRRDocument(); | ||
| } | ||
| createDocumentType(qualifiedName, publicId, systemId) { | ||
| const doctype = new (BaseRRDocumentTypeImpl(BaseRRNode))(qualifiedName, publicId, systemId); | ||
| doctype.ownerDocument = this; | ||
| return doctype; | ||
| } | ||
| createElement(tagName) { | ||
| const element = new (BaseRRElementImpl(BaseRRNode))(tagName); | ||
| element.ownerDocument = this; | ||
| return element; | ||
| } | ||
| createElementNS(_namespaceURI, qualifiedName) { | ||
| return this.createElement(qualifiedName); | ||
| } | ||
| createTextNode(data) { | ||
| const text = new (BaseRRTextImpl(BaseRRNode))(data); | ||
| text.ownerDocument = this; | ||
| return text; | ||
| } | ||
| createComment(data) { | ||
| const comment = new (BaseRRCommentImpl(BaseRRNode))(data); | ||
| comment.ownerDocument = this; | ||
| return comment; | ||
| } | ||
| createCDATASection(data) { | ||
| const CDATASection = new (BaseRRCDATASectionImpl(BaseRRNode))(data); | ||
| CDATASection.ownerDocument = this; | ||
| return CDATASection; | ||
| } | ||
| toString() { | ||
| return 'RRDocument'; | ||
| } | ||
| }; | ||
| } | ||
| function BaseRRDocumentTypeImpl(RRNodeClass) { | ||
| return class BaseRRDocumentType extends RRNodeClass { | ||
| constructor(qualifiedName, publicId, systemId) { | ||
| super(); | ||
| this.nodeType = NodeType.DOCUMENT_TYPE_NODE; | ||
| this.RRNodeType = NodeType$1.DocumentType; | ||
| this.name = qualifiedName; | ||
| this.publicId = publicId; | ||
| this.systemId = systemId; | ||
| this.nodeName = qualifiedName; | ||
| this.textContent = null; | ||
| } | ||
| toString() { | ||
| return 'RRDocumentType'; | ||
| } | ||
| }; | ||
| } | ||
| function BaseRRElementImpl(RRNodeClass) { | ||
| return class BaseRRElement extends RRNodeClass { | ||
| constructor(tagName) { | ||
| super(); | ||
| this.nodeType = NodeType.ELEMENT_NODE; | ||
| this.RRNodeType = NodeType$1.Element; | ||
| this.attributes = {}; | ||
| this.shadowRoot = null; | ||
| this.tagName = tagName.toUpperCase(); | ||
| this.nodeName = tagName.toUpperCase(); | ||
| } | ||
| get textContent() { | ||
| let result = ''; | ||
| this.childNodes.forEach((node) => (result += node.textContent)); | ||
| return result; | ||
| } | ||
| set textContent(textContent) { | ||
| this.firstChild = null; | ||
| this.lastChild = null; | ||
| this.appendChild(this.ownerDocument.createTextNode(textContent)); | ||
| } | ||
| get classList() { | ||
| return new ClassList(this.attributes.class, (newClassName) => { | ||
| this.attributes.class = newClassName; | ||
| }); | ||
| } | ||
| get id() { | ||
| return this.attributes.id || ''; | ||
| } | ||
| get className() { | ||
| return this.attributes.class || ''; | ||
| } | ||
| get style() { | ||
| const style = (this.attributes.style ? parseCSSText(this.attributes.style) : {}); | ||
| const hyphenateRE = /\B([A-Z])/g; | ||
| style.setProperty = (name, value, priority) => { | ||
| if (hyphenateRE.test(name)) | ||
| return; | ||
| const normalizedName = camelize(name); | ||
| if (!value) | ||
| delete style[normalizedName]; | ||
| else | ||
| style[normalizedName] = value; | ||
| if (priority === 'important') | ||
| style[normalizedName] += ' !important'; | ||
| this.attributes.style = toCSSText(style); | ||
| }; | ||
| style.removeProperty = (name) => { | ||
| if (hyphenateRE.test(name)) | ||
| return ''; | ||
| const normalizedName = camelize(name); | ||
| const value = style[normalizedName] || ''; | ||
| delete style[normalizedName]; | ||
| this.attributes.style = toCSSText(style); | ||
| return value; | ||
| }; | ||
| return style; | ||
| } | ||
| getAttribute(name) { | ||
| return this.attributes[name] || null; | ||
| } | ||
| setAttribute(name, attribute) { | ||
| this.attributes[name] = attribute; | ||
| } | ||
| setAttributeNS(_namespace, qualifiedName, value) { | ||
| this.setAttribute(qualifiedName, value); | ||
| } | ||
| removeAttribute(name) { | ||
| delete this.attributes[name]; | ||
| } | ||
| appendChild(newChild) { | ||
| return appendChild(this, newChild); | ||
| } | ||
| insertBefore(newChild, refChild) { | ||
| return insertBefore(this, newChild, refChild); | ||
| } | ||
| removeChild(node) { | ||
| return removeChild(this, node); | ||
| } | ||
| attachShadow(_init) { | ||
| const shadowRoot = this.ownerDocument.createElement('SHADOWROOT'); | ||
| this.shadowRoot = shadowRoot; | ||
| return shadowRoot; | ||
| } | ||
| dispatchEvent(_event) { | ||
| return true; | ||
| } | ||
| toString() { | ||
| let attributeString = ''; | ||
| for (const attribute in this.attributes) { | ||
| attributeString += `${attribute}="${this.attributes[attribute]}" `; | ||
| } | ||
| return `${this.tagName} ${attributeString}`; | ||
| } | ||
| }; | ||
| } | ||
| function BaseRRMediaElementImpl(RRElementClass) { | ||
| return class BaseRRMediaElement extends RRElementClass { | ||
| attachShadow(_init) { | ||
| throw new Error(`RRDomException: Failed to execute 'attachShadow' on 'RRElement': This RRElement does not support attachShadow`); | ||
| } | ||
| play() { | ||
| this.paused = false; | ||
| } | ||
| pause() { | ||
| this.paused = true; | ||
| } | ||
| }; | ||
| } | ||
| function BaseRRTextImpl(RRNodeClass) { | ||
| return class BaseRRText extends RRNodeClass { | ||
| constructor(data) { | ||
| super(); | ||
| this.nodeType = NodeType.TEXT_NODE; | ||
| this.nodeName = '#text'; | ||
| this.RRNodeType = NodeType$1.Text; | ||
| this.data = data; | ||
| } | ||
| get textContent() { | ||
| return this.data; | ||
| } | ||
| set textContent(textContent) { | ||
| this.data = textContent; | ||
| } | ||
| toString() { | ||
| return `RRText text=${JSON.stringify(this.data)}`; | ||
| } | ||
| }; | ||
| } | ||
| function BaseRRCommentImpl(RRNodeClass) { | ||
| return class BaseRRComment extends RRNodeClass { | ||
| constructor(data) { | ||
| super(); | ||
| this.nodeType = NodeType.COMMENT_NODE; | ||
| this.nodeName = '#comment'; | ||
| this.RRNodeType = NodeType$1.Comment; | ||
| this.data = data; | ||
| } | ||
| get textContent() { | ||
| return this.data; | ||
| } | ||
| set textContent(textContent) { | ||
| this.data = textContent; | ||
| } | ||
| toString() { | ||
| return `RRComment text=${JSON.stringify(this.data)}`; | ||
| } | ||
| }; | ||
| } | ||
| function BaseRRCDATASectionImpl(RRNodeClass) { | ||
| return class BaseRRCDATASection extends RRNodeClass { | ||
| constructor(data) { | ||
| super(); | ||
| this.nodeName = '#cdata-section'; | ||
| this.nodeType = NodeType.CDATA_SECTION_NODE; | ||
| this.RRNodeType = NodeType$1.CDATA; | ||
| this.data = data; | ||
| } | ||
| get textContent() { | ||
| return this.data; | ||
| } | ||
| set textContent(textContent) { | ||
| this.data = textContent; | ||
| } | ||
| toString() { | ||
| return `RRCDATASection data=${JSON.stringify(this.data)}`; | ||
| } | ||
| }; | ||
| } | ||
| class ClassList { | ||
| constructor(classText, onChange) { | ||
| this.classes = []; | ||
| this.add = (...classNames) => { | ||
| for (const item of classNames) { | ||
| const className = String(item); | ||
| if (this.classes.indexOf(className) >= 0) | ||
| continue; | ||
| this.classes.push(className); | ||
| } | ||
| this.onChange && this.onChange(this.classes.join(' ')); | ||
| }; | ||
| this.remove = (...classNames) => { | ||
| this.classes = this.classes.filter((item) => classNames.indexOf(item) === -1); | ||
| this.onChange && this.onChange(this.classes.join(' ')); | ||
| }; | ||
| if (classText) { | ||
| const classes = classText.trim().split(/\s+/); | ||
| this.classes.push(...classes); | ||
| } | ||
| this.onChange = onChange; | ||
| } | ||
| } | ||
| function appendChild(parent, newChild) { | ||
| if (newChild.parentNode) | ||
| newChild.parentNode.removeChild(newChild); | ||
| if (parent.lastChild) { | ||
| parent.lastChild.nextSibling = newChild; | ||
| newChild.previousSibling = parent.lastChild; | ||
| } | ||
| else { | ||
| parent.firstChild = newChild; | ||
| newChild.previousSibling = null; | ||
| } | ||
| parent.lastChild = newChild; | ||
| newChild.nextSibling = null; | ||
| newChild.parentNode = parent; | ||
| newChild.parentElement = parent; | ||
| newChild.ownerDocument = parent.ownerDocument; | ||
| return newChild; | ||
| } | ||
| function insertBefore(parent, newChild, refChild) { | ||
| if (!refChild) | ||
| return appendChild(parent, newChild); | ||
| if (refChild.parentNode !== parent) | ||
| throw new Error("Failed to execute 'insertBefore' on 'RRNode': The RRNode before which the new node is to be inserted is not a child of this RRNode."); | ||
| if (newChild === refChild) | ||
| return newChild; | ||
| if (newChild.parentNode) | ||
| newChild.parentNode.removeChild(newChild); | ||
| newChild.previousSibling = refChild.previousSibling; | ||
| refChild.previousSibling = newChild; | ||
| newChild.nextSibling = refChild; | ||
| if (newChild.previousSibling) | ||
| newChild.previousSibling.nextSibling = newChild; | ||
| else | ||
| parent.firstChild = newChild; | ||
| newChild.parentElement = parent; | ||
| newChild.parentNode = parent; | ||
| newChild.ownerDocument = parent.ownerDocument; | ||
| return newChild; | ||
| } | ||
| function removeChild(parent, child) { | ||
| if (child.parentNode !== parent) | ||
| throw new Error("Failed to execute 'removeChild' on 'RRNode': The RRNode to be removed is not a child of this RRNode."); | ||
| if (child.previousSibling) | ||
| child.previousSibling.nextSibling = child.nextSibling; | ||
| else | ||
| parent.firstChild = child.nextSibling; | ||
| if (child.nextSibling) | ||
| child.nextSibling.previousSibling = child.previousSibling; | ||
| else | ||
| parent.lastChild = child.previousSibling; | ||
| child.previousSibling = null; | ||
| child.nextSibling = null; | ||
| child.parentElement = null; | ||
| child.parentNode = null; | ||
| return child; | ||
| } | ||
| var NodeType; | ||
| (function (NodeType) { | ||
| NodeType[NodeType["PLACEHOLDER"] = 0] = "PLACEHOLDER"; | ||
| NodeType[NodeType["ELEMENT_NODE"] = 1] = "ELEMENT_NODE"; | ||
| NodeType[NodeType["ATTRIBUTE_NODE"] = 2] = "ATTRIBUTE_NODE"; | ||
| NodeType[NodeType["TEXT_NODE"] = 3] = "TEXT_NODE"; | ||
| NodeType[NodeType["CDATA_SECTION_NODE"] = 4] = "CDATA_SECTION_NODE"; | ||
| NodeType[NodeType["ENTITY_REFERENCE_NODE"] = 5] = "ENTITY_REFERENCE_NODE"; | ||
| NodeType[NodeType["ENTITY_NODE"] = 6] = "ENTITY_NODE"; | ||
| NodeType[NodeType["PROCESSING_INSTRUCTION_NODE"] = 7] = "PROCESSING_INSTRUCTION_NODE"; | ||
| NodeType[NodeType["COMMENT_NODE"] = 8] = "COMMENT_NODE"; | ||
| NodeType[NodeType["DOCUMENT_NODE"] = 9] = "DOCUMENT_NODE"; | ||
| NodeType[NodeType["DOCUMENT_TYPE_NODE"] = 10] = "DOCUMENT_TYPE_NODE"; | ||
| NodeType[NodeType["DOCUMENT_FRAGMENT_NODE"] = 11] = "DOCUMENT_FRAGMENT_NODE"; | ||
| })(NodeType || (NodeType = {})); | ||
| const nwsapi = require('nwsapi'); | ||
| const cssom = require('cssom'); | ||
| const cssstyle = require('cssstyle'); | ||
| class RRNode extends BaseRRNode { | ||
| } | ||
| class RRWindow { | ||
| constructor() { | ||
| this.scrollLeft = 0; | ||
| this.scrollTop = 0; | ||
| } | ||
| scrollTo(options) { | ||
| if (!options) | ||
| return; | ||
| if (typeof options.left === 'number') | ||
| this.scrollLeft = options.left; | ||
| if (typeof options.top === 'number') | ||
| this.scrollTop = options.top; | ||
| } | ||
| } | ||
| class RRDocument extends BaseRRDocumentImpl(RRNode) { | ||
| constructor() { | ||
| super(...arguments); | ||
| this.nodeName = '#document'; | ||
| } | ||
| get nwsapi() { | ||
| if (!this._nwsapi) { | ||
| this._nwsapi = nwsapi({ | ||
| document: this, | ||
| DOMException: null, | ||
| }); | ||
| this._nwsapi.configure({ | ||
| LOGERRORS: false, | ||
| IDS_DUPES: true, | ||
| MIXEDCASE: true, | ||
| }); | ||
| } | ||
| return this._nwsapi; | ||
| } | ||
| get documentElement() { | ||
| return super.documentElement; | ||
| } | ||
| get body() { | ||
| return super.body; | ||
| } | ||
| get head() { | ||
| return super.head; | ||
| } | ||
| get implementation() { | ||
| return this; | ||
| } | ||
| get firstElementChild() { | ||
| return this.documentElement; | ||
| } | ||
| appendChild(childNode) { | ||
| return super.appendChild(childNode); | ||
| } | ||
| insertBefore(newChild, refChild) { | ||
| return super.insertBefore(newChild, refChild); | ||
| } | ||
| querySelectorAll(selectors) { | ||
| return this.nwsapi.select(selectors); | ||
| } | ||
| getElementsByTagName(tagName) { | ||
| if (this.documentElement) | ||
| return this.documentElement.getElementsByTagName(tagName); | ||
| return []; | ||
| } | ||
| getElementsByClassName(className) { | ||
| if (this.documentElement) | ||
| return this.documentElement.getElementsByClassName(className); | ||
| return []; | ||
| } | ||
| getElementById(elementId) { | ||
| if (this.documentElement) | ||
| return this.documentElement.getElementById(elementId); | ||
| return null; | ||
| } | ||
| createDocument(_namespace, _qualifiedName, _doctype) { | ||
| return new RRDocument(); | ||
| } | ||
| createDocumentType(qualifiedName, publicId, systemId) { | ||
| const documentTypeNode = new RRDocumentType(qualifiedName, publicId, systemId); | ||
| documentTypeNode.ownerDocument = this; | ||
| return documentTypeNode; | ||
| } | ||
| createElement(tagName) { | ||
| const upperTagName = tagName.toUpperCase(); | ||
| let element; | ||
| switch (upperTagName) { | ||
| case 'AUDIO': | ||
| case 'VIDEO': | ||
| element = new RRMediaElement(upperTagName); | ||
| break; | ||
| case 'IFRAME': | ||
| element = new RRIFrameElement(upperTagName); | ||
| break; | ||
| case 'IMG': | ||
| element = new RRImageElement(upperTagName); | ||
| break; | ||
| case 'CANVAS': | ||
| element = new RRCanvasElement(upperTagName); | ||
| break; | ||
| case 'STYLE': | ||
| element = new RRStyleElement(upperTagName); | ||
| break; | ||
| default: | ||
| element = new RRElement(upperTagName); | ||
| break; | ||
| } | ||
| element.ownerDocument = this; | ||
| return element; | ||
| } | ||
| createElementNS(_namespaceURI, qualifiedName) { | ||
| return this.createElement(qualifiedName); | ||
| } | ||
| createComment(data) { | ||
| const commentNode = new RRComment(data); | ||
| commentNode.ownerDocument = this; | ||
| return commentNode; | ||
| } | ||
| createCDATASection(data) { | ||
| const sectionNode = new RRCDATASection(data); | ||
| sectionNode.ownerDocument = this; | ||
| return sectionNode; | ||
| } | ||
| createTextNode(data) { | ||
| const textNode = new RRText(data); | ||
| textNode.ownerDocument = this; | ||
| return textNode; | ||
| } | ||
| } | ||
| class RRDocumentType extends BaseRRDocumentTypeImpl(RRNode) { | ||
| } | ||
| class RRElement extends BaseRRElementImpl(RRNode) { | ||
| constructor(tagName) { | ||
| super(tagName); | ||
| this._style = new cssstyle.CSSStyleDeclaration(); | ||
| const style = this._style; | ||
| Object.defineProperty(this.attributes, 'style', { | ||
| get() { | ||
| return style.cssText; | ||
| }, | ||
| set(cssText) { | ||
| style.cssText = cssText; | ||
| }, | ||
| }); | ||
| } | ||
| get style() { | ||
| return this._style; | ||
| } | ||
| attachShadow(_init) { | ||
| return super.attachShadow(_init); | ||
| } | ||
| appendChild(newChild) { | ||
| return super.appendChild(newChild); | ||
| } | ||
| insertBefore(newChild, refChild) { | ||
| return super.insertBefore(newChild, refChild); | ||
| } | ||
| getAttribute(name) { | ||
| const upperName = name && name.toLowerCase(); | ||
| if (upperName in this.attributes) | ||
| return this.attributes[upperName]; | ||
| return null; | ||
| } | ||
| setAttribute(name, attribute) { | ||
| this.attributes[name.toLowerCase()] = attribute; | ||
| } | ||
| removeAttribute(name) { | ||
| delete this.attributes[name.toLowerCase()]; | ||
| } | ||
| get firstElementChild() { | ||
| for (const child of this.childNodes) | ||
| if (child.RRNodeType === NodeType$2.Element) | ||
| return child; | ||
| return null; | ||
| } | ||
| get nextElementSibling() { | ||
| const parentNode = this.parentNode; | ||
| if (!parentNode) | ||
| return null; | ||
| const siblings = parentNode.childNodes; | ||
| const index = siblings.indexOf(this); | ||
| for (let i = index + 1; i < siblings.length; i++) | ||
| if (siblings[i] instanceof RRElement) | ||
| return siblings[i]; | ||
| return null; | ||
| } | ||
| querySelectorAll(selectors) { | ||
| const result = []; | ||
| if (this.ownerDocument !== null) { | ||
| this.ownerDocument.nwsapi.select(selectors, this, (element) => { | ||
| if (element !== this) | ||
| result.push(element); | ||
| }); | ||
| } | ||
| return result; | ||
| } | ||
| getElementById(elementId) { | ||
| if (this.id === elementId) | ||
| return this; | ||
| for (const child of this.childNodes) { | ||
| if (child instanceof RRElement) { | ||
| const result = child.getElementById(elementId); | ||
| if (result !== null) | ||
| return result; | ||
| } | ||
| } | ||
| return null; | ||
| } | ||
| getElementsByClassName(className) { | ||
| let elements = []; | ||
| const queryClassList = new ClassList(className); | ||
| if (this instanceof RRElement && | ||
| queryClassList.classes.filter((queriedClassName) => this.classList.classes.some((name) => name === queriedClassName)).length == queryClassList.classes.length) | ||
| elements.push(this); | ||
| for (const child of this.childNodes) { | ||
| if (child instanceof RRElement) | ||
| elements = elements.concat(child.getElementsByClassName(className)); | ||
| } | ||
| return elements; | ||
| } | ||
| getElementsByTagName(tagName) { | ||
| let elements = []; | ||
| const normalizedTagName = tagName.toUpperCase(); | ||
| if (this instanceof RRElement && this.tagName === normalizedTagName) | ||
| elements.push(this); | ||
| for (const child of this.childNodes) { | ||
| if (child instanceof RRElement) | ||
| elements = elements.concat(child.getElementsByTagName(tagName)); | ||
| } | ||
| return elements; | ||
| } | ||
| } | ||
| class RRImageElement extends RRElement { | ||
| } | ||
| class RRMediaElement extends BaseRRMediaElementImpl(RRElement) { | ||
| } | ||
| class RRCanvasElement extends RRElement { | ||
| getContext() { | ||
| return null; | ||
| } | ||
| } | ||
| class RRStyleElement extends RRElement { | ||
| constructor() { | ||
| super(...arguments); | ||
| this._sheet = null; | ||
| } | ||
| get sheet() { | ||
| if (!this._sheet) { | ||
| let result = ''; | ||
| for (const child of this.childNodes) | ||
| if (child.RRNodeType === NodeType$2.Text) | ||
| result += child.textContent; | ||
| this._sheet = cssom.parse(result); | ||
| } | ||
| return this._sheet; | ||
| } | ||
| } | ||
| class RRIFrameElement extends RRElement { | ||
| constructor(tagName) { | ||
| super(tagName); | ||
| this.width = ''; | ||
| this.height = ''; | ||
| this.src = ''; | ||
| this.contentDocument = new RRDocument(); | ||
| this.contentWindow = new RRWindow(); | ||
| const htmlElement = this.contentDocument.createElement('HTML'); | ||
| this.contentDocument.appendChild(htmlElement); | ||
| htmlElement.appendChild(this.contentDocument.createElement('HEAD')); | ||
| htmlElement.appendChild(this.contentDocument.createElement('BODY')); | ||
| } | ||
| } | ||
| class RRText extends BaseRRTextImpl(RRNode) { | ||
| constructor() { | ||
| super(...arguments); | ||
| this.nodeName = '#text'; | ||
| } | ||
| } | ||
| class RRComment extends BaseRRCommentImpl(RRNode) { | ||
| constructor() { | ||
| super(...arguments); | ||
| this.nodeName = '#comment'; | ||
| } | ||
| } | ||
| class RRCDATASection extends BaseRRCDATASectionImpl(RRNode) { | ||
| constructor() { | ||
| super(...arguments); | ||
| this.nodeName = '#cdata-section'; | ||
| } | ||
| } | ||
| export { RRCDATASection, RRCanvasElement, RRComment, RRDocument, RRDocumentType, RRElement, RRIFrameElement, RRImageElement, RRMediaElement, RRNode, RRStyleElement, RRText, RRWindow }; |
| var e,t;function n(e){const t=[];for(const n in e){const s=e[n];if("string"!=typeof s)continue;const o=l(n);t.push(`${o}: ${s};`)}return t.join(" ")}!function(e){e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment"}(e||(e={})),function(e){e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment"}(t||(t={}));const s=/-([a-z])/g,o=/^--[a-zA-Z0-9-]+$/,i=e=>o.test(e)?e:e.replace(s,((e,t)=>t?t.toUpperCase():"")),r=/\B([A-Z])/g,l=e=>e.replace(r,"-$1").toLowerCase();class u{constructor(...e){this.parentElement=null,this.parentNode=null,this.firstChild=null,this.lastChild=null,this.previousSibling=null,this.nextSibling=null,this.ELEMENT_NODE=D.ELEMENT_NODE,this.TEXT_NODE=D.TEXT_NODE}get childNodes(){const e=[];let t=this.firstChild;for(;t;)e.push(t),t=t.nextSibling;return e}contains(e){if(!(e instanceof u))return!1;if(e.ownerDocument!==this.ownerDocument)return!1;if(e===this)return!0;for(;e.parentNode;){if(e.parentNode===this)return!0;e=e.parentNode}return!1}appendChild(e){throw new Error("RRDomException: Failed to execute 'appendChild' on 'RRNode': This RRNode type does not support this method.")}insertBefore(e,t){throw new Error("RRDomException: Failed to execute 'insertBefore' on 'RRNode': This RRNode type does not support this method.")}removeChild(e){throw new Error("RRDomException: Failed to execute 'removeChild' on 'RRNode': This RRNode type does not support this method.")}toString(){return"RRNode"}}function c(e){return class extends e{constructor(e,n,s){super(),this.nodeType=D.DOCUMENT_TYPE_NODE,this.RRNodeType=t.DocumentType,this.name=e,this.publicId=n,this.systemId=s,this.nodeName=e,this.textContent=null}toString(){return"RRDocumentType"}}}function h(e){return class extends e{constructor(e){super(),this.nodeType=D.ELEMENT_NODE,this.RRNodeType=t.Element,this.attributes={},this.shadowRoot=null,this.tagName=e.toUpperCase(),this.nodeName=e.toUpperCase()}get textContent(){let e="";return this.childNodes.forEach((t=>e+=t.textContent)),e}set textContent(e){this.firstChild=null,this.lastChild=null,this.appendChild(this.ownerDocument.createTextNode(e))}get classList(){return new p(this.attributes.class,(e=>{this.attributes.class=e}))}get id(){return this.attributes.id||""}get className(){return this.attributes.class||""}get style(){const e=this.attributes.style?function(e){const t={},n=/:(.+)/;return e.replace(/\/\*.*?\*\//g,"").split(/;(?![^(]*\))/g).forEach((function(e){if(e){const s=e.split(n);s.length>1&&(t[i(s[0].trim())]=s[1].trim())}})),t}(this.attributes.style):{},t=/\B([A-Z])/g;return e.setProperty=(s,o,r)=>{if(t.test(s))return;const l=i(s);o?e[l]=o:delete e[l],"important"===r&&(e[l]+=" !important"),this.attributes.style=n(e)},e.removeProperty=s=>{if(t.test(s))return"";const o=i(s),r=e[o]||"";return delete e[o],this.attributes.style=n(e),r},e}getAttribute(e){return this.attributes[e]||null}setAttribute(e,t){this.attributes[e]=t}setAttributeNS(e,t,n){this.setAttribute(t,n)}removeAttribute(e){delete this.attributes[e]}appendChild(e){return E(this,e)}insertBefore(e,t){return N(this,e,t)}removeChild(e){return T(this,e)}attachShadow(e){const t=this.ownerDocument.createElement("SHADOWROOT");return this.shadowRoot=t,t}dispatchEvent(e){return!0}toString(){let e="";for(const t in this.attributes)e+=`${t}="${this.attributes[t]}" `;return`${this.tagName} ${e}`}}}function a(e){return class extends e{constructor(e){super(),this.nodeType=D.TEXT_NODE,this.nodeName="#text",this.RRNodeType=t.Text,this.data=e}get textContent(){return this.data}set textContent(e){this.data=e}toString(){return`RRText text=${JSON.stringify(this.data)}`}}}function d(e){return class extends e{constructor(e){super(),this.nodeType=D.COMMENT_NODE,this.nodeName="#comment",this.RRNodeType=t.Comment,this.data=e}get textContent(){return this.data}set textContent(e){this.data=e}toString(){return`RRComment text=${JSON.stringify(this.data)}`}}}function m(e){return class extends e{constructor(e){super(),this.nodeName="#cdata-section",this.nodeType=D.CDATA_SECTION_NODE,this.RRNodeType=t.CDATA,this.data=e}get textContent(){return this.data}set textContent(e){this.data=e}toString(){return`RRCDATASection data=${JSON.stringify(this.data)}`}}}class p{constructor(e,t){if(this.classes=[],this.add=(...e)=>{for(const t of e){const e=String(t);this.classes.indexOf(e)>=0||this.classes.push(e)}this.onChange&&this.onChange(this.classes.join(" "))},this.remove=(...e)=>{this.classes=this.classes.filter((t=>-1===e.indexOf(t))),this.onChange&&this.onChange(this.classes.join(" "))},e){const t=e.trim().split(/\s+/);this.classes.push(...t)}this.onChange=t}}function E(e,t){return t.parentNode&&t.parentNode.removeChild(t),e.lastChild?(e.lastChild.nextSibling=t,t.previousSibling=e.lastChild):(e.firstChild=t,t.previousSibling=null),e.lastChild=t,t.nextSibling=null,t.parentNode=e,t.parentElement=e,t.ownerDocument=e.ownerDocument,t}function N(e,t,n){if(!n)return E(e,t);if(n.parentNode!==e)throw new Error("Failed to execute 'insertBefore' on 'RRNode': The RRNode before which the new node is to be inserted is not a child of this RRNode.");return t===n||(t.parentNode&&t.parentNode.removeChild(t),t.previousSibling=n.previousSibling,n.previousSibling=t,t.nextSibling=n,t.previousSibling?t.previousSibling.nextSibling=t:e.firstChild=t,t.parentElement=e,t.parentNode=e,t.ownerDocument=e.ownerDocument),t}function T(e,t){if(t.parentNode!==e)throw new Error("Failed to execute 'removeChild' on 'RRNode': The RRNode to be removed is not a child of this RRNode.");return t.previousSibling?t.previousSibling.nextSibling=t.nextSibling:e.firstChild=t.nextSibling,t.nextSibling?t.nextSibling.previousSibling=t.previousSibling:e.lastChild=t.previousSibling,t.previousSibling=null,t.nextSibling=null,t.parentElement=null,t.parentNode=null,t}var D;!function(e){e[e.PLACEHOLDER=0]="PLACEHOLDER",e[e.ELEMENT_NODE=1]="ELEMENT_NODE",e[e.ATTRIBUTE_NODE=2]="ATTRIBUTE_NODE",e[e.TEXT_NODE=3]="TEXT_NODE",e[e.CDATA_SECTION_NODE=4]="CDATA_SECTION_NODE",e[e.ENTITY_REFERENCE_NODE=5]="ENTITY_REFERENCE_NODE",e[e.ENTITY_NODE=6]="ENTITY_NODE",e[e.PROCESSING_INSTRUCTION_NODE=7]="PROCESSING_INSTRUCTION_NODE",e[e.COMMENT_NODE=8]="COMMENT_NODE",e[e.DOCUMENT_NODE=9]="DOCUMENT_NODE",e[e.DOCUMENT_TYPE_NODE=10]="DOCUMENT_TYPE_NODE",e[e.DOCUMENT_FRAGMENT_NODE=11]="DOCUMENT_FRAGMENT_NODE"}(D||(D={}));const C=require("nwsapi"),R=require("cssom"),f=require("cssstyle");class g extends u{}class w{constructor(){this.scrollLeft=0,this.scrollTop=0}scrollTo(e){e&&("number"==typeof e.left&&(this.scrollLeft=e.left),"number"==typeof e.top&&(this.scrollTop=e.top))}}class x extends(function(e){return class n extends e{constructor(...e){super(e),this.nodeType=D.DOCUMENT_NODE,this.nodeName="#document",this.compatMode="CSS1Compat",this.RRNodeType=t.Document,this.textContent=null,this.ownerDocument=this}get documentElement(){return this.childNodes.find((e=>e.RRNodeType===t.Element&&"HTML"===e.tagName))||null}get body(){var e;return(null===(e=this.documentElement)||void 0===e?void 0:e.childNodes.find((e=>e.RRNodeType===t.Element&&"BODY"===e.tagName)))||null}get head(){var e;return(null===(e=this.documentElement)||void 0===e?void 0:e.childNodes.find((e=>e.RRNodeType===t.Element&&"HEAD"===e.tagName)))||null}get implementation(){return this}get firstElementChild(){return this.documentElement}appendChild(e){const n=e.RRNodeType;if((n===t.Element||n===t.DocumentType)&&this.childNodes.some((e=>e.RRNodeType===n)))throw new Error(`RRDomException: Failed to execute 'appendChild' on 'RRNode': Only one ${n===t.Element?"RRElement":"RRDoctype"} on RRDocument allowed.`);const s=E(this,e);return s.parentElement=null,s}insertBefore(e,n){const s=e.RRNodeType;if((s===t.Element||s===t.DocumentType)&&this.childNodes.some((e=>e.RRNodeType===s)))throw new Error(`RRDomException: Failed to execute 'insertBefore' on 'RRNode': Only one ${s===t.Element?"RRElement":"RRDoctype"} on RRDocument allowed.`);const o=N(this,e,n);return o.parentElement=null,o}removeChild(e){return T(this,e)}open(){this.firstChild=null,this.lastChild=null}close(){}write(e){let t;if('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">'===e?t="-//W3C//DTD XHTML 1.0 Transitional//EN":'<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "">'===e&&(t="-//W3C//DTD HTML 4.0 Transitional//EN"),t){const e=this.createDocumentType("html",t,"");this.open(),this.appendChild(e)}}createDocument(e,t,s){return new n}createDocumentType(e,t,n){const s=new(c(u))(e,t,n);return s.ownerDocument=this,s}createElement(e){const t=new(h(u))(e);return t.ownerDocument=this,t}createElementNS(e,t){return this.createElement(t)}createTextNode(e){const t=new(a(u))(e);return t.ownerDocument=this,t}createComment(e){const t=new(d(u))(e);return t.ownerDocument=this,t}createCDATASection(e){const t=new(m(u))(e);return t.ownerDocument=this,t}toString(){return"RRDocument"}}}(g)){constructor(){super(...arguments),this.nodeName="#document"}get nwsapi(){return this._nwsapi||(this._nwsapi=C({document:this,DOMException:null}),this._nwsapi.configure({LOGERRORS:!1,IDS_DUPES:!0,MIXEDCASE:!0})),this._nwsapi}get documentElement(){return super.documentElement}get body(){return super.body}get head(){return super.head}get implementation(){return this}get firstElementChild(){return this.documentElement}appendChild(e){return super.appendChild(e)}insertBefore(e,t){return super.insertBefore(e,t)}querySelectorAll(e){return this.nwsapi.select(e)}getElementsByTagName(e){return this.documentElement?this.documentElement.getElementsByTagName(e):[]}getElementsByClassName(e){return this.documentElement?this.documentElement.getElementsByClassName(e):[]}getElementById(e){return this.documentElement?this.documentElement.getElementById(e):null}createDocument(e,t,n){return new x}createDocumentType(e,t,n){const s=new y(e,t,n);return s.ownerDocument=this,s}createElement(e){const t=e.toUpperCase();let n;switch(t){case"AUDIO":case"VIDEO":n=new b(t);break;case"IFRAME":n=new v(t);break;case"IMG":n=new S(t);break;case"CANVAS":n=new _(t);break;case"STYLE":n=new A(t);break;default:n=new O(t)}return n.ownerDocument=this,n}createElementNS(e,t){return this.createElement(t)}createComment(e){const t=new B(e);return t.ownerDocument=this,t}createCDATASection(e){const t=new I(e);return t.ownerDocument=this,t}createTextNode(e){const t=new M(e);return t.ownerDocument=this,t}}class y extends(c(g)){}class O extends(h(g)){constructor(e){super(e),this._style=new f.CSSStyleDeclaration;const t=this._style;Object.defineProperty(this.attributes,"style",{get:()=>t.cssText,set(e){t.cssText=e}})}get style(){return this._style}attachShadow(e){return super.attachShadow(e)}appendChild(e){return super.appendChild(e)}insertBefore(e,t){return super.insertBefore(e,t)}getAttribute(e){const t=e&&e.toLowerCase();return t in this.attributes?this.attributes[t]:null}setAttribute(e,t){this.attributes[e.toLowerCase()]=t}removeAttribute(e){delete this.attributes[e.toLowerCase()]}get firstElementChild(){for(const t of this.childNodes)if(t.RRNodeType===e.Element)return t;return null}get nextElementSibling(){const e=this.parentNode;if(!e)return null;const t=e.childNodes;for(let e=t.indexOf(this)+1;e<t.length;e++)if(t[e]instanceof O)return t[e];return null}querySelectorAll(e){const t=[];return null!==this.ownerDocument&&this.ownerDocument.nwsapi.select(e,this,(e=>{e!==this&&t.push(e)})),t}getElementById(e){if(this.id===e)return this;for(const t of this.childNodes)if(t instanceof O){const n=t.getElementById(e);if(null!==n)return n}return null}getElementsByClassName(e){let t=[];const n=new p(e);this instanceof O&&n.classes.filter((e=>this.classList.classes.some((t=>t===e)))).length==n.classes.length&&t.push(this);for(const n of this.childNodes)n instanceof O&&(t=t.concat(n.getElementsByClassName(e)));return t}getElementsByTagName(e){let t=[];const n=e.toUpperCase();this instanceof O&&this.tagName===n&&t.push(this);for(const n of this.childNodes)n instanceof O&&(t=t.concat(n.getElementsByTagName(e)));return t}}class S extends O{}class b extends(function(e){return class extends e{attachShadow(e){throw new Error("RRDomException: Failed to execute 'attachShadow' on 'RRElement': This RRElement does not support attachShadow")}play(){this.paused=!1}pause(){this.paused=!0}}}(O)){}class _ extends O{getContext(){return null}}class A extends O{constructor(){super(...arguments),this._sheet=null}get sheet(){if(!this._sheet){let t="";for(const n of this.childNodes)n.RRNodeType===e.Text&&(t+=n.textContent);this._sheet=R.parse(t)}return this._sheet}}class v extends O{constructor(e){super(e),this.width="",this.height="",this.src="",this.contentDocument=new x,this.contentWindow=new w;const t=this.contentDocument.createElement("HTML");this.contentDocument.appendChild(t),t.appendChild(this.contentDocument.createElement("HEAD")),t.appendChild(this.contentDocument.createElement("BODY"))}}class M extends(a(g)){constructor(){super(...arguments),this.nodeName="#text"}}class B extends(d(g)){constructor(){super(...arguments),this.nodeName="#comment"}}class I extends(m(g)){constructor(){super(...arguments),this.nodeName="#cdata-section"}}export{I as RRCDATASection,_ as RRCanvasElement,B as RRComment,x as RRDocument,y as RRDocumentType,O as RRElement,v as RRIFrameElement,S as RRImageElement,b as RRMediaElement,g as RRNode,A as RRStyleElement,M as RRText,w as RRWindow}; | ||
| //# sourceMappingURL=document-nodejs.min.js.map |
Sorry, the diff of this file is too big to display
| export * from './document-nodejs'; |
| export declare function polyfillPerformance(): void; | ||
| export declare function polyfillRAF(): void; | ||
| export declare function polyfillEvent(): void; | ||
| export declare function polyfillNode(): void; | ||
| export declare function polyfillDocument(): void; |
| var NodeType$2; | ||
| (function (NodeType) { | ||
| NodeType[NodeType["Document"] = 0] = "Document"; | ||
| NodeType[NodeType["DocumentType"] = 1] = "DocumentType"; | ||
| NodeType[NodeType["Element"] = 2] = "Element"; | ||
| NodeType[NodeType["Text"] = 3] = "Text"; | ||
| NodeType[NodeType["CDATA"] = 4] = "CDATA"; | ||
| NodeType[NodeType["Comment"] = 5] = "Comment"; | ||
| })(NodeType$2 || (NodeType$2 = {})); | ||
| var NodeType$1; | ||
| (function (NodeType) { | ||
| NodeType[NodeType["Document"] = 0] = "Document"; | ||
| NodeType[NodeType["DocumentType"] = 1] = "DocumentType"; | ||
| NodeType[NodeType["Element"] = 2] = "Element"; | ||
| NodeType[NodeType["Text"] = 3] = "Text"; | ||
| NodeType[NodeType["CDATA"] = 4] = "CDATA"; | ||
| NodeType[NodeType["Comment"] = 5] = "Comment"; | ||
| })(NodeType$1 || (NodeType$1 = {})); | ||
| function parseCSSText(cssText) { | ||
| const res = {}; | ||
| const listDelimiter = /;(?![^(]*\))/g; | ||
| const propertyDelimiter = /:(.+)/; | ||
| const comment = /\/\*.*?\*\//g; | ||
| cssText | ||
| .replace(comment, '') | ||
| .split(listDelimiter) | ||
| .forEach(function (item) { | ||
| if (item) { | ||
| const tmp = item.split(propertyDelimiter); | ||
| tmp.length > 1 && (res[camelize(tmp[0].trim())] = tmp[1].trim()); | ||
| } | ||
| }); | ||
| return res; | ||
| } | ||
| function toCSSText(style) { | ||
| const properties = []; | ||
| for (const name in style) { | ||
| const value = style[name]; | ||
| if (typeof value !== 'string') | ||
| continue; | ||
| const normalizedName = hyphenate(name); | ||
| properties.push(`${normalizedName}: ${value};`); | ||
| } | ||
| return properties.join(' '); | ||
| } | ||
| const camelizeRE = /-([a-z])/g; | ||
| const CUSTOM_PROPERTY_REGEX = /^--[a-zA-Z0-9-]+$/; | ||
| const camelize = (str) => { | ||
| if (CUSTOM_PROPERTY_REGEX.test(str)) | ||
| return str; | ||
| return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : '')); | ||
| }; | ||
| const hyphenateRE = /\B([A-Z])/g; | ||
| const hyphenate = (str) => { | ||
| return str.replace(hyphenateRE, '-$1').toLowerCase(); | ||
| }; | ||
| class BaseRRNode { | ||
| constructor(..._args) { | ||
| this.parentElement = null; | ||
| this.parentNode = null; | ||
| this.firstChild = null; | ||
| this.lastChild = null; | ||
| this.previousSibling = null; | ||
| this.nextSibling = null; | ||
| this.ELEMENT_NODE = NodeType.ELEMENT_NODE; | ||
| this.TEXT_NODE = NodeType.TEXT_NODE; | ||
| } | ||
| get childNodes() { | ||
| const childNodes = []; | ||
| let childIterator = this.firstChild; | ||
| while (childIterator) { | ||
| childNodes.push(childIterator); | ||
| childIterator = childIterator.nextSibling; | ||
| } | ||
| return childNodes; | ||
| } | ||
| contains(node) { | ||
| if (!(node instanceof BaseRRNode)) | ||
| return false; | ||
| else if (node.ownerDocument !== this.ownerDocument) | ||
| return false; | ||
| else if (node === this) | ||
| return true; | ||
| while (node.parentNode) { | ||
| if (node.parentNode === this) | ||
| return true; | ||
| node = node.parentNode; | ||
| } | ||
| return false; | ||
| } | ||
| appendChild(_newChild) { | ||
| throw new Error(`RRDomException: Failed to execute 'appendChild' on 'RRNode': This RRNode type does not support this method.`); | ||
| } | ||
| insertBefore(_newChild, _refChild) { | ||
| throw new Error(`RRDomException: Failed to execute 'insertBefore' on 'RRNode': This RRNode type does not support this method.`); | ||
| } | ||
| removeChild(_node) { | ||
| throw new Error(`RRDomException: Failed to execute 'removeChild' on 'RRNode': This RRNode type does not support this method.`); | ||
| } | ||
| toString() { | ||
| return 'RRNode'; | ||
| } | ||
| } | ||
| function BaseRRDocumentImpl(RRNodeClass) { | ||
| return class BaseRRDocument extends RRNodeClass { | ||
| constructor(...args) { | ||
| super(args); | ||
| this.nodeType = NodeType.DOCUMENT_NODE; | ||
| this.nodeName = '#document'; | ||
| this.compatMode = 'CSS1Compat'; | ||
| this.RRNodeType = NodeType$1.Document; | ||
| this.textContent = null; | ||
| this.ownerDocument = this; | ||
| } | ||
| get documentElement() { | ||
| return (this.childNodes.find((node) => node.RRNodeType === NodeType$1.Element && | ||
| node.tagName === 'HTML') || null); | ||
| } | ||
| get body() { | ||
| var _a; | ||
| return (((_a = this.documentElement) === null || _a === void 0 ? void 0 : _a.childNodes.find((node) => node.RRNodeType === NodeType$1.Element && | ||
| node.tagName === 'BODY')) || null); | ||
| } | ||
| get head() { | ||
| var _a; | ||
| return (((_a = this.documentElement) === null || _a === void 0 ? void 0 : _a.childNodes.find((node) => node.RRNodeType === NodeType$1.Element && | ||
| node.tagName === 'HEAD')) || null); | ||
| } | ||
| get implementation() { | ||
| return this; | ||
| } | ||
| get firstElementChild() { | ||
| return this.documentElement; | ||
| } | ||
| appendChild(newChild) { | ||
| const nodeType = newChild.RRNodeType; | ||
| if (nodeType === NodeType$1.Element || | ||
| nodeType === NodeType$1.DocumentType) { | ||
| if (this.childNodes.some((s) => s.RRNodeType === nodeType)) { | ||
| throw new Error(`RRDomException: Failed to execute 'appendChild' on 'RRNode': Only one ${nodeType === NodeType$1.Element ? 'RRElement' : 'RRDoctype'} on RRDocument allowed.`); | ||
| } | ||
| } | ||
| const child = appendChild(this, newChild); | ||
| child.parentElement = null; | ||
| return child; | ||
| } | ||
| insertBefore(newChild, refChild) { | ||
| const nodeType = newChild.RRNodeType; | ||
| if (nodeType === NodeType$1.Element || | ||
| nodeType === NodeType$1.DocumentType) { | ||
| if (this.childNodes.some((s) => s.RRNodeType === nodeType)) { | ||
| throw new Error(`RRDomException: Failed to execute 'insertBefore' on 'RRNode': Only one ${nodeType === NodeType$1.Element ? 'RRElement' : 'RRDoctype'} on RRDocument allowed.`); | ||
| } | ||
| } | ||
| const child = insertBefore(this, newChild, refChild); | ||
| child.parentElement = null; | ||
| return child; | ||
| } | ||
| removeChild(node) { | ||
| return removeChild(this, node); | ||
| } | ||
| open() { | ||
| this.firstChild = null; | ||
| this.lastChild = null; | ||
| } | ||
| close() { | ||
| } | ||
| write(content) { | ||
| let publicId; | ||
| if (content === | ||
| '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">') | ||
| publicId = '-//W3C//DTD XHTML 1.0 Transitional//EN'; | ||
| else if (content === | ||
| '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "">') | ||
| publicId = '-//W3C//DTD HTML 4.0 Transitional//EN'; | ||
| if (publicId) { | ||
| const doctype = this.createDocumentType('html', publicId, ''); | ||
| this.open(); | ||
| this.appendChild(doctype); | ||
| } | ||
| } | ||
| createDocument(_namespace, _qualifiedName, _doctype) { | ||
| return new BaseRRDocument(); | ||
| } | ||
| createDocumentType(qualifiedName, publicId, systemId) { | ||
| const doctype = new (BaseRRDocumentTypeImpl(BaseRRNode))(qualifiedName, publicId, systemId); | ||
| doctype.ownerDocument = this; | ||
| return doctype; | ||
| } | ||
| createElement(tagName) { | ||
| const element = new (BaseRRElementImpl(BaseRRNode))(tagName); | ||
| element.ownerDocument = this; | ||
| return element; | ||
| } | ||
| createElementNS(_namespaceURI, qualifiedName) { | ||
| return this.createElement(qualifiedName); | ||
| } | ||
| createTextNode(data) { | ||
| const text = new (BaseRRTextImpl(BaseRRNode))(data); | ||
| text.ownerDocument = this; | ||
| return text; | ||
| } | ||
| createComment(data) { | ||
| const comment = new (BaseRRCommentImpl(BaseRRNode))(data); | ||
| comment.ownerDocument = this; | ||
| return comment; | ||
| } | ||
| createCDATASection(data) { | ||
| const CDATASection = new (BaseRRCDATASectionImpl(BaseRRNode))(data); | ||
| CDATASection.ownerDocument = this; | ||
| return CDATASection; | ||
| } | ||
| toString() { | ||
| return 'RRDocument'; | ||
| } | ||
| }; | ||
| } | ||
| function BaseRRDocumentTypeImpl(RRNodeClass) { | ||
| return class BaseRRDocumentType extends RRNodeClass { | ||
| constructor(qualifiedName, publicId, systemId) { | ||
| super(); | ||
| this.nodeType = NodeType.DOCUMENT_TYPE_NODE; | ||
| this.RRNodeType = NodeType$1.DocumentType; | ||
| this.name = qualifiedName; | ||
| this.publicId = publicId; | ||
| this.systemId = systemId; | ||
| this.nodeName = qualifiedName; | ||
| this.textContent = null; | ||
| } | ||
| toString() { | ||
| return 'RRDocumentType'; | ||
| } | ||
| }; | ||
| } | ||
| function BaseRRElementImpl(RRNodeClass) { | ||
| return class BaseRRElement extends RRNodeClass { | ||
| constructor(tagName) { | ||
| super(); | ||
| this.nodeType = NodeType.ELEMENT_NODE; | ||
| this.RRNodeType = NodeType$1.Element; | ||
| this.attributes = {}; | ||
| this.shadowRoot = null; | ||
| this.tagName = tagName.toUpperCase(); | ||
| this.nodeName = tagName.toUpperCase(); | ||
| } | ||
| get textContent() { | ||
| let result = ''; | ||
| this.childNodes.forEach((node) => (result += node.textContent)); | ||
| return result; | ||
| } | ||
| set textContent(textContent) { | ||
| this.firstChild = null; | ||
| this.lastChild = null; | ||
| this.appendChild(this.ownerDocument.createTextNode(textContent)); | ||
| } | ||
| get classList() { | ||
| return new ClassList(this.attributes.class, (newClassName) => { | ||
| this.attributes.class = newClassName; | ||
| }); | ||
| } | ||
| get id() { | ||
| return this.attributes.id || ''; | ||
| } | ||
| get className() { | ||
| return this.attributes.class || ''; | ||
| } | ||
| get style() { | ||
| const style = (this.attributes.style ? parseCSSText(this.attributes.style) : {}); | ||
| const hyphenateRE = /\B([A-Z])/g; | ||
| style.setProperty = (name, value, priority) => { | ||
| if (hyphenateRE.test(name)) | ||
| return; | ||
| const normalizedName = camelize(name); | ||
| if (!value) | ||
| delete style[normalizedName]; | ||
| else | ||
| style[normalizedName] = value; | ||
| if (priority === 'important') | ||
| style[normalizedName] += ' !important'; | ||
| this.attributes.style = toCSSText(style); | ||
| }; | ||
| style.removeProperty = (name) => { | ||
| if (hyphenateRE.test(name)) | ||
| return ''; | ||
| const normalizedName = camelize(name); | ||
| const value = style[normalizedName] || ''; | ||
| delete style[normalizedName]; | ||
| this.attributes.style = toCSSText(style); | ||
| return value; | ||
| }; | ||
| return style; | ||
| } | ||
| getAttribute(name) { | ||
| return this.attributes[name] || null; | ||
| } | ||
| setAttribute(name, attribute) { | ||
| this.attributes[name] = attribute; | ||
| } | ||
| setAttributeNS(_namespace, qualifiedName, value) { | ||
| this.setAttribute(qualifiedName, value); | ||
| } | ||
| removeAttribute(name) { | ||
| delete this.attributes[name]; | ||
| } | ||
| appendChild(newChild) { | ||
| return appendChild(this, newChild); | ||
| } | ||
| insertBefore(newChild, refChild) { | ||
| return insertBefore(this, newChild, refChild); | ||
| } | ||
| removeChild(node) { | ||
| return removeChild(this, node); | ||
| } | ||
| attachShadow(_init) { | ||
| const shadowRoot = this.ownerDocument.createElement('SHADOWROOT'); | ||
| this.shadowRoot = shadowRoot; | ||
| return shadowRoot; | ||
| } | ||
| dispatchEvent(_event) { | ||
| return true; | ||
| } | ||
| toString() { | ||
| let attributeString = ''; | ||
| for (const attribute in this.attributes) { | ||
| attributeString += `${attribute}="${this.attributes[attribute]}" `; | ||
| } | ||
| return `${this.tagName} ${attributeString}`; | ||
| } | ||
| }; | ||
| } | ||
| function BaseRRMediaElementImpl(RRElementClass) { | ||
| return class BaseRRMediaElement extends RRElementClass { | ||
| attachShadow(_init) { | ||
| throw new Error(`RRDomException: Failed to execute 'attachShadow' on 'RRElement': This RRElement does not support attachShadow`); | ||
| } | ||
| play() { | ||
| this.paused = false; | ||
| } | ||
| pause() { | ||
| this.paused = true; | ||
| } | ||
| }; | ||
| } | ||
| function BaseRRTextImpl(RRNodeClass) { | ||
| return class BaseRRText extends RRNodeClass { | ||
| constructor(data) { | ||
| super(); | ||
| this.nodeType = NodeType.TEXT_NODE; | ||
| this.nodeName = '#text'; | ||
| this.RRNodeType = NodeType$1.Text; | ||
| this.data = data; | ||
| } | ||
| get textContent() { | ||
| return this.data; | ||
| } | ||
| set textContent(textContent) { | ||
| this.data = textContent; | ||
| } | ||
| toString() { | ||
| return `RRText text=${JSON.stringify(this.data)}`; | ||
| } | ||
| }; | ||
| } | ||
| function BaseRRCommentImpl(RRNodeClass) { | ||
| return class BaseRRComment extends RRNodeClass { | ||
| constructor(data) { | ||
| super(); | ||
| this.nodeType = NodeType.COMMENT_NODE; | ||
| this.nodeName = '#comment'; | ||
| this.RRNodeType = NodeType$1.Comment; | ||
| this.data = data; | ||
| } | ||
| get textContent() { | ||
| return this.data; | ||
| } | ||
| set textContent(textContent) { | ||
| this.data = textContent; | ||
| } | ||
| toString() { | ||
| return `RRComment text=${JSON.stringify(this.data)}`; | ||
| } | ||
| }; | ||
| } | ||
| function BaseRRCDATASectionImpl(RRNodeClass) { | ||
| return class BaseRRCDATASection extends RRNodeClass { | ||
| constructor(data) { | ||
| super(); | ||
| this.nodeName = '#cdata-section'; | ||
| this.nodeType = NodeType.CDATA_SECTION_NODE; | ||
| this.RRNodeType = NodeType$1.CDATA; | ||
| this.data = data; | ||
| } | ||
| get textContent() { | ||
| return this.data; | ||
| } | ||
| set textContent(textContent) { | ||
| this.data = textContent; | ||
| } | ||
| toString() { | ||
| return `RRCDATASection data=${JSON.stringify(this.data)}`; | ||
| } | ||
| }; | ||
| } | ||
| class ClassList { | ||
| constructor(classText, onChange) { | ||
| this.classes = []; | ||
| this.add = (...classNames) => { | ||
| for (const item of classNames) { | ||
| const className = String(item); | ||
| if (this.classes.indexOf(className) >= 0) | ||
| continue; | ||
| this.classes.push(className); | ||
| } | ||
| this.onChange && this.onChange(this.classes.join(' ')); | ||
| }; | ||
| this.remove = (...classNames) => { | ||
| this.classes = this.classes.filter((item) => classNames.indexOf(item) === -1); | ||
| this.onChange && this.onChange(this.classes.join(' ')); | ||
| }; | ||
| if (classText) { | ||
| const classes = classText.trim().split(/\s+/); | ||
| this.classes.push(...classes); | ||
| } | ||
| this.onChange = onChange; | ||
| } | ||
| } | ||
| function appendChild(parent, newChild) { | ||
| if (newChild.parentNode) | ||
| newChild.parentNode.removeChild(newChild); | ||
| if (parent.lastChild) { | ||
| parent.lastChild.nextSibling = newChild; | ||
| newChild.previousSibling = parent.lastChild; | ||
| } | ||
| else { | ||
| parent.firstChild = newChild; | ||
| newChild.previousSibling = null; | ||
| } | ||
| parent.lastChild = newChild; | ||
| newChild.nextSibling = null; | ||
| newChild.parentNode = parent; | ||
| newChild.parentElement = parent; | ||
| newChild.ownerDocument = parent.ownerDocument; | ||
| return newChild; | ||
| } | ||
| function insertBefore(parent, newChild, refChild) { | ||
| if (!refChild) | ||
| return appendChild(parent, newChild); | ||
| if (refChild.parentNode !== parent) | ||
| throw new Error("Failed to execute 'insertBefore' on 'RRNode': The RRNode before which the new node is to be inserted is not a child of this RRNode."); | ||
| if (newChild === refChild) | ||
| return newChild; | ||
| if (newChild.parentNode) | ||
| newChild.parentNode.removeChild(newChild); | ||
| newChild.previousSibling = refChild.previousSibling; | ||
| refChild.previousSibling = newChild; | ||
| newChild.nextSibling = refChild; | ||
| if (newChild.previousSibling) | ||
| newChild.previousSibling.nextSibling = newChild; | ||
| else | ||
| parent.firstChild = newChild; | ||
| newChild.parentElement = parent; | ||
| newChild.parentNode = parent; | ||
| newChild.ownerDocument = parent.ownerDocument; | ||
| return newChild; | ||
| } | ||
| function removeChild(parent, child) { | ||
| if (child.parentNode !== parent) | ||
| throw new Error("Failed to execute 'removeChild' on 'RRNode': The RRNode to be removed is not a child of this RRNode."); | ||
| if (child.previousSibling) | ||
| child.previousSibling.nextSibling = child.nextSibling; | ||
| else | ||
| parent.firstChild = child.nextSibling; | ||
| if (child.nextSibling) | ||
| child.nextSibling.previousSibling = child.previousSibling; | ||
| else | ||
| parent.lastChild = child.previousSibling; | ||
| child.previousSibling = null; | ||
| child.nextSibling = null; | ||
| child.parentElement = null; | ||
| child.parentNode = null; | ||
| return child; | ||
| } | ||
| var NodeType; | ||
| (function (NodeType) { | ||
| NodeType[NodeType["PLACEHOLDER"] = 0] = "PLACEHOLDER"; | ||
| NodeType[NodeType["ELEMENT_NODE"] = 1] = "ELEMENT_NODE"; | ||
| NodeType[NodeType["ATTRIBUTE_NODE"] = 2] = "ATTRIBUTE_NODE"; | ||
| NodeType[NodeType["TEXT_NODE"] = 3] = "TEXT_NODE"; | ||
| NodeType[NodeType["CDATA_SECTION_NODE"] = 4] = "CDATA_SECTION_NODE"; | ||
| NodeType[NodeType["ENTITY_REFERENCE_NODE"] = 5] = "ENTITY_REFERENCE_NODE"; | ||
| NodeType[NodeType["ENTITY_NODE"] = 6] = "ENTITY_NODE"; | ||
| NodeType[NodeType["PROCESSING_INSTRUCTION_NODE"] = 7] = "PROCESSING_INSTRUCTION_NODE"; | ||
| NodeType[NodeType["COMMENT_NODE"] = 8] = "COMMENT_NODE"; | ||
| NodeType[NodeType["DOCUMENT_NODE"] = 9] = "DOCUMENT_NODE"; | ||
| NodeType[NodeType["DOCUMENT_TYPE_NODE"] = 10] = "DOCUMENT_TYPE_NODE"; | ||
| NodeType[NodeType["DOCUMENT_FRAGMENT_NODE"] = 11] = "DOCUMENT_FRAGMENT_NODE"; | ||
| })(NodeType || (NodeType = {})); | ||
| const nwsapi = require('nwsapi'); | ||
| const cssom = require('cssom'); | ||
| const cssstyle = require('cssstyle'); | ||
| class RRNode extends BaseRRNode { | ||
| } | ||
| class RRWindow { | ||
| constructor() { | ||
| this.scrollLeft = 0; | ||
| this.scrollTop = 0; | ||
| } | ||
| scrollTo(options) { | ||
| if (!options) | ||
| return; | ||
| if (typeof options.left === 'number') | ||
| this.scrollLeft = options.left; | ||
| if (typeof options.top === 'number') | ||
| this.scrollTop = options.top; | ||
| } | ||
| } | ||
| class RRDocument extends BaseRRDocumentImpl(RRNode) { | ||
| constructor() { | ||
| super(...arguments); | ||
| this.nodeName = '#document'; | ||
| } | ||
| get nwsapi() { | ||
| if (!this._nwsapi) { | ||
| this._nwsapi = nwsapi({ | ||
| document: this, | ||
| DOMException: null, | ||
| }); | ||
| this._nwsapi.configure({ | ||
| LOGERRORS: false, | ||
| IDS_DUPES: true, | ||
| MIXEDCASE: true, | ||
| }); | ||
| } | ||
| return this._nwsapi; | ||
| } | ||
| get documentElement() { | ||
| return super.documentElement; | ||
| } | ||
| get body() { | ||
| return super.body; | ||
| } | ||
| get head() { | ||
| return super.head; | ||
| } | ||
| get implementation() { | ||
| return this; | ||
| } | ||
| get firstElementChild() { | ||
| return this.documentElement; | ||
| } | ||
| appendChild(childNode) { | ||
| return super.appendChild(childNode); | ||
| } | ||
| insertBefore(newChild, refChild) { | ||
| return super.insertBefore(newChild, refChild); | ||
| } | ||
| querySelectorAll(selectors) { | ||
| return this.nwsapi.select(selectors); | ||
| } | ||
| getElementsByTagName(tagName) { | ||
| if (this.documentElement) | ||
| return this.documentElement.getElementsByTagName(tagName); | ||
| return []; | ||
| } | ||
| getElementsByClassName(className) { | ||
| if (this.documentElement) | ||
| return this.documentElement.getElementsByClassName(className); | ||
| return []; | ||
| } | ||
| getElementById(elementId) { | ||
| if (this.documentElement) | ||
| return this.documentElement.getElementById(elementId); | ||
| return null; | ||
| } | ||
| createDocument(_namespace, _qualifiedName, _doctype) { | ||
| return new RRDocument(); | ||
| } | ||
| createDocumentType(qualifiedName, publicId, systemId) { | ||
| const documentTypeNode = new RRDocumentType(qualifiedName, publicId, systemId); | ||
| documentTypeNode.ownerDocument = this; | ||
| return documentTypeNode; | ||
| } | ||
| createElement(tagName) { | ||
| const upperTagName = tagName.toUpperCase(); | ||
| let element; | ||
| switch (upperTagName) { | ||
| case 'AUDIO': | ||
| case 'VIDEO': | ||
| element = new RRMediaElement(upperTagName); | ||
| break; | ||
| case 'IFRAME': | ||
| element = new RRIFrameElement(upperTagName); | ||
| break; | ||
| case 'IMG': | ||
| element = new RRImageElement(upperTagName); | ||
| break; | ||
| case 'CANVAS': | ||
| element = new RRCanvasElement(upperTagName); | ||
| break; | ||
| case 'STYLE': | ||
| element = new RRStyleElement(upperTagName); | ||
| break; | ||
| default: | ||
| element = new RRElement(upperTagName); | ||
| break; | ||
| } | ||
| element.ownerDocument = this; | ||
| return element; | ||
| } | ||
| createElementNS(_namespaceURI, qualifiedName) { | ||
| return this.createElement(qualifiedName); | ||
| } | ||
| createComment(data) { | ||
| const commentNode = new RRComment(data); | ||
| commentNode.ownerDocument = this; | ||
| return commentNode; | ||
| } | ||
| createCDATASection(data) { | ||
| const sectionNode = new RRCDATASection(data); | ||
| sectionNode.ownerDocument = this; | ||
| return sectionNode; | ||
| } | ||
| createTextNode(data) { | ||
| const textNode = new RRText(data); | ||
| textNode.ownerDocument = this; | ||
| return textNode; | ||
| } | ||
| } | ||
| class RRDocumentType extends BaseRRDocumentTypeImpl(RRNode) { | ||
| } | ||
| class RRElement extends BaseRRElementImpl(RRNode) { | ||
| constructor(tagName) { | ||
| super(tagName); | ||
| this._style = new cssstyle.CSSStyleDeclaration(); | ||
| const style = this._style; | ||
| Object.defineProperty(this.attributes, 'style', { | ||
| get() { | ||
| return style.cssText; | ||
| }, | ||
| set(cssText) { | ||
| style.cssText = cssText; | ||
| }, | ||
| }); | ||
| } | ||
| get style() { | ||
| return this._style; | ||
| } | ||
| attachShadow(_init) { | ||
| return super.attachShadow(_init); | ||
| } | ||
| appendChild(newChild) { | ||
| return super.appendChild(newChild); | ||
| } | ||
| insertBefore(newChild, refChild) { | ||
| return super.insertBefore(newChild, refChild); | ||
| } | ||
| getAttribute(name) { | ||
| const upperName = name && name.toLowerCase(); | ||
| if (upperName in this.attributes) | ||
| return this.attributes[upperName]; | ||
| return null; | ||
| } | ||
| setAttribute(name, attribute) { | ||
| this.attributes[name.toLowerCase()] = attribute; | ||
| } | ||
| removeAttribute(name) { | ||
| delete this.attributes[name.toLowerCase()]; | ||
| } | ||
| get firstElementChild() { | ||
| for (const child of this.childNodes) | ||
| if (child.RRNodeType === NodeType$2.Element) | ||
| return child; | ||
| return null; | ||
| } | ||
| get nextElementSibling() { | ||
| const parentNode = this.parentNode; | ||
| if (!parentNode) | ||
| return null; | ||
| const siblings = parentNode.childNodes; | ||
| const index = siblings.indexOf(this); | ||
| for (let i = index + 1; i < siblings.length; i++) | ||
| if (siblings[i] instanceof RRElement) | ||
| return siblings[i]; | ||
| return null; | ||
| } | ||
| querySelectorAll(selectors) { | ||
| const result = []; | ||
| if (this.ownerDocument !== null) { | ||
| this.ownerDocument.nwsapi.select(selectors, this, (element) => { | ||
| if (element !== this) | ||
| result.push(element); | ||
| }); | ||
| } | ||
| return result; | ||
| } | ||
| getElementById(elementId) { | ||
| if (this.id === elementId) | ||
| return this; | ||
| for (const child of this.childNodes) { | ||
| if (child instanceof RRElement) { | ||
| const result = child.getElementById(elementId); | ||
| if (result !== null) | ||
| return result; | ||
| } | ||
| } | ||
| return null; | ||
| } | ||
| getElementsByClassName(className) { | ||
| let elements = []; | ||
| const queryClassList = new ClassList(className); | ||
| if (this instanceof RRElement && | ||
| queryClassList.classes.filter((queriedClassName) => this.classList.classes.some((name) => name === queriedClassName)).length == queryClassList.classes.length) | ||
| elements.push(this); | ||
| for (const child of this.childNodes) { | ||
| if (child instanceof RRElement) | ||
| elements = elements.concat(child.getElementsByClassName(className)); | ||
| } | ||
| return elements; | ||
| } | ||
| getElementsByTagName(tagName) { | ||
| let elements = []; | ||
| const normalizedTagName = tagName.toUpperCase(); | ||
| if (this instanceof RRElement && this.tagName === normalizedTagName) | ||
| elements.push(this); | ||
| for (const child of this.childNodes) { | ||
| if (child instanceof RRElement) | ||
| elements = elements.concat(child.getElementsByTagName(tagName)); | ||
| } | ||
| return elements; | ||
| } | ||
| } | ||
| class RRImageElement extends RRElement { | ||
| } | ||
| class RRMediaElement extends BaseRRMediaElementImpl(RRElement) { | ||
| } | ||
| class RRCanvasElement extends RRElement { | ||
| getContext() { | ||
| return null; | ||
| } | ||
| } | ||
| class RRStyleElement extends RRElement { | ||
| constructor() { | ||
| super(...arguments); | ||
| this._sheet = null; | ||
| } | ||
| get sheet() { | ||
| if (!this._sheet) { | ||
| let result = ''; | ||
| for (const child of this.childNodes) | ||
| if (child.RRNodeType === NodeType$2.Text) | ||
| result += child.textContent; | ||
| this._sheet = cssom.parse(result); | ||
| } | ||
| return this._sheet; | ||
| } | ||
| } | ||
| class RRIFrameElement extends RRElement { | ||
| constructor(tagName) { | ||
| super(tagName); | ||
| this.width = ''; | ||
| this.height = ''; | ||
| this.src = ''; | ||
| this.contentDocument = new RRDocument(); | ||
| this.contentWindow = new RRWindow(); | ||
| const htmlElement = this.contentDocument.createElement('HTML'); | ||
| this.contentDocument.appendChild(htmlElement); | ||
| htmlElement.appendChild(this.contentDocument.createElement('HEAD')); | ||
| htmlElement.appendChild(this.contentDocument.createElement('BODY')); | ||
| } | ||
| } | ||
| class RRText extends BaseRRTextImpl(RRNode) { | ||
| constructor() { | ||
| super(...arguments); | ||
| this.nodeName = '#text'; | ||
| } | ||
| } | ||
| class RRComment extends BaseRRCommentImpl(RRNode) { | ||
| constructor() { | ||
| super(...arguments); | ||
| this.nodeName = '#comment'; | ||
| } | ||
| } | ||
| class RRCDATASection extends BaseRRCDATASectionImpl(RRNode) { | ||
| constructor() { | ||
| super(...arguments); | ||
| this.nodeName = '#cdata-section'; | ||
| } | ||
| } | ||
| function polyfillPerformance() { | ||
| if (typeof window !== 'undefined' || 'performance' in global) | ||
| return; | ||
| const performance = require('perf_hooks').performance; | ||
| global.performance = performance; | ||
| } | ||
| function polyfillRAF() { | ||
| if (typeof window !== 'undefined' || 'requestAnimationFrame' in global) | ||
| return; | ||
| const FPS = 60, INTERVAL = 1000 / FPS; | ||
| let timeoutHandle = null, rafCount = 0, requests = Object.create(null); | ||
| function onFrameTimer() { | ||
| const currentRequests = requests; | ||
| requests = Object.create(null); | ||
| timeoutHandle = null; | ||
| Object.keys(currentRequests).forEach(function (id) { | ||
| const request = currentRequests[id]; | ||
| if (request) | ||
| request(Date.now()); | ||
| }); | ||
| } | ||
| function requestAnimationFrame(callback) { | ||
| const cbHandle = ++rafCount; | ||
| requests[cbHandle] = callback; | ||
| if (timeoutHandle === null) | ||
| timeoutHandle = setTimeout(onFrameTimer, INTERVAL); | ||
| return cbHandle; | ||
| } | ||
| function cancelAnimationFrame(handleId) { | ||
| delete requests[handleId]; | ||
| if (Object.keys(requests).length === 0 && timeoutHandle !== null) { | ||
| clearTimeout(timeoutHandle); | ||
| timeoutHandle = null; | ||
| } | ||
| } | ||
| global.requestAnimationFrame = | ||
| requestAnimationFrame; | ||
| global.cancelAnimationFrame = | ||
| cancelAnimationFrame; | ||
| } | ||
| function polyfillEvent() { | ||
| if (typeof Event !== 'undefined') | ||
| return; | ||
| global.Event = function () { | ||
| }; | ||
| } | ||
| function polyfillNode() { | ||
| if (typeof Node !== 'undefined') | ||
| return; | ||
| global.Node = RRNode; | ||
| } | ||
| function polyfillDocument() { | ||
| if (typeof document !== 'undefined') | ||
| return; | ||
| const rrdom = new RRDocument(); | ||
| (() => { | ||
| rrdom.appendChild(rrdom.createElement('html')); | ||
| rrdom.documentElement.appendChild(rrdom.createElement('head')); | ||
| rrdom.documentElement.appendChild(rrdom.createElement('body')); | ||
| })(); | ||
| global.document = rrdom; | ||
| } | ||
| polyfillPerformance(); | ||
| polyfillRAF(); | ||
| polyfillEvent(); | ||
| polyfillNode(); | ||
| polyfillDocument(); | ||
| export { RRCDATASection, RRCanvasElement, RRComment, RRDocument, RRDocumentType, RRElement, RRIFrameElement, RRImageElement, RRMediaElement, RRNode, RRStyleElement, RRText, RRWindow }; |
| var e,t;function n(e){const t=[];for(const n in e){const s=e[n];if("string"!=typeof s)continue;const o=l(n);t.push(`${o}: ${s};`)}return t.join(" ")}!function(e){e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment"}(e||(e={})),function(e){e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment"}(t||(t={}));const s=/-([a-z])/g,o=/^--[a-zA-Z0-9-]+$/,i=e=>o.test(e)?e:e.replace(s,((e,t)=>t?t.toUpperCase():"")),r=/\B([A-Z])/g,l=e=>e.replace(r,"-$1").toLowerCase();class u{constructor(...e){this.parentElement=null,this.parentNode=null,this.firstChild=null,this.lastChild=null,this.previousSibling=null,this.nextSibling=null,this.ELEMENT_NODE=f.ELEMENT_NODE,this.TEXT_NODE=f.TEXT_NODE}get childNodes(){const e=[];let t=this.firstChild;for(;t;)e.push(t),t=t.nextSibling;return e}contains(e){if(!(e instanceof u))return!1;if(e.ownerDocument!==this.ownerDocument)return!1;if(e===this)return!0;for(;e.parentNode;){if(e.parentNode===this)return!0;e=e.parentNode}return!1}appendChild(e){throw new Error("RRDomException: Failed to execute 'appendChild' on 'RRNode': This RRNode type does not support this method.")}insertBefore(e,t){throw new Error("RRDomException: Failed to execute 'insertBefore' on 'RRNode': This RRNode type does not support this method.")}removeChild(e){throw new Error("RRDomException: Failed to execute 'removeChild' on 'RRNode': This RRNode type does not support this method.")}toString(){return"RRNode"}}function c(e){return class extends e{constructor(e,n,s){super(),this.nodeType=f.DOCUMENT_TYPE_NODE,this.RRNodeType=t.DocumentType,this.name=e,this.publicId=n,this.systemId=s,this.nodeName=e,this.textContent=null}toString(){return"RRDocumentType"}}}function a(e){return class extends e{constructor(e){super(),this.nodeType=f.ELEMENT_NODE,this.RRNodeType=t.Element,this.attributes={},this.shadowRoot=null,this.tagName=e.toUpperCase(),this.nodeName=e.toUpperCase()}get textContent(){let e="";return this.childNodes.forEach((t=>e+=t.textContent)),e}set textContent(e){this.firstChild=null,this.lastChild=null,this.appendChild(this.ownerDocument.createTextNode(e))}get classList(){return new p(this.attributes.class,(e=>{this.attributes.class=e}))}get id(){return this.attributes.id||""}get className(){return this.attributes.class||""}get style(){const e=this.attributes.style?function(e){const t={},n=/:(.+)/;return e.replace(/\/\*.*?\*\//g,"").split(/;(?![^(]*\))/g).forEach((function(e){if(e){const s=e.split(n);s.length>1&&(t[i(s[0].trim())]=s[1].trim())}})),t}(this.attributes.style):{},t=/\B([A-Z])/g;return e.setProperty=(s,o,r)=>{if(t.test(s))return;const l=i(s);o?e[l]=o:delete e[l],"important"===r&&(e[l]+=" !important"),this.attributes.style=n(e)},e.removeProperty=s=>{if(t.test(s))return"";const o=i(s),r=e[o]||"";return delete e[o],this.attributes.style=n(e),r},e}getAttribute(e){return this.attributes[e]||null}setAttribute(e,t){this.attributes[e]=t}setAttributeNS(e,t,n){this.setAttribute(t,n)}removeAttribute(e){delete this.attributes[e]}appendChild(e){return E(this,e)}insertBefore(e,t){return N(this,e,t)}removeChild(e){return T(this,e)}attachShadow(e){const t=this.ownerDocument.createElement("SHADOWROOT");return this.shadowRoot=t,t}dispatchEvent(e){return!0}toString(){let e="";for(const t in this.attributes)e+=`${t}="${this.attributes[t]}" `;return`${this.tagName} ${e}`}}}function h(e){return class extends e{constructor(e){super(),this.nodeType=f.TEXT_NODE,this.nodeName="#text",this.RRNodeType=t.Text,this.data=e}get textContent(){return this.data}set textContent(e){this.data=e}toString(){return`RRText text=${JSON.stringify(this.data)}`}}}function d(e){return class extends e{constructor(e){super(),this.nodeType=f.COMMENT_NODE,this.nodeName="#comment",this.RRNodeType=t.Comment,this.data=e}get textContent(){return this.data}set textContent(e){this.data=e}toString(){return`RRComment text=${JSON.stringify(this.data)}`}}}function m(e){return class extends e{constructor(e){super(),this.nodeName="#cdata-section",this.nodeType=f.CDATA_SECTION_NODE,this.RRNodeType=t.CDATA,this.data=e}get textContent(){return this.data}set textContent(e){this.data=e}toString(){return`RRCDATASection data=${JSON.stringify(this.data)}`}}}class p{constructor(e,t){if(this.classes=[],this.add=(...e)=>{for(const t of e){const e=String(t);this.classes.indexOf(e)>=0||this.classes.push(e)}this.onChange&&this.onChange(this.classes.join(" "))},this.remove=(...e)=>{this.classes=this.classes.filter((t=>-1===e.indexOf(t))),this.onChange&&this.onChange(this.classes.join(" "))},e){const t=e.trim().split(/\s+/);this.classes.push(...t)}this.onChange=t}}function E(e,t){return t.parentNode&&t.parentNode.removeChild(t),e.lastChild?(e.lastChild.nextSibling=t,t.previousSibling=e.lastChild):(e.firstChild=t,t.previousSibling=null),e.lastChild=t,t.nextSibling=null,t.parentNode=e,t.parentElement=e,t.ownerDocument=e.ownerDocument,t}function N(e,t,n){if(!n)return E(e,t);if(n.parentNode!==e)throw new Error("Failed to execute 'insertBefore' on 'RRNode': The RRNode before which the new node is to be inserted is not a child of this RRNode.");return t===n||(t.parentNode&&t.parentNode.removeChild(t),t.previousSibling=n.previousSibling,n.previousSibling=t,t.nextSibling=n,t.previousSibling?t.previousSibling.nextSibling=t:e.firstChild=t,t.parentElement=e,t.parentNode=e,t.ownerDocument=e.ownerDocument),t}function T(e,t){if(t.parentNode!==e)throw new Error("Failed to execute 'removeChild' on 'RRNode': The RRNode to be removed is not a child of this RRNode.");return t.previousSibling?t.previousSibling.nextSibling=t.nextSibling:e.firstChild=t.nextSibling,t.nextSibling?t.nextSibling.previousSibling=t.previousSibling:e.lastChild=t.previousSibling,t.previousSibling=null,t.nextSibling=null,t.parentElement=null,t.parentNode=null,t}var f;!function(e){e[e.PLACEHOLDER=0]="PLACEHOLDER",e[e.ELEMENT_NODE=1]="ELEMENT_NODE",e[e.ATTRIBUTE_NODE=2]="ATTRIBUTE_NODE",e[e.TEXT_NODE=3]="TEXT_NODE",e[e.CDATA_SECTION_NODE=4]="CDATA_SECTION_NODE",e[e.ENTITY_REFERENCE_NODE=5]="ENTITY_REFERENCE_NODE",e[e.ENTITY_NODE=6]="ENTITY_NODE",e[e.PROCESSING_INSTRUCTION_NODE=7]="PROCESSING_INSTRUCTION_NODE",e[e.COMMENT_NODE=8]="COMMENT_NODE",e[e.DOCUMENT_NODE=9]="DOCUMENT_NODE",e[e.DOCUMENT_TYPE_NODE=10]="DOCUMENT_TYPE_NODE",e[e.DOCUMENT_FRAGMENT_NODE=11]="DOCUMENT_FRAGMENT_NODE"}(f||(f={}));const D=require("nwsapi"),C=require("cssom"),R=require("cssstyle");class g extends u{}class w{constructor(){this.scrollLeft=0,this.scrollTop=0}scrollTo(e){e&&("number"==typeof e.left&&(this.scrollLeft=e.left),"number"==typeof e.top&&(this.scrollTop=e.top))}}class y extends(function(e){return class n extends e{constructor(...e){super(e),this.nodeType=f.DOCUMENT_NODE,this.nodeName="#document",this.compatMode="CSS1Compat",this.RRNodeType=t.Document,this.textContent=null,this.ownerDocument=this}get documentElement(){return this.childNodes.find((e=>e.RRNodeType===t.Element&&"HTML"===e.tagName))||null}get body(){var e;return(null===(e=this.documentElement)||void 0===e?void 0:e.childNodes.find((e=>e.RRNodeType===t.Element&&"BODY"===e.tagName)))||null}get head(){var e;return(null===(e=this.documentElement)||void 0===e?void 0:e.childNodes.find((e=>e.RRNodeType===t.Element&&"HEAD"===e.tagName)))||null}get implementation(){return this}get firstElementChild(){return this.documentElement}appendChild(e){const n=e.RRNodeType;if((n===t.Element||n===t.DocumentType)&&this.childNodes.some((e=>e.RRNodeType===n)))throw new Error(`RRDomException: Failed to execute 'appendChild' on 'RRNode': Only one ${n===t.Element?"RRElement":"RRDoctype"} on RRDocument allowed.`);const s=E(this,e);return s.parentElement=null,s}insertBefore(e,n){const s=e.RRNodeType;if((s===t.Element||s===t.DocumentType)&&this.childNodes.some((e=>e.RRNodeType===s)))throw new Error(`RRDomException: Failed to execute 'insertBefore' on 'RRNode': Only one ${s===t.Element?"RRElement":"RRDoctype"} on RRDocument allowed.`);const o=N(this,e,n);return o.parentElement=null,o}removeChild(e){return T(this,e)}open(){this.firstChild=null,this.lastChild=null}close(){}write(e){let t;if('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">'===e?t="-//W3C//DTD XHTML 1.0 Transitional//EN":'<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "">'===e&&(t="-//W3C//DTD HTML 4.0 Transitional//EN"),t){const e=this.createDocumentType("html",t,"");this.open(),this.appendChild(e)}}createDocument(e,t,s){return new n}createDocumentType(e,t,n){const s=new(c(u))(e,t,n);return s.ownerDocument=this,s}createElement(e){const t=new(a(u))(e);return t.ownerDocument=this,t}createElementNS(e,t){return this.createElement(t)}createTextNode(e){const t=new(h(u))(e);return t.ownerDocument=this,t}createComment(e){const t=new(d(u))(e);return t.ownerDocument=this,t}createCDATASection(e){const t=new(m(u))(e);return t.ownerDocument=this,t}toString(){return"RRDocument"}}}(g)){constructor(){super(...arguments),this.nodeName="#document"}get nwsapi(){return this._nwsapi||(this._nwsapi=D({document:this,DOMException:null}),this._nwsapi.configure({LOGERRORS:!1,IDS_DUPES:!0,MIXEDCASE:!0})),this._nwsapi}get documentElement(){return super.documentElement}get body(){return super.body}get head(){return super.head}get implementation(){return this}get firstElementChild(){return this.documentElement}appendChild(e){return super.appendChild(e)}insertBefore(e,t){return super.insertBefore(e,t)}querySelectorAll(e){return this.nwsapi.select(e)}getElementsByTagName(e){return this.documentElement?this.documentElement.getElementsByTagName(e):[]}getElementsByClassName(e){return this.documentElement?this.documentElement.getElementsByClassName(e):[]}getElementById(e){return this.documentElement?this.documentElement.getElementById(e):null}createDocument(e,t,n){return new y}createDocumentType(e,t,n){const s=new b(e,t,n);return s.ownerDocument=this,s}createElement(e){const t=e.toUpperCase();let n;switch(t){case"AUDIO":case"VIDEO":n=new S(t);break;case"IFRAME":n=new v(t);break;case"IMG":n=new O(t);break;case"CANVAS":n=new _(t);break;case"STYLE":n=new A(t);break;default:n=new x(t)}return n.ownerDocument=this,n}createElementNS(e,t){return this.createElement(t)}createComment(e){const t=new B(e);return t.ownerDocument=this,t}createCDATASection(e){const t=new I(e);return t.ownerDocument=this,t}createTextNode(e){const t=new M(e);return t.ownerDocument=this,t}}class b extends(c(g)){}class x extends(a(g)){constructor(e){super(e),this._style=new R.CSSStyleDeclaration;const t=this._style;Object.defineProperty(this.attributes,"style",{get:()=>t.cssText,set(e){t.cssText=e}})}get style(){return this._style}attachShadow(e){return super.attachShadow(e)}appendChild(e){return super.appendChild(e)}insertBefore(e,t){return super.insertBefore(e,t)}getAttribute(e){const t=e&&e.toLowerCase();return t in this.attributes?this.attributes[t]:null}setAttribute(e,t){this.attributes[e.toLowerCase()]=t}removeAttribute(e){delete this.attributes[e.toLowerCase()]}get firstElementChild(){for(const t of this.childNodes)if(t.RRNodeType===e.Element)return t;return null}get nextElementSibling(){const e=this.parentNode;if(!e)return null;const t=e.childNodes;for(let e=t.indexOf(this)+1;e<t.length;e++)if(t[e]instanceof x)return t[e];return null}querySelectorAll(e){const t=[];return null!==this.ownerDocument&&this.ownerDocument.nwsapi.select(e,this,(e=>{e!==this&&t.push(e)})),t}getElementById(e){if(this.id===e)return this;for(const t of this.childNodes)if(t instanceof x){const n=t.getElementById(e);if(null!==n)return n}return null}getElementsByClassName(e){let t=[];const n=new p(e);this instanceof x&&n.classes.filter((e=>this.classList.classes.some((t=>t===e)))).length==n.classes.length&&t.push(this);for(const n of this.childNodes)n instanceof x&&(t=t.concat(n.getElementsByClassName(e)));return t}getElementsByTagName(e){let t=[];const n=e.toUpperCase();this instanceof x&&this.tagName===n&&t.push(this);for(const n of this.childNodes)n instanceof x&&(t=t.concat(n.getElementsByTagName(e)));return t}}class O extends x{}class S extends(function(e){return class extends e{attachShadow(e){throw new Error("RRDomException: Failed to execute 'attachShadow' on 'RRElement': This RRElement does not support attachShadow")}play(){this.paused=!1}pause(){this.paused=!0}}}(x)){}class _ extends x{getContext(){return null}}class A extends x{constructor(){super(...arguments),this._sheet=null}get sheet(){if(!this._sheet){let t="";for(const n of this.childNodes)n.RRNodeType===e.Text&&(t+=n.textContent);this._sheet=C.parse(t)}return this._sheet}}class v extends x{constructor(e){super(e),this.width="",this.height="",this.src="",this.contentDocument=new y,this.contentWindow=new w;const t=this.contentDocument.createElement("HTML");this.contentDocument.appendChild(t),t.appendChild(this.contentDocument.createElement("HEAD")),t.appendChild(this.contentDocument.createElement("BODY"))}}class M extends(h(g)){constructor(){super(...arguments),this.nodeName="#text"}}class B extends(d(g)){constructor(){super(...arguments),this.nodeName="#comment"}}class I extends(m(g)){constructor(){super(...arguments),this.nodeName="#cdata-section"}}!function(){if("undefined"!=typeof window||"performance"in global)return;const e=require("perf_hooks").performance;global.performance=e}(),function(){if("undefined"!=typeof window||"requestAnimationFrame"in global)return;let e=null,t=0,n=Object.create(null);function s(){const t=n;n=Object.create(null),e=null,Object.keys(t).forEach((function(e){const n=t[e];n&&n(Date.now())}))}global.requestAnimationFrame=function(o){const i=++t;return n[i]=o,null===e&&(e=setTimeout(s,16.666666666666668)),i},global.cancelAnimationFrame=function(t){delete n[t],0===Object.keys(n).length&&null!==e&&(clearTimeout(e),e=null)}}(),"undefined"==typeof Event&&(global.Event=function(){}),"undefined"==typeof Node&&(global.Node=g),function(){if("undefined"!=typeof document)return;const e=new y;e.appendChild(e.createElement("html")),e.documentElement.appendChild(e.createElement("head")),e.documentElement.appendChild(e.createElement("body")),global.document=e}();export{I as RRCDATASection,_ as RRCanvasElement,B as RRComment,y as RRDocument,b as RRDocumentType,x as RRElement,v as RRIFrameElement,O as RRImageElement,S as RRMediaElement,g as RRNode,A as RRStyleElement,M as RRText,w as RRWindow}; | ||
| //# sourceMappingURL=rrdom-nodejs.min.js.map |
Sorry, the diff of this file is too big to display
| 'use strict'; | ||
| Object.defineProperty(exports, '__esModule', { value: true }); | ||
| var NodeType$2; | ||
| (function (NodeType) { | ||
| NodeType[NodeType["Document"] = 0] = "Document"; | ||
| NodeType[NodeType["DocumentType"] = 1] = "DocumentType"; | ||
| NodeType[NodeType["Element"] = 2] = "Element"; | ||
| NodeType[NodeType["Text"] = 3] = "Text"; | ||
| NodeType[NodeType["CDATA"] = 4] = "CDATA"; | ||
| NodeType[NodeType["Comment"] = 5] = "Comment"; | ||
| })(NodeType$2 || (NodeType$2 = {})); | ||
| var NodeType$1; | ||
| (function (NodeType) { | ||
| NodeType[NodeType["Document"] = 0] = "Document"; | ||
| NodeType[NodeType["DocumentType"] = 1] = "DocumentType"; | ||
| NodeType[NodeType["Element"] = 2] = "Element"; | ||
| NodeType[NodeType["Text"] = 3] = "Text"; | ||
| NodeType[NodeType["CDATA"] = 4] = "CDATA"; | ||
| NodeType[NodeType["Comment"] = 5] = "Comment"; | ||
| })(NodeType$1 || (NodeType$1 = {})); | ||
| function parseCSSText(cssText) { | ||
| const res = {}; | ||
| const listDelimiter = /;(?![^(]*\))/g; | ||
| const propertyDelimiter = /:(.+)/; | ||
| const comment = /\/\*.*?\*\//g; | ||
| cssText | ||
| .replace(comment, '') | ||
| .split(listDelimiter) | ||
| .forEach(function (item) { | ||
| if (item) { | ||
| const tmp = item.split(propertyDelimiter); | ||
| tmp.length > 1 && (res[camelize(tmp[0].trim())] = tmp[1].trim()); | ||
| } | ||
| }); | ||
| return res; | ||
| } | ||
| function toCSSText(style) { | ||
| const properties = []; | ||
| for (const name in style) { | ||
| const value = style[name]; | ||
| if (typeof value !== 'string') | ||
| continue; | ||
| const normalizedName = hyphenate(name); | ||
| properties.push(`${normalizedName}: ${value};`); | ||
| } | ||
| return properties.join(' '); | ||
| } | ||
| const camelizeRE = /-([a-z])/g; | ||
| const CUSTOM_PROPERTY_REGEX = /^--[a-zA-Z0-9-]+$/; | ||
| const camelize = (str) => { | ||
| if (CUSTOM_PROPERTY_REGEX.test(str)) | ||
| return str; | ||
| return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : '')); | ||
| }; | ||
| const hyphenateRE = /\B([A-Z])/g; | ||
| const hyphenate = (str) => { | ||
| return str.replace(hyphenateRE, '-$1').toLowerCase(); | ||
| }; | ||
| class BaseRRNode { | ||
| constructor(..._args) { | ||
| this.parentElement = null; | ||
| this.parentNode = null; | ||
| this.firstChild = null; | ||
| this.lastChild = null; | ||
| this.previousSibling = null; | ||
| this.nextSibling = null; | ||
| this.ELEMENT_NODE = NodeType.ELEMENT_NODE; | ||
| this.TEXT_NODE = NodeType.TEXT_NODE; | ||
| } | ||
| get childNodes() { | ||
| const childNodes = []; | ||
| let childIterator = this.firstChild; | ||
| while (childIterator) { | ||
| childNodes.push(childIterator); | ||
| childIterator = childIterator.nextSibling; | ||
| } | ||
| return childNodes; | ||
| } | ||
| contains(node) { | ||
| if (!(node instanceof BaseRRNode)) | ||
| return false; | ||
| else if (node.ownerDocument !== this.ownerDocument) | ||
| return false; | ||
| else if (node === this) | ||
| return true; | ||
| while (node.parentNode) { | ||
| if (node.parentNode === this) | ||
| return true; | ||
| node = node.parentNode; | ||
| } | ||
| return false; | ||
| } | ||
| appendChild(_newChild) { | ||
| throw new Error(`RRDomException: Failed to execute 'appendChild' on 'RRNode': This RRNode type does not support this method.`); | ||
| } | ||
| insertBefore(_newChild, _refChild) { | ||
| throw new Error(`RRDomException: Failed to execute 'insertBefore' on 'RRNode': This RRNode type does not support this method.`); | ||
| } | ||
| removeChild(_node) { | ||
| throw new Error(`RRDomException: Failed to execute 'removeChild' on 'RRNode': This RRNode type does not support this method.`); | ||
| } | ||
| toString() { | ||
| return 'RRNode'; | ||
| } | ||
| } | ||
| function BaseRRDocumentImpl(RRNodeClass) { | ||
| return class BaseRRDocument extends RRNodeClass { | ||
| constructor(...args) { | ||
| super(args); | ||
| this.nodeType = NodeType.DOCUMENT_NODE; | ||
| this.nodeName = '#document'; | ||
| this.compatMode = 'CSS1Compat'; | ||
| this.RRNodeType = NodeType$1.Document; | ||
| this.textContent = null; | ||
| this.ownerDocument = this; | ||
| } | ||
| get documentElement() { | ||
| return (this.childNodes.find((node) => node.RRNodeType === NodeType$1.Element && | ||
| node.tagName === 'HTML') || null); | ||
| } | ||
| get body() { | ||
| var _a; | ||
| return (((_a = this.documentElement) === null || _a === void 0 ? void 0 : _a.childNodes.find((node) => node.RRNodeType === NodeType$1.Element && | ||
| node.tagName === 'BODY')) || null); | ||
| } | ||
| get head() { | ||
| var _a; | ||
| return (((_a = this.documentElement) === null || _a === void 0 ? void 0 : _a.childNodes.find((node) => node.RRNodeType === NodeType$1.Element && | ||
| node.tagName === 'HEAD')) || null); | ||
| } | ||
| get implementation() { | ||
| return this; | ||
| } | ||
| get firstElementChild() { | ||
| return this.documentElement; | ||
| } | ||
| appendChild(newChild) { | ||
| const nodeType = newChild.RRNodeType; | ||
| if (nodeType === NodeType$1.Element || | ||
| nodeType === NodeType$1.DocumentType) { | ||
| if (this.childNodes.some((s) => s.RRNodeType === nodeType)) { | ||
| throw new Error(`RRDomException: Failed to execute 'appendChild' on 'RRNode': Only one ${nodeType === NodeType$1.Element ? 'RRElement' : 'RRDoctype'} on RRDocument allowed.`); | ||
| } | ||
| } | ||
| const child = appendChild(this, newChild); | ||
| child.parentElement = null; | ||
| return child; | ||
| } | ||
| insertBefore(newChild, refChild) { | ||
| const nodeType = newChild.RRNodeType; | ||
| if (nodeType === NodeType$1.Element || | ||
| nodeType === NodeType$1.DocumentType) { | ||
| if (this.childNodes.some((s) => s.RRNodeType === nodeType)) { | ||
| throw new Error(`RRDomException: Failed to execute 'insertBefore' on 'RRNode': Only one ${nodeType === NodeType$1.Element ? 'RRElement' : 'RRDoctype'} on RRDocument allowed.`); | ||
| } | ||
| } | ||
| const child = insertBefore(this, newChild, refChild); | ||
| child.parentElement = null; | ||
| return child; | ||
| } | ||
| removeChild(node) { | ||
| return removeChild(this, node); | ||
| } | ||
| open() { | ||
| this.firstChild = null; | ||
| this.lastChild = null; | ||
| } | ||
| close() { | ||
| } | ||
| write(content) { | ||
| let publicId; | ||
| if (content === | ||
| '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">') | ||
| publicId = '-//W3C//DTD XHTML 1.0 Transitional//EN'; | ||
| else if (content === | ||
| '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "">') | ||
| publicId = '-//W3C//DTD HTML 4.0 Transitional//EN'; | ||
| if (publicId) { | ||
| const doctype = this.createDocumentType('html', publicId, ''); | ||
| this.open(); | ||
| this.appendChild(doctype); | ||
| } | ||
| } | ||
| createDocument(_namespace, _qualifiedName, _doctype) { | ||
| return new BaseRRDocument(); | ||
| } | ||
| createDocumentType(qualifiedName, publicId, systemId) { | ||
| const doctype = new (BaseRRDocumentTypeImpl(BaseRRNode))(qualifiedName, publicId, systemId); | ||
| doctype.ownerDocument = this; | ||
| return doctype; | ||
| } | ||
| createElement(tagName) { | ||
| const element = new (BaseRRElementImpl(BaseRRNode))(tagName); | ||
| element.ownerDocument = this; | ||
| return element; | ||
| } | ||
| createElementNS(_namespaceURI, qualifiedName) { | ||
| return this.createElement(qualifiedName); | ||
| } | ||
| createTextNode(data) { | ||
| const text = new (BaseRRTextImpl(BaseRRNode))(data); | ||
| text.ownerDocument = this; | ||
| return text; | ||
| } | ||
| createComment(data) { | ||
| const comment = new (BaseRRCommentImpl(BaseRRNode))(data); | ||
| comment.ownerDocument = this; | ||
| return comment; | ||
| } | ||
| createCDATASection(data) { | ||
| const CDATASection = new (BaseRRCDATASectionImpl(BaseRRNode))(data); | ||
| CDATASection.ownerDocument = this; | ||
| return CDATASection; | ||
| } | ||
| toString() { | ||
| return 'RRDocument'; | ||
| } | ||
| }; | ||
| } | ||
| function BaseRRDocumentTypeImpl(RRNodeClass) { | ||
| return class BaseRRDocumentType extends RRNodeClass { | ||
| constructor(qualifiedName, publicId, systemId) { | ||
| super(); | ||
| this.nodeType = NodeType.DOCUMENT_TYPE_NODE; | ||
| this.RRNodeType = NodeType$1.DocumentType; | ||
| this.name = qualifiedName; | ||
| this.publicId = publicId; | ||
| this.systemId = systemId; | ||
| this.nodeName = qualifiedName; | ||
| this.textContent = null; | ||
| } | ||
| toString() { | ||
| return 'RRDocumentType'; | ||
| } | ||
| }; | ||
| } | ||
| function BaseRRElementImpl(RRNodeClass) { | ||
| return class BaseRRElement extends RRNodeClass { | ||
| constructor(tagName) { | ||
| super(); | ||
| this.nodeType = NodeType.ELEMENT_NODE; | ||
| this.RRNodeType = NodeType$1.Element; | ||
| this.attributes = {}; | ||
| this.shadowRoot = null; | ||
| this.tagName = tagName.toUpperCase(); | ||
| this.nodeName = tagName.toUpperCase(); | ||
| } | ||
| get textContent() { | ||
| let result = ''; | ||
| this.childNodes.forEach((node) => (result += node.textContent)); | ||
| return result; | ||
| } | ||
| set textContent(textContent) { | ||
| this.firstChild = null; | ||
| this.lastChild = null; | ||
| this.appendChild(this.ownerDocument.createTextNode(textContent)); | ||
| } | ||
| get classList() { | ||
| return new ClassList(this.attributes.class, (newClassName) => { | ||
| this.attributes.class = newClassName; | ||
| }); | ||
| } | ||
| get id() { | ||
| return this.attributes.id || ''; | ||
| } | ||
| get className() { | ||
| return this.attributes.class || ''; | ||
| } | ||
| get style() { | ||
| const style = (this.attributes.style ? parseCSSText(this.attributes.style) : {}); | ||
| const hyphenateRE = /\B([A-Z])/g; | ||
| style.setProperty = (name, value, priority) => { | ||
| if (hyphenateRE.test(name)) | ||
| return; | ||
| const normalizedName = camelize(name); | ||
| if (!value) | ||
| delete style[normalizedName]; | ||
| else | ||
| style[normalizedName] = value; | ||
| if (priority === 'important') | ||
| style[normalizedName] += ' !important'; | ||
| this.attributes.style = toCSSText(style); | ||
| }; | ||
| style.removeProperty = (name) => { | ||
| if (hyphenateRE.test(name)) | ||
| return ''; | ||
| const normalizedName = camelize(name); | ||
| const value = style[normalizedName] || ''; | ||
| delete style[normalizedName]; | ||
| this.attributes.style = toCSSText(style); | ||
| return value; | ||
| }; | ||
| return style; | ||
| } | ||
| getAttribute(name) { | ||
| return this.attributes[name] || null; | ||
| } | ||
| setAttribute(name, attribute) { | ||
| this.attributes[name] = attribute; | ||
| } | ||
| setAttributeNS(_namespace, qualifiedName, value) { | ||
| this.setAttribute(qualifiedName, value); | ||
| } | ||
| removeAttribute(name) { | ||
| delete this.attributes[name]; | ||
| } | ||
| appendChild(newChild) { | ||
| return appendChild(this, newChild); | ||
| } | ||
| insertBefore(newChild, refChild) { | ||
| return insertBefore(this, newChild, refChild); | ||
| } | ||
| removeChild(node) { | ||
| return removeChild(this, node); | ||
| } | ||
| attachShadow(_init) { | ||
| const shadowRoot = this.ownerDocument.createElement('SHADOWROOT'); | ||
| this.shadowRoot = shadowRoot; | ||
| return shadowRoot; | ||
| } | ||
| dispatchEvent(_event) { | ||
| return true; | ||
| } | ||
| toString() { | ||
| let attributeString = ''; | ||
| for (const attribute in this.attributes) { | ||
| attributeString += `${attribute}="${this.attributes[attribute]}" `; | ||
| } | ||
| return `${this.tagName} ${attributeString}`; | ||
| } | ||
| }; | ||
| } | ||
| function BaseRRMediaElementImpl(RRElementClass) { | ||
| return class BaseRRMediaElement extends RRElementClass { | ||
| attachShadow(_init) { | ||
| throw new Error(`RRDomException: Failed to execute 'attachShadow' on 'RRElement': This RRElement does not support attachShadow`); | ||
| } | ||
| play() { | ||
| this.paused = false; | ||
| } | ||
| pause() { | ||
| this.paused = true; | ||
| } | ||
| }; | ||
| } | ||
| function BaseRRTextImpl(RRNodeClass) { | ||
| return class BaseRRText extends RRNodeClass { | ||
| constructor(data) { | ||
| super(); | ||
| this.nodeType = NodeType.TEXT_NODE; | ||
| this.nodeName = '#text'; | ||
| this.RRNodeType = NodeType$1.Text; | ||
| this.data = data; | ||
| } | ||
| get textContent() { | ||
| return this.data; | ||
| } | ||
| set textContent(textContent) { | ||
| this.data = textContent; | ||
| } | ||
| toString() { | ||
| return `RRText text=${JSON.stringify(this.data)}`; | ||
| } | ||
| }; | ||
| } | ||
| function BaseRRCommentImpl(RRNodeClass) { | ||
| return class BaseRRComment extends RRNodeClass { | ||
| constructor(data) { | ||
| super(); | ||
| this.nodeType = NodeType.COMMENT_NODE; | ||
| this.nodeName = '#comment'; | ||
| this.RRNodeType = NodeType$1.Comment; | ||
| this.data = data; | ||
| } | ||
| get textContent() { | ||
| return this.data; | ||
| } | ||
| set textContent(textContent) { | ||
| this.data = textContent; | ||
| } | ||
| toString() { | ||
| return `RRComment text=${JSON.stringify(this.data)}`; | ||
| } | ||
| }; | ||
| } | ||
| function BaseRRCDATASectionImpl(RRNodeClass) { | ||
| return class BaseRRCDATASection extends RRNodeClass { | ||
| constructor(data) { | ||
| super(); | ||
| this.nodeName = '#cdata-section'; | ||
| this.nodeType = NodeType.CDATA_SECTION_NODE; | ||
| this.RRNodeType = NodeType$1.CDATA; | ||
| this.data = data; | ||
| } | ||
| get textContent() { | ||
| return this.data; | ||
| } | ||
| set textContent(textContent) { | ||
| this.data = textContent; | ||
| } | ||
| toString() { | ||
| return `RRCDATASection data=${JSON.stringify(this.data)}`; | ||
| } | ||
| }; | ||
| } | ||
| class ClassList { | ||
| constructor(classText, onChange) { | ||
| this.classes = []; | ||
| this.add = (...classNames) => { | ||
| for (const item of classNames) { | ||
| const className = String(item); | ||
| if (this.classes.indexOf(className) >= 0) | ||
| continue; | ||
| this.classes.push(className); | ||
| } | ||
| this.onChange && this.onChange(this.classes.join(' ')); | ||
| }; | ||
| this.remove = (...classNames) => { | ||
| this.classes = this.classes.filter((item) => classNames.indexOf(item) === -1); | ||
| this.onChange && this.onChange(this.classes.join(' ')); | ||
| }; | ||
| if (classText) { | ||
| const classes = classText.trim().split(/\s+/); | ||
| this.classes.push(...classes); | ||
| } | ||
| this.onChange = onChange; | ||
| } | ||
| } | ||
| function appendChild(parent, newChild) { | ||
| if (newChild.parentNode) | ||
| newChild.parentNode.removeChild(newChild); | ||
| if (parent.lastChild) { | ||
| parent.lastChild.nextSibling = newChild; | ||
| newChild.previousSibling = parent.lastChild; | ||
| } | ||
| else { | ||
| parent.firstChild = newChild; | ||
| newChild.previousSibling = null; | ||
| } | ||
| parent.lastChild = newChild; | ||
| newChild.nextSibling = null; | ||
| newChild.parentNode = parent; | ||
| newChild.parentElement = parent; | ||
| newChild.ownerDocument = parent.ownerDocument; | ||
| return newChild; | ||
| } | ||
| function insertBefore(parent, newChild, refChild) { | ||
| if (!refChild) | ||
| return appendChild(parent, newChild); | ||
| if (refChild.parentNode !== parent) | ||
| throw new Error("Failed to execute 'insertBefore' on 'RRNode': The RRNode before which the new node is to be inserted is not a child of this RRNode."); | ||
| if (newChild === refChild) | ||
| return newChild; | ||
| if (newChild.parentNode) | ||
| newChild.parentNode.removeChild(newChild); | ||
| newChild.previousSibling = refChild.previousSibling; | ||
| refChild.previousSibling = newChild; | ||
| newChild.nextSibling = refChild; | ||
| if (newChild.previousSibling) | ||
| newChild.previousSibling.nextSibling = newChild; | ||
| else | ||
| parent.firstChild = newChild; | ||
| newChild.parentElement = parent; | ||
| newChild.parentNode = parent; | ||
| newChild.ownerDocument = parent.ownerDocument; | ||
| return newChild; | ||
| } | ||
| function removeChild(parent, child) { | ||
| if (child.parentNode !== parent) | ||
| throw new Error("Failed to execute 'removeChild' on 'RRNode': The RRNode to be removed is not a child of this RRNode."); | ||
| if (child.previousSibling) | ||
| child.previousSibling.nextSibling = child.nextSibling; | ||
| else | ||
| parent.firstChild = child.nextSibling; | ||
| if (child.nextSibling) | ||
| child.nextSibling.previousSibling = child.previousSibling; | ||
| else | ||
| parent.lastChild = child.previousSibling; | ||
| child.previousSibling = null; | ||
| child.nextSibling = null; | ||
| child.parentElement = null; | ||
| child.parentNode = null; | ||
| return child; | ||
| } | ||
| var NodeType; | ||
| (function (NodeType) { | ||
| NodeType[NodeType["PLACEHOLDER"] = 0] = "PLACEHOLDER"; | ||
| NodeType[NodeType["ELEMENT_NODE"] = 1] = "ELEMENT_NODE"; | ||
| NodeType[NodeType["ATTRIBUTE_NODE"] = 2] = "ATTRIBUTE_NODE"; | ||
| NodeType[NodeType["TEXT_NODE"] = 3] = "TEXT_NODE"; | ||
| NodeType[NodeType["CDATA_SECTION_NODE"] = 4] = "CDATA_SECTION_NODE"; | ||
| NodeType[NodeType["ENTITY_REFERENCE_NODE"] = 5] = "ENTITY_REFERENCE_NODE"; | ||
| NodeType[NodeType["ENTITY_NODE"] = 6] = "ENTITY_NODE"; | ||
| NodeType[NodeType["PROCESSING_INSTRUCTION_NODE"] = 7] = "PROCESSING_INSTRUCTION_NODE"; | ||
| NodeType[NodeType["COMMENT_NODE"] = 8] = "COMMENT_NODE"; | ||
| NodeType[NodeType["DOCUMENT_NODE"] = 9] = "DOCUMENT_NODE"; | ||
| NodeType[NodeType["DOCUMENT_TYPE_NODE"] = 10] = "DOCUMENT_TYPE_NODE"; | ||
| NodeType[NodeType["DOCUMENT_FRAGMENT_NODE"] = 11] = "DOCUMENT_FRAGMENT_NODE"; | ||
| })(NodeType || (NodeType = {})); | ||
| const nwsapi = require('nwsapi'); | ||
| const cssom = require('cssom'); | ||
| const cssstyle = require('cssstyle'); | ||
| class RRNode extends BaseRRNode { | ||
| } | ||
| class RRWindow { | ||
| constructor() { | ||
| this.scrollLeft = 0; | ||
| this.scrollTop = 0; | ||
| } | ||
| scrollTo(options) { | ||
| if (!options) | ||
| return; | ||
| if (typeof options.left === 'number') | ||
| this.scrollLeft = options.left; | ||
| if (typeof options.top === 'number') | ||
| this.scrollTop = options.top; | ||
| } | ||
| } | ||
| class RRDocument extends BaseRRDocumentImpl(RRNode) { | ||
| constructor() { | ||
| super(...arguments); | ||
| this.nodeName = '#document'; | ||
| } | ||
| get nwsapi() { | ||
| if (!this._nwsapi) { | ||
| this._nwsapi = nwsapi({ | ||
| document: this, | ||
| DOMException: null, | ||
| }); | ||
| this._nwsapi.configure({ | ||
| LOGERRORS: false, | ||
| IDS_DUPES: true, | ||
| MIXEDCASE: true, | ||
| }); | ||
| } | ||
| return this._nwsapi; | ||
| } | ||
| get documentElement() { | ||
| return super.documentElement; | ||
| } | ||
| get body() { | ||
| return super.body; | ||
| } | ||
| get head() { | ||
| return super.head; | ||
| } | ||
| get implementation() { | ||
| return this; | ||
| } | ||
| get firstElementChild() { | ||
| return this.documentElement; | ||
| } | ||
| appendChild(childNode) { | ||
| return super.appendChild(childNode); | ||
| } | ||
| insertBefore(newChild, refChild) { | ||
| return super.insertBefore(newChild, refChild); | ||
| } | ||
| querySelectorAll(selectors) { | ||
| return this.nwsapi.select(selectors); | ||
| } | ||
| getElementsByTagName(tagName) { | ||
| if (this.documentElement) | ||
| return this.documentElement.getElementsByTagName(tagName); | ||
| return []; | ||
| } | ||
| getElementsByClassName(className) { | ||
| if (this.documentElement) | ||
| return this.documentElement.getElementsByClassName(className); | ||
| return []; | ||
| } | ||
| getElementById(elementId) { | ||
| if (this.documentElement) | ||
| return this.documentElement.getElementById(elementId); | ||
| return null; | ||
| } | ||
| createDocument(_namespace, _qualifiedName, _doctype) { | ||
| return new RRDocument(); | ||
| } | ||
| createDocumentType(qualifiedName, publicId, systemId) { | ||
| const documentTypeNode = new RRDocumentType(qualifiedName, publicId, systemId); | ||
| documentTypeNode.ownerDocument = this; | ||
| return documentTypeNode; | ||
| } | ||
| createElement(tagName) { | ||
| const upperTagName = tagName.toUpperCase(); | ||
| let element; | ||
| switch (upperTagName) { | ||
| case 'AUDIO': | ||
| case 'VIDEO': | ||
| element = new RRMediaElement(upperTagName); | ||
| break; | ||
| case 'IFRAME': | ||
| element = new RRIFrameElement(upperTagName); | ||
| break; | ||
| case 'IMG': | ||
| element = new RRImageElement(upperTagName); | ||
| break; | ||
| case 'CANVAS': | ||
| element = new RRCanvasElement(upperTagName); | ||
| break; | ||
| case 'STYLE': | ||
| element = new RRStyleElement(upperTagName); | ||
| break; | ||
| default: | ||
| element = new RRElement(upperTagName); | ||
| break; | ||
| } | ||
| element.ownerDocument = this; | ||
| return element; | ||
| } | ||
| createElementNS(_namespaceURI, qualifiedName) { | ||
| return this.createElement(qualifiedName); | ||
| } | ||
| createComment(data) { | ||
| const commentNode = new RRComment(data); | ||
| commentNode.ownerDocument = this; | ||
| return commentNode; | ||
| } | ||
| createCDATASection(data) { | ||
| const sectionNode = new RRCDATASection(data); | ||
| sectionNode.ownerDocument = this; | ||
| return sectionNode; | ||
| } | ||
| createTextNode(data) { | ||
| const textNode = new RRText(data); | ||
| textNode.ownerDocument = this; | ||
| return textNode; | ||
| } | ||
| } | ||
| class RRDocumentType extends BaseRRDocumentTypeImpl(RRNode) { | ||
| } | ||
| class RRElement extends BaseRRElementImpl(RRNode) { | ||
| constructor(tagName) { | ||
| super(tagName); | ||
| this._style = new cssstyle.CSSStyleDeclaration(); | ||
| const style = this._style; | ||
| Object.defineProperty(this.attributes, 'style', { | ||
| get() { | ||
| return style.cssText; | ||
| }, | ||
| set(cssText) { | ||
| style.cssText = cssText; | ||
| }, | ||
| }); | ||
| } | ||
| get style() { | ||
| return this._style; | ||
| } | ||
| attachShadow(_init) { | ||
| return super.attachShadow(_init); | ||
| } | ||
| appendChild(newChild) { | ||
| return super.appendChild(newChild); | ||
| } | ||
| insertBefore(newChild, refChild) { | ||
| return super.insertBefore(newChild, refChild); | ||
| } | ||
| getAttribute(name) { | ||
| const upperName = name && name.toLowerCase(); | ||
| if (upperName in this.attributes) | ||
| return this.attributes[upperName]; | ||
| return null; | ||
| } | ||
| setAttribute(name, attribute) { | ||
| this.attributes[name.toLowerCase()] = attribute; | ||
| } | ||
| removeAttribute(name) { | ||
| delete this.attributes[name.toLowerCase()]; | ||
| } | ||
| get firstElementChild() { | ||
| for (const child of this.childNodes) | ||
| if (child.RRNodeType === NodeType$2.Element) | ||
| return child; | ||
| return null; | ||
| } | ||
| get nextElementSibling() { | ||
| const parentNode = this.parentNode; | ||
| if (!parentNode) | ||
| return null; | ||
| const siblings = parentNode.childNodes; | ||
| const index = siblings.indexOf(this); | ||
| for (let i = index + 1; i < siblings.length; i++) | ||
| if (siblings[i] instanceof RRElement) | ||
| return siblings[i]; | ||
| return null; | ||
| } | ||
| querySelectorAll(selectors) { | ||
| const result = []; | ||
| if (this.ownerDocument !== null) { | ||
| this.ownerDocument.nwsapi.select(selectors, this, (element) => { | ||
| if (element !== this) | ||
| result.push(element); | ||
| }); | ||
| } | ||
| return result; | ||
| } | ||
| getElementById(elementId) { | ||
| if (this.id === elementId) | ||
| return this; | ||
| for (const child of this.childNodes) { | ||
| if (child instanceof RRElement) { | ||
| const result = child.getElementById(elementId); | ||
| if (result !== null) | ||
| return result; | ||
| } | ||
| } | ||
| return null; | ||
| } | ||
| getElementsByClassName(className) { | ||
| let elements = []; | ||
| const queryClassList = new ClassList(className); | ||
| if (this instanceof RRElement && | ||
| queryClassList.classes.filter((queriedClassName) => this.classList.classes.some((name) => name === queriedClassName)).length == queryClassList.classes.length) | ||
| elements.push(this); | ||
| for (const child of this.childNodes) { | ||
| if (child instanceof RRElement) | ||
| elements = elements.concat(child.getElementsByClassName(className)); | ||
| } | ||
| return elements; | ||
| } | ||
| getElementsByTagName(tagName) { | ||
| let elements = []; | ||
| const normalizedTagName = tagName.toUpperCase(); | ||
| if (this instanceof RRElement && this.tagName === normalizedTagName) | ||
| elements.push(this); | ||
| for (const child of this.childNodes) { | ||
| if (child instanceof RRElement) | ||
| elements = elements.concat(child.getElementsByTagName(tagName)); | ||
| } | ||
| return elements; | ||
| } | ||
| } | ||
| class RRImageElement extends RRElement { | ||
| } | ||
| class RRMediaElement extends BaseRRMediaElementImpl(RRElement) { | ||
| } | ||
| class RRCanvasElement extends RRElement { | ||
| getContext() { | ||
| return null; | ||
| } | ||
| } | ||
| class RRStyleElement extends RRElement { | ||
| constructor() { | ||
| super(...arguments); | ||
| this._sheet = null; | ||
| } | ||
| get sheet() { | ||
| if (!this._sheet) { | ||
| let result = ''; | ||
| for (const child of this.childNodes) | ||
| if (child.RRNodeType === NodeType$2.Text) | ||
| result += child.textContent; | ||
| this._sheet = cssom.parse(result); | ||
| } | ||
| return this._sheet; | ||
| } | ||
| } | ||
| class RRIFrameElement extends RRElement { | ||
| constructor(tagName) { | ||
| super(tagName); | ||
| this.width = ''; | ||
| this.height = ''; | ||
| this.src = ''; | ||
| this.contentDocument = new RRDocument(); | ||
| this.contentWindow = new RRWindow(); | ||
| const htmlElement = this.contentDocument.createElement('HTML'); | ||
| this.contentDocument.appendChild(htmlElement); | ||
| htmlElement.appendChild(this.contentDocument.createElement('HEAD')); | ||
| htmlElement.appendChild(this.contentDocument.createElement('BODY')); | ||
| } | ||
| } | ||
| class RRText extends BaseRRTextImpl(RRNode) { | ||
| constructor() { | ||
| super(...arguments); | ||
| this.nodeName = '#text'; | ||
| } | ||
| } | ||
| class RRComment extends BaseRRCommentImpl(RRNode) { | ||
| constructor() { | ||
| super(...arguments); | ||
| this.nodeName = '#comment'; | ||
| } | ||
| } | ||
| class RRCDATASection extends BaseRRCDATASectionImpl(RRNode) { | ||
| constructor() { | ||
| super(...arguments); | ||
| this.nodeName = '#cdata-section'; | ||
| } | ||
| } | ||
| exports.RRCDATASection = RRCDATASection; | ||
| exports.RRCanvasElement = RRCanvasElement; | ||
| exports.RRComment = RRComment; | ||
| exports.RRDocument = RRDocument; | ||
| exports.RRDocumentType = RRDocumentType; | ||
| exports.RRElement = RRElement; | ||
| exports.RRIFrameElement = RRIFrameElement; | ||
| exports.RRImageElement = RRImageElement; | ||
| exports.RRMediaElement = RRMediaElement; | ||
| exports.RRNode = RRNode; | ||
| exports.RRStyleElement = RRStyleElement; | ||
| exports.RRText = RRText; | ||
| exports.RRWindow = RRWindow; |
| import { NodeType as RRNodeType } from 'rrweb-snapshot'; | ||
| import type { NWSAPI } from 'nwsapi'; | ||
| import { BaseRRNode, ClassList, IRRDocument, CSSStyleDeclaration } from 'rrdom'; | ||
| export declare class RRNode extends BaseRRNode { | ||
| } | ||
| export declare class RRWindow { | ||
| scrollLeft: number; | ||
| scrollTop: number; | ||
| scrollTo(options?: ScrollToOptions): void; | ||
| } | ||
| declare const RRDocument_base: (new (...args: any[]) => { | ||
| readonly nodeType: number; | ||
| readonly nodeName: "#document"; | ||
| readonly compatMode: "BackCompat" | "CSS1Compat"; | ||
| readonly RRNodeType: RRNodeType.Document; | ||
| readonly documentElement: import("rrdom").IRRElement | null; | ||
| readonly body: import("rrdom").IRRElement | null; | ||
| readonly head: import("rrdom").IRRElement | null; | ||
| readonly implementation: IRRDocument; | ||
| readonly firstElementChild: import("rrdom").IRRElement | null; | ||
| appendChild(newChild: import("rrdom").IRRNode): import("rrdom").IRRNode; | ||
| insertBefore(newChild: import("rrdom").IRRNode, refChild: import("rrdom").IRRNode | null): import("rrdom").IRRNode; | ||
| removeChild(node: import("rrdom").IRRNode): import("rrdom").IRRNode; | ||
| open(): void; | ||
| close(): void; | ||
| write(content: string): void; | ||
| createDocument(_namespace: string | null, _qualifiedName: string | null, _doctype?: DocumentType | null | undefined): IRRDocument; | ||
| createDocumentType(qualifiedName: string, publicId: string, systemId: string): import("rrdom").IRRDocumentType; | ||
| createElement(tagName: string): import("rrdom").IRRElement; | ||
| createElementNS(_namespaceURI: string, qualifiedName: string): import("rrdom").IRRElement; | ||
| createTextNode(data: string): import("rrdom").IRRText; | ||
| createComment(data: string): import("rrdom").IRRComment; | ||
| createCDATASection(data: string): import("rrdom").IRRCDATASection; | ||
| toString(): string; | ||
| parentElement: import("rrdom").IRRNode | null; | ||
| parentNode: import("rrdom").IRRNode | null; | ||
| ownerDocument: IRRDocument; | ||
| readonly childNodes: import("rrdom").IRRNode[]; | ||
| readonly ELEMENT_NODE: number; | ||
| readonly TEXT_NODE: number; | ||
| firstChild: import("rrdom").IRRNode | null; | ||
| lastChild: import("rrdom").IRRNode | null; | ||
| previousSibling: import("rrdom").IRRNode | null; | ||
| nextSibling: import("rrdom").IRRNode | null; | ||
| textContent: string | null; | ||
| contains(node: import("rrdom").IRRNode): boolean; | ||
| }) & typeof RRNode; | ||
| export declare class RRDocument extends RRDocument_base implements IRRDocument { | ||
| readonly nodeName: '#document'; | ||
| private _nwsapi; | ||
| get nwsapi(): NWSAPI; | ||
| get documentElement(): RRElement | null; | ||
| get body(): RRElement | null; | ||
| get head(): RRElement | null; | ||
| get implementation(): RRDocument; | ||
| get firstElementChild(): RRElement | null; | ||
| appendChild(childNode: RRNode): import("rrdom").IRRNode; | ||
| insertBefore(newChild: RRNode, refChild: RRNode | null): import("rrdom").IRRNode; | ||
| querySelectorAll(selectors: string): RRNode[]; | ||
| getElementsByTagName(tagName: string): RRElement[]; | ||
| getElementsByClassName(className: string): RRElement[]; | ||
| getElementById(elementId: string): RRElement | null; | ||
| createDocument(_namespace: string | null, _qualifiedName: string | null, _doctype?: DocumentType | null): RRDocument; | ||
| createDocumentType(qualifiedName: string, publicId: string, systemId: string): RRDocumentType; | ||
| createElement<K extends keyof HTMLElementTagNameMap>(tagName: K): RRElementType<K>; | ||
| createElement(tagName: string): RRElement; | ||
| createElementNS(_namespaceURI: string, qualifiedName: string): RRElement | RRMediaElement | RRCanvasElement | RRIFrameElement | RRImageElement | RRStyleElement; | ||
| createComment(data: string): RRComment; | ||
| createCDATASection(data: string): RRCDATASection; | ||
| createTextNode(data: string): RRText; | ||
| } | ||
| declare const RRDocumentType_base: (new (qualifiedName: string, publicId: string, systemId: string) => { | ||
| readonly nodeType: number; | ||
| readonly RRNodeType: RRNodeType.DocumentType; | ||
| readonly nodeName: string; | ||
| readonly name: string; | ||
| readonly publicId: string; | ||
| readonly systemId: string; | ||
| toString(): string; | ||
| parentElement: import("rrdom").IRRNode | null; | ||
| parentNode: import("rrdom").IRRNode | null; | ||
| ownerDocument: IRRDocument; | ||
| readonly childNodes: import("rrdom").IRRNode[]; | ||
| readonly ELEMENT_NODE: number; | ||
| readonly TEXT_NODE: number; | ||
| firstChild: import("rrdom").IRRNode | null; | ||
| lastChild: import("rrdom").IRRNode | null; | ||
| previousSibling: import("rrdom").IRRNode | null; | ||
| nextSibling: import("rrdom").IRRNode | null; | ||
| textContent: string | null; | ||
| contains(node: import("rrdom").IRRNode): boolean; | ||
| appendChild(newChild: import("rrdom").IRRNode): import("rrdom").IRRNode; | ||
| insertBefore(newChild: import("rrdom").IRRNode, refChild: import("rrdom").IRRNode | null): import("rrdom").IRRNode; | ||
| removeChild(node: import("rrdom").IRRNode): import("rrdom").IRRNode; | ||
| }) & typeof RRNode; | ||
| export declare class RRDocumentType extends RRDocumentType_base { | ||
| } | ||
| declare const RRElement_base: (new (tagName: string) => { | ||
| readonly nodeType: number; | ||
| readonly RRNodeType: RRNodeType.Element; | ||
| readonly nodeName: string; | ||
| tagName: string; | ||
| attributes: Record<string, string>; | ||
| shadowRoot: import("rrdom").IRRElement | null; | ||
| scrollLeft?: number | undefined; | ||
| scrollTop?: number | undefined; | ||
| textContent: string; | ||
| readonly classList: ClassList; | ||
| readonly id: string; | ||
| readonly className: string; | ||
| readonly style: CSSStyleDeclaration; | ||
| getAttribute(name: string): string | null; | ||
| setAttribute(name: string, attribute: string): void; | ||
| setAttributeNS(_namespace: string | null, qualifiedName: string, value: string): void; | ||
| removeAttribute(name: string): void; | ||
| appendChild(newChild: import("rrdom").IRRNode): import("rrdom").IRRNode; | ||
| insertBefore(newChild: import("rrdom").IRRNode, refChild: import("rrdom").IRRNode | null): import("rrdom").IRRNode; | ||
| removeChild(node: import("rrdom").IRRNode): import("rrdom").IRRNode; | ||
| attachShadow(_init: ShadowRootInit): import("rrdom").IRRElement; | ||
| dispatchEvent(_event: Event): boolean; | ||
| toString(): string; | ||
| parentElement: import("rrdom").IRRNode | null; | ||
| parentNode: import("rrdom").IRRNode | null; | ||
| ownerDocument: IRRDocument; | ||
| readonly childNodes: import("rrdom").IRRNode[]; | ||
| readonly ELEMENT_NODE: number; | ||
| readonly TEXT_NODE: number; | ||
| firstChild: import("rrdom").IRRNode | null; | ||
| lastChild: import("rrdom").IRRNode | null; | ||
| previousSibling: import("rrdom").IRRNode | null; | ||
| nextSibling: import("rrdom").IRRNode | null; | ||
| contains(node: import("rrdom").IRRNode): boolean; | ||
| }) & typeof RRNode; | ||
| export declare class RRElement extends RRElement_base { | ||
| private _style; | ||
| constructor(tagName: string); | ||
| get style(): CSSStyleDeclaration; | ||
| attachShadow(_init: ShadowRootInit): RRElement; | ||
| appendChild(newChild: RRNode): RRNode; | ||
| insertBefore(newChild: RRNode, refChild: RRNode | null): RRNode; | ||
| getAttribute(name: string): string | null; | ||
| setAttribute(name: string, attribute: string): void; | ||
| removeAttribute(name: string): void; | ||
| get firstElementChild(): RRElement | null; | ||
| get nextElementSibling(): RRElement | null; | ||
| querySelectorAll(selectors: string): RRNode[]; | ||
| getElementById(elementId: string): RRElement | null; | ||
| getElementsByClassName(className: string): RRElement[]; | ||
| getElementsByTagName(tagName: string): RRElement[]; | ||
| } | ||
| export declare class RRImageElement extends RRElement { | ||
| src: string; | ||
| width: number; | ||
| height: number; | ||
| onload: ((this: GlobalEventHandlers, ev: Event) => unknown) | null; | ||
| } | ||
| declare const RRMediaElement_base: (new (...args: any[]) => { | ||
| currentTime?: number | undefined; | ||
| volume?: number | undefined; | ||
| paused?: boolean | undefined; | ||
| muted?: boolean | undefined; | ||
| playbackRate?: number | undefined; | ||
| loop?: boolean | undefined; | ||
| attachShadow(_init: ShadowRootInit): import("rrdom").IRRElement; | ||
| play(): void; | ||
| pause(): void; | ||
| tagName: string; | ||
| attributes: Record<string, string>; | ||
| shadowRoot: import("rrdom").IRRElement | null; | ||
| scrollLeft?: number | undefined; | ||
| scrollTop?: number | undefined; | ||
| id: string; | ||
| className: string; | ||
| classList: ClassList; | ||
| style: CSSStyleDeclaration; | ||
| getAttribute(name: string): string | null; | ||
| setAttribute(name: string, attribute: string): void; | ||
| setAttributeNS(namespace: string | null, qualifiedName: string, value: string): void; | ||
| removeAttribute(name: string): void; | ||
| dispatchEvent(event: Event): boolean; | ||
| parentElement: import("rrdom").IRRNode | null; | ||
| parentNode: import("rrdom").IRRNode | null; | ||
| ownerDocument: IRRDocument; | ||
| readonly childNodes: import("rrdom").IRRNode[]; | ||
| readonly ELEMENT_NODE: number; | ||
| readonly TEXT_NODE: number; | ||
| readonly nodeType: number; | ||
| readonly nodeName: string; | ||
| readonly RRNodeType: RRNodeType; | ||
| firstChild: import("rrdom").IRRNode | null; | ||
| lastChild: import("rrdom").IRRNode | null; | ||
| previousSibling: import("rrdom").IRRNode | null; | ||
| nextSibling: import("rrdom").IRRNode | null; | ||
| textContent: string | null; | ||
| contains(node: import("rrdom").IRRNode): boolean; | ||
| appendChild(newChild: import("rrdom").IRRNode): import("rrdom").IRRNode; | ||
| insertBefore(newChild: import("rrdom").IRRNode, refChild: import("rrdom").IRRNode | null): import("rrdom").IRRNode; | ||
| removeChild(node: import("rrdom").IRRNode): import("rrdom").IRRNode; | ||
| toString(): string; | ||
| }) & typeof RRElement; | ||
| export declare class RRMediaElement extends RRMediaElement_base { | ||
| } | ||
| export declare class RRCanvasElement extends RRElement { | ||
| getContext(): CanvasRenderingContext2D | null; | ||
| } | ||
| export declare class RRStyleElement extends RRElement { | ||
| private _sheet; | ||
| get sheet(): CSSStyleSheet | null; | ||
| } | ||
| export declare class RRIFrameElement extends RRElement { | ||
| width: string; | ||
| height: string; | ||
| src: string; | ||
| contentDocument: RRDocument; | ||
| contentWindow: RRWindow; | ||
| constructor(tagName: string); | ||
| } | ||
| declare const RRText_base: (new (data: string) => { | ||
| readonly nodeType: number; | ||
| readonly nodeName: "#text"; | ||
| readonly RRNodeType: RRNodeType.Text; | ||
| data: string; | ||
| textContent: string; | ||
| toString(): string; | ||
| parentElement: import("rrdom").IRRNode | null; | ||
| parentNode: import("rrdom").IRRNode | null; | ||
| ownerDocument: IRRDocument; | ||
| readonly childNodes: import("rrdom").IRRNode[]; | ||
| readonly ELEMENT_NODE: number; | ||
| readonly TEXT_NODE: number; | ||
| firstChild: import("rrdom").IRRNode | null; | ||
| lastChild: import("rrdom").IRRNode | null; | ||
| previousSibling: import("rrdom").IRRNode | null; | ||
| nextSibling: import("rrdom").IRRNode | null; | ||
| contains(node: import("rrdom").IRRNode): boolean; | ||
| appendChild(newChild: import("rrdom").IRRNode): import("rrdom").IRRNode; | ||
| insertBefore(newChild: import("rrdom").IRRNode, refChild: import("rrdom").IRRNode | null): import("rrdom").IRRNode; | ||
| removeChild(node: import("rrdom").IRRNode): import("rrdom").IRRNode; | ||
| }) & typeof RRNode; | ||
| export declare class RRText extends RRText_base { | ||
| readonly nodeName: '#text'; | ||
| } | ||
| declare const RRComment_base: (new (data: string) => { | ||
| readonly nodeType: number; | ||
| readonly nodeName: "#comment"; | ||
| readonly RRNodeType: RRNodeType.Comment; | ||
| data: string; | ||
| textContent: string; | ||
| toString(): string; | ||
| parentElement: import("rrdom").IRRNode | null; | ||
| parentNode: import("rrdom").IRRNode | null; | ||
| ownerDocument: IRRDocument; | ||
| readonly childNodes: import("rrdom").IRRNode[]; | ||
| readonly ELEMENT_NODE: number; | ||
| readonly TEXT_NODE: number; | ||
| firstChild: import("rrdom").IRRNode | null; | ||
| lastChild: import("rrdom").IRRNode | null; | ||
| previousSibling: import("rrdom").IRRNode | null; | ||
| nextSibling: import("rrdom").IRRNode | null; | ||
| contains(node: import("rrdom").IRRNode): boolean; | ||
| appendChild(newChild: import("rrdom").IRRNode): import("rrdom").IRRNode; | ||
| insertBefore(newChild: import("rrdom").IRRNode, refChild: import("rrdom").IRRNode | null): import("rrdom").IRRNode; | ||
| removeChild(node: import("rrdom").IRRNode): import("rrdom").IRRNode; | ||
| }) & typeof RRNode; | ||
| export declare class RRComment extends RRComment_base { | ||
| readonly nodeName: '#comment'; | ||
| } | ||
| declare const RRCDATASection_base: (new (data: string) => { | ||
| readonly nodeName: "#cdata-section"; | ||
| readonly nodeType: number; | ||
| readonly RRNodeType: RRNodeType.CDATA; | ||
| data: string; | ||
| textContent: string; | ||
| toString(): string; | ||
| parentElement: import("rrdom").IRRNode | null; | ||
| parentNode: import("rrdom").IRRNode | null; | ||
| ownerDocument: IRRDocument; | ||
| readonly childNodes: import("rrdom").IRRNode[]; | ||
| readonly ELEMENT_NODE: number; | ||
| readonly TEXT_NODE: number; | ||
| firstChild: import("rrdom").IRRNode | null; | ||
| lastChild: import("rrdom").IRRNode | null; | ||
| previousSibling: import("rrdom").IRRNode | null; | ||
| nextSibling: import("rrdom").IRRNode | null; | ||
| contains(node: import("rrdom").IRRNode): boolean; | ||
| appendChild(newChild: import("rrdom").IRRNode): import("rrdom").IRRNode; | ||
| insertBefore(newChild: import("rrdom").IRRNode, refChild: import("rrdom").IRRNode | null): import("rrdom").IRRNode; | ||
| removeChild(node: import("rrdom").IRRNode): import("rrdom").IRRNode; | ||
| }) & typeof RRNode; | ||
| export declare class RRCDATASection extends RRCDATASection_base { | ||
| readonly nodeName: '#cdata-section'; | ||
| } | ||
| interface RRElementTagNameMap { | ||
| audio: RRMediaElement; | ||
| canvas: RRCanvasElement; | ||
| iframe: RRIFrameElement; | ||
| img: RRImageElement; | ||
| style: RRStyleElement; | ||
| video: RRMediaElement; | ||
| } | ||
| type RRElementType<K extends keyof HTMLElementTagNameMap> = K extends keyof RRElementTagNameMap ? RRElementTagNameMap[K] : RRElement; | ||
| export {}; |
| export * from './document-nodejs'; |
| export declare function polyfillPerformance(): void; | ||
| export declare function polyfillRAF(): void; | ||
| export declare function polyfillEvent(): void; | ||
| export declare function polyfillNode(): void; | ||
| export declare function polyfillDocument(): void; |
| 'use strict'; | ||
| Object.defineProperty(exports, '__esModule', { value: true }); | ||
| var NodeType$2; | ||
| (function (NodeType) { | ||
| NodeType[NodeType["Document"] = 0] = "Document"; | ||
| NodeType[NodeType["DocumentType"] = 1] = "DocumentType"; | ||
| NodeType[NodeType["Element"] = 2] = "Element"; | ||
| NodeType[NodeType["Text"] = 3] = "Text"; | ||
| NodeType[NodeType["CDATA"] = 4] = "CDATA"; | ||
| NodeType[NodeType["Comment"] = 5] = "Comment"; | ||
| })(NodeType$2 || (NodeType$2 = {})); | ||
| var NodeType$1; | ||
| (function (NodeType) { | ||
| NodeType[NodeType["Document"] = 0] = "Document"; | ||
| NodeType[NodeType["DocumentType"] = 1] = "DocumentType"; | ||
| NodeType[NodeType["Element"] = 2] = "Element"; | ||
| NodeType[NodeType["Text"] = 3] = "Text"; | ||
| NodeType[NodeType["CDATA"] = 4] = "CDATA"; | ||
| NodeType[NodeType["Comment"] = 5] = "Comment"; | ||
| })(NodeType$1 || (NodeType$1 = {})); | ||
| function parseCSSText(cssText) { | ||
| const res = {}; | ||
| const listDelimiter = /;(?![^(]*\))/g; | ||
| const propertyDelimiter = /:(.+)/; | ||
| const comment = /\/\*.*?\*\//g; | ||
| cssText | ||
| .replace(comment, '') | ||
| .split(listDelimiter) | ||
| .forEach(function (item) { | ||
| if (item) { | ||
| const tmp = item.split(propertyDelimiter); | ||
| tmp.length > 1 && (res[camelize(tmp[0].trim())] = tmp[1].trim()); | ||
| } | ||
| }); | ||
| return res; | ||
| } | ||
| function toCSSText(style) { | ||
| const properties = []; | ||
| for (const name in style) { | ||
| const value = style[name]; | ||
| if (typeof value !== 'string') | ||
| continue; | ||
| const normalizedName = hyphenate(name); | ||
| properties.push(`${normalizedName}: ${value};`); | ||
| } | ||
| return properties.join(' '); | ||
| } | ||
| const camelizeRE = /-([a-z])/g; | ||
| const CUSTOM_PROPERTY_REGEX = /^--[a-zA-Z0-9-]+$/; | ||
| const camelize = (str) => { | ||
| if (CUSTOM_PROPERTY_REGEX.test(str)) | ||
| return str; | ||
| return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : '')); | ||
| }; | ||
| const hyphenateRE = /\B([A-Z])/g; | ||
| const hyphenate = (str) => { | ||
| return str.replace(hyphenateRE, '-$1').toLowerCase(); | ||
| }; | ||
| class BaseRRNode { | ||
| constructor(..._args) { | ||
| this.parentElement = null; | ||
| this.parentNode = null; | ||
| this.firstChild = null; | ||
| this.lastChild = null; | ||
| this.previousSibling = null; | ||
| this.nextSibling = null; | ||
| this.ELEMENT_NODE = NodeType.ELEMENT_NODE; | ||
| this.TEXT_NODE = NodeType.TEXT_NODE; | ||
| } | ||
| get childNodes() { | ||
| const childNodes = []; | ||
| let childIterator = this.firstChild; | ||
| while (childIterator) { | ||
| childNodes.push(childIterator); | ||
| childIterator = childIterator.nextSibling; | ||
| } | ||
| return childNodes; | ||
| } | ||
| contains(node) { | ||
| if (!(node instanceof BaseRRNode)) | ||
| return false; | ||
| else if (node.ownerDocument !== this.ownerDocument) | ||
| return false; | ||
| else if (node === this) | ||
| return true; | ||
| while (node.parentNode) { | ||
| if (node.parentNode === this) | ||
| return true; | ||
| node = node.parentNode; | ||
| } | ||
| return false; | ||
| } | ||
| appendChild(_newChild) { | ||
| throw new Error(`RRDomException: Failed to execute 'appendChild' on 'RRNode': This RRNode type does not support this method.`); | ||
| } | ||
| insertBefore(_newChild, _refChild) { | ||
| throw new Error(`RRDomException: Failed to execute 'insertBefore' on 'RRNode': This RRNode type does not support this method.`); | ||
| } | ||
| removeChild(_node) { | ||
| throw new Error(`RRDomException: Failed to execute 'removeChild' on 'RRNode': This RRNode type does not support this method.`); | ||
| } | ||
| toString() { | ||
| return 'RRNode'; | ||
| } | ||
| } | ||
| function BaseRRDocumentImpl(RRNodeClass) { | ||
| return class BaseRRDocument extends RRNodeClass { | ||
| constructor(...args) { | ||
| super(args); | ||
| this.nodeType = NodeType.DOCUMENT_NODE; | ||
| this.nodeName = '#document'; | ||
| this.compatMode = 'CSS1Compat'; | ||
| this.RRNodeType = NodeType$1.Document; | ||
| this.textContent = null; | ||
| this.ownerDocument = this; | ||
| } | ||
| get documentElement() { | ||
| return (this.childNodes.find((node) => node.RRNodeType === NodeType$1.Element && | ||
| node.tagName === 'HTML') || null); | ||
| } | ||
| get body() { | ||
| var _a; | ||
| return (((_a = this.documentElement) === null || _a === void 0 ? void 0 : _a.childNodes.find((node) => node.RRNodeType === NodeType$1.Element && | ||
| node.tagName === 'BODY')) || null); | ||
| } | ||
| get head() { | ||
| var _a; | ||
| return (((_a = this.documentElement) === null || _a === void 0 ? void 0 : _a.childNodes.find((node) => node.RRNodeType === NodeType$1.Element && | ||
| node.tagName === 'HEAD')) || null); | ||
| } | ||
| get implementation() { | ||
| return this; | ||
| } | ||
| get firstElementChild() { | ||
| return this.documentElement; | ||
| } | ||
| appendChild(newChild) { | ||
| const nodeType = newChild.RRNodeType; | ||
| if (nodeType === NodeType$1.Element || | ||
| nodeType === NodeType$1.DocumentType) { | ||
| if (this.childNodes.some((s) => s.RRNodeType === nodeType)) { | ||
| throw new Error(`RRDomException: Failed to execute 'appendChild' on 'RRNode': Only one ${nodeType === NodeType$1.Element ? 'RRElement' : 'RRDoctype'} on RRDocument allowed.`); | ||
| } | ||
| } | ||
| const child = appendChild(this, newChild); | ||
| child.parentElement = null; | ||
| return child; | ||
| } | ||
| insertBefore(newChild, refChild) { | ||
| const nodeType = newChild.RRNodeType; | ||
| if (nodeType === NodeType$1.Element || | ||
| nodeType === NodeType$1.DocumentType) { | ||
| if (this.childNodes.some((s) => s.RRNodeType === nodeType)) { | ||
| throw new Error(`RRDomException: Failed to execute 'insertBefore' on 'RRNode': Only one ${nodeType === NodeType$1.Element ? 'RRElement' : 'RRDoctype'} on RRDocument allowed.`); | ||
| } | ||
| } | ||
| const child = insertBefore(this, newChild, refChild); | ||
| child.parentElement = null; | ||
| return child; | ||
| } | ||
| removeChild(node) { | ||
| return removeChild(this, node); | ||
| } | ||
| open() { | ||
| this.firstChild = null; | ||
| this.lastChild = null; | ||
| } | ||
| close() { | ||
| } | ||
| write(content) { | ||
| let publicId; | ||
| if (content === | ||
| '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">') | ||
| publicId = '-//W3C//DTD XHTML 1.0 Transitional//EN'; | ||
| else if (content === | ||
| '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "">') | ||
| publicId = '-//W3C//DTD HTML 4.0 Transitional//EN'; | ||
| if (publicId) { | ||
| const doctype = this.createDocumentType('html', publicId, ''); | ||
| this.open(); | ||
| this.appendChild(doctype); | ||
| } | ||
| } | ||
| createDocument(_namespace, _qualifiedName, _doctype) { | ||
| return new BaseRRDocument(); | ||
| } | ||
| createDocumentType(qualifiedName, publicId, systemId) { | ||
| const doctype = new (BaseRRDocumentTypeImpl(BaseRRNode))(qualifiedName, publicId, systemId); | ||
| doctype.ownerDocument = this; | ||
| return doctype; | ||
| } | ||
| createElement(tagName) { | ||
| const element = new (BaseRRElementImpl(BaseRRNode))(tagName); | ||
| element.ownerDocument = this; | ||
| return element; | ||
| } | ||
| createElementNS(_namespaceURI, qualifiedName) { | ||
| return this.createElement(qualifiedName); | ||
| } | ||
| createTextNode(data) { | ||
| const text = new (BaseRRTextImpl(BaseRRNode))(data); | ||
| text.ownerDocument = this; | ||
| return text; | ||
| } | ||
| createComment(data) { | ||
| const comment = new (BaseRRCommentImpl(BaseRRNode))(data); | ||
| comment.ownerDocument = this; | ||
| return comment; | ||
| } | ||
| createCDATASection(data) { | ||
| const CDATASection = new (BaseRRCDATASectionImpl(BaseRRNode))(data); | ||
| CDATASection.ownerDocument = this; | ||
| return CDATASection; | ||
| } | ||
| toString() { | ||
| return 'RRDocument'; | ||
| } | ||
| }; | ||
| } | ||
| function BaseRRDocumentTypeImpl(RRNodeClass) { | ||
| return class BaseRRDocumentType extends RRNodeClass { | ||
| constructor(qualifiedName, publicId, systemId) { | ||
| super(); | ||
| this.nodeType = NodeType.DOCUMENT_TYPE_NODE; | ||
| this.RRNodeType = NodeType$1.DocumentType; | ||
| this.name = qualifiedName; | ||
| this.publicId = publicId; | ||
| this.systemId = systemId; | ||
| this.nodeName = qualifiedName; | ||
| this.textContent = null; | ||
| } | ||
| toString() { | ||
| return 'RRDocumentType'; | ||
| } | ||
| }; | ||
| } | ||
| function BaseRRElementImpl(RRNodeClass) { | ||
| return class BaseRRElement extends RRNodeClass { | ||
| constructor(tagName) { | ||
| super(); | ||
| this.nodeType = NodeType.ELEMENT_NODE; | ||
| this.RRNodeType = NodeType$1.Element; | ||
| this.attributes = {}; | ||
| this.shadowRoot = null; | ||
| this.tagName = tagName.toUpperCase(); | ||
| this.nodeName = tagName.toUpperCase(); | ||
| } | ||
| get textContent() { | ||
| let result = ''; | ||
| this.childNodes.forEach((node) => (result += node.textContent)); | ||
| return result; | ||
| } | ||
| set textContent(textContent) { | ||
| this.firstChild = null; | ||
| this.lastChild = null; | ||
| this.appendChild(this.ownerDocument.createTextNode(textContent)); | ||
| } | ||
| get classList() { | ||
| return new ClassList(this.attributes.class, (newClassName) => { | ||
| this.attributes.class = newClassName; | ||
| }); | ||
| } | ||
| get id() { | ||
| return this.attributes.id || ''; | ||
| } | ||
| get className() { | ||
| return this.attributes.class || ''; | ||
| } | ||
| get style() { | ||
| const style = (this.attributes.style ? parseCSSText(this.attributes.style) : {}); | ||
| const hyphenateRE = /\B([A-Z])/g; | ||
| style.setProperty = (name, value, priority) => { | ||
| if (hyphenateRE.test(name)) | ||
| return; | ||
| const normalizedName = camelize(name); | ||
| if (!value) | ||
| delete style[normalizedName]; | ||
| else | ||
| style[normalizedName] = value; | ||
| if (priority === 'important') | ||
| style[normalizedName] += ' !important'; | ||
| this.attributes.style = toCSSText(style); | ||
| }; | ||
| style.removeProperty = (name) => { | ||
| if (hyphenateRE.test(name)) | ||
| return ''; | ||
| const normalizedName = camelize(name); | ||
| const value = style[normalizedName] || ''; | ||
| delete style[normalizedName]; | ||
| this.attributes.style = toCSSText(style); | ||
| return value; | ||
| }; | ||
| return style; | ||
| } | ||
| getAttribute(name) { | ||
| return this.attributes[name] || null; | ||
| } | ||
| setAttribute(name, attribute) { | ||
| this.attributes[name] = attribute; | ||
| } | ||
| setAttributeNS(_namespace, qualifiedName, value) { | ||
| this.setAttribute(qualifiedName, value); | ||
| } | ||
| removeAttribute(name) { | ||
| delete this.attributes[name]; | ||
| } | ||
| appendChild(newChild) { | ||
| return appendChild(this, newChild); | ||
| } | ||
| insertBefore(newChild, refChild) { | ||
| return insertBefore(this, newChild, refChild); | ||
| } | ||
| removeChild(node) { | ||
| return removeChild(this, node); | ||
| } | ||
| attachShadow(_init) { | ||
| const shadowRoot = this.ownerDocument.createElement('SHADOWROOT'); | ||
| this.shadowRoot = shadowRoot; | ||
| return shadowRoot; | ||
| } | ||
| dispatchEvent(_event) { | ||
| return true; | ||
| } | ||
| toString() { | ||
| let attributeString = ''; | ||
| for (const attribute in this.attributes) { | ||
| attributeString += `${attribute}="${this.attributes[attribute]}" `; | ||
| } | ||
| return `${this.tagName} ${attributeString}`; | ||
| } | ||
| }; | ||
| } | ||
| function BaseRRMediaElementImpl(RRElementClass) { | ||
| return class BaseRRMediaElement extends RRElementClass { | ||
| attachShadow(_init) { | ||
| throw new Error(`RRDomException: Failed to execute 'attachShadow' on 'RRElement': This RRElement does not support attachShadow`); | ||
| } | ||
| play() { | ||
| this.paused = false; | ||
| } | ||
| pause() { | ||
| this.paused = true; | ||
| } | ||
| }; | ||
| } | ||
| function BaseRRTextImpl(RRNodeClass) { | ||
| return class BaseRRText extends RRNodeClass { | ||
| constructor(data) { | ||
| super(); | ||
| this.nodeType = NodeType.TEXT_NODE; | ||
| this.nodeName = '#text'; | ||
| this.RRNodeType = NodeType$1.Text; | ||
| this.data = data; | ||
| } | ||
| get textContent() { | ||
| return this.data; | ||
| } | ||
| set textContent(textContent) { | ||
| this.data = textContent; | ||
| } | ||
| toString() { | ||
| return `RRText text=${JSON.stringify(this.data)}`; | ||
| } | ||
| }; | ||
| } | ||
| function BaseRRCommentImpl(RRNodeClass) { | ||
| return class BaseRRComment extends RRNodeClass { | ||
| constructor(data) { | ||
| super(); | ||
| this.nodeType = NodeType.COMMENT_NODE; | ||
| this.nodeName = '#comment'; | ||
| this.RRNodeType = NodeType$1.Comment; | ||
| this.data = data; | ||
| } | ||
| get textContent() { | ||
| return this.data; | ||
| } | ||
| set textContent(textContent) { | ||
| this.data = textContent; | ||
| } | ||
| toString() { | ||
| return `RRComment text=${JSON.stringify(this.data)}`; | ||
| } | ||
| }; | ||
| } | ||
| function BaseRRCDATASectionImpl(RRNodeClass) { | ||
| return class BaseRRCDATASection extends RRNodeClass { | ||
| constructor(data) { | ||
| super(); | ||
| this.nodeName = '#cdata-section'; | ||
| this.nodeType = NodeType.CDATA_SECTION_NODE; | ||
| this.RRNodeType = NodeType$1.CDATA; | ||
| this.data = data; | ||
| } | ||
| get textContent() { | ||
| return this.data; | ||
| } | ||
| set textContent(textContent) { | ||
| this.data = textContent; | ||
| } | ||
| toString() { | ||
| return `RRCDATASection data=${JSON.stringify(this.data)}`; | ||
| } | ||
| }; | ||
| } | ||
| class ClassList { | ||
| constructor(classText, onChange) { | ||
| this.classes = []; | ||
| this.add = (...classNames) => { | ||
| for (const item of classNames) { | ||
| const className = String(item); | ||
| if (this.classes.indexOf(className) >= 0) | ||
| continue; | ||
| this.classes.push(className); | ||
| } | ||
| this.onChange && this.onChange(this.classes.join(' ')); | ||
| }; | ||
| this.remove = (...classNames) => { | ||
| this.classes = this.classes.filter((item) => classNames.indexOf(item) === -1); | ||
| this.onChange && this.onChange(this.classes.join(' ')); | ||
| }; | ||
| if (classText) { | ||
| const classes = classText.trim().split(/\s+/); | ||
| this.classes.push(...classes); | ||
| } | ||
| this.onChange = onChange; | ||
| } | ||
| } | ||
| function appendChild(parent, newChild) { | ||
| if (newChild.parentNode) | ||
| newChild.parentNode.removeChild(newChild); | ||
| if (parent.lastChild) { | ||
| parent.lastChild.nextSibling = newChild; | ||
| newChild.previousSibling = parent.lastChild; | ||
| } | ||
| else { | ||
| parent.firstChild = newChild; | ||
| newChild.previousSibling = null; | ||
| } | ||
| parent.lastChild = newChild; | ||
| newChild.nextSibling = null; | ||
| newChild.parentNode = parent; | ||
| newChild.parentElement = parent; | ||
| newChild.ownerDocument = parent.ownerDocument; | ||
| return newChild; | ||
| } | ||
| function insertBefore(parent, newChild, refChild) { | ||
| if (!refChild) | ||
| return appendChild(parent, newChild); | ||
| if (refChild.parentNode !== parent) | ||
| throw new Error("Failed to execute 'insertBefore' on 'RRNode': The RRNode before which the new node is to be inserted is not a child of this RRNode."); | ||
| if (newChild === refChild) | ||
| return newChild; | ||
| if (newChild.parentNode) | ||
| newChild.parentNode.removeChild(newChild); | ||
| newChild.previousSibling = refChild.previousSibling; | ||
| refChild.previousSibling = newChild; | ||
| newChild.nextSibling = refChild; | ||
| if (newChild.previousSibling) | ||
| newChild.previousSibling.nextSibling = newChild; | ||
| else | ||
| parent.firstChild = newChild; | ||
| newChild.parentElement = parent; | ||
| newChild.parentNode = parent; | ||
| newChild.ownerDocument = parent.ownerDocument; | ||
| return newChild; | ||
| } | ||
| function removeChild(parent, child) { | ||
| if (child.parentNode !== parent) | ||
| throw new Error("Failed to execute 'removeChild' on 'RRNode': The RRNode to be removed is not a child of this RRNode."); | ||
| if (child.previousSibling) | ||
| child.previousSibling.nextSibling = child.nextSibling; | ||
| else | ||
| parent.firstChild = child.nextSibling; | ||
| if (child.nextSibling) | ||
| child.nextSibling.previousSibling = child.previousSibling; | ||
| else | ||
| parent.lastChild = child.previousSibling; | ||
| child.previousSibling = null; | ||
| child.nextSibling = null; | ||
| child.parentElement = null; | ||
| child.parentNode = null; | ||
| return child; | ||
| } | ||
| var NodeType; | ||
| (function (NodeType) { | ||
| NodeType[NodeType["PLACEHOLDER"] = 0] = "PLACEHOLDER"; | ||
| NodeType[NodeType["ELEMENT_NODE"] = 1] = "ELEMENT_NODE"; | ||
| NodeType[NodeType["ATTRIBUTE_NODE"] = 2] = "ATTRIBUTE_NODE"; | ||
| NodeType[NodeType["TEXT_NODE"] = 3] = "TEXT_NODE"; | ||
| NodeType[NodeType["CDATA_SECTION_NODE"] = 4] = "CDATA_SECTION_NODE"; | ||
| NodeType[NodeType["ENTITY_REFERENCE_NODE"] = 5] = "ENTITY_REFERENCE_NODE"; | ||
| NodeType[NodeType["ENTITY_NODE"] = 6] = "ENTITY_NODE"; | ||
| NodeType[NodeType["PROCESSING_INSTRUCTION_NODE"] = 7] = "PROCESSING_INSTRUCTION_NODE"; | ||
| NodeType[NodeType["COMMENT_NODE"] = 8] = "COMMENT_NODE"; | ||
| NodeType[NodeType["DOCUMENT_NODE"] = 9] = "DOCUMENT_NODE"; | ||
| NodeType[NodeType["DOCUMENT_TYPE_NODE"] = 10] = "DOCUMENT_TYPE_NODE"; | ||
| NodeType[NodeType["DOCUMENT_FRAGMENT_NODE"] = 11] = "DOCUMENT_FRAGMENT_NODE"; | ||
| })(NodeType || (NodeType = {})); | ||
| const nwsapi = require('nwsapi'); | ||
| const cssom = require('cssom'); | ||
| const cssstyle = require('cssstyle'); | ||
| class RRNode extends BaseRRNode { | ||
| } | ||
| class RRWindow { | ||
| constructor() { | ||
| this.scrollLeft = 0; | ||
| this.scrollTop = 0; | ||
| } | ||
| scrollTo(options) { | ||
| if (!options) | ||
| return; | ||
| if (typeof options.left === 'number') | ||
| this.scrollLeft = options.left; | ||
| if (typeof options.top === 'number') | ||
| this.scrollTop = options.top; | ||
| } | ||
| } | ||
| class RRDocument extends BaseRRDocumentImpl(RRNode) { | ||
| constructor() { | ||
| super(...arguments); | ||
| this.nodeName = '#document'; | ||
| } | ||
| get nwsapi() { | ||
| if (!this._nwsapi) { | ||
| this._nwsapi = nwsapi({ | ||
| document: this, | ||
| DOMException: null, | ||
| }); | ||
| this._nwsapi.configure({ | ||
| LOGERRORS: false, | ||
| IDS_DUPES: true, | ||
| MIXEDCASE: true, | ||
| }); | ||
| } | ||
| return this._nwsapi; | ||
| } | ||
| get documentElement() { | ||
| return super.documentElement; | ||
| } | ||
| get body() { | ||
| return super.body; | ||
| } | ||
| get head() { | ||
| return super.head; | ||
| } | ||
| get implementation() { | ||
| return this; | ||
| } | ||
| get firstElementChild() { | ||
| return this.documentElement; | ||
| } | ||
| appendChild(childNode) { | ||
| return super.appendChild(childNode); | ||
| } | ||
| insertBefore(newChild, refChild) { | ||
| return super.insertBefore(newChild, refChild); | ||
| } | ||
| querySelectorAll(selectors) { | ||
| return this.nwsapi.select(selectors); | ||
| } | ||
| getElementsByTagName(tagName) { | ||
| if (this.documentElement) | ||
| return this.documentElement.getElementsByTagName(tagName); | ||
| return []; | ||
| } | ||
| getElementsByClassName(className) { | ||
| if (this.documentElement) | ||
| return this.documentElement.getElementsByClassName(className); | ||
| return []; | ||
| } | ||
| getElementById(elementId) { | ||
| if (this.documentElement) | ||
| return this.documentElement.getElementById(elementId); | ||
| return null; | ||
| } | ||
| createDocument(_namespace, _qualifiedName, _doctype) { | ||
| return new RRDocument(); | ||
| } | ||
| createDocumentType(qualifiedName, publicId, systemId) { | ||
| const documentTypeNode = new RRDocumentType(qualifiedName, publicId, systemId); | ||
| documentTypeNode.ownerDocument = this; | ||
| return documentTypeNode; | ||
| } | ||
| createElement(tagName) { | ||
| const upperTagName = tagName.toUpperCase(); | ||
| let element; | ||
| switch (upperTagName) { | ||
| case 'AUDIO': | ||
| case 'VIDEO': | ||
| element = new RRMediaElement(upperTagName); | ||
| break; | ||
| case 'IFRAME': | ||
| element = new RRIFrameElement(upperTagName); | ||
| break; | ||
| case 'IMG': | ||
| element = new RRImageElement(upperTagName); | ||
| break; | ||
| case 'CANVAS': | ||
| element = new RRCanvasElement(upperTagName); | ||
| break; | ||
| case 'STYLE': | ||
| element = new RRStyleElement(upperTagName); | ||
| break; | ||
| default: | ||
| element = new RRElement(upperTagName); | ||
| break; | ||
| } | ||
| element.ownerDocument = this; | ||
| return element; | ||
| } | ||
| createElementNS(_namespaceURI, qualifiedName) { | ||
| return this.createElement(qualifiedName); | ||
| } | ||
| createComment(data) { | ||
| const commentNode = new RRComment(data); | ||
| commentNode.ownerDocument = this; | ||
| return commentNode; | ||
| } | ||
| createCDATASection(data) { | ||
| const sectionNode = new RRCDATASection(data); | ||
| sectionNode.ownerDocument = this; | ||
| return sectionNode; | ||
| } | ||
| createTextNode(data) { | ||
| const textNode = new RRText(data); | ||
| textNode.ownerDocument = this; | ||
| return textNode; | ||
| } | ||
| } | ||
| class RRDocumentType extends BaseRRDocumentTypeImpl(RRNode) { | ||
| } | ||
| class RRElement extends BaseRRElementImpl(RRNode) { | ||
| constructor(tagName) { | ||
| super(tagName); | ||
| this._style = new cssstyle.CSSStyleDeclaration(); | ||
| const style = this._style; | ||
| Object.defineProperty(this.attributes, 'style', { | ||
| get() { | ||
| return style.cssText; | ||
| }, | ||
| set(cssText) { | ||
| style.cssText = cssText; | ||
| }, | ||
| }); | ||
| } | ||
| get style() { | ||
| return this._style; | ||
| } | ||
| attachShadow(_init) { | ||
| return super.attachShadow(_init); | ||
| } | ||
| appendChild(newChild) { | ||
| return super.appendChild(newChild); | ||
| } | ||
| insertBefore(newChild, refChild) { | ||
| return super.insertBefore(newChild, refChild); | ||
| } | ||
| getAttribute(name) { | ||
| const upperName = name && name.toLowerCase(); | ||
| if (upperName in this.attributes) | ||
| return this.attributes[upperName]; | ||
| return null; | ||
| } | ||
| setAttribute(name, attribute) { | ||
| this.attributes[name.toLowerCase()] = attribute; | ||
| } | ||
| removeAttribute(name) { | ||
| delete this.attributes[name.toLowerCase()]; | ||
| } | ||
| get firstElementChild() { | ||
| for (const child of this.childNodes) | ||
| if (child.RRNodeType === NodeType$2.Element) | ||
| return child; | ||
| return null; | ||
| } | ||
| get nextElementSibling() { | ||
| const parentNode = this.parentNode; | ||
| if (!parentNode) | ||
| return null; | ||
| const siblings = parentNode.childNodes; | ||
| const index = siblings.indexOf(this); | ||
| for (let i = index + 1; i < siblings.length; i++) | ||
| if (siblings[i] instanceof RRElement) | ||
| return siblings[i]; | ||
| return null; | ||
| } | ||
| querySelectorAll(selectors) { | ||
| const result = []; | ||
| if (this.ownerDocument !== null) { | ||
| this.ownerDocument.nwsapi.select(selectors, this, (element) => { | ||
| if (element !== this) | ||
| result.push(element); | ||
| }); | ||
| } | ||
| return result; | ||
| } | ||
| getElementById(elementId) { | ||
| if (this.id === elementId) | ||
| return this; | ||
| for (const child of this.childNodes) { | ||
| if (child instanceof RRElement) { | ||
| const result = child.getElementById(elementId); | ||
| if (result !== null) | ||
| return result; | ||
| } | ||
| } | ||
| return null; | ||
| } | ||
| getElementsByClassName(className) { | ||
| let elements = []; | ||
| const queryClassList = new ClassList(className); | ||
| if (this instanceof RRElement && | ||
| queryClassList.classes.filter((queriedClassName) => this.classList.classes.some((name) => name === queriedClassName)).length == queryClassList.classes.length) | ||
| elements.push(this); | ||
| for (const child of this.childNodes) { | ||
| if (child instanceof RRElement) | ||
| elements = elements.concat(child.getElementsByClassName(className)); | ||
| } | ||
| return elements; | ||
| } | ||
| getElementsByTagName(tagName) { | ||
| let elements = []; | ||
| const normalizedTagName = tagName.toUpperCase(); | ||
| if (this instanceof RRElement && this.tagName === normalizedTagName) | ||
| elements.push(this); | ||
| for (const child of this.childNodes) { | ||
| if (child instanceof RRElement) | ||
| elements = elements.concat(child.getElementsByTagName(tagName)); | ||
| } | ||
| return elements; | ||
| } | ||
| } | ||
| class RRImageElement extends RRElement { | ||
| } | ||
| class RRMediaElement extends BaseRRMediaElementImpl(RRElement) { | ||
| } | ||
| class RRCanvasElement extends RRElement { | ||
| getContext() { | ||
| return null; | ||
| } | ||
| } | ||
| class RRStyleElement extends RRElement { | ||
| constructor() { | ||
| super(...arguments); | ||
| this._sheet = null; | ||
| } | ||
| get sheet() { | ||
| if (!this._sheet) { | ||
| let result = ''; | ||
| for (const child of this.childNodes) | ||
| if (child.RRNodeType === NodeType$2.Text) | ||
| result += child.textContent; | ||
| this._sheet = cssom.parse(result); | ||
| } | ||
| return this._sheet; | ||
| } | ||
| } | ||
| class RRIFrameElement extends RRElement { | ||
| constructor(tagName) { | ||
| super(tagName); | ||
| this.width = ''; | ||
| this.height = ''; | ||
| this.src = ''; | ||
| this.contentDocument = new RRDocument(); | ||
| this.contentWindow = new RRWindow(); | ||
| const htmlElement = this.contentDocument.createElement('HTML'); | ||
| this.contentDocument.appendChild(htmlElement); | ||
| htmlElement.appendChild(this.contentDocument.createElement('HEAD')); | ||
| htmlElement.appendChild(this.contentDocument.createElement('BODY')); | ||
| } | ||
| } | ||
| class RRText extends BaseRRTextImpl(RRNode) { | ||
| constructor() { | ||
| super(...arguments); | ||
| this.nodeName = '#text'; | ||
| } | ||
| } | ||
| class RRComment extends BaseRRCommentImpl(RRNode) { | ||
| constructor() { | ||
| super(...arguments); | ||
| this.nodeName = '#comment'; | ||
| } | ||
| } | ||
| class RRCDATASection extends BaseRRCDATASectionImpl(RRNode) { | ||
| constructor() { | ||
| super(...arguments); | ||
| this.nodeName = '#cdata-section'; | ||
| } | ||
| } | ||
| function polyfillPerformance() { | ||
| if (typeof window !== 'undefined' || 'performance' in global) | ||
| return; | ||
| const performance = require('perf_hooks').performance; | ||
| global.performance = performance; | ||
| } | ||
| function polyfillRAF() { | ||
| if (typeof window !== 'undefined' || 'requestAnimationFrame' in global) | ||
| return; | ||
| const FPS = 60, INTERVAL = 1000 / FPS; | ||
| let timeoutHandle = null, rafCount = 0, requests = Object.create(null); | ||
| function onFrameTimer() { | ||
| const currentRequests = requests; | ||
| requests = Object.create(null); | ||
| timeoutHandle = null; | ||
| Object.keys(currentRequests).forEach(function (id) { | ||
| const request = currentRequests[id]; | ||
| if (request) | ||
| request(Date.now()); | ||
| }); | ||
| } | ||
| function requestAnimationFrame(callback) { | ||
| const cbHandle = ++rafCount; | ||
| requests[cbHandle] = callback; | ||
| if (timeoutHandle === null) | ||
| timeoutHandle = setTimeout(onFrameTimer, INTERVAL); | ||
| return cbHandle; | ||
| } | ||
| function cancelAnimationFrame(handleId) { | ||
| delete requests[handleId]; | ||
| if (Object.keys(requests).length === 0 && timeoutHandle !== null) { | ||
| clearTimeout(timeoutHandle); | ||
| timeoutHandle = null; | ||
| } | ||
| } | ||
| global.requestAnimationFrame = | ||
| requestAnimationFrame; | ||
| global.cancelAnimationFrame = | ||
| cancelAnimationFrame; | ||
| } | ||
| function polyfillEvent() { | ||
| if (typeof Event !== 'undefined') | ||
| return; | ||
| global.Event = function () { | ||
| }; | ||
| } | ||
| function polyfillNode() { | ||
| if (typeof Node !== 'undefined') | ||
| return; | ||
| global.Node = RRNode; | ||
| } | ||
| function polyfillDocument() { | ||
| if (typeof document !== 'undefined') | ||
| return; | ||
| const rrdom = new RRDocument(); | ||
| (() => { | ||
| rrdom.appendChild(rrdom.createElement('html')); | ||
| rrdom.documentElement.appendChild(rrdom.createElement('head')); | ||
| rrdom.documentElement.appendChild(rrdom.createElement('body')); | ||
| })(); | ||
| global.document = rrdom; | ||
| } | ||
| polyfillPerformance(); | ||
| polyfillRAF(); | ||
| polyfillEvent(); | ||
| polyfillNode(); | ||
| polyfillDocument(); | ||
| exports.RRCDATASection = RRCDATASection; | ||
| exports.RRCanvasElement = RRCanvasElement; | ||
| exports.RRComment = RRComment; | ||
| exports.RRDocument = RRDocument; | ||
| exports.RRDocumentType = RRDocumentType; | ||
| exports.RRElement = RRElement; | ||
| exports.RRIFrameElement = RRIFrameElement; | ||
| exports.RRImageElement = RRImageElement; | ||
| exports.RRMediaElement = RRMediaElement; | ||
| exports.RRNode = RRNode; | ||
| exports.RRStyleElement = RRStyleElement; | ||
| exports.RRText = RRText; | ||
| exports.RRWindow = RRWindow; |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
694526
43.27%13
-27.78%3
-25%1
-50%180
Infinity%Yes
NaN12
-20%3028
-25.09%5
25%1
Infinity%Updated