diff --git a/CHANGELOG.md b/CHANGELOG.md index e2808811..b13f7e65 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - bug fixes - modal: display issue when a modal receives the same value mutliple times - patchbay: `outputs` property not handling object value properly + - server: resolution conflict between app files and user files - widgets - patchbay: trigger `onValue` script when a connection changes diff --git a/src/client/ipc/callbacks.js b/src/client/ipc/callbacks.js index 5467d722..10fe5095 100644 --- a/src/client/ipc/callbacks.js +++ b/src/client/ipc/callbacks.js @@ -90,7 +90,7 @@ module.exports = { }, reloadCss: function(){ - var queryString = '?reload=' + Date.now() + var queryString = '?__OSC_ASSET__=1&reload=' + Date.now() DOM.each(document, 'link[rel="stylesheet"][hot-reload]', (el)=>{ el.href = el.href.replace(/\?.*|$/, queryString) }) diff --git a/src/html/client.html b/src/html/client.html index d27c1038..d678dd03 100644 --- a/src/html/client.html +++ b/src/html/client.html @@ -6,14 +6,14 @@ - - - - - - - - + + + + + + + + diff --git a/src/html/launcher.html b/src/html/launcher.html index 60f6e86b..c532ab62 100644 --- a/src/html/launcher.html +++ b/src/html/launcher.html @@ -2,10 +2,10 @@ - - - - + + + + diff --git a/src/server/server.js b/src/server/server.js index a5145ccc..af81b6d5 100644 --- a/src/server/server.js +++ b/src/server/server.js @@ -48,13 +48,7 @@ function resolvePath(url, clientId) { var sessionPath - if (!ipc.clients[clientId]) { - // safari seems to be picky with cookies - if (clientId === undefined) console.error(`(ERROR, HTTP) Could not resolve requested url ${url} (client id not found in http cookies)`) - // this should never happen, but just in case... - // it happens when importing css file from theme - else if (debug) console.log(`(DEBUG, HTTP) Requested url ${url} not resolved against session path (unregistered client id ${clientId})`) - } else { + if (ipc.clients[clientId]) { sessionPath = path.dirname(ipc.clients[clientId].sessionPath) } @@ -68,6 +62,14 @@ function resolvePath(url, clientId) { if (fs.existsSync(p)) return p } + if (debug && !ipc.clients[clientId]) { + // safari seems to be picky with cookies + if (clientId === undefined) console.log(`(DEBUG, HTTP) Could not resolve requested url ${url} (client id not found in http cookies)`) + // this should never happen, but just in case... + // it happens when importing css file from theme + else console.log(`(DEBUG, HTTP) Requested url ${url} not resolved against session path (unregistered client id ${clientId})`) + } + return false } @@ -97,35 +99,42 @@ function httpRoute(req, res) { // res.sendFile(path.resolve(__dirname + '/../client/index.html')) - } else { - if (url.indexOf('__APP__/theme.css') != -1) { + if (url.indexOf('__OSC_ASSET__=1') != -1) { - res.setHeader('Content-Type', 'text/css') - if (settings.read('theme')) { - var str = theme.get(), + // osc asset files + + if (url.indexOf('theme.css') != -1) { + + res.setHeader('Content-Type', 'text/css') + if (settings.read('theme')) { + var str = theme.get(), buf = Buffer.from && Buffer.from !== Uint8Array.from ? Buffer.from(str) : new Buffer(str) - res.write(buf) + res.write(buf) + } else { + res.write('') + } + res.end() + } else { - res.write('') + + if (prod) res.setHeader('Cache-Control', 'public, max-age=2592000') + try { + res.sendFile(path.resolve(__dirname + '/../' + url)) + return true + } catch(e) {} + + console.error(`(ERROR, HTTP) File not found: ${url}`) + res.writeHead(404) + res.end() + } - res.end() - - } else if (/^\/__APP__\//.test(url)){ - - if (prod) res.setHeader('Cache-Control', 'public, max-age=2592000') - try { - res.sendFile(path.resolve(__dirname + '/..' + url.replace('__APP__', ''))) - return true - } catch(e) {} - - console.error(`(ERROR, HTTP) File not found: ${url}`) - res.writeHead(404) - res.end() } else { + // user files + // windows absolute path fix url = url.replace('_:_', ':') // escaped drive colon url = url.replace(/^\/([^/]*:)/, '$1') // strip leading slash