extension: add runtime/routes.html

This commit is contained in:
Omar Rizwan 2021-04-22 17:23:05 -07:00
parent e404d44985
commit 4ed3736a61

View file

@ -613,9 +613,33 @@ Routes["/runtime/background.js"] = {
} }
}; };
Routes["/runtime/routes.html"] = routeWithContents(async () => {
return `
<html>
<body>
<dl>
${Object.entries(Routes).map(([path, {usage}]) => {
const usages = usage ? (Array.isArray(usage) ? usage : [usage]) : [];
return `
<dt>${path}</dt>
<dd>Usage:
<ul>
${usages.map(u => `<li>${u}</li>`).join('\n')}
</ul>
</dd>
`;
}).join('\n')}
</dl>
</body>
</html>
`;
});
Routes["/runtime/background.js.html"] = routeWithContents(async () => { Routes["/runtime/background.js.html"] = routeWithContents(async () => {
// WIP
const classes = [ const classes = [
[/Routes\["[^\]]+"\] = /, 'route'] [/Routes\["[^\]]+"\] = /, 'route'],
[/usage:/, 'usage']
]; ];
const js = await window.backgroundJS; const js = await window.backgroundJS;
@ -645,12 +669,6 @@ Routes["/runtime/background.js.html"] = routeWithContents(async () => {
</style> </style>
</head> </head>
<body> <body>
<!-- <dl>
${Object.entries(Routes).map(([a, b]) => `
<dt>${a}</dt>
<dd>${b}</dd>
`).join('\n')}
</dl> -->
<pre><code>${classedJs}</code></pre> <pre><code>${classedJs}</code></pre>
<script> <script>
@ -658,7 +676,7 @@ Routes["/runtime/background.js.html"] = routeWithContents(async () => {
function render() { function render() {
let y = 0; let y = 0;
for (let line of lines) { for (let line of lines) {
if (line.classList.contains('route') || line.dataset.expand == 'true') { if (line.classList.contains('route') || line.classList.contains('usage')) {
line.style.height = '15px'; line.style.height = '15px';
line.style.transform = 'translate(0px, ' + y + 'px)'; line.style.transform = 'translate(0px, ' + y + 'px)';
y += 15; y += 15;