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AAY,UACpB,QAAQ,eAAiB,eACzB,QAAQ,YAAc","file":"/npm/@wpe-tkpd/jsdom@23.0.2/lib/api.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@wpe-tkpd/jsdom@23.0.2/lib/api.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","\"use strict\";\n\nconst path = require(\"path\");\nconst fs = require(\"fs\").promises;\nconst vm = require(\"vm\");\nconst toughCookie = require(\"tough-cookie\");\nconst sniffHTMLEncoding = require(\"html-encoding-sniffer\");\nconst whatwgURL = require(\"whatwg-url\");\nconst whatwgEncoding = require(\"whatwg-encoding\");\nconst {\n  URL\n} = require(\"whatwg-url\");\nconst MIMEType = require(\"whatwg-mimetype\");\nconst idlUtils = require(\"./jsdom/living/generated/utils.js\");\nconst VirtualConsole = require(\"./jsdom/virtual-console.js\");\nconst {\n  createWindow\n} = require(\"./jsdom/browser/Window.js\");\nconst {\n  parseIntoDocument\n} = require(\"./jsdom/browser/parser\");\nconst {\n  fragmentSerialization\n} = require(\"./jsdom/living/domparsing/serialization.js\");\nconst ResourceLoader = require(\"./jsdom/browser/resources/resource-loader.js\");\nconst NoOpResourceLoader = require(\"./jsdom/browser/resources/no-op-resource-loader.js\");\nclass CookieJar extends toughCookie.CookieJar {\n  constructor(store, options) {\n    // jsdom cookie jars must be loose by default\n    super(store, {\n      looseMode: true,\n      ...options\n    });\n  }\n}\nconst window = Symbol(\"window\");\nlet sharedFragmentDocument = null;\nclass JSDOM {\n  constructor(input = \"\", options = {}) {\n    const mimeType = new MIMEType(options.contentType === undefined ? \"text/html\" : options.contentType);\n    const {\n      html,\n      encoding\n    } = normalizeHTML(input, mimeType);\n    options = transformOptions(options, encoding, mimeType);\n    this[window] = createWindow(options.windowOptions);\n    const documentImpl = idlUtils.implForWrapper(this[window]._document);\n    options.beforeParse(this[window]._globalProxy);\n    parseIntoDocument(html, documentImpl);\n    documentImpl.close();\n  }\n  get window() {\n    // It's important to grab the global proxy, instead of just the result of `createWindow(...)`, since otherwise\n    // things like `window.eval` don't exist.\n    return this[window]._globalProxy;\n  }\n  get virtualConsole() {\n    return this[window]._virtualConsole;\n  }\n  get cookieJar() {\n    // TODO NEWAPI move _cookieJar to window probably\n    return idlUtils.implForWrapper(this[window]._document)._cookieJar;\n  }\n  serialize() {\n    return fragmentSerialization(idlUtils.implForWrapper(this[window]._document), {\n      requireWellFormed: false\n    });\n  }\n  nodeLocation(node) {\n    if (!idlUtils.implForWrapper(this[window]._document)._parseOptions.sourceCodeLocationInfo) {\n      throw new Error(\"Location information was not saved for this jsdom. Use includeNodeLocations during creation.\");\n    }\n    return idlUtils.implForWrapper(node).sourceCodeLocation;\n  }\n  getInternalVMContext() {\n    if (!vm.isContext(this[window])) {\n      throw new TypeError(\"This jsdom was not configured to allow script running. \" + \"Use the runScripts option during creation.\");\n    }\n    return this[window];\n  }\n  reconfigure(settings) {\n    if (\"windowTop\" in settings) {\n      this[window]._top = settings.windowTop;\n    }\n    if (\"url\" in settings) {\n      const document = idlUtils.implForWrapper(this[window]._document);\n      const url = whatwgURL.parseURL(settings.url);\n      if (url === null) {\n        throw new TypeError(`Could not parse \"${settings.url}\" as a URL`);\n      }\n      document._URL = url;\n      document._origin = whatwgURL.serializeURLOrigin(document._URL);\n      this[window]._sessionHistory.currentEntry.url = url;\n    }\n  }\n  static fragment(string = \"\") {\n    if (!sharedFragmentDocument) {\n      sharedFragmentDocument = new JSDOM().window.document;\n    }\n    const template = sharedFragmentDocument.createElement(\"template\");\n    template.innerHTML = string;\n    return template.content;\n  }\n  static fromURL(url, options = {}) {\n    return Promise.resolve().then(() => {\n      // Remove the hash while sending this through the research loader fetch().\n      // It gets added back a few lines down when constructing the JSDOM object.\n      const parsedURL = new URL(url);\n      const originalHash = parsedURL.hash;\n      parsedURL.hash = \"\";\n      url = parsedURL.href;\n      options = normalizeFromURLOptions(options);\n      const resourceLoader = resourcesToResourceLoader(options.resources);\n      const resourceLoaderForInitialRequest = resourceLoader.constructor === NoOpResourceLoader ? new ResourceLoader() : resourceLoader;\n      const req = resourceLoaderForInitialRequest.fetch(url, {\n        accept: \"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\",\n        cookieJar: options.cookieJar,\n        referrer: options.referrer\n      });\n      return req.then(body => {\n        const res = req.response;\n        options = Object.assign(options, {\n          url: req.href + originalHash,\n          contentType: res.headers[\"content-type\"],\n          referrer: req.getHeader(\"referer\") || undefined\n        });\n        return new JSDOM(body, options);\n      });\n    });\n  }\n  static async fromFile(filename, options = {}) {\n    options = normalizeFromFileOptions(filename, options);\n    const buffer = await fs.readFile(filename);\n    return new JSDOM(buffer, options);\n  }\n}\nfunction normalizeFromURLOptions(options) {\n  // Checks on options that are invalid for `fromURL`\n  if (options.url !== undefined) {\n    throw new TypeError(\"Cannot supply a url option when using fromURL\");\n  }\n  if (options.contentType !== undefined) {\n    throw new TypeError(\"Cannot supply a contentType option when using fromURL\");\n  }\n\n  // Normalization of options which must be done before the rest of the fromURL code can use them, because they are\n  // given to request()\n  const normalized = {\n    ...options\n  };\n  if (options.referrer !== undefined) {\n    normalized.referrer = new URL(options.referrer).href;\n  }\n  if (options.cookieJar === undefined) {\n    normalized.cookieJar = new CookieJar();\n  }\n  return normalized;\n\n  // All other options don't need to be processed yet, and can be taken care of in the normal course of things when\n  // `fromURL` calls `new JSDOM(html, options)`.\n}\nfunction normalizeFromFileOptions(filename, options) {\n  const normalized = {\n    ...options\n  };\n  if (normalized.contentType === undefined) {\n    const extname = path.extname(filename);\n    if (extname === \".xhtml\" || extname === \".xht\" || extname === \".xml\") {\n      normalized.contentType = \"application/xhtml+xml\";\n    }\n  }\n  if (normalized.url === undefined) {\n    normalized.url = new URL(\"file:\" + path.resolve(filename));\n  }\n  return normalized;\n}\nfunction transformOptions(options, encoding, mimeType) {\n  const transformed = {\n    windowOptions: {\n      // Defaults\n      url: \"about:blank\",\n      referrer: \"\",\n      contentType: \"text/html\",\n      parsingMode: \"html\",\n      parseOptions: {\n        sourceCodeLocationInfo: false,\n        scriptingEnabled: false\n      },\n      runScripts: undefined,\n      encoding,\n      pretendToBeVisual: false,\n      storageQuota: 5000000,\n      // Defaults filled in later\n      resourceLoader: undefined,\n      virtualConsole: undefined,\n      cookieJar: undefined\n    },\n    // Defaults\n    beforeParse() {}\n  };\n\n  // options.contentType was parsed into mimeType by the caller.\n  if (!mimeType.isHTML() && !mimeType.isXML()) {\n    throw new RangeError(`The given content type of \"${options.contentType}\" was not a HTML or XML content type`);\n  }\n  transformed.windowOptions.contentType = mimeType.essence;\n  transformed.windowOptions.parsingMode = mimeType.isHTML() ? \"html\" : \"xml\";\n  if (options.url !== undefined) {\n    transformed.windowOptions.url = new URL(options.url).href;\n  }\n  if (options.referrer !== undefined) {\n    transformed.windowOptions.referrer = new URL(options.referrer).href;\n  }\n  if (options.includeNodeLocations) {\n    if (transformed.windowOptions.parsingMode === \"xml\") {\n      throw new TypeError(\"Cannot set includeNodeLocations to true with an XML content type\");\n    }\n    transformed.windowOptions.parseOptions = {\n      sourceCodeLocationInfo: true\n    };\n  }\n  transformed.windowOptions.cookieJar = options.cookieJar === undefined ? new CookieJar() : options.cookieJar;\n  transformed.windowOptions.virtualConsole = options.virtualConsole === undefined ? new VirtualConsole().sendTo(console) : options.virtualConsole;\n  if (!(transformed.windowOptions.virtualConsole instanceof VirtualConsole)) {\n    throw new TypeError(\"virtualConsole must be an instance of VirtualConsole\");\n  }\n  transformed.windowOptions.resourceLoader = resourcesToResourceLoader(options.resources);\n  if (options.runScripts !== undefined) {\n    transformed.windowOptions.runScripts = String(options.runScripts);\n    if (transformed.windowOptions.runScripts === \"dangerously\") {\n      transformed.windowOptions.parseOptions.scriptingEnabled = true;\n    } else if (transformed.windowOptions.runScripts !== \"outside-only\") {\n      throw new RangeError(`runScripts must be undefined, \"dangerously\", or \"outside-only\"`);\n    }\n  }\n  if (options.beforeParse !== undefined) {\n    transformed.beforeParse = options.beforeParse;\n  }\n  if (options.pretendToBeVisual !== undefined) {\n    transformed.windowOptions.pretendToBeVisual = Boolean(options.pretendToBeVisual);\n  }\n  if (options.storageQuota !== undefined) {\n    transformed.windowOptions.storageQuota = Number(options.storageQuota);\n  }\n  return transformed;\n}\nfunction normalizeHTML(html, mimeType) {\n  let encoding = \"UTF-8\";\n  if (ArrayBuffer.isView(html)) {\n    html = Buffer.from(html.buffer, html.byteOffset, html.byteLength);\n  } else if (html instanceof ArrayBuffer) {\n    html = Buffer.from(html);\n  }\n  if (Buffer.isBuffer(html)) {\n    encoding = sniffHTMLEncoding(html, {\n      defaultEncoding: mimeType.isXML() ? \"UTF-8\" : \"windows-1252\",\n      transportLayerEncodingLabel: mimeType.parameters.get(\"charset\")\n    });\n    html = whatwgEncoding.decode(html, encoding);\n  } else {\n    html = String(html);\n  }\n  return {\n    html,\n    encoding\n  };\n}\nfunction resourcesToResourceLoader(resources) {\n  switch (resources) {\n    case undefined:\n      {\n        return new NoOpResourceLoader();\n      }\n    case \"usable\":\n      {\n        return new ResourceLoader();\n      }\n    default:\n      {\n        if (!(resources instanceof ResourceLoader)) {\n          throw new TypeError(\"resources must be an instance of ResourceLoader\");\n        }\n        return resources;\n      }\n  }\n}\nexports.JSDOM = JSDOM;\nexports.VirtualConsole = VirtualConsole;\nexports.CookieJar = CookieJar;\nexports.ResourceLoader = ResourceLoader;\nexports.toughCookie = toughCookie;"]}