UNPKG

gamelet-pixui-frame

Version:

pixui开发者框架

51 lines 1.55 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RPCArgProcessor = void 0; var utilities_1 = require("./utilities"); var RPCArgProcessor = /** @class */ (function () { function RPCArgProcessor() { } RPCArgProcessor.encode = function (arg, opcode, magic) { if (magic === void 0) { magic = 0; } var t = typeof (arg); if (t == 'object' && t == null) { return { argType: "null", argValue: null }; } if (t == 'function') { var uid = arg["___rpcFuncArgUID"]; if (uid == undefined) { uid = (0, utilities_1.generateUID)(magic); arg["___rpcFuncArgUID"] = uid; } return { argType: "function", argValue: { func: uid, opcode: opcode, }, }; } return { argType: t, argValue: arg }; }; RPCArgProcessor.decode = function (arg) { if (arg.argType == 'null') { return null; } if (arg.argType == 'undefined') { return undefined; } if (arg.argType == 'function') { throw new Error("rpc from sdk to window's arguments should not contain any function"); } return arg.argValue; }; return RPCArgProcessor; }()); exports.RPCArgProcessor = RPCArgProcessor; //# sourceMappingURL=rpc_arg_processor.js.map