forked from zhengguorong/suzyApp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
郑国榕
committed
Aug 2, 2016
1 parent
f9572d4
commit cb2490d
Showing
23 changed files
with
85,908 additions
and
123 deletions.
There are no files selected for viewing
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
/* global __fbBatchedBridge, self, importScripts, postMessage, onmessage: true */ | ||
/* eslint no-unused-vars: 0 */ | ||
'use strict'; | ||
|
||
var messageHandlers = { | ||
'executeApplicationScript': function(message, sendReply) { | ||
for (var key in message.inject) { | ||
self[key] = JSON.parse(message.inject[key]); | ||
} | ||
importScripts(message.url); | ||
sendReply(); | ||
} | ||
}; | ||
|
||
onmessage = function(message) { | ||
var object = message.data; | ||
|
||
var sendReply = function(result) { | ||
postMessage({replyID: object.id, result: result}); | ||
}; | ||
|
||
var handler = messageHandlers[object.method]; | ||
if (handler) { | ||
// Special cased handlers | ||
handler(object, sendReply); | ||
} else { | ||
// Other methods get called on the bridge | ||
var returnValue = [[], [], [], 0]; | ||
try { | ||
if (typeof __fbBatchedBridge === 'object') { | ||
returnValue = __fbBatchedBridge[object.method].apply(null, object.arguments); | ||
} | ||
} finally { | ||
sendReply(JSON.stringify(returnValue)); | ||
} | ||
} | ||
}; |
Oops, something went wrong.