init({
    acls = [],
    secret = null,
    onReady = null,
    targetSelectors = '',
    options = {},
    customMethods = {},
    dispatchFunction = null,
    authorizeMessage = null,
  }) {
    this.acls = [].concat(acls);
    this.secret = secret;
    this.options = options;
    this.onReady = onReady;
    this.targetSelectors = targetSelectors;
    this.resizeConfig = null;
    this.requestResize = this.requestResize.bind(this);
    this.handleConsumerMessage = this.handleConsumerMessage.bind(this);
    this.authorizeConsumer = this.authorizeConsumer.bind(this);
    this.verifyChallenge = this.verifyChallenge.bind(this);
    this.emitError = this.emitError.bind(this);
    this.unload = this.unload.bind(this);

    this.dispatchFunction = dispatchFunction || ((message, targetOrigin) => {
      // Don't send messages if not embedded
      if (window.self !== window.top) {
        parent.postMessage(message, targetOrigin);
      }
    });

    this.isMessageAuthorized = authorizeMessage || this.authorizeConsumerMessage;

    // Resize for slow loading images
    document.addEventListener('load', this.imageRequestResize.bind(this), true);

    const self = this;
    this.JSONRPC = new JSONRPC(
      self.send.bind(self),
      ({
        event(event, detail) {
          self.emit(event, detail);
          return Promise.resolve();
        },

        resize(config = {}) {
          self.resizeConfig = config;

          self.requestResize();

          // Registers a mutation observer for body
          const observer = new MutationObserver(
            (mutations) => self.requestResize(),
          );
          observer.observe(
            document.body,
            {
              attributes: true, childList: true, characterData: true, subtree: true,
            },
          );

          // Registers a listener to window.onresize
          // Optimizes the listener by debouncing (https://bencentra.com/code/2015/02/27/optimizing-window-resize.html#debouncing)
          const interval = 100; // Resize event will be considered complete if no follow-up events within `interval` ms.
          let resizeTimer = null;
          window.onresize = (event) => {
            clearTimeout(resizeTimer);
            resizeTimer = setTimeout(() => self.requestResize(), interval);
          };

          return Promise.resolve();
        },
        ...customMethods,
      }),
    );

    window.addEventListener('message', this.handleConsumerMessage);
    window.addEventListener('beforeunload', this.unload);
  }
/**
   * init method
   * @param  options.acls            An array that contains white listed origins
   * @param  options.secret          A string or function used for authorization with Consumer
   * @param  options.onReady         A function that will be called after App is authorized
   * @param  options.targetSelectors A DOMString containing one or more selectors to match against.
   *                                 This string must be a valid CSS selector string; if it's not,
   *                                 a SyntaxError exception is thrown.
   * @param  options.options         An optional object used for App to transmit details to frame
   *                                 after App is authorized.
   * @param options.dispatchFunction A function that will be used to dispatch messages instead of
   *                                 `parent.postMessage`. This function will receive the same
   *                                 `message` and `targetOrigin` arguments as `postMessage`.
   * @param options.authorizeMessage A function that will be called with a MessageEvent when the
   *                                 consumer dispatches a message in order to decide whether to
   *                                 handle the message or not. The message will be handled if this
   *                                 function returns true.
   */
init method
@param  options.acls            An array that contains white listed origins
@param  options.secret          A string or function used for authorization with Consumer
@param  options.onReady         A function that will be called after App is authorized
@param  options.targetSelectors A DOMString containing one or more selectors to match against.
This string must be a valid CSS selector string; if it's not,
a SyntaxError exception is thrown.
@param  options.options         An optional object used for App to transmit details to frame
after App is authorized.
@param options.dispatchFunction A function that will be used to dispatch messages instead of
`parent.postMessage`.
init method @param options . acls An array that contains white listed origins @param options . secret A string or function used for authorization with Consumer @param options . onReady A function that will be called after App is authorized @param options . targetSelectors A DOMString containing one or more selectors to match against . This string must be a valid CSS selector string ; if it ' s not a SyntaxError exception is thrown . @param options . options An optional object used for App to transmit details to frame after App is authorized . @param options . dispatchFunction A function that will be used to dispatch messages instead of ` parent . postMessage ` .
init({
    acls = [],
    secret = null,
    onReady = null,
    targetSelectors = '',
    options = {},
    customMethods = {},
    dispatchFunction = null,
    authorizeMessage = null,
  }) {
    this.acls = [].concat(acls);
    this.secret = secret;
    this.options = options;
    this.onReady = onReady;
    this.targetSelectors = targetSelectors;
    this.resizeConfig = null;
    this.requestResize = this.requestResize.bind(this);
    this.handleConsumerMessage = this.handleConsumerMessage.bind(this);
    this.authorizeConsumer = this.authorizeConsumer.bind(this);
    this.verifyChallenge = this.verifyChallenge.bind(this);
    this.emitError = this.emitError.bind(this);
    this.unload = this.unload.bind(this);
    this.dispatchFunction = dispatchFunction || ((message, targetOrigin) => {
      if (window.self !== window.top) {
        parent.postMessage(message, targetOrigin);
      }
    });
    this.isMessageAuthorized = authorizeMessage || this.authorizeConsumerMessage;
    document.addEventListener('load', this.imageRequestResize.bind(this), true);
    const self = this;
    this.JSONRPC = new JSONRPC(
      self.send.bind(self),
      ({
        event(event, detail) {
          self.emit(event, detail);
          return Promise.resolve();
        },
        resize(config = {}) {
          self.resizeConfig = config;
          self.requestResize();
          const observer = new MutationObserver(
            (mutations) => self.requestResize(),
          );
          observer.observe(
            document.body,
            {
              attributes: true, childList: true, characterData: true, subtree: true,
            },
          );
          const interval = 100; 
          let resizeTimer = null;
          window.onresize = (event) => {
            clearTimeout(resizeTimer);
            resizeTimer = setTimeout(() => self.requestResize(), interval);
          };
          return Promise.resolve();
        },
        ...customMethods,
      }),
    );
    window.addEventListener('message', this.handleConsumerMessage);
    window.addEventListener('beforeunload', this.unload);
  }
init ( { acls = [ ] , secret = null , onReady = null , targetSelectors = '' , options = { } , customMethods = { } , dispatchFunction = null , authorizeMessage = null , } ) { this . acls = [ ] . concat ( acls ) ; this . secret = secret ; this . options = options ; this . onReady = onReady ; this . targetSelectors = targetSelectors ; this . resizeConfig = null ; this . requestResize = this . requestResize . bind ( this ) ; this . handleConsumerMessage = this . handleConsumerMessage . bind ( this ) ; this . authorizeConsumer = this . authorizeConsumer . bind ( this ) ; this . verifyChallenge = this . verifyChallenge . bind ( this ) ; this . emitError = this . emitError . bind ( this ) ; this . unload = this . unload . bind ( this ) ; this . dispatchFunction = dispatchFunction || ( ( message , targetOrigin ) => { if ( window . self !== window . top ) { parent . postMessage ( message , targetOrigin ) ; } } ) ; this . isMessageAuthorized = authorizeMessage || this . authorizeConsumerMessage ; document . addEventListener ( 'load' , this . imageRequestResize . bind ( this ) , true ) ; const self = this ; this . JSONRPC = new JSONRPC ( self . send . bind ( self ) , ( { event ( event , detail ) { self . emit ( event , detail ) ; return Promise . resolve ( ) ; } , resize ( config = { } ) { self . resizeConfig = config ; self . requestResize ( ) ; const observer = new MutationObserver ( ( mutations ) => self . requestResize ( ) , ) ; observer . observe ( document . body , { attributes : true , childList : true , characterData : true , subtree : true , } , ) ; const interval = 100 ; let resizeTimer = null ; window . onresize = ( event ) => { clearTimeout ( resizeTimer ) ; resizeTimer = setTimeout ( ( ) => self . requestResize ( ) , interval ) ; } ; return Promise . resolve ( ) ; } , ... customMethods , } ) , ) ; window . addEventListener ( 'message' , this . handleConsumerMessage ) ; window . addEventListener ( 'beforeunload' , this . unload ) ; }
init method
 @param  options.acls            An array that contains white listed origins
 @param  options.secret          A string or function used for authorization with Consumer
 @param  options.onReady         A function that will be called after App is authorized
 @param  options.targetSelectors A DOMString containing one or more selectors to match against.
init method @param options . acls An array that contains white listed origins @param options . secret A string or function used for authorization with Consumer @param options . onReady A function that will be called after App is authorized @param options . targetSelectors A DOMString containing one or more selectors to match against .
// Don't send messages if not embedded // Resize for slow loading images // Registers a mutation observer for body // Registers a listener to window.onresize // Optimizes the listener by debouncing (https://bencentra.com/code/2015/02/27/optimizing-window-resize.html#debouncing) // Resize event will be considered complete if no follow-up events within `interval` ms.