diff --git a/www/common/inner/cache.js b/www/common/inner/cache.js index 7db9635b4..be5b781c2 100644 --- a/www/common/inner/cache.js +++ b/www/common/inner/cache.js @@ -8,19 +8,17 @@ define([ var e = err || (data && data.error); if (e) { return void cb(e); } if (!data || typeof(data) !== "object") { return void cb('EINVAL'); } - var u8 = Uint8Array.from(data); - cb(null, u8); - }); + cb(null, data); + }, { raw: true }); }; var setBlobCache = function (id, u8, cb) { - var array = [].slice.call(u8); sframeChan.query('Q_SET_BLOB_CACHE', { id: id, - u8: array + u8: u8 }, function (err, data) { var e = err || (data && data.error) || undefined; cb(e); - }); + }, { raw: true }); }; diff --git a/www/common/media-tag.js b/www/common/media-tag.js index e391a2530..c855df328 100644 --- a/www/common/media-tag.js +++ b/www/common/media-tag.js @@ -591,7 +591,7 @@ var factory = function () { var getCache = function () { var c = cache[uid]; - if (!c || !c.promise || !c.mt) { console.error(uid);return; } + if (!c || !c.promise || !c.mt) { return; } return c; }; diff --git a/www/common/outer/worker-channel.js b/www/common/outer/worker-channel.js index 545ce435b..a359d8836 100644 --- a/www/common/outer/worker-channel.js +++ b/www/common/outer/worker-channel.js @@ -65,11 +65,13 @@ define([ cb(undefined, data.content, msg); }; evReady.reg(function () { - postMsg(JSON.stringify({ + var toSend = { txid: txid, content: content, - q: q - })); + q: q, + raw: opts.raw + }; + postMsg(opts.raw ? toSend : JSON.stringify(toSend)); }); }; @@ -84,12 +86,13 @@ define([ // If the type is a query, your handler will be invoked with a reply function that takes // one argument (the content to reply with). chan.on = function (queryType, handler, quiet) { - var h = function (data, msg) { + var h = function (data, msg, raw) { handler(data.content, function (replyContent) { - postMsg(JSON.stringify({ + var toSend = { txid: data.txid, content: replyContent - })); + }; + postMsg(raw ? toSend : JSON.stringify(toSend)); }, msg); }; (handlers[queryType] = handlers[queryType] || []).push(h); @@ -150,7 +153,7 @@ define([ onMsg.reg(function (msg) { if (!chanLoaded) { return; } if (!msg.data || msg.data === '_READY') { return; } - var data = JSON.parse(msg.data); + var data = typeof(msg.data) === "object" ? msg.data : JSON.parse(msg.data); if (typeof(data.ack) !== "undefined") { if (acks[data.txid]) { acks[data.txid](!data.ack); } } else if (typeof(data.q) === 'string') { @@ -163,7 +166,7 @@ define([ })); } handlers[data.q].forEach(function (f) { - f(data || JSON.parse(msg.data), msg); + f(data || JSON.parse(msg.data), msg, data && data.raw); data = undefined; }); } else { diff --git a/www/common/sframe-common-outer.js b/www/common/sframe-common-outer.js index 49d52c37b..e43c169ed 100644 --- a/www/common/sframe-common-outer.js +++ b/www/common/sframe-common-outer.js @@ -683,15 +683,12 @@ define([ sframeChan.on('Q_GET_BLOB_CACHE', function (data, cb) { Utils.Cache.getBlobCache(data.id, function (err, obj) { if (err) { return void cb({error: err}); } - var arr = [].slice.call(obj); - cb(arr); + cb(obj); }); }); sframeChan.on('Q_SET_BLOB_CACHE', function (data, cb) { if (!data || !data.u8 || typeof(data.u8) !== "object") { return void cb({error: 'EINVAL'}); } - var arr = data.u8; - var u8 = Uint8Array.from(arr); - Utils.Cache.setBlobCache(data.id, u8, function (err) { + Utils.Cache.setBlobCache(data.id, data.u8, function (err) { if (err) { return void cb({error: err}); } cb(); }); diff --git a/www/secureiframe/main.js b/www/secureiframe/main.js index 1bf5e3e7b..62175c5a0 100644 --- a/www/secureiframe/main.js +++ b/www/secureiframe/main.js @@ -33,7 +33,7 @@ define([ // loading screen setup. var done = waitFor(); var onMsg = function (msg) { - var data = JSON.parse(msg.data); + var data = typeof(msg.data) === "object" ? msg.data : JSON.parse(msg.data); if (data.q !== 'READY') { return; } window.removeEventListener('message', onMsg); var _done = done;