How to use the @firebase/util.isNodeSdk function in @firebase/util

To help you get started, we’ve selected a few @firebase/util examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github firebase / firebase-js-sdk / packages / database / src / realtime / BrowserPollConnection.ts View on Github external
static isAvailable() {
    if (isNodeSdk()) {
      return false;
    } else if (BrowserPollConnection.forceAllow_) {
      return true;
    } else {
      // NOTE: In React-Native there's normally no 'document', but if you debug a React-Native app in
      // the Chrome debugger, 'document' is defined, but document.createElement is null (2015/06/08).
      return (
        !BrowserPollConnection.forceDisallow_ &&
        typeof document !== 'undefined' &&
        document.createElement != null &&
        !isChromeExtensionContentScript() &&
        !isWindowsStoreApp()
      );
    }
  }
github firebase / firebase-js-sdk / packages / database / src / realtime / BrowserPollConnection.ts View on Github external
addTag(url: string, loadCB: () => void) {
    if (isNodeSdk()) {
      // eslint-disable-next-line @typescript-eslint/no-explicit-any
      (this as any).doNodeLongPoll(url, loadCB);
    } else {
      setTimeout(() => {
        try {
          // if we're already closed, don't add this poll
          if (!this.sendNewPolls) {
            return;
          }
          const newScript = this.myIFrame.doc.createElement('script');
          newScript.type = 'text/javascript';
          newScript.async = true;
          newScript.src = url;
          // eslint-disable-next-line @typescript-eslint/no-explicit-any
          newScript.onload = (newScript as any).onreadystatechange = function() {
            // eslint-disable-next-line @typescript-eslint/no-explicit-any
github firebase / firebase-js-sdk / packages / database / src / core / util / util.ts View on Github external
export const executeWhenDOMReady = function(fn: () => void) {
  if (isNodeSdk() || document.readyState === 'complete') {
    fn();
  } else {
    // Modeled after jQuery. Try DOMContentLoaded and onreadystatechange (which
    // fire before onload), but fall back to onload.

    let called = false;
    const wrappedFn = function() {
      if (!document.body) {
        setTimeout(wrappedFn, Math.floor(10));
        return;
      }

      if (!called) {
        called = true;
        fn();
      }
github firebase / firebase-js-sdk / packages / database / src / realtime / BrowserPollConnection.ts View on Github external
addDisconnectPingFrame(id: string, pw: string) {
    if (isNodeSdk()) {
      return;
    }
    this.myDisconnFrame = document.createElement('iframe');
    const urlParams: { [k: string]: string } = {};
    urlParams[FIREBASE_LONGPOLL_DISCONN_FRAME_REQUEST_PARAM] = 't';
    urlParams[FIREBASE_LONGPOLL_ID_PARAM] = id;
    urlParams[FIREBASE_LONGPOLL_PW_PARAM] = pw;
    this.myDisconnFrame.src = this.urlFn(urlParams);
    this.myDisconnFrame.style.display = 'none';

    document.body.appendChild(this.myDisconnFrame);
  }
github firebase / firebase-js-sdk / packages / database / src / realtime / WebSocketConnection.ts View on Github external
private static connectionURL_(
    repoInfo: RepoInfo,
    transportSessionId?: string,
    lastSessionId?: string
  ): string {
    const urlParams: { [k: string]: string } = {};
    urlParams[VERSION_PARAM] = PROTOCOL_VERSION;

    if (
      !isNodeSdk() &&
      typeof location !== 'undefined' &&
      location.href &&
      location.href.indexOf(FORGE_DOMAIN) !== -1
    ) {
      urlParams[REFERER_PARAM] = FORGE_REF;
    }
    if (transportSessionId) {
      urlParams[TRANSPORT_SESSION_PARAM] = transportSessionId;
    }
    if (lastSessionId) {
      urlParams[LAST_SESSION_PARAM] = lastSessionId;
    }
    return repoInfo.connectionURL(WEBSOCKET, urlParams);
  }
github firebase / firebase-js-sdk / packages / database / index.node.ts View on Github external
Reference,
          Query,
          Database,
          DataSnapshot,
          enableLogging,
          INTERNAL,
          ServerValue,
          TEST_ACCESS
        }
      )
      .setMultipleInstances(true)
  );

  instance.registerVersion(name, version, 'node');

  if (isNodeSdk()) {
    module.exports = Object.assign({}, namespace, { initStandalone });
  }
}