Merge branch 'master' into prettier
This commit is contained in:
@ -3,6 +3,10 @@ let g_api = {};
|
||||
let g_next_id = 1;
|
||||
let g_calls = {};
|
||||
|
||||
/**
|
||||
* TODOC
|
||||
* @returns
|
||||
*/
|
||||
function get_is_browser() {
|
||||
try {
|
||||
return window !== undefined && console !== undefined;
|
||||
@ -15,6 +19,13 @@ if (k_is_browser) {
|
||||
print = console.log;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODOC
|
||||
* @param {*} target
|
||||
* @param {*} prop
|
||||
* @param {*} receiver
|
||||
* @returns
|
||||
*/
|
||||
function make_rpc(target, prop, receiver) {
|
||||
return function () {
|
||||
let id = g_next_id++;
|
||||
@ -43,6 +54,10 @@ function make_rpc(target, prop, receiver) {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* TODOC
|
||||
* @param {*} response
|
||||
*/
|
||||
function send(response) {
|
||||
if (k_is_browser) {
|
||||
window.parent.postMessage(response, '*');
|
||||
@ -51,6 +66,10 @@ function send(response) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* TODOC
|
||||
* @param {*} message
|
||||
*/
|
||||
function call_rpc(message) {
|
||||
if (message && message.message === 'tfrpc') {
|
||||
let id = message.id;
|
||||
@ -105,6 +124,10 @@ if (k_is_browser) {
|
||||
|
||||
export let rpc = new Proxy({}, {get: make_rpc});
|
||||
|
||||
/**
|
||||
* TODOC
|
||||
* @param {*} method
|
||||
*/
|
||||
export function register(method) {
|
||||
g_api[method.name] = method;
|
||||
}
|
||||
|
Reference in New Issue
Block a user