Fix cache and merge issues
This commit is contained in:
parent
305b47132c
commit
48dc8c78b4
@ -769,8 +769,10 @@ define([
|
|||||||
var postMsg, worker;
|
var postMsg, worker;
|
||||||
Nthen(function (waitFor2) {
|
Nthen(function (waitFor2) {
|
||||||
if (SharedWorker) {
|
if (SharedWorker) {
|
||||||
worker = new SharedWorker('/common/outer/sharedworker.js' + urlArgs);
|
worker = new SharedWorker('/common/outer/sharedworker.js?' + urlArgs);
|
||||||
console.log(worker);
|
worker.onerror = function (e) {
|
||||||
|
console.error(e);
|
||||||
|
};
|
||||||
worker.port.onmessage = function (ev) {
|
worker.port.onmessage = function (ev) {
|
||||||
if (ev.data === "SW_READY") {
|
if (ev.data === "SW_READY") {
|
||||||
return;
|
return;
|
||||||
@ -789,7 +791,7 @@ define([
|
|||||||
if (worker) { return void worker.postMessage(data); }
|
if (worker) { return void worker.postMessage(data); }
|
||||||
};
|
};
|
||||||
|
|
||||||
navigator.serviceWorker.register('/common/outer/serviceworker.js' + urlArgs, {scope: '/'})
|
navigator.serviceWorker.register('/common/outer/serviceworker.js?' + urlArgs, {scope: '/'})
|
||||||
.then(function(reg) {
|
.then(function(reg) {
|
||||||
// Add handler for receiving messages from the service worker
|
// Add handler for receiving messages from the service worker
|
||||||
navigator.serviceWorker.addEventListener('message', function (ev) {
|
navigator.serviceWorker.addEventListener('message', function (ev) {
|
||||||
@ -829,7 +831,7 @@ define([
|
|||||||
/**/console.log('Registration failed with ' + error);
|
/**/console.log('Registration failed with ' + error);
|
||||||
});
|
});
|
||||||
} else if (Worker) {
|
} else if (Worker) {
|
||||||
worker = new Worker('/common/outer/webworker.js' + urlArgs);
|
worker = new Worker('/common/outer/webworker.js?' + urlArgs);
|
||||||
worker.onmessage = function (ev) {
|
worker.onmessage = function (ev) {
|
||||||
msgEv.fire(ev);
|
msgEv.fire(ev);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1049,7 +1049,7 @@ define([
|
|||||||
channel.queue.forEach(function (data) {
|
channel.queue.forEach(function (data) {
|
||||||
channel.sendMessage(data.message, clientId);
|
channel.sendMessage(data.message, clientId);
|
||||||
});
|
});
|
||||||
postMessage("PAD_CONNECT", {
|
channel.bcast("PAD_CONNECT", {
|
||||||
myID: wc.myID,
|
myID: wc.myID,
|
||||||
id: wc.id,
|
id: wc.id,
|
||||||
members: wc.members
|
members: wc.members
|
||||||
|
|||||||
@ -1,22 +1,5 @@
|
|||||||
/* 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 = {
|
||||||
@ -24,17 +7,22 @@ localStorage = {
|
|||||||
getItem: function (k) { return localStorage[k]; }
|
getItem: function (k) { return localStorage[k]; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
self.tabs = {};
|
||||||
|
|
||||||
var postMsg = function (client, data) {
|
var postMsg = function (client, data) {
|
||||||
client.postMessage(data);
|
client.postMessage(data);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
var debug = function (msg) { console.log(msg); };
|
var debug = function (msg) { console.log(msg); };
|
||||||
// debug = function () {};
|
// debug = function () {};
|
||||||
|
|
||||||
var init = function (client, cb) {
|
var init = function (client, cb) {
|
||||||
debug('SW INIT');
|
debug('SW INIT');
|
||||||
|
|
||||||
|
require([
|
||||||
|
'/common/requireconfig.js'
|
||||||
|
], function (RequireConfig) {
|
||||||
|
require.config(RequireConfig());
|
||||||
require([
|
require([
|
||||||
'/common/common-util.js',
|
'/common/common-util.js',
|
||||||
'/common/outer/worker-channel.js',
|
'/common/outer/worker-channel.js',
|
||||||
@ -138,9 +126,9 @@ var init = function (client, cb) {
|
|||||||
|
|
||||||
self.tabs[client.id].msgEv = msgEv;
|
self.tabs[client.id].msgEv = msgEv;
|
||||||
});
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
self.tabs = {};
|
|
||||||
self.addEventListener('message', function (e) {
|
self.addEventListener('message', function (e) {
|
||||||
var cId = e.source.id;
|
var cId = e.source.id;
|
||||||
if (e.data === "INIT") {
|
if (e.data === "INIT") {
|
||||||
|
|||||||
@ -1,23 +1,5 @@
|
|||||||
console.log('SW!');
|
|
||||||
/* 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 = {
|
||||||
@ -26,16 +8,6 @@ localStorage = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
self.tabs = {};
|
self.tabs = {};
|
||||||
var findTab = function (port) {
|
|
||||||
var tab;
|
|
||||||
Object.keys(self.tabs).some(function (id) {
|
|
||||||
if (self.tabs[id].port === port) {
|
|
||||||
tab = port;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return tab;
|
|
||||||
};
|
|
||||||
|
|
||||||
var postMsg = function (client, data) {
|
var postMsg = function (client, data) {
|
||||||
client.port.postMessage(data);
|
client.port.postMessage(data);
|
||||||
@ -47,6 +19,10 @@ var debug = function (msg) { console.log(msg); };
|
|||||||
var init = function (client, cb) {
|
var init = function (client, cb) {
|
||||||
debug('SharedW INIT');
|
debug('SharedW INIT');
|
||||||
|
|
||||||
|
require([
|
||||||
|
'/common/requireconfig.js'
|
||||||
|
], function (RequireConfig) {
|
||||||
|
require.config(RequireConfig());
|
||||||
require([
|
require([
|
||||||
'/common/common-util.js',
|
'/common/common-util.js',
|
||||||
'/common/outer/worker-channel.js',
|
'/common/outer/worker-channel.js',
|
||||||
@ -152,10 +128,11 @@ var init = function (client, cb) {
|
|||||||
|
|
||||||
client.msgEv = msgEv;
|
client.msgEv = msgEv;
|
||||||
});
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
onconnect = function(e) {
|
onconnect = function(e) {
|
||||||
debug('New ShardWorker client');
|
debug('New SharedWorker client');
|
||||||
var port = e.ports[0];
|
var port = e.ports[0];
|
||||||
var cId = Number(Math.floor(Math.random() * Number.MAX_SAFE_INTEGER))
|
var cId = Number(Math.floor(Math.random() * Number.MAX_SAFE_INTEGER))
|
||||||
var client = self.tabs[cId] = {
|
var client = self.tabs[cId] = {
|
||||||
@ -176,29 +153,3 @@ onconnect = function(e) {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
self.tabs = {};
|
|
||||||
self.addEventListener('message', function (e) {
|
|
||||||
var cId = e.source.id;
|
|
||||||
if (e.data === "INIT") {
|
|
||||||
if (tabs[cId]) { return; }
|
|
||||||
tabs[cId] = {
|
|
||||||
client: e.source
|
|
||||||
};
|
|
||||||
init(e.source, function () {
|
|
||||||
postMsg(e.source, 'SW_READY');
|
|
||||||
});
|
|
||||||
} else if (self.tabs[cId] && self.tabs[cId].msgEv) {
|
|
||||||
self.tabs[cId].msgEv.fire(e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
self.addEventListener('install', function (e) {
|
|
||||||
debug('V1 installing…');
|
|
||||||
self.skipWaiting();
|
|
||||||
});
|
|
||||||
|
|
||||||
self.addEventListener('activate', function (e) {
|
|
||||||
debug('V1 now ready to handle fetches!');
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user