feat(editor): build standalone vocab-rank bundle for console

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
mwiegand 2026-05-17 17:41:24 +02:00
parent ca6a7aa74c
commit d8dd2d23d2
No known key found for this signature in database
3 changed files with 9 additions and 1 deletions

View file

@ -0,0 +1 @@
(()=>{function f(r,o){if(o===r)return 0;if(o.startsWith(r))return 1+o.length;let t=o.indexOf(r);return t!==-1?1e4+t:-1}function e(r,o,{limit:t=50}={}){if(!r)return[];let i=r.toLowerCase(),a=[...o.cvars.map(n=>({...n,kind:"cvar"})),...o.commands.map(n=>({...n,kind:"command"}))],s=[];for(let n of a){let c=f(i,n.name.toLowerCase());if(c!==-1&&(s.push([c,n]),s.length>t*4))break}return s.sort((n,c)=>n[0]-c[0]),s.slice(0,t).map(([,n])=>n)}window.__rankVocab=e;})();

View file

@ -5,7 +5,9 @@
"private": true,
"type": "module",
"scripts": {
"build": "esbuild editor-entry.js --bundle --minify --format=iife --global-name=__editor_pkg --outfile=../../l4d2web/static/vendor/editor.bundle.js --metafile=meta.json"
"build:editor": "esbuild editor-entry.js --bundle --minify --format=iife --global-name=__editor_pkg --outfile=../../l4d2web/static/vendor/editor.bundle.js --metafile=meta.json",
"build:vocab-rank": "esbuild vocab-rank-entry.js --bundle --minify --format=iife --outfile=../../l4d2web/static/vendor/vocab-rank.bundle.js",
"build": "npm run build:editor && npm run build:vocab-rank"
},
"devDependencies": {
"esbuild": "^0.24.0"

View file

@ -0,0 +1,5 @@
import { rankVocab } from "./vocab-rank.js";
// Expose as a global function so plain (non-module) scripts on
// server_detail.html can call window.__rankVocab(query, vocab).
window.__rankVocab = rankVocab;