|
|
@ -1,63 +1,52 @@
|
|
|
|
/* jshint ignore:start */
|
|
|
|
/* jshint ignore:start */
|
|
|
|
importScripts('/bower_components/requirejs/require.js');
|
|
|
|
importScripts('/bower_components/requirejs/require.js');
|
|
|
|
require.config({
|
|
|
|
|
|
|
|
// fix up locations so that relative urls work.
|
|
|
|
|
|
|
|
baseUrl: '/',
|
|
|
|
|
|
|
|
paths: {
|
|
|
|
|
|
|
|
// jquery declares itself as literally "jquery" so it cannot be pulled by path :(
|
|
|
|
|
|
|
|
"jquery": "/bower_components/jquery/dist/jquery.min",
|
|
|
|
|
|
|
|
// json.sortify same
|
|
|
|
|
|
|
|
"json.sortify": "/bower_components/json.sortify/dist/JSON.sortify",
|
|
|
|
|
|
|
|
cm: '/bower_components/codemirror'
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
map: {
|
|
|
|
|
|
|
|
'*': {
|
|
|
|
|
|
|
|
'css': '/bower_components/require-css/css.js',
|
|
|
|
|
|
|
|
'less': '/common/RequireLess.js',
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
window = self;
|
|
|
|
window = self;
|
|
|
|
localStorage = {
|
|
|
|
localStorage = {
|
|
|
|
setItem: function (k, v) { localStorage[k] = v; },
|
|
|
|
setItem: function (k, v) { localStorage[k] = v; },
|
|
|
|
getItem: function (k) { return localStorage[k]; }
|
|
|
|
getItem: function (k) { return localStorage[k]; }
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
require([
|
|
|
|
require([
|
|
|
|
'/common/common-util.js',
|
|
|
|
'/common/requireconfig.js'
|
|
|
|
'/common/outer/worker-channel.js',
|
|
|
|
], function (RequireConfig) {
|
|
|
|
'/common/outer/store-rpc.js'
|
|
|
|
require.config(RequireConfig());
|
|
|
|
], function (Util, Channel, Rpc) {
|
|
|
|
require([
|
|
|
|
var msgEv = Util.mkEvent();
|
|
|
|
'/common/common-util.js',
|
|
|
|
|
|
|
|
'/common/outer/worker-channel.js',
|
|
|
|
|
|
|
|
'/common/outer/store-rpc.js'
|
|
|
|
|
|
|
|
], function (Util, Channel, Rpc) {
|
|
|
|
|
|
|
|
var msgEv = Util.mkEvent();
|
|
|
|
|
|
|
|
|
|
|
|
Channel.create(msgEv, postMessage, function (chan) {
|
|
|
|
Channel.create(msgEv, postMessage, function (chan) {
|
|
|
|
console.log('ww ready');
|
|
|
|
console.log('ww ready');
|
|
|
|
Object.keys(Rpc.queries).forEach(function (q) {
|
|
|
|
Object.keys(Rpc.queries).forEach(function (q) {
|
|
|
|
if (q === 'CONNECT') { return; }
|
|
|
|
if (q === 'CONNECT') { return; }
|
|
|
|
chan.on(q, function (data, cb) {
|
|
|
|
chan.on(q, function (data, cb) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Rpc.queries[q](data, cb);
|
|
|
|
Rpc.queries[q](data, cb);
|
|
|
|
} catch (e) {
|
|
|
|
} catch (e) {
|
|
|
|
console.error('Error in webworker when executing query ' + q);
|
|
|
|
console.error('Error in webworker when executing query ' + q);
|
|
|
|
console.error(e);
|
|
|
|
console.error(e);
|
|
|
|
console.log(data);
|
|
|
|
console.log(data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
chan.on('CONNECT', function (cfg, cb) {
|
|
|
|
|
|
|
|
console.log('onConnect');
|
|
|
|
|
|
|
|
// load Store here, with cfg, and pass a "query" (chan.query)
|
|
|
|
|
|
|
|
cfg.query = function (cmd, data, cb) {
|
|
|
|
|
|
|
|
chan.query(cmd, data, function (err, data) {
|
|
|
|
|
|
|
|
if (err) { return void cb({error: err}); }
|
|
|
|
|
|
|
|
cb(data);
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
});
|
|
|
|
Rpc.queries['CONNECT'](cfg, cb);
|
|
|
|
chan.on('CONNECT', function (cfg, cb) {
|
|
|
|
});
|
|
|
|
console.log('onConnect');
|
|
|
|
}, true);
|
|
|
|
// load Store here, with cfg, and pass a "query" (chan.query)
|
|
|
|
|
|
|
|
cfg.query = function (cmd, data, cb) {
|
|
|
|
|
|
|
|
chan.query(cmd, data, function (err, data) {
|
|
|
|
|
|
|
|
if (err) { return void cb({error: err}); }
|
|
|
|
|
|
|
|
cb(data);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
Rpc.queries['CONNECT'](cfg, cb);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}, true);
|
|
|
|
|
|
|
|
|
|
|
|
onmessage = function (e) {
|
|
|
|
onmessage = function (e) {
|
|
|
|
msgEv.fire(e);
|
|
|
|
msgEv.fire(e);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|