Last active
February 8, 2023 06:25
Revisions
-
axemclion revised this gist
Sep 10, 2017 . 1 changed file with 14 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -28,8 +28,22 @@ export default { reverseModuleTable[name] = parseInt(id, 10); }); const oldGuard = __fbBatchedBridge.__guard; __fbBatchedBridge.__guard = (fn) => { this._inCall++; try { fn(); } catch (error) { console.log(error); } finally { this._inCall--; } } (function run(i) { if (i >= queue.length) { __fbBatchedBridge.__guard = oldGuard; return; } else { let action = queue[i]; -
axemclion revised this gist
Sep 7, 2017 . 1 changed file with 15 additions and 16 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,38 +10,29 @@ export default { MessageQueue.spy(msg => { if (msg.type === 1) { now = now || new Date().getTime(); queue.push({ ...msg, time: new Date().getTime() - now }); now = new Date().getTime(); } }); }, stop() { MessageQueue.spy(false); }, replay: (url = 'http://localhost:3000') => { // Setup replay table let reverseModuleTable = {}; Object.entries(__fbBatchedBridge._remoteModuleTable).forEach(([id, name]) => { reverseModuleTable[name] = parseInt(id, 10); }); (function run(i) { if (i >= queue.length) { return; } else { let action = queue[i]; let moduleId = reverseModuleTable[action.module] if (moduleId && WHITELIST.indexOf(action.module) !== -1) { @@ -58,6 +49,14 @@ export default { setTimeout(() => run(i + 1), action.time); } }(0)) }, upload: (url = 'http://localhost:3000') => fetch(url, { headers: { 'Content-Type': 'text/plain' }, method: 'POST', body: `[${queue.map(q => JSON.stringify(q)).join(',\n')}]` }), download: async (url = 'http://localhost:3000') => { let resp = await fetch(url); queue = await resp.json(); }, } -
axemclion created this gist
Sep 7, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,63 @@ import MessageQueue from 'react-native/Libraries/BatchedBridge/MessageQueue.js'; const WHITELIST = ['UIManager']; const NOOP = () => { }; let queue = []; let now = 0; export default { start() { MessageQueue.spy(msg => { if (msg.type === 1) { now = now || new Date().getTime(); queue.push(JSON.stringify({ ...msg, time: new Date().getTime() - now })); now = new Date().getTime(); } }); }, stop() { MessageQueue.spy(false); }, upload: (url = 'http://localhost:3000') => fetch(url, { headers: { 'Content-Type': 'text/plain' }, method: 'POST', body: `[${queue.join(',\n')}]` }), replay: async (url = 'http://localhost:3000') => { let resp = await fetch(url); let actions = await resp.json(); // Setup replay table let reverseModuleTable = {}; Object.entries(__fbBatchedBridge._remoteModuleTable).forEach(([id, name]) => { reverseModuleTable[name] = parseInt(id, 10); }); (function run(i) { if (i >= actions.length) { return; } else { let action = actions[i]; let moduleId = reverseModuleTable[action.module] if (moduleId && WHITELIST.indexOf(action.module) !== -1) { if (action.successCbId !== -1) { __fbBatchedBridge._successCallbacks[action.successCbId >>> 1] = NOOP; } __fbBatchedBridge.enqueueNativeCall( moduleId, __fbBatchedBridge._remoteMethodTable[moduleId].indexOf(action.method), action.args ); } setTimeout(() => run(i + 1), action.time); } }(0)) } }