Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
instantiatePage() {
let component;
try {
const { document, evaluator } = this.driver;
let { factory } = getPage(this.pageName, this.raxInstance);
component = applyFactory(factory, {
page: this,
clientId: this.clientId,
pageName: this.pageName,
rax: this.raxInstance,
pageQuery: this.pageQuery,
document,
evaluator,
});
} catch (err) {
log('Instantite page with error, catch and show error page.');
console.error(err);
component = applyFactory(getUnknownPageFactory(this.raxInstance, '加载出现了错误'));
}
return component;
}
if (!params.replaceState) {
history.go(-delta);
return;
}
let prevClient = this.currentClient;
do {
prevClient = prevClient.prevClient;
} while (--delta && prevClient);
if (prevClient) {
this.currentClient.destroy();
this.currentClient = prevClient;
this.currentClient.show();
} else {
log('No prev page at all.');
}
this.notifyListeners();
}
eventHandler = (evt) => {
/**
* Message:
* { type: String, target: String, ...others }
*/
const { data } = evt;
if (!data) {
log('Receive illegal data', evt);
return;
}
const { target, payload } = data;
if (target === 'AppWorker') {
this._worker.postMessage(data);
} else if (target === 'AppContainer') {
this.handleMessageFromWorker(payload);
} else if (this._channels[target]) {
this._channels[target].onmessage(payload);
} else {
this.defaultHandler(data);
}
}
}
onmessage() {
log(`w->r@${clientId}`, 'Unexpected handler of message.');
},
};
this._tabbar[method](params);
this.callbackRemoteCall(callId, null, null);
break;
default:
const resolveCallback = (result) => {
this.callbackRemoteCall(callId, null, result);
};
const rejectCallback = (err) => {
this.callbackRemoteCall(callId, err, null);
};
if (my[method]) {
my[method](params, resolveCallback, rejectCallback);
} else {
log('WARN: API Module not exists or supported.');
}
}
}
* @Note: if navigateType is `navigate`, which means
* it is navigateTo, others are the right types.
*/
if (!navigateType || navigateType === 'navigate') navigateType = 'navigateTo';
my[navigateType]({ url: navigateTo });
break;
}
case EVENT_UPDATE_PAGEDATA: {
const client = getClient(payload.clientId);
client.emitEvent('updatePageData', payload.data);
break;
}
default:
log('Can not recognize message', data);
}
}