All files / near-membrane-shared-dom/dist index.mjs.js

95.24% Statements 20/21
66.67% Branches 6/9
50% Functions 1/2
95.24% Lines 20/21

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71  44x               44x             44x       44x 44x     44x         44x             44x         44x         44x 44x       44x     44x 44x       44x 44x 44x     44x     44x 44x    
import { ArrayIsArray, ReflectApply, ArrayProtoFind, RegExpProtoTest, ObjectLookupOwnGetter } from '@locker/near-membrane-shared';
const rootWindow = window;
const {
  // We don't cherry-pick the 'userAgent' property from `navigator` here
  // to avoid triggering its getter.
  navigator,
  navigator: {
    userAgentData
  }
} = rootWindow; // The user-agent client hints API is experimental and subject to change.
// https://caniuse.com/mdn-api_navigator_useragentdata
// istanbul ignore next: optional chaining and nullish coalescing results in an expansion that contains an unreachable "void 0" branch for every occurrence of the operator
 
const brands = userAgentData == null ? void 0 : userAgentData.brands; // Note: Chromium identifies itself as Chrome in its user-agent string.
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent
 
const chromiumUserAgentRegExp = / (?:Headless)?Chrome\/\d+/;
let userAgent;
 
function getUserAgent() {
  Eif (userAgent === undefined) {
    userAgent = navigator.userAgent;
  }
 
  return userAgent;
}
 
const IS_CHROMIUM_BROWSER = // While experimental, `navigator.userAgentData.brands` may be defined as an
// empty array in headless Chromium based browsers.
ArrayIsArray(brands) && brands.length ? // Use user-agent client hints API if available to avoid deprecation
// warnings.
// https://developer.mozilla.org/en-US/docs/Web/API/User-Agent_Client_Hints_API
// istanbul ignore next: this code is not reachable in the coverage run.
ReflectApply(ArrayProtoFind, brands, [// prettier-ignore
item => (item == null ? void 0 : item.brand) === 'Chromium']) !== undefined : // Fallback to a standard user-agent string sniff.
ReflectApply(RegExpProtoTest, chromiumUserAgentRegExp, [getUserAgent()]);
const IS_OLD_CHROMIUM_BROWSER = IS_CHROMIUM_BROWSER && // Chromium added support for `navigator.userAgentData` in v90.
// https://caniuse.com/mdn-api_navigator_useragentdata
userAgentData === undefined;
const {
  prototype: DocumentProto
} = Document;
const {
  close: DocumentProtoClose,
  createElement: DocumentProtoCreateElement,
  open: DocumentProtoOpen
} = DocumentProto;
const DocumentProtoBodyGetter = ObjectLookupOwnGetter(DocumentProto, 'body'); // The DOMException constructor was exposed in Edge 12 but wasn't invocable
// until Edge 79. As long as this is used for instanceof checks it should be fine.
// https://developer.mozilla.org/en-US/docs/Web/API/DOMException#browser_compatibility
 
const DOMExceptionCtor = DOMException;
const {
  DATA_CLONE_ERR: DATA_CLONE_ERROR_CODE
} = DOMExceptionCtor;
const DOMExceptionProtoCodeGetter = ObjectLookupOwnGetter(DOMExceptionCtor.prototype, 'code');
const {
  remove: ElementProtoRemove,
  setAttribute: ElementProtoSetAttribute
} = Element.prototype;
const HTMLElementProtoStyleGetter = ObjectLookupOwnGetter(HTMLElement.prototype, 'style');
const HTMLIFrameElementProtoContentWindowGetter = ObjectLookupOwnGetter(HTMLIFrameElement.prototype, 'contentWindow');
const {
  prototype: NodeProto
} = Node;
const {
  appendChild: NodeProtoAppendChild
} = NodeProto;
const NodeProtoLastChildGetter = ObjectLookupOwnGetter(NodeProto, 'lastChild');
export { DATA_CLONE_ERROR_CODE, DOMExceptionCtor, DOMExceptionProtoCodeGetter, DocumentProtoBodyGetter, DocumentProtoClose, DocumentProtoCreateElement, DocumentProtoOpen, ElementProtoRemove, ElementProtoSetAttribute, HTMLElementProtoStyleGetter, HTMLIFrameElementProtoContentWindowGetter, IS_CHROMIUM_BROWSER, IS_OLD_CHROMIUM_BROWSER, NodeProtoAppendChild, NodeProtoLastChildGetter, rootWindow };