function onmessage( e ) {
	debug( 'onmessage' );

	// safeguard...
	if ( e.origin !== proxyOrigin ) {
		debug( 'ignoring message... %o !== %o', e.origin, proxyOrigin );
		return;
	}

	let { data } = e;
	if ( ! data ) {
		return debug( 'no `data`, bailing' );
	}

	// Once the iframe is loaded, we can start using it.
	if ( data === 'ready' ) {
		onload();
		return;
	}

	if ( postStrings && 'string' === typeof data ) {
		data = JSON.parse( data );
	}

	// check if we're receiving a "progress" event
	if ( data.upload || data.download ) {
		return onprogress( data );
	}

	if ( ! data.length ) {
		return debug( '`e.data` doesn\'t appear to be an Array, bailing...' );
	}

	// first get the `xhr` instance that we're interested in
	const id = data[ data.length - 1 ];
	if ( ! ( id in requests ) ) {
		return debug( 'bailing, no matching request with callback: %o', id );
	}

	const xhr = requests[ id ];

	// Build `error` and `body` object from the `data` object
	const { params } = xhr;
	let body, statusCode, headers;

	// apiNamespace (WP-API)
	const { apiNamespace } = params;

	body = data[ 0 ];
	statusCode = data[ 1 ];
	headers = data[ 2 ];

	if ( statusCode === 207 ) {
		// 207 is a signal from rest-proxy. It means, "this isn't the final
		// response to the query." The proxy supports WebSocket connections
		// by invoking the original success callback for each message received.
	} else {
		// this is the final response to this query
		delete requests[ id ];
	}

	if ( ! params.metaAPI ) {
		debug( 'got %o status code for URL: %o', statusCode, params.path );
	} else {
		statusCode = body === 'metaAPIupdated' ? 200 : 500;
	}

	// add statusCode into headers object
	if ( typeof headers === 'object' ) {
		headers.status = statusCode;
	}

	if ( statusCode && 2 === Math.floor( statusCode / 100 ) ) {
		// 2xx status code, success
		resolve( xhr, body, headers );
	} else {
		// any other status code is a failure
		const wpe = WPError( params, statusCode, body );
		reject( xhr, wpe, headers );
	}
}
function onmessage( e ) {
	debug( 'onmessage' );

	
	if ( e.origin !== proxyOrigin ) {
		debug( 'ignoring message... %o !== %o', e.origin, proxyOrigin );
		return;
	}

	let { data } = e;
	if ( ! data ) {
		return debug( 'no `data`, bailing' );
	}

	
	if ( data === 'ready' ) {
		onload();
		return;
	}

	if ( postStrings && 'string' === typeof data ) {
		data = JSON.parse( data );
	}

	
	if ( data.upload || data.download ) {
		return onprogress( data );
	}

	if ( ! data.length ) {
		return debug( '`e.data` doesn\'t appear to be an Array, bailing...' );
	}

	
	const id = data[ data.length - 1 ];
	if ( ! ( id in requests ) ) {
		return debug( 'bailing, no matching request with callback: %o', id );
	}

	const xhr = requests[ id ];

	
	const { params } = xhr;
	let body, statusCode, headers;

	
	const { apiNamespace } = params;

	body = data[ 0 ];
	statusCode = data[ 1 ];
	headers = data[ 2 ];

	if ( statusCode === 207 ) {
		
		
		
	} else {
		
		delete requests[ id ];
	}

	if ( ! params.metaAPI ) {
		debug( 'got %o status code for URL: %o', statusCode, params.path );
	} else {
		statusCode = body === 'metaAPIupdated' ? 200 : 500;
	}

	
	if ( typeof headers === 'object' ) {
		headers.status = statusCode;
	}

	if ( statusCode && 2 === Math.floor( statusCode / 100 ) ) {
		
		resolve( xhr, body, headers );
	} else {
		
		const wpe = WPError( params, statusCode, body );
		reject( xhr, wpe, headers );
	}
}
function onmessage ( e ) { debug ( 'onmessage' ) ; // safeguard... if ( e . origin !== proxyOrigin ) { debug ( 'ignoring message... %o !== %o' , e . origin , proxyOrigin ) ; return ; } let { data } = e ; if ( ! data ) { return debug ( 'no `data`, bailing' ) ; } // Once the iframe is loaded, we can start using it. if ( data === 'ready' ) { onload ( ) ; return ; } if ( postStrings && 'string' === typeof data ) { data = JSON . parse ( data ) ; } // check if we're receiving a "progress" event if ( data . upload || data . download ) { return onprogress ( data ) ; } if ( ! data . length ) { return debug ( '`e.data` doesn\'t appear to be an Array, bailing...' ) ; } // first get the `xhr` instance that we're interested in const id = data [ data . length - 1 ] ; if ( ! ( id in requests ) ) { return debug ( 'bailing, no matching request with callback: %o' , id ) ; } const xhr = requests [ id ] ; // Build `error` and `body` object from the `data` object const { params } = xhr ; let body , statusCode , headers ; // apiNamespace (WP-API) const { apiNamespace } = params ; body = data [ 0 ] ; statusCode = data [ 1 ] ; headers = data [ 2 ] ; if ( statusCode === 207 ) { // 207 is a signal from rest-proxy. It means, "this isn't the final // response to the query." The proxy supports WebSocket connections // by invoking the original success callback for each message received. } else { // this is the final response to this query delete requests [ id ] ; } if ( ! params . metaAPI ) { debug ( 'got %o status code for URL: %o' , statusCode , params . path ) ; } else { statusCode = body === 'metaAPIupdated' ? 200 : 500 ; } // add statusCode into headers object if ( typeof headers === 'object' ) { headers . status = statusCode ; } if ( statusCode && 2 === Math . floor ( statusCode / 100 ) ) { // 2xx status code, success resolve ( xhr , body , headers ) ; } else { // any other status code is a failure const wpe = WPError ( params , statusCode , body ) ; reject ( xhr , wpe , headers ) ; } }
The main `window` object's "message" event callback function.

@param {Event} e
@api private
The main window object s message event callback function .