refactor: standardize runtime guard patterns with lodash-es (#154)
* refactor(ui): replace runtime type guards with lodash-es predicates * refactor(runtime): migrate typeof checks to lodash-es in core modules * refactor(ipc): standardize runtime guards with lodash-es * test(refactor): align runtime guard checks with lodash-es * docs(agents): add lodash-es runtime guard skill summary
This commit is contained in:
33 files changed
+303
-208
No files matched your search
@@ -6,17 +6,18 @@ const injectCloudAccountsFailureScript = `
|
||||
(() => {
|
||||
const START_ORPC_SERVER = 'start-orpc-server';
|
||||
const originalPostMessage = window.postMessage.bind(window);
|
||||
const isStringValue = (value) => Object.prototype.toString.call(value) === '[object String]';
|
||||
|
||||
window.postMessage = function (message, targetOrigin, transfer) {
|
||||
if (message === START_ORPC_SERVER && Array.isArray(transfer) && transfer[0]) {
|
||||
const serverPort = transfer[0];
|
||||
if (typeof serverPort.start === 'function') {
|
||||
if (serverPort.start instanceof Function) {
|
||||
serverPort.start();
|
||||
}
|
||||
|
||||
serverPort.onmessage = (event) => {
|
||||
try {
|
||||
const request = typeof event.data === 'string' ? JSON.parse(event.data) : event.data;
|
||||
const request = isStringValue(event.data) ? JSON.parse(event.data) : event.data;
|
||||
const requestId = request && (request.i || request.id);
|
||||
const requestUrl = (request && request.p && request.p.u) || '';
|
||||
|
||||
|
||||
Reference in new issue
Block a user