diff --git a/extension/background.js b/extension/background.js index f140ee9..aa7a4de 100644 --- a/extension/background.js +++ b/extension/background.js @@ -659,35 +659,22 @@ Routes["/runtime/reload"] = { }); })(); -// added at first to make development on Safari less painful: Safari -// normally requires you to recompile the whole Xcode project to -// deploy any update to background.js. -Routes["/runtime/background.js"] = { - usage: '', - ...makeRouteWithContents( - async () => { - // `window.backgroundJS` is (a Promise of) the source code of - // the file you're reading right now! - return window.backgroundJS; - }, - async ({}, buf) => { window.backgroundJS = buf; } - ), - async release({fh}) { - // Note that we eval on release, not on write. - eval(await window.backgroundJS); - // TODO: would be better if we could call 'super'.release() so - // we wouldn't need to involve how Cache works here. - makeRouteWithContents.Cache.removeObjectForHandle(fh); - return {}; - } -}; - Routes["/runtime/routes.html"] = makeRouteWithContents(async () => { // WIP const jsLines = (await window.backgroundJS).split('\n'); - function findRouteLineNumber(path) { + function findRouteLineRange(path) { + console.log('frlr', path); for (let i = 0; i < jsLines.length; i++) { - if (jsLines[i].includes(path)) { return i + 1; } + if (jsLines[i].includes(`Routes["${path}"] = `)) { return [ + i + 1, // + 1 because GitHub line numbers are 1-indexed + (function() { + // TODO: + // find the first bracket on that line after the = + // walk forward until we find the corresponding match for it + // that's the last line? + return i + 2; + })() + ]; } } } return ` @@ -697,19 +684,24 @@ Routes["/runtime/routes.html"] = makeRouteWithContents(async () => {
${jsLines[lineRange[0] - 1]}+
(very work in progress)
- -${classedJs}
-
-
- @@ -717,72 +709,6 @@ Routes["/runtime/routes.html"] = makeRouteWithContents(async () => { `; }); -Routes["/runtime/background.js.html"] = makeRouteWithContents(async () => { - // WIP - const classes = [ - [/Routes\["[^\]]+"\] = /, 'route'], - [/usage:/, 'usage'], - [/description:/, 'description'] - ]; - - const js = await window.backgroundJS; - const classedJs = - js.split('\n') - .map((line, i) => { - const class_ = classes.find(([re, class_]) => re.test(line)); - line = line - .replace(/&/g, "&") - .replace(//g, ">") - .replace(/"/g, """) - .replace(/'/g, "'"); - if (!class_) { return `
`; } - return `
`; - }) - .join(''); - - return ` - -
- - -
-