mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-02-15 09:16:35 +08:00
Enable HMR
Reviewed By: svcscm Differential Revision: D2932137 fb-gh-sync-id: 8bfab09aaac22ae498ac4fa896eee495111abc0d shipit-source-id: 8bfab09aaac22ae498ac4fa896eee495111abc0d
This commit is contained in:
committed by
facebook-github-bot-4
parent
8eddead868
commit
e018aa3100
@@ -59,6 +59,13 @@ static JSValueRef nativePerformanceNow(
|
||||
size_t argumentCount,
|
||||
const JSValueRef arguments[],
|
||||
JSValueRef *exception);
|
||||
static JSValueRef nativeInjectHMRUpdate(
|
||||
JSContextRef ctx,
|
||||
JSObjectRef function,
|
||||
JSObjectRef thisObject,
|
||||
size_t argumentCount,
|
||||
const JSValueRef arguments[],
|
||||
JSValueRef *exception);
|
||||
|
||||
static std::string executeJSCallWithJSC(
|
||||
JSGlobalContextRef ctx,
|
||||
@@ -93,6 +100,7 @@ JSCExecutor::JSCExecutor(FlushImmediateCallback cb, const std::string& cacheDir)
|
||||
installGlobalFunction(m_context, "nativeStartWorker", nativeStartWorker);
|
||||
installGlobalFunction(m_context, "nativePostMessageToWorker", nativePostMessageToWorker);
|
||||
installGlobalFunction(m_context, "nativeTerminateWorker", nativeTerminateWorker);
|
||||
installGlobalFunction(m_context, "nativeInjectHMRUpdate", nativeInjectHMRUpdate);
|
||||
|
||||
installGlobalFunction(m_context, "nativeLoggingHook", JSLogging::nativeHook);
|
||||
|
||||
@@ -140,7 +148,7 @@ void JSCExecutor::executeApplicationScript(
|
||||
if (!jsSourceURL) {
|
||||
evaluateScript(m_context, jsScript, jsSourceURL);
|
||||
} else {
|
||||
// If we're evaluating a script, get the device's cache dir
|
||||
// If we're evaluating a script, get the device's cache dir
|
||||
// in which a cache file for that script will be stored.
|
||||
evaluateScript(m_context, jsScript, jsSourceURL, m_deviceCacheDir.c_str());
|
||||
}
|
||||
@@ -471,4 +479,16 @@ static JSValueRef nativePerformanceNow(
|
||||
return JSValueMakeNumber(ctx, (nano / (double)NANOSECONDS_IN_MILLISECOND));
|
||||
}
|
||||
|
||||
static JSValueRef nativeInjectHMRUpdate(
|
||||
JSContextRef ctx,
|
||||
JSObjectRef function,
|
||||
JSObjectRef thisObject,
|
||||
size_t argumentCount,
|
||||
const JSValueRef arguments[], JSValueRef *exception) {
|
||||
String execJSString = Value(ctx, arguments[0]).toString();
|
||||
String jsURL = Value(ctx, arguments[1]).toString();
|
||||
evaluateScript(ctx, execJSString, jsURL);
|
||||
return JSValueMakeUndefined(ctx);
|
||||
}
|
||||
|
||||
} }
|
||||
|
||||
Reference in New Issue
Block a user