mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Refactored bridge to support transferrables (e.g. typed array buffers) and added transferable param to postMessage for op codes
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
const chromeLaunch = require('chrome-launch'); // eslint-disable-line import/no-extraneous-dependencies
|
||||
const { resolve } = require('path');
|
||||
|
||||
const EXTENSION_PATH = resolve('shells/chrome/build/unpacked');
|
||||
const EXTENSION_PATH = resolve('shells/browser/chrome/build/unpacked');
|
||||
const START_URL = 'https://facebook.github.io/react/';
|
||||
|
||||
chromeLaunch(START_URL, {
|
||||
|
||||
@@ -4,7 +4,7 @@ const { exec } = require('child-process-promise');
|
||||
const { Finder } = require('firefox-profile');
|
||||
const { resolve } = require('path');
|
||||
|
||||
const EXTENSION_PATH = resolve('shells/firefox/build/unpacked');
|
||||
const EXTENSION_PATH = resolve('shells/browser/firefox/build/unpacked');
|
||||
const START_URL = 'https://facebook.github.io/react/';
|
||||
|
||||
const main = async () => {
|
||||
|
||||
@@ -42,13 +42,14 @@ function setup(hook) {
|
||||
listeners.push(listener);
|
||||
window.addEventListener('message', listener);
|
||||
},
|
||||
send(data) {
|
||||
send(event: string, payload: any, transferable?: Array<any>) {
|
||||
window.postMessage(
|
||||
{
|
||||
source: 'react-devtools-bridge',
|
||||
payload: data,
|
||||
payload: { event, payload },
|
||||
},
|
||||
'*'
|
||||
'*',
|
||||
transferable
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -50,11 +50,11 @@ inject(chrome.runtime.getURL('build/backend.js'), () => {
|
||||
listen(fn) {
|
||||
port.onMessage.addListener(message => fn(message));
|
||||
},
|
||||
send(data) {
|
||||
send(event: string, payload: any, transferable?: Array<any>) {
|
||||
if (disconnected) {
|
||||
return;
|
||||
}
|
||||
port.postMessage(data);
|
||||
port.postMessage({ event, payload }, transferable);
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user