Elffuss BraidHub

utopia-ia/elffuss-code public

Extensions: say in plain words what each one does here, and show it after installing

Before installing, every search result gets a one-line verdict read from
its package.json: works, partly works (button names what you get), or its
main feature needs its own code (Install disabled, and only promises the
next version when the code could run in a browser without its own
windows). After installing, a notice says what changed and where: a
theme-only extension is applied with Undo and Choose theme, open files
are highlighted at once with Go to, language settings are spelled out,
snippets show their count, prefixes and Try in. The Installed list says
what each extension is doing right now. Code-only .vsix files are no
longer installed. No internal terms in any panel text.
Changesete0009187e422ebbd1c18f1176decfa8090bcb9694c92bace5d23d0dddb217727
AuthorKikoCis <kikocisneros@gmail.com> · 2026-10-12 11:45 +02:00
CommitterKikoCis <kikocisneros@gmail.com> · 2026-10-12 11:45 +02:00
Parents901cc036b9a2

Browse the files at this changeset

8 files changed

modified web/css/ext.css +22 −5
@@ -20,7 +20,7 @@
2020 /* vacío sigue en la página (región viva), pero sin ocupar sitio */
2121 .ext-msg:empty { margin: 0; padding: 0; border: 0; }
2222 /* solo para lectores de pantalla */
23-.ext-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
23+.ext-msg.ext-msg-sr, .ext-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
2424 .ext-hint { font-size: .78rem; margin: 10px 0 2px; }
2525 .ext-results, .ext-installed { margin-top: 4px; }
2626 .ext-row { display: flex; align-items: flex-start; gap: 10px; padding: 9px 10px; background: var(--bg3); border: 1px solid var(--line); border-radius: 9px; margin-bottom: 6px; font-size: .8rem; }
@@ -42,8 +42,24 @@
4242 .ext-meta a { color: var(--accent2); }
4343 .ext-detail { margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--line); }
4444 .ext-detail[hidden] { display: none; }
45-.ext-applies { font-size: .74rem; color: #7ee787; margin-top: 3px; }
46-.ext-nothing, .ext-ignored { font-size: .72rem; color: #e5a53a; margin-top: 3px; }
45+.ext-ignored { font-size: .72rem; color: #e5a53a; margin-top: 3px; }
46+/* veredicto: primero la frase que decide (verde si funciona, ámbar si no) */
47+.ext-verdict { margin-top: 4px; font-size: .74rem; line-height: 1.4; overflow-wrap: anywhere; }
48+.ext-v-main { font-weight: 600; color: #7ee787; }
49+.ext-v-partial .ext-v-main { color: #b9e08a; }
50+.ext-v-mostlyCode .ext-v-main, .ext-v-code .ext-v-main, .ext-v-nothing .ext-v-main { color: #e5a53a; }
51+.ext-v-more { color: var(--muted); margin-top: 2px; font-size: .72rem; overflow-wrap: anywhere; }
52+/* lo que hace ahora cada instalada */
53+.ext-now { margin-top: 4px; font-size: .74rem; color: #7ee787; }
54+.ext-now.muted { color: var(--muted); }
55+.ext-now-line { overflow-wrap: anywhere; }
56+/* aviso tras instalar: qué cambió y dónde verlo */
57+.ext-done { margin: 6px 0 0; padding: 8px 10px; border-radius: 8px; font-size: .78rem; background: var(--bg3); border: 1px solid rgba(63,185,112,.35); overflow-wrap: anywhere; }
58+.ext-done-h { font-weight: 700; margin-bottom: 4px; }
59+.ext-done-part { margin-top: 6px; }
60+.ext-done-acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
61+.ext-done-acts button { font-size: .74rem; padding: 4px 10px; border-radius: 6px; cursor: pointer; background: none; border: 1px solid var(--line); color: var(--fg); max-width: 100%; white-space: normal; text-align: left; }
62+.ext-done-acts button:hover { border-color: var(--accent2); }
4763 .ext-theme-chips { margin-top: 6px; }
4864 .ext-license { margin: 6px 0 0; max-height: 180px; overflow: auto; white-space: pre-wrap; font-size: .68rem; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
4965 .ext-license[hidden] { display: none; }
@@ -51,7 +67,8 @@
5167 .ext-warn summary { cursor: pointer; }
5268 .ext-warn ul { margin: 4px 0 0 18px; padding: 0; color: var(--muted); overflow-wrap: anywhere; }
5369 .ext-actions { display: flex; flex-direction: column; gap: 6px; flex: 0 0 auto; }
54-.ext-actions button { font-size: .74rem; padding: 5px 11px; border-radius: 6px; cursor: pointer; white-space: nowrap; }
70+.ext-actions { max-width: 40%; }
71+.ext-actions button { font-size: .74rem; padding: 5px 11px; border-radius: 6px; cursor: pointer; white-space: normal; text-align: center; }
5572 .ext-actions .primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); border: none; color: #fff; }
5673 .ext-actions .ghost { background: none; border: 1px solid var(--line); color: var(--muted); }
5774 .ext-actions .ghost:hover:not(:disabled):not([aria-disabled="true"]) { color: var(--fg); border-color: var(--accent2); }
@@ -59,7 +76,7 @@
5976 .ext-more { display: block; margin: 4px auto 10px; font-size: .76rem; }
6077 @media (max-width: 560px) {
6178 .ext-row { flex-wrap: wrap; }
62- .ext-actions { flex-direction: row; width: 100%; justify-content: flex-end; }
79+ .ext-actions { flex-direction: row; width: 100%; max-width: none; justify-content: flex-end; }
6380 }
6481
6582 /* selector de tema: como la paleta de comandos */
modified web/js/ext/host.js +35 −0
@@ -215,6 +215,14 @@
215215 if (meta && v.id !== `${meta.namespace}.${meta.name}`.toLowerCase()) {
216216 throw Object.assign(new Error(`el paquete dice ser ${v.id}, no ${meta.namespace}.${meta.name}`), { code: 'mismatch', got: v.id, want: `${meta.namespace}.${meta.name}` });
217217 }
218+ // lo que el usuario VERÍA: temas, snippets, resaltado de un lenguaje o los
219+ // ajustes de uno nuevo. Un lenguaje que solo asocia extensiones de fichero
220+ // no cambia nada en pantalla; si además el valor de la extensión es su
221+ // código, instalarla sería inútil y se dice en vez de fingir que funciona.
222+ const seVe = v.themes.length || v.snippets.length
223+ || v.grammars.some(g => g.language && !(builtin.has(g.language) && !canOverride(monaco, g.language)))
224+ || v.languages.some(l => l.config && !builtin.has(l.id));
225+ if (!seVe && v.analysis.hasCode) throw Object.assign(new Error('codeonly'), { code: 'codeonly', analysis: v.analysis, displayName: v.displayName });
218226 if (!v.themes.length && !v.grammars.length && !v.snippets.length && !v.languages.length) {
219227 // declaraba cosas aplicables pero ninguna se pudo leer: no es lo mismo
220228 // que no traer nada, y el usuario tiene que saber por qué
@@ -231,6 +239,7 @@
231239 license: (meta?.license || v.license || '').slice(0, 200), sha256, verified, source, size: bytes.length,
232240 installedAt: previo?.installedAt || Date.now(), enabled: previo ? previo.enabled : true,
233241 hasCode: v.analysis.hasCode, ignored: v.analysis.ignored, pack: v.analysis.pack, warnings: v.warnings.slice(0, 20),
242+ categories: v.analysis.categories, sizes: v.analysis.sizes, webviews: v.analysis.webviews, browserEntry: v.analysis.browserEntry,
234243 themes: v.themes.map(t => { const key = k('theme/' + t.index); files.set(key, t.data); return { key, label: t.label, uiTheme: t.uiTheme, themeId: themeIdFor(v.id, t, t.index, usados) }; }),
235244 grammars: v.grammars.map(g => {
236245 const key = k(g.path); files.set(key, g.data);
@@ -286,5 +295,31 @@
286295 // de serie (Monaco conserva la suya)
287296 grammarSkippedFor: lang => typeof lang === 'string' && builtin.has(lang) && !canOverride(monaco, lang),
288297 builtinLanguage: id => builtin.has(id),
298+ // para decir en llano lo que hace cada extensión (panel.js)
299+ languageName(id) {
300+ for (let i = langContribs.length - 1; i >= 0; i--) if (langContribs[i].id === id && langContribs[i].aliases?.[0]) return langContribs[i].aliases[0];
301+ return monaco.languages.getLanguages().find(l => l.id === id)?.aliases?.[0] || null;
302+ },
303+ languageExtensions(id) {
304+ const out = new Set();
305+ for (const l of langContribs) if (l.id === id) for (const x of l.extensions || []) out.add(x);
306+ for (const x of monaco.languages.getLanguages().find(l => l.id === id)?.extensions || []) out.add(x);
307+ return [...out];
308+ },
309+ async snippetPrefixes(id, n = 3) {
310+ const e = exts.find(x => x.id === id);
311+ const out = [];
312+ for (const s of e?.snippets || []) {
313+ for (const x of (await store.getFile(s.key).catch(() => null)) || []) {
314+ if (x?.prefix && !out.includes(x.prefix)) out.push(x.prefix);
315+ if (out.length >= n) return out;
316+ }
317+ }
318+ return out;
319+ },
320+ async languageConfig(id, lang) {
321+ const l = exts.find(x => x.id === id)?.languages?.find(x => x.id === lang);
322+ return l?.configKey ? store.getFile(l.configKey).catch(() => null) : null;
323+ },
289324 };
290325 }
modified web/js/ext/i18n.js +74 −12
@@ -15,11 +15,44 @@
1515 install: 'Instalar', installing: 'Instalando…', downloading: 'Descargando… {pct}%', installedOk: 'Instalada ✓', update: 'Actualizar a {v}',
1616 enable: 'Activar', disable: 'Desactivar', disabled: 'desactivada', uninstall: 'Desinstalar', confirmUninstall: '¿Desinstalar «{name}»?',
1717 details: 'Detalles', loadingDetails: 'Leyendo el manifiesto…',
18- applies: 'Aplica: {list}', ignores: 'No aplica: {list}', nothing: 'Nada de esta extensión se puede aplicar aquí.',
19- needsCode: 'necesita su código', notYet: 'aún no',
20- hasCode: 'Trae código (main/browser): no se ejecuta — haría falta un host de extensiones.',
18+ nothing: 'Nada de esta extensión se puede aplicar aquí.',
2119 pack: 'Es un paquete de {n} extensiones: instálalas una a una.',
22- themes: '{n} tema|{n} temas', grammars: '{n} gramática|{n} gramáticas', snippets: 'snippets ({langs})', languages: '{n} lenguaje|{n} lenguajes',
20+ andMore: '{n} más', quoted: '«{x}»',
21+ fFormat: 'formatear código', fLint: 'avisar de errores', fDebug: 'depurar', fPreview: 'vistas previas propias', fNotebooks: 'cuadernos',
22+ fTesting: 'ejecutar tests', fScm: 'control de versiones', fData: 'herramientas de datos', fAI: 'asistente de IA', fKeys: 'atajos de teclado',
23+ fLangPack: 'traducir la interfaz', fCloud: 'servicios en la nube', fCommands: 'sus propias acciones', fPanels: 'paneles propios', fTasks: 'tareas',
24+ fSettings: 'sus ajustes', fJsonCheck: 'validar ficheros JSON', fSemantic: 'colorear según el significado del código', fIcons: 'iconos',
25+ fTerminal: 'terminal', fAccounts: 'iniciar sesión en servicios', fWalk: 'guías de inicio', fStatus: 'avisos en la barra de estado',
26+ fCodeActions: 'arreglos rápidos', fLangServer: 'ayudas del lenguaje', fOther: 'otras funciones', fOwn: 'lo que hace su propio código',
27+ pThemes: 'el tema {list}|los temas {list}', pThemesCount: 'un tema de color|{n} temas de color', pHighlight: 'el resaltado de {list}', pSettings: 'comentarios y corchetes de {list}',
28+ pSnippetsN: '{n} snippet para {list}|{n} snippets para {list}', pSnippets: 'snippets para {list}',
29+ vFull: 'Funciona en Code: añade {list}.', vPartial: 'Funciona en parte: añade {list}.',
30+ vMainBroken: 'Lo principal de esta extensión ({what}) no funciona en Code: necesita ejecutar su propio código.',
31+ vOnly: 'Solo se aplicaría {list}.',
32+ vNextVersion: 'Eso llegará con la siguiente versión de Code.',
33+ vNever: 'Y no está previsto: usa ventanas o programas propios que Code no puede abrir.',
34+ vMissingNext: 'No funciona: {list}. Necesita ejecutar su propio código; llegará con la siguiente versión de Code.',
35+ vMissingNever: 'No funciona: {list}. Necesita ejecutar su propio código, y eso no está previsto en Code.',
36+ vMissingLater: 'Aún no se aplica: {list}.',
37+ keepsBuiltin: 'Code ya resalta {list} a su manera y lo mantiene.',
38+ installOnlyThemes: 'Instalar solo los temas', installOnlyHighlight: 'Instalar solo el resaltado', installOnlySnippets: 'Instalar solo los snippets',
39+ installOnlyWorking: 'Instalar solo lo que funciona', notHere: 'No funciona en Code', nothingHere: 'Nada que aplicar',
40+ errCodeOnly: '«{name}» no se ha instalado.',
41+ cThemeApplied: 'Tema «{name}» aplicado.', cThemeReady: 'Tema «{name}» listo para usar.', cThemesReady: '{n} temas listos: {list}.',
42+ bApplyNow: 'Aplicar ahora', bUndo: 'Deshacer', bPickTheme: 'Elegir tema…',
43+ cHighlight: 'Resaltado para {list}.', cHighlightOpen: 'Ya se ve en {files}, que está abierto.|Ya se ve en {files}, que están abiertos.',
44+ cHighlightTry: 'Abre un fichero {exts} para verlo.',
45+ bGoto: 'Ir a {file}', bOpenFile: 'Abrir {file} de ejemplo', bTry: 'Probar', bTryIn: 'Probar en {file}',
46+ cSettings: 'En {lang}: {what}.', sComment: 'comentar con {c} (Ctrl+/)', sBrackets: 'corchetes {b}', sAutoClose: 'cierre automático de {p}',
47+ cSnippets: '{n} snippet para {list}.|{n} snippets para {list}.',
48+ cSnippetsTry: 'Prueba: escribe {prefixes} y elige la sugerencia con Tab o Enter.',
49+ nThemeActive: 'Tema activo: «{name}».', nThemeIdle: 'Ningún tema suyo está activo: pulsa uno para aplicarlo.',
50+ nHighlighting: 'Resaltando {n} fichero abierto ({list}).|Resaltando {n} ficheros abiertos ({list}).',
51+ nHighlightIdle: 'Resalta {list}; ahora no hay ninguno abierto.',
52+ nSnippets: '{n} snippet listo ({list}).|{n} snippets listos ({list}).', nSettings: 'Comentarios y corchetes de {list}.',
53+ nOff: 'Desactivada: ahora no aplica nada.',
54+ tryHighlightNamed: 'Probar el resaltado de {name}', trySnippetsNamed: 'Probar los snippets de {name}',
55+ statusTrySnippets: 'Snippets: escribe {prefixes} y elige la sugerencia con Tab o Enter.',
2356 license: 'Licencia: {l}', viewLicense: 'ver licencia', noLicense: 'sin licencia declarada',
2457 verified: 'suma SHA-256 comprobada', unverified: 'Open VSX no publica suma SHA-256', fromFile: 'desde fichero',
2558 downloads: '{n} descargas',
@@ -40,8 +73,6 @@
4073 errQuota: 'No queda espacio en el almacenamiento del navegador para instalarla.',
4174 err: 'No se pudo: {e}', cancelled: 'Cancelado.',
4275 installedMsg: '«{name}» instalada.',
43- grammarNotApplied: 'gramática de {lang} (Monaco conserva su coloreado de serie)',
44- settingsNotApplied: 'configuración de {lang} (Monaco conserva la suya)',
4576 warnSummary: '{n} parte no se pudo usar|{n} partes no se pudieron usar',
4677 warn_theme: 'Tema «{name}»: {why}', warn_grammar: 'Gramática {name}: {why}', warn_snippets: 'Snippets {name}: {why}',
4778 warn_config: 'Configuración de {name}: {why}', warn_regex: 'Expresión descartada en {name}, podría congelar la pestaña: {why}',
@@ -67,11 +98,44 @@
6798 install: 'Install', installing: 'Installing…', downloading: 'Downloading… {pct}%', installedOk: 'Installed ✓', update: 'Update to {v}',
6899 enable: 'Enable', disable: 'Disable', disabled: 'disabled', uninstall: 'Uninstall', confirmUninstall: 'Uninstall “{name}”?',
69100 details: 'Details', loadingDetails: 'Reading the manifest…',
70- applies: 'Applies: {list}', ignores: 'Not applied: {list}', nothing: 'Nothing in this extension can be applied here.',
71- needsCode: 'needs its code', notYet: 'not yet',
72- hasCode: 'Ships code (main/browser): it does not run here — that needs an extension host.',
101+ nothing: 'Nothing in this extension can be applied here.',
73102 pack: 'This is a pack of {n} extensions: install them one by one.',
74- themes: '{n} theme|{n} themes', grammars: '{n} grammar|{n} grammars', snippets: 'snippets ({langs})', languages: '{n} language|{n} languages',
103+ andMore: '{n} more', quoted: '“{x}”',
104+ fFormat: 'formatting code', fLint: 'flagging errors', fDebug: 'debugging', fPreview: 'its own previews', fNotebooks: 'notebooks',
105+ fTesting: 'running tests', fScm: 'version control', fData: 'data tools', fAI: 'an AI assistant', fKeys: 'keyboard shortcuts',
106+ fLangPack: 'translating the interface', fCloud: 'cloud services', fCommands: 'its own actions', fPanels: 'its own panels', fTasks: 'tasks',
107+ fSettings: 'its settings', fJsonCheck: 'checking JSON files', fSemantic: 'colouring by what the code means', fIcons: 'icons',
108+ fTerminal: 'a terminal', fAccounts: 'signing in to services', fWalk: 'getting-started guides', fStatus: 'status bar items',
109+ fCodeActions: 'quick fixes', fLangServer: 'language help', fOther: 'other features', fOwn: 'what its own code does',
110+ pThemes: 'the theme {list}|the themes {list}', pThemesCount: 'a colour theme|{n} colour themes', pHighlight: 'highlighting for {list}', pSettings: 'comments and brackets for {list}',
111+ pSnippetsN: '{n} snippet for {list}|{n} snippets for {list}', pSnippets: 'snippets for {list}',
112+ vFull: 'Works in Code: adds {list}.', vPartial: 'Partly works: adds {list}.',
113+ vMainBroken: 'The main thing this extension does ({what}) does not work in Code: it needs to run its own code.',
114+ vOnly: 'Only {list} would apply.',
115+ vNextVersion: 'That comes with the next version of Code.',
116+ vNever: 'And it is not planned: it uses its own windows or programs, which Code cannot open.',
117+ vMissingNext: 'Does not work: {list}. It needs to run its own code; that comes with the next version of Code.',
118+ vMissingNever: 'Does not work: {list}. It needs to run its own code, and that is not planned for Code.',
119+ vMissingLater: 'Not applied yet: {list}.',
120+ keepsBuiltin: 'Code already highlights {list} its own way and keeps it.',
121+ installOnlyThemes: 'Install only the themes', installOnlyHighlight: 'Install only the highlighting', installOnlySnippets: 'Install only the snippets',
122+ installOnlyWorking: 'Install only what works', notHere: 'Does not work in Code', nothingHere: 'Nothing to apply',
123+ errCodeOnly: '“{name}” was not installed.',
124+ cThemeApplied: 'Theme “{name}” applied.', cThemeReady: 'Theme “{name}” is ready to use.', cThemesReady: '{n} themes ready: {list}.',
125+ bApplyNow: 'Apply now', bUndo: 'Undo', bPickTheme: 'Choose theme…',
126+ cHighlight: 'Syntax highlighting for {list}.', cHighlightOpen: 'Already visible in {files}, which is open.|Already visible in {files}, which are open.',
127+ cHighlightTry: 'Open a {exts} file to see it.',
128+ bGoto: 'Go to {file}', bOpenFile: 'Open {file} as an example', bTry: 'Try it', bTryIn: 'Try in {file}',
129+ cSettings: 'In {lang}: {what}.', sComment: 'comment with {c} (Ctrl+/)', sBrackets: 'brackets {b}', sAutoClose: 'auto-closing {p}',
130+ cSnippets: '{n} snippet for {list}.|{n} snippets for {list}.',
131+ cSnippetsTry: 'Try it: type {prefixes} and pick the suggestion with Tab or Enter.',
132+ nThemeActive: 'Active theme: “{name}”.', nThemeIdle: 'None of its themes is active: click one to apply it.',
133+ nHighlighting: 'Highlighting {n} open file ({list}).|Highlighting {n} open files ({list}).',
134+ nHighlightIdle: 'Highlights {list}; none is open right now.',
135+ nSnippets: '{n} snippet ready ({list}).|{n} snippets ready ({list}).', nSettings: 'Comments and brackets for {list}.',
136+ nOff: 'Disabled: nothing applied right now.',
137+ tryHighlightNamed: 'Try the {name} highlighting', trySnippetsNamed: 'Try the {name} snippets',
138+ statusTrySnippets: 'Snippets: type {prefixes} and pick the suggestion with Tab or Enter.',
75139 license: 'Licence: {l}', viewLicense: 'view licence', noLicense: 'no licence declared',
76140 verified: 'SHA-256 checked', unverified: 'Open VSX publishes no SHA-256', fromFile: 'from file',
77141 downloads: '{n} downloads',
@@ -92,8 +156,6 @@
92156 errQuota: 'There is no browser storage left to install it.',
93157 err: 'Could not do it: {e}', cancelled: 'Cancelled.',
94158 installedMsg: '“{name}” installed.',
95- grammarNotApplied: '{lang} grammar (Monaco keeps its built-in highlighting)',
96- settingsNotApplied: '{lang} settings (Monaco keeps its own)',
97159 warnSummary: '{n} part could not be used|{n} parts could not be used',
98160 warn_theme: 'Theme “{name}”: {why}', warn_grammar: 'Grammar {name}: {why}', warn_snippets: 'Snippets {name}: {why}',
99161 warn_config: 'Settings for {name}: {why}', warn_regex: 'Expression discarded in {name}, it could freeze the tab: {why}',
modified web/js/ext/openvsx.js +6 −0
@@ -62,6 +62,12 @@
6262 return getJson(meta.files.manifest, signal);
6363 }
6464
65+// El package.json de un resultado de búsqueda, sin pedir antes sus metadatos:
66+// una sola petición por fila para decir qué haría antes de instalarla.
67+export function manifestOf({ namespace, name, version }, { signal } = {}) {
68+ return getJson(`${BASE}/api/${seg(namespace)}/${seg(name)}/${seg(version)}/file/package.json`, signal);
69+}
70+
6571 export async function text(url, { signal, max = 200_000 } = {}) {
6672 const u = deOpenVsx(url);
6773 if (!u) throw new OpenVsxError('URL fuera de Open VSX', 'http');
modified web/js/ext/panel.js +338 −54
@@ -8,6 +8,7 @@
88 // <summary>), los resultados y avisos se anuncian (role=status/alert), el
99 // foco no se pierde al repintar ni al cerrar, y Escape cierra el panel.
1010 import { tx } from './i18n.js';
11+import { describe, lista, listaO, esTexto } from './verdict.js';
1112
1213 const $ = id => document.getElementById(id);
1314 const el = (tag, cls, txt) => { const e = document.createElement(tag); if (cls) e.className = cls; if (txt != null) e.textContent = txt; return e; };
@@ -21,6 +22,7 @@
2122 let abridor = null; // quién tenía el foco al abrir el panel
2223 let focoPendiente = null; // control a recuperar tras repintar «Instaladas»
2324 let nDetalle = 0;
25+let ideCargado = null; // ../ide.js, para contar pestañas al pintar «Instaladas»
2426
2527 function ponCss() {
2628 if (cssPuesto) return;
@@ -57,6 +59,7 @@
5759 if (!$('ext-panel')?.isConnected || box.hidden) abridor = document.activeElement;
5860 estado.msg = null; // un aviso viejo no se repite al volver a abrir
5961 pinta();
62+ if (!ideCargado) ide().then(m => { ideCargado = m; if ($('ext-panel')?.isConnected) pintaInstaladas(); });
6063 }
6164
6265 function cierraPanel() {
@@ -70,7 +73,7 @@
7073 // ── mensajes legibles (exportados para las pruebas en Node) ──
7174 const ERRORES = {
7275 rate: 'errRate', sha: 'errSha', nothing: 'errNothing', notvsix: 'errNotVsix', notfound: 'errNotFound',
73- big: 'errBig', noname: 'errNoName', blocked: 'errBlocked',
76+ big: 'errBig', noname: 'errNoName', blocked: 'errBlocked', codeonly: 'notHere',
7477 };
7578 export function textoError(e) {
7679 const code = e?.code;
@@ -115,6 +118,7 @@
115118 m.hidden = false;
116119 m.textContent = texto || '';
117120 m.classList.toggle('err', !!error);
121+ m.classList.remove('ext-msg-sr');
118122 }
119123 // Estado de la búsqueda para el lector de pantalla (la cabecera visible se
120124 // rehace en cada repintado y no podría anunciarse).
@@ -126,34 +130,76 @@
126130 // «Aplica: 2 temas · No aplica: commands (necesita su código)», con lo que de
127131 // verdad se aplicaría aquí: la gramática de un lenguaje de serie sin Monarch
128132 // (JSON) y la configuración de un lenguaje de serie no se aplican, y no cuentan.
129-function resumen({ themes = 0, grammarLangs = [], languageList = [], snippetLangs = [], ignored = [], hasCode = false, pack = [] }) {
130- const saltaGram = l => !!l && !!host.grammarSkippedFor?.(l);
133+// ── qué hace cada extensión, en llano (verdict.js) ──
134+const BONITOS = {
135+ javascript: 'JavaScript', typescript: 'TypeScript', javascriptreact: 'JavaScript React', typescriptreact: 'TypeScript React',
136+ html: 'HTML', css: 'CSS', scss: 'SCSS', less: 'Less', json: 'JSON', jsonc: 'JSON', vue: 'Vue', python: 'Python', markdown: 'Markdown',
137+ shellscript: 'Shell', go: 'Go', rust: 'Rust', java: 'Java', php: 'PHP', ruby: 'Ruby', csharp: 'C#', cpp: 'C++', c: 'C', yaml: 'YAML',
138+};
139+function nombreLenguaje(id, langs = []) {
140+ return langs.find(l => l.id === id && esTexto(l.name))?.name || host?.languageName?.(id) || BONITOS[id] || id;
141+}
142+function extsDe(id, langs = []) {
143+ const propias = langs.filter(l => l.id === id).flatMap(l => l.extensions || []);
144+ return [...new Set(propias.length ? propias : host?.languageExtensions?.(id) || [])];
145+}
146+// Hechos comunes a un package.json (antes de instalar) y a un registro instalado.
147+function hechos(base, { themes = [], grammarLangs = [], langs = [], snippets = [] }) {
148+ const salta = l => !!host.grammarSkippedFor?.(l);
131149 const deSerie = id => !!host.builtinLanguage?.(id);
132- const gramSaltadas = [...new Set(grammarLangs.filter(saltaGram))];
133- const confSaltadas = [...new Set(languageList.filter(l => l.config && deSerie(l.id)).map(l => l.id))];
134- const grammars = grammarLangs.filter(l => !saltaGram(l)).length;
135- const languages = languageList.filter(l => !deSerie(l.id)).length;
136- const aplica = [];
137- if (themes) aplica.push(tx('themes', { n: themes }));
138- if (grammars) aplica.push(tx('grammars', { n: grammars }));
139- if (languages) aplica.push(tx('languages', { n: languages }));
140- if (snippetLangs.length) aplica.push(tx('snippets', { langs: snippetLangs.slice(0, 6).join(', ') + (snippetLangs.length > 6 ? '…' : '') }));
141- const porMotivo = { code: [], later: [] };
142- for (const i of ignored) (porMotivo[i.why] || porMotivo.later).push(i.key);
143- const no = [...gramSaltadas.map(lang => tx('grammarNotApplied', { lang })), ...confSaltadas.map(lang => tx('settingsNotApplied', { lang }))];
144- if (porMotivo.code.length) no.push(`${porMotivo.code.join(', ')} (${tx('needsCode')})`);
145- if (porMotivo.later.length) no.push(`${porMotivo.later.join(', ')} (${tx('notYet')})`);
146- const lineas = [];
147- lineas.push(aplica.length ? { cls: 'ext-applies', t: tx('applies', { list: aplica.join(' · ') }) } : { cls: 'ext-nothing', t: tx('nothing') });
148- if (no.length) lineas.push({ cls: 'ext-ignored', t: tx('ignores', { list: no.join(' · ') }) });
149- if (hasCode) lineas.push({ cls: 'ext-ignored', t: tx('hasCode') });
150- if (pack.length) lineas.push({ cls: 'ext-ignored', t: tx('pack', { n: pack.length }) });
151- return { lineas, any: aplica.length > 0 };
152-}
153-
154-// Botón de acción: texto visible y nombre accesible con la extensión
155-// («Instalar Monokai»). Sin nombre accesible, el lector lee el texto visible
156-// (el progreso de la descarga, por ejemplo).
150+ const conGram = [...new Set(grammarLangs.filter(l => l && !salta(l)))];
151+ // snippets de un lenguaje que Code no tiene (javascriptreact, vue…) no
152+ // saldrían nunca: ni se cuentan ni se prometen. Y un mismo fichero que sirve
153+ // a varios lenguajes se cuenta una vez.
154+ const existe = id => langs.some(l => l.id === id) || !!host.languageName?.(id) || !!host.builtinLanguage?.(id);
155+ const porLang = new Map();
156+ const vistos = new Set();
157+ for (const s of snippets.filter(x => existe(x.language))) {
158+ const n = !Number.isFinite(s.count) ? NaN : s.key && vistos.has(s.key) ? 0 : s.count;
159+ if (s.key) vistos.add(s.key);
160+ porLang.set(s.language, (porLang.has(s.language) ? porLang.get(s.language) : 0) + n);
161+ }
162+ return {
163+ ...base, themes,
164+ highlight: conGram.map(id => ({ id, name: nombreLenguaje(id, langs), exts: extsDe(id, langs) })),
165+ settingsOnly: langs.filter(l => l.config && !deSerie(l.id) && !conGram.includes(l.id)).map(l => nombreLenguaje(l.id, langs)),
166+ keepsBuiltin: [...new Set(grammarLangs.filter(l => l && salta(l)))].map(id => nombreLenguaje(id, langs)),
167+ snippets: [...porLang].map(([id, n]) => ({ id, name: nombreLenguaje(id, langs), count: Number.isFinite(n) ? n : null })),
168+ };
169+}
170+function hechosDeManifiesto(a) {
171+ return hechos({ hasCode: a.hasCode, browserEntry: a.browserEntry, categories: a.categories || [], sizes: a.sizes || {}, webviews: a.webviews, ignored: a.ignored || [], pack: a.pack || [] }, {
172+ themes: a.themeLabels || [], grammarLangs: a.grammarLangs || [], langs: a.languageList || [],
173+ snippets: (a.snippetLangs || []).map(language => ({ language, count: null })),
174+ });
175+}
176+function hechosDeRegistro(e) {
177+ // registros de antes de guardar categorías: se asume que lo que se aplica es lo principal
178+ const categories = e.categories || ['Programming Languages'];
179+ return hechos({ hasCode: e.hasCode, browserEntry: !!e.browserEntry, categories, sizes: e.sizes || {}, webviews: e.webviews, ignored: e.ignored || [], pack: e.pack || [] }, {
180+ themes: (e.themes || []).map(t => t.label), grammarLangs: (e.grammars || []).map(g => g.language ?? null),
181+ langs: (e.languages || []).map(l => ({ id: l.id, name: l.aliases?.[0], extensions: l.extensions || [], config: !!l.configKey })),
182+ snippets: (e.snippets || []).map(s => ({ language: s.language, key: s.key, count: Number.isFinite(s.count) ? s.count : null })),
183+ });
184+}
185+// El bloque del veredicto: primero la frase que decide, luego el detalle.
186+function bloqueVeredicto(f, v, { principal = true } = {}) {
187+ const box = el('div', 'ext-verdict ext-v-' + v.kind);
188+ box.id = 'ext-v-' + (++nDetalle);
189+ if (principal || v.kind === 'code' || v.kind === 'nothing') box.appendChild(el('div', 'ext-v-main', v.verdict));
190+ for (const l of v.lines) box.appendChild(el('div', 'ext-v-more', l));
191+ if (f.keepsBuiltin?.length) box.appendChild(el('div', 'ext-v-more', tx('keepsBuiltin', { list: lista(f.keepsBuiltin) })));
192+ if (f.pack?.length) box.appendChild(el('div', 'ext-v-more', tx('pack', { n: f.pack.length })));
193+ return box;
194+}
195+// El botón de instalar dice lo que vas a tener; si no se ve nada, no se ofrece.
196+function botonSegunVeredicto(b, v, nombre) {
197+ const texto = tx(v.button.key);
198+ rotula(b, texto, v.button.key === 'install' ? tx('installNamed', { name: nombre }) : `${texto}: ${nombre}`);
199+ b.className = (v.button.style === 'primary' ? 'primary' : 'ghost') + ' ext-install';
200+ inerte(b, v.button.disabled);
201+}
202+
157203 function rotula(b, texto, accesible = null) {
158204 b.textContent = texto;
159205 if (accesible) b.setAttribute('aria-label', accesible); else b.removeAttribute('aria-label');
@@ -329,6 +375,47 @@
329375 return letra;
330376 }
331377
378+// ── análisis previo de cada resultado: su package.json (una petición por fila,
379+// cuatro a la vez, en caché) para dar el veredicto ANTES de instalar ──
380+const analisis = new Map();
381+const colaAnalisis = [];
382+let analizando = 0;
383+const claveDe = it => `${it.namespace}.${it.name}@${it.version}`;
384+function bombea() {
385+ while (analizando < 4 && colaAnalisis.length) {
386+ const { it, res, rej } = colaAnalisis.shift();
387+ analizando++;
388+ (async () => {
389+ const ovsx = await import('./openvsx.js');
390+ const { analyzeManifest } = await import('./vsix.js');
391+ return analyzeManifest(await ovsx.manifestOf(it));
392+ })().then(res, rej).finally(() => { analizando--; bombea(); });
393+ }
394+}
395+function analiza(it) {
396+ const k = claveDe(it);
397+ if (!analisis.has(k)) {
398+ const p = new Promise((res, rej) => { colaAnalisis.push({ it, res, rej }); bombea(); });
399+ analisis.set(k, p);
400+ p.catch(() => analisis.delete(k)); // se reintenta la próxima vez
401+ }
402+ return analisis.get(k);
403+}
404+function pintaVeredictoFila(row, it, a, instalada) {
405+ const f = hechosDeManifiesto(a);
406+ const v = describe(f);
407+ const sitio = row.querySelector('.ext-verdict-slot');
408+ if (!sitio) return v;
409+ const bloque = bloqueVeredicto(f, v);
410+ sitio.replaceChildren(bloque);
411+ const b = row.querySelector('.ext-install');
412+ if (b && !instalada && !b.dataset.ocupado) {
413+ botonSegunVeredicto(b, v, it.displayName);
414+ if (v.button.disabled) { b.setAttribute('aria-describedby', bloque.id); b.title = v.verdict; } else { b.removeAttribute('aria-describedby'); b.removeAttribute('title'); }
415+ }
416+ return v;
417+}
418+
332419 function filaResultado(it, instalada) {
333420 const row = el('div', 'ext-row');
334421 row.dataset.id = `${it.namespace}.${it.name}`;
@@ -336,8 +423,6 @@
336423 const det = el('div', 'ext-detail');
337424 det.id = 'ext-det-' + (++nDetalle);
338425 det.hidden = true;
339- // el nombre es el botón que despliega el detalle (qué aplicaría y qué no):
340- // antes de instalar, también con teclado
341426 const t = el('div', 'ext-title');
342427 const nombre = el('button', 'ext-name', it.displayName);
343428 nombre.type = 'button';
@@ -348,6 +433,7 @@
348433 t.append(nombre, el('span', 'muted', ` ${it.namespace} · v${it.version}`));
349434 if (it.verified) t.appendChild(el('span', 'ext-badge', '✓'));
350435 main.append(t, el('div', 'ext-desc', it.description));
436+ main.appendChild(el('div', 'ext-verdict-slot'));
351437 main.appendChild(el('div', 'ext-meta muted', tx('downloads', { n: it.downloadCount.toLocaleString() })));
352438 main.appendChild(det);
353439 main.onclick = e => { if (!e.target.closest('button, a, summary')) detalle(it, det, nombre); };
@@ -364,6 +450,7 @@
364450 b.onclick = e => { e.stopPropagation(); if (!esInerte(b)) instala(it, b); };
365451 acc.appendChild(b);
366452 row.append(icono(it.icon, it.displayName), main, acc);
453+ analiza(it).then(a => pintaVeredictoFila(row, it, a, instalada)).catch(() => { /* sin veredicto: el botón de siempre */ });
367454 return row;
368455 }
369456
@@ -374,12 +461,13 @@
374461 det.replaceChildren(el('div', 'muted', tx('loadingDetails')));
375462 try {
376463 const ovsx = await import('./openvsx.js');
377- const { analyzeManifest } = await import('./vsix.js');
378464 const meta = await ovsx.metadata(it.namespace, it.name, it.version);
379- const a = analyzeManifest(await ovsx.manifest(meta));
380- const r = resumen({ themes: a.applies.themes, grammarLangs: a.grammarLangs, languageList: a.languageList, snippetLangs: a.snippetLangs, ignored: a.ignored, hasCode: a.hasCode, pack: a.pack });
465+ const a = await analiza(it);
466+ const f = hechosDeManifiesto(a);
467+ const v = describe(f);
381468 det.replaceChildren();
382- for (const l of r.lineas) det.appendChild(el('div', l.cls, l.t));
469+ // el veredicto ya va en la fila; aquí, además, todo lo que no funcionaría
470+ if (v.missing.length && v.kind !== 'partial') det.appendChild(el('div', 'ext-v-more', tx(v.future === 'next' ? 'vMissingNext' : 'vMissingNever', { list: lista(v.missing) })));
383471 const lic = el('div', 'ext-meta muted', tx('license', { l: meta.license || tx('noLicense') }) + ' ');
384472 if (meta.files.license) {
385473 const a2 = el('a', null, tx('viewLicense'));
@@ -390,32 +478,190 @@
390478 }
391479 det.appendChild(lic);
392480 det.dataset.listo = '1';
393- // nada aplicable: instalarla solo daría un error, mejor decirlo en el botón
394- const inst = det.closest('.ext-row')?.querySelector('.ext-install');
395- if (!r.any && inst && !esInerte(inst)) { inerte(inst, true); inst.title = tx('nothing'); inst.className = 'ghost ext-install'; }
481+ const fila = det.closest('.ext-row');
482+ if (fila) pintaVeredictoFila(fila, it, a, host.list().find(e => e.id === `${it.namespace}.${it.name}`.toLowerCase()));
396483 } catch (e) { det.replaceChildren(el('div', 'ext-ignored', textoError(e))); }
397484 }
398485
486+// «No se ha instalado», con el porqué en llano.
487+function textoNoInstalada(nombre, a) {
488+ const v = describe(hechosDeManifiesto(a));
489+ return [tx('errCodeOnly', { name: nombre }), v.verdict, ...v.lines].join(' ');
490+}
491+
399492 async function instala(src, boton) {
400- const nombre = src instanceof Blob ? src.name : src.displayName;
493+ const esFichero = src instanceof Blob;
494+ const nombre = esFichero ? src.name : src.displayName;
495+ if (!esFichero) {
496+ // sin veredicto todavía (red lenta): se pide ahora, y si no se vería nada, no se baja
497+ const a = await analiza(src).catch(() => null);
498+ if (a) {
499+ const fila = boton?.closest('.ext-row');
500+ const v = fila ? pintaVeredictoFila(fila, src, a, null) : describe(hechosDeManifiesto(a));
501+ if (v.button.disabled) { aviso(textoNoInstalada(nombre, a), true); return; }
502+ }
503+ }
401504 const original = boton ? { texto: boton.textContent, accesible: boton.getAttribute('aria-label') } : null;
402- if (boton) { inerte(boton, true); rotula(boton, tx('installing')); }
505+ if (boton) { inerte(boton, true); boton.dataset.ocupado = '1'; rotula(boton, tx('installing')); }
403506 aviso(null);
507+ $('ext-done')?.remove();
508+ const temaAntes = host.currentTheme();
404509 try {
405- const rec = await host.install(src instanceof Blob ? src : { namespace: src.namespace, name: src.name, version: src.version }, {
510+ const rec = await host.install(esFichero ? src : { namespace: src.namespace, name: src.name, version: src.version }, {
406511 onProgress: (n, total) => { if (boton && total) boton.textContent = tx('downloading', { pct: Math.round(n / total * 100) }); },
407512 confirmLarge: async mb => confirm(tx('bigConfirm', { mb })),
408513 });
409- if (boton) { rotula(boton, tx('installedOk'), tx('installedNamed', { name: rec.displayName || nombre })); boton.className = 'ghost ext-install'; }
514+ if (boton) { delete boton.dataset.ocupado; rotula(boton, tx('installedOk'), tx('installedNamed', { name: rec.displayName || nombre })); boton.className = 'ghost ext-install'; }
515+ // una extensión que solo trae temas se ve al instante: se aplica el primero
516+ // (con «Deshacer» en el aviso)
517+ const soloTemas = rec.themes?.length && !rec.grammars?.length && !rec.snippets?.length && !(rec.languages || []).some(l => l.configKey && !host.builtinLanguage?.(l.id));
518+ let auto = false;
519+ if (soloTemas && !rec.themes.some(t => t.themeId === host.currentTheme()) && rec.enabled !== false && !host.paused) {
520+ await host.setTheme(rec.themes[0].themeId);
521+ auto = true;
522+ }
410523 const nAvisos = avisosVisibles(rec.warnings).length;
411- aviso(tx('installedMsg', { name: rec.displayName || nombre }) + (nAvisos ? ' ' + tx('warnSummary', { n: nAvisos }) + '.' : ''));
524+ const primera = auto ? ' ' + tx('cThemeApplied', { name: rec.themes[0].label }) : '';
525+ aviso(tx('installedMsg', { name: rec.displayName || nombre }) + primera + (nAvisos ? ' ' + tx('warnSummary', { n: nAvisos }) + '.' : ''));
526+ await pintaTarjeta(rec, { previo: auto ? temaAntes : null });
527+ pintaInstaladas();
412528 } catch (e) {
413- if (boton) { inerte(boton, false); rotula(boton, original.texto, original.accesible); }
414- aviso(textoError(e), true);
529+ if (boton) { delete boton.dataset.ocupado; inerte(boton, false); rotula(boton, original.texto, original.accesible); }
530+ if (e?.code === 'codeonly') {
531+ aviso(textoNoInstalada(e.displayName || nombre, e.analysis), true);
532+ if (boton) { const v = describe(hechosDeManifiesto(e.analysis)); botonSegunVeredicto(boton, v, nombre); }
533+ } else aviso(textoError(e), true);
534+ }
535+}
536+
537+// ── después de instalar: qué cambió, dónde verlo y un botón para probarlo ──
538+const baseName = p => String(p).split('/').pop();
539+const cita = x => tx('quoted', { x });
540+async function ide() { try { return await import('../ide.js'); } catch { return null; } }
541+async function ficherosDelProyecto() { try { return await (await import('../tools/code.js')).fileList(); } catch { return []; } }
542+function pestañasCon(ideMod, langs) {
543+ const ids = new Set(langs);
544+ return (ideMod?.openTabs?.() || []).filter(t => ids.has(t.language) || ids.has(host.languageForPath?.(t.path)));
545+}
546+async function ficheroCon(ideMod, langs) {
547+ const ids = new Set(langs);
548+ const abiertas = pestañasCon(ideMod, langs);
549+ if (abiertas.length) return { path: (abiertas.find(t => t.active) || abiertas[0]).path, abierta: true };
550+ for (const f of await ficherosDelProyecto()) if (ids.has(host.languageForPath?.(f) || ideMod?.languageOfPath?.(f))) return { path: f, abierta: false };
551+ return null;
552+}
553+async function irA(path, { foco = true } = {}) {
554+ const m = await ide();
555+ cierraPanel();
556+ await m?.openFile(path);
557+ if (foco) m?.focusEditor();
558+}
559+async function pruebaSnippets(rec, objetivo) {
560+ const prefijos = await host.snippetPrefixes(rec.id).catch(() => []);
561+ const pista = tx('statusTrySnippets', { prefixes: listaO(prefijos.map(cita)) });
562+ if (!objetivo) { aviso(pista); return; }
563+ await irA(objetivo);
564+ const sb = document.getElementById('statusbar');
565+ if (sb) sb.textContent = pista;
566+}
567+async function pruebaResaltado(langs) {
568+ const m = await ide();
569+ const f = await ficheroCon(m, langs);
570+ if (f) { await irA(f.path); return; }
571+ aviso(tx('cHighlightTry', { exts: lista(langs.flatMap(l => extsDe(l)).slice(0, 4)) }));
572+}
573+function resumenAjustes(conf) {
574+ if (!conf || typeof conf !== 'object') return [];
575+ const que = [];
576+ const lc = conf.comments?.lineComment, bc = conf.comments?.blockComment;
577+ if (typeof lc === 'string') que.push(tx('sComment', { c: lc }));
578+ else if (Array.isArray(bc) && bc.length === 2) que.push(tx('sComment', { c: bc.join(' … ') }));
579+ const par = p => (Array.isArray(p) ? p[0] + p[1] : p && typeof p.open === 'string' ? p.open + p.close : null);
580+ if (Array.isArray(conf.brackets) && conf.brackets.length) que.push(tx('sBrackets', { b: conf.brackets.map(par).filter(Boolean).slice(0, 4).join(' ') }));
581+ if (Array.isArray(conf.autoClosingPairs) && conf.autoClosingPairs.length) que.push(tx('sAutoClose', { p: conf.autoClosingPairs.map(par).filter(Boolean).slice(0, 5).join(' ') }));
582+ return que;
583+}
584+
585+async function pintaTarjeta(rec, { previo = null } = {}) {
586+ const sitio = $('ext-msg');
587+ if (!sitio) return;
588+ const m = await ide();
589+ const f = hechosDeRegistro(rec);
590+ const v = describe(f);
591+ const box = el('section', 'ext-done');
592+ box.id = 'ext-done';
593+ box.setAttribute('aria-labelledby', 'ext-done-h');
594+ const h = el('div', 'ext-done-h', tx('installedMsg', { name: rec.displayName }));
595+ h.id = 'ext-done-h';
596+ box.appendChild(h);
597+ const parte = () => { const p = el('div', 'ext-done-part'); box.appendChild(p); return p; };
598+ const botones = p => { const x = el('div', 'ext-done-acts'); p.appendChild(x); return x; };
599+ const boton = (fila, texto, act, fn, accesible = null) => {
600+ const b = el('button', 'ghost', texto);
601+ b.type = 'button';
602+ b.dataset.act = act;
603+ if (accesible) b.setAttribute('aria-label', accesible);
604+ b.onclick = fn;
605+ fila.appendChild(b);
606+ return b;
607+ };
608+
609+ if (rec.themes?.length) {
610+ const p = parte();
611+ const pinta = (enfoca = null) => {
612+ p.replaceChildren();
613+ const activo = rec.themes.find(t => t.themeId === host.currentTheme());
614+ p.appendChild(el('div', null, activo ? tx('cThemeApplied', { name: activo.label })
615+ : rec.themes.length === 1 ? tx('cThemeReady', { name: rec.themes[0].label }) : tx('cThemesReady', { n: rec.themes.length, list: lista(rec.themes.map(t => cita(t.label))) })));
616+ const fila = botones(p);
617+ if (activo && previo && previo !== activo.themeId) boton(fila, tx('bUndo'), 'undo-theme', async () => { await host.setTheme(previo); pinta('apply-theme'); pintaInstaladas(); });
618+ if (!activo) boton(fila, tx('bApplyNow'), 'apply-theme', async () => { await host.setTheme(rec.themes[0].themeId); pinta('undo-theme'); pintaInstaladas(); });
619+ boton(fila, tx('bPickTheme'), 'pick-theme', () => openThemePicker(host));
620+ if (enfoca) (fila.querySelector(`[data-act="${enfoca}"]`) || fila.querySelector('button'))?.focus();
621+ };
622+ pinta();
623+ }
624+
625+ if (f.highlight.length) {
626+ const p = parte();
627+ const ids = f.highlight.map(x => x.id);
628+ p.appendChild(el('div', null, tx('cHighlight', { list: lista(f.highlight.map(x => x.name + (x.exts.length ? ` (${x.exts.slice(0, 3).join(', ')})` : ''))) })));
629+ const abiertas = pestañasCon(m, ids);
630+ if (abiertas.length) {
631+ p.appendChild(el('div', null, tx('cHighlightOpen', { n: abiertas.length, files: lista(abiertas.slice(0, 3).map(t => baseName(t.path))) })));
632+ const destino = abiertas.find(t => t.active) || abiertas[0];
633+ boton(botones(p), tx('bGoto', { file: baseName(destino.path) }), 'goto', () => irA(destino.path));
634+ } else {
635+ const fich = await ficheroCon(m, ids);
636+ if (fich) boton(botones(p), tx('bOpenFile', { file: baseName(fich.path) }), 'open-example', () => irA(fich.path));
637+ else p.appendChild(el('div', 'muted', tx('cHighlightTry', { exts: lista(f.highlight.flatMap(x => x.exts).slice(0, 4)) })));
638+ }
415639 }
640+
641+ for (const l of rec.languages || []) {
642+ if (!l.configKey || host.builtinLanguage?.(l.id)) continue;
643+ const que = resumenAjustes(await host.languageConfig(rec.id, l.id).catch(() => null));
644+ if (que.length) parte().appendChild(el('div', null, tx('cSettings', { lang: nombreLenguaje(l.id, [{ id: l.id, name: l.aliases?.[0] }]), what: lista(que) })));
645+ }
646+
647+ if (f.snippets.length) {
648+ const p = parte();
649+ const n = f.snippets.reduce((a, s) => a + (s.count || 0), 0);
650+ p.appendChild(el('div', null, tx('cSnippets', { n, list: lista(f.snippets.map(s => s.name)) })));
651+ const prefijos = await host.snippetPrefixes(rec.id).catch(() => []);
652+ if (prefijos.length) p.appendChild(el('div', null, tx('cSnippetsTry', { prefixes: listaO(prefijos.map(cita)) })));
653+ const destino = await ficheroCon(m, f.snippets.map(s => s.id));
654+ if (destino) boton(botones(p), tx('bTryIn', { file: baseName(destino.path) }), 'try-snippet', () => pruebaSnippets(rec, destino.path));
655+ }
656+
657+ for (const l of v.lines) box.appendChild(el('div', 'ext-done-part ext-v-more', l));
658+ if (f.keepsBuiltin.length) box.appendChild(el('div', 'ext-done-part ext-v-more', tx('keepsBuiltin', { list: lista(f.keepsBuiltin) })));
659+ $('ext-done')?.remove();
660+ sitio.after(box);
661+ // la región viva sigue anunciándolo; a la vista basta con la tarjeta
662+ if (!sitio.classList.contains('err')) sitio.classList.add('ext-msg-sr');
416663 }
417664
418-// ── instaladas ──
419665 function claveFoco(x) {
420666 const k = x?.closest?.('[data-k]')?.dataset.k;
421667 const id = x?.closest?.('.ext-row')?.dataset.id;
@@ -429,6 +675,46 @@
429675 if (x) x.focus(); else $('ext-installed-h')?.focus();
430676 }
431677
678+// Lo que esta extensión está haciendo AHORA, con un botón para verlo.
679+function lineasAhora(e, f) {
680+ const box = el('div', 'ext-now');
681+ const linea = (texto, act = null, accesible = null, fn = null) => {
682+ const d = el('div', 'ext-now-line', texto + ' ');
683+ if (act) {
684+ const b = el('button', 'ext-link', tx('bTry'));
685+ b.type = 'button';
686+ b.dataset.act = act;
687+ b.dataset.k = act;
688+ if (accesible) b.setAttribute('aria-label', accesible);
689+ b.onclick = fn;
690+ d.appendChild(b);
691+ }
692+ box.appendChild(d);
693+ };
694+ if (e.themes?.length) {
695+ const activo = e.themes.find(t => t.themeId === host.currentTheme());
696+ linea(activo ? tx('nThemeActive', { name: activo.label }) : tx('nThemeIdle'));
697+ }
698+ if (f.highlight.length) {
699+ const ids = f.highlight.map(x => x.id);
700+ const abiertas = pestañasCon(ideCargado, ids);
701+ const nombres = lista(f.highlight.map(x => x.name));
702+ linea(abiertas.length ? tx('nHighlighting', { n: abiertas.length, list: nombres })
703+ : tx('nHighlightIdle', { list: lista(f.highlight.map(x => x.name + (x.exts.length ? ` (${x.exts.slice(0, 3).join(', ')})` : ''))) }),
704+ 'try-highlight', tx('tryHighlightNamed', { name: nombres }), () => pruebaResaltado(ids));
705+ }
706+ if (f.settingsOnly.length) linea(tx('nSettings', { list: lista(f.settingsOnly) }));
707+ if (f.snippets.length) {
708+ const n = f.snippets.reduce((a, s) => a + (s.count || 0), 0);
709+ const langs = lista(f.snippets.map(s => s.name));
710+ linea(tx('nSnippets', { n, list: langs }), 'try-snippet', tx('trySnippetsNamed', { name: e.displayName }), async () => {
711+ const destino = await ficheroCon(await ide(), f.snippets.map(s => s.id));
712+ await pruebaSnippets(e, destino?.path);
713+ });
714+ }
715+ return box.childNodes.length ? box : null;
716+}
717+
432718 function pintaInstaladas() {
433719 const box = $('ext-installed');
434720 if (!box) return;
@@ -451,15 +737,13 @@
451737 t.append(el('b', null, e.displayName), el('span', 'muted', ` ${e.id} · v${e.version}${e.enabled ? '' : ' · ' + tx('disabled')}`));
452738 main.append(t);
453739 if (e.description) main.appendChild(el('div', 'ext-desc', e.description));
454- const r = resumen({
455- themes: e.themes?.length || 0,
456- grammarLangs: (e.grammars || []).map(g => g.language ?? null),
457- languageList: (e.languages || []).map(l => ({ id: l.id, config: !!l.configKey })),
458- snippetLangs: [...new Set((e.snippets || []).map(s => s.language))],
459- ignored: e.ignored || [], hasCode: e.hasCode, pack: e.pack || [],
460- });
461- for (const l of r.lineas) main.appendChild(el('div', l.cls, l.t));
462- // lo que el paquete declaraba y no se pudo usar: plegado, sin esconderlo
740+ const f = hechosDeRegistro(e);
741+ const v = describe(f);
742+ if (e.enabled && !host.paused) {
743+ const ahora = lineasAhora(e, f);
744+ if (ahora) main.appendChild(ahora);
745+ } else main.appendChild(el('div', 'ext-now muted', tx('nOff')));
746+ main.appendChild(bloqueVeredicto(f, v, { principal: false }));
463747 const avisos = avisosVisibles(e.warnings).map(textoAviso).filter(Boolean);
464748 if (avisos.length) {
465749 const d = el('details', 'ext-warn');
added web/js/ext/verdict.js +121 −0
@@ -0,0 +1,121 @@
1+// Lo que una extensión hará de verdad en Code, dicho en llano y en una línea,
2+// antes de instalarla y después. Nada de términos internos (los nombres de
3+// las contribuciones, «main/browser», «host de extensiones»): el usuario ve
4+// qué funciona, qué no, y si lo que no funciona llegará o no.
5+//
6+// Entrada: los «hechos» de una extensión (del package.json de Open VSX antes de
7+// instalar, o del registro ya instalado; panel.js los arma):
8+// hasCode, browserEntry, categories, sizes {clave de contribución: cuántas},
9+// webviews, ignored [{key}], themes [nombre], highlight [{name, exts}],
10+// settingsOnly [nombre], snippets [{name, count|null}]
11+import { tx } from './i18n.js';
12+import { uiLang } from '../i18n.js';
13+
14+export function listaO(xs) {
15+ const v = [...new Set(xs.filter(Boolean))];
16+ try { return new Intl.ListFormat(uiLang(), { type: 'disjunction' }).format(v); } catch { return v.join(', '); }
17+}
18+export function lista(xs) {
19+ const v = [...new Set(xs.filter(Boolean))];
20+ try { return new Intl.ListFormat(uiLang(), { type: 'conjunction' }).format(v); } catch { return v.join(', '); }
21+}
22+export const esTexto = x => typeof x === 'string' && !!x.trim() && !/^%[^%\s]+%$/.test(x);
23+const corta = (xs, n = 4) => (xs.length > n ? [...xs.slice(0, n), tx('andMore', { n: xs.length - n })] : xs);
24+
25+// Categorías de Open VSX que hablan de una función que hace su código.
26+const POR_CATEGORIA = {
27+ Formatters: 'fFormat', Linters: 'fLint', Debuggers: 'fDebug', Visualization: 'fPreview', Notebooks: 'fNotebooks',
28+ Testing: 'fTesting', 'SCM Providers': 'fScm', 'Data Science': 'fData', 'Machine Learning': 'fAI', AI: 'fAI', Chat: 'fAI',
29+ Keymaps: 'fKeys', Education: null, Other: null, Themes: null, Snippets: null, 'Programming Languages': null, 'Language Packs': 'fLangPack',
30+ Azure: 'fCloud', 'Extension Packs': null,
31+};
32+// Contribuciones que necesitan el código de la extensión, en palabras llanas.
33+const POR_CLAVE = {
34+ commands: 'fCommands', menus: 'fCommands', submenus: 'fCommands', keybindings: 'fKeys', customEditors: 'fPreview',
35+ views: 'fPanels', viewsContainers: 'fPanels', viewsWelcome: 'fPanels', debuggers: 'fDebug', breakpoints: 'fDebug',
36+ taskDefinitions: 'fTasks', notebooks: 'fNotebooks', notebookRenderer: 'fNotebooks', configuration: 'fSettings',
37+ jsonValidation: 'fJsonCheck', semanticTokenTypes: 'fSemantic', semanticTokenScopes: 'fSemantic', semanticTokenModifiers: 'fSemantic',
38+ iconThemes: 'fIcons', productIconThemes: 'fIcons', terminal: 'fTerminal', chatParticipants: 'fAI', languageModelTools: 'fAI',
39+ mcpServerDefinitionProviders: 'fAI', authentication: 'fAccounts', walkthroughs: 'fWalk', statusBarItems: 'fStatus',
40+ codeActions: 'fCodeActions', typescriptServerPlugins: 'fLangServer', problemMatchers: 'fTasks', problemPatterns: 'fTasks',
41+ resourceLabelFormatters: null, configurationDefaults: null, remoteHelp: null, colors: null, icons: 'fIcons',
42+};
43+// Lo que ni con la siguiente versión funcionaría aquí: ventanas propias
44+// (vistas web, editores a medida), depuradores, terminales, cuadernos.
45+const NUNCA = new Set(['customEditors', 'notebookRenderer', 'notebooks', 'debuggers', 'terminal', 'views', 'viewsContainers']);
46+const DECLARATIVAS = new Set(['Themes', 'Snippets', 'Programming Languages']);
47+
48+// Funciones que no funcionan, en llano y sin repetir.
49+export function missingFeatures(f) {
50+ const claves = [];
51+ for (const c of f.categories || []) if (POR_CATEGORIA[c]) claves.push(POR_CATEGORIA[c]);
52+ const principales = [...new Set(claves)];
53+ for (const i of f.ignored || []) {
54+ const k = Object.hasOwn(POR_CLAVE, i.key) ? POR_CLAVE[i.key] : 'fOther';
55+ if (k) claves.push(k);
56+ }
57+ return { principales: principales.map(k => tx(k)), todas: [...new Set(claves)].map(k => tx(k)) };
58+}
59+
60+// Lo principal que no funciona: lo que dicen sus categorías o, si no dicen
61+// nada, sus funciones concretas; «otras funciones» sola no explica nada.
62+function loPrincipal(principales, faltan) {
63+ const concretas = faltan.filter(x => x !== tx('fOther'));
64+ return lista((principales.length ? principales : concretas.length ? concretas : [tx('fOwn')]).slice(0, 3));
65+}
66+
67+export function describe(f) {
68+ const partes = []; // { tipo, texto }
69+ const themes = f.themes || [], highlight = f.highlight || [], settingsOnly = f.settingsOnly || [], snippets = f.snippets || [];
70+ // el package.json de Open VSX puede traer los nombres sin traducir (%clave%):
71+ // entonces se cuentan en vez de nombrarlos
72+ const conNombre = themes.filter(esTexto);
73+ if (themes.length) partes.push({ tipo: 'theme', texto: conNombre.length === themes.length ? tx('pThemes', { n: themes.length, list: lista(corta(themes.map(t => tx('quoted', { x: t })))) }) : tx('pThemesCount', { n: themes.length }) });
74+ if (highlight.length) partes.push({ tipo: 'highlight', texto: tx('pHighlight', { list: lista(corta(highlight.map(h => h.name))) }) });
75+ if (settingsOnly.length) partes.push({ tipo: 'settings', texto: tx('pSettings', { list: lista(corta(settingsOnly)) }) });
76+ if (snippets.length) {
77+ const total = snippets.every(s => Number.isFinite(s.count)) ? snippets.reduce((a, s) => a + s.count, 0) : null;
78+ const langs = lista(corta([...new Set(snippets.map(s => s.name))]));
79+ partes.push({ tipo: 'snippets', texto: total != null ? tx('pSnippetsN', { n: total, list: langs }) : tx('pSnippets', { list: langs }) });
80+ }
81+ const usable = partes.length > 0;
82+ const hasCode = !!f.hasCode;
83+ const sizes = f.sizes || {};
84+ const nunca = !!f.webviews || Object.keys(sizes).some(k => NUNCA.has(k));
85+ const { principales, todas } = missingFeatures(f);
86+ const faltan = hasCode && !todas.length ? [tx('fOwn')] : todas;
87+ // ¿lo principal es lo que hace su código? Si no se declara como tema,
88+ // snippets o lenguaje; si trae ventanas propias; o si casi todo son comandos
89+ const categorias = f.categories || [];
90+ const codigoManda = hasCode && (!usable || !categorias.some(c => DECLARATIVAS.has(c)) || nunca || (sizes.commands || 0) >= 10);
91+ const futuro = !hasCode ? null : f.browserEntry && !nunca ? 'next' : 'never';
92+ const queTraen = lista(partes.map(p => p.texto));
93+ const lineas = [];
94+ let kind, verdict;
95+ if (!usable) {
96+ kind = hasCode ? 'code' : 'nothing';
97+ if (hasCode) {
98+ verdict = tx('vMainBroken', { what: loPrincipal(principales, faltan) });
99+ lineas.push(tx(futuro === 'next' ? 'vNextVersion' : 'vNever'));
100+ } else verdict = tx('nothing');
101+ } else if (!hasCode && !faltan.length) {
102+ kind = 'full';
103+ verdict = tx('vFull', { list: queTraen });
104+ } else if (codigoManda) {
105+ kind = 'mostlyCode';
106+ verdict = tx('vMainBroken', { what: loPrincipal(principales, faltan) });
107+ lineas.push(tx('vOnly', { list: queTraen }));
108+ lineas.push(tx(futuro === 'next' ? 'vNextVersion' : 'vNever'));
109+ } else {
110+ kind = 'partial';
111+ verdict = tx('vPartial', { list: queTraen });
112+ lineas.push(tx(!hasCode ? 'vMissingLater' : futuro === 'next' ? 'vMissingNext' : 'vMissingNever', { list: lista(faltan) }));
113+ }
114+ const tipos = [...new Set(partes.map(p => p.tipo === 'settings' ? 'highlight' : p.tipo))];
115+ const soloQue = tipos.length === 1 ? { theme: 'installOnlyThemes', highlight: 'installOnlyHighlight', snippets: 'installOnlySnippets' }[tipos[0]] : 'installOnlyWorking';
116+ const button = kind === 'full' ? { key: 'install', style: 'primary', disabled: false }
117+ : kind === 'partial' ? { key: soloQue, style: 'primary', disabled: false }
118+ : kind === 'mostlyCode' ? { key: soloQue, style: 'ghost', disabled: false }
119+ : { key: kind === 'code' ? 'notHere' : 'nothingHere', style: 'ghost', disabled: true };
120+ return { kind, verdict, lines: lineas, button, future: futuro, usable, missing: faltan, parts: partes };
121+}
modified web/js/ext/vsix.js +16 −2
@@ -39,8 +39,22 @@
3939 // para decir qué NO se aplicaría aunque se instale (panel.js): el lenguaje
4040 // de cada gramática y si cada lenguaje trae configuración
4141 const grammarLangs = arr('grammars').map(g => (typeof g?.language === 'string' ? g.language : null));
42- const languageList = arr('languages').filter(l => typeof l?.id === 'string' && l.id).map(l => ({ id: l.id, config: typeof l.configuration === 'string' }));
43- return { applies, ignored, hasCode, pack, snippetLangs, languages, grammarLangs, languageList, any: Object.values(applies).some(Boolean) };
42+ const languageList = arr('languages').filter(l => typeof l?.id === 'string' && l.id).map(l => ({
43+ id: l.id, config: typeof l.configuration === 'string',
44+ name: Array.isArray(l.aliases) && typeof l.aliases[0] === 'string' ? l.aliases[0] : undefined,
45+ extensions: Array.isArray(l.extensions) ? l.extensions.filter(x => typeof x === 'string') : [],
46+ }));
47+ // para el veredicto en lenguaje llano (verdict.js): de qué va, qué partes
48+ // necesitan su código y si ese código podría correr en un navegador
49+ const categories = Array.isArray(pkg?.categories) ? pkg.categories.filter(x => typeof x === 'string') : [];
50+ const sizes = {};
51+ for (const k of Object.keys(c)) sizes[k] = Array.isArray(c[k]) ? c[k].length : c[k] && typeof c[k] === 'object' ? Object.keys(c[k]).length : 1;
52+ const webviews = Object.values(c.views && typeof c.views === 'object' ? c.views : {}).some(v => Array.isArray(v) && v.some(x => x?.type === 'webview'));
53+ const themeLabels = arr('themes').map(t => (typeof t?.label === 'string' ? t.label : typeof t?.id === 'string' ? t.id : null)).filter(Boolean);
54+ return {
55+ applies, ignored, hasCode, pack, snippetLangs, languages, grammarLangs, languageList, any: Object.values(applies).some(Boolean),
56+ categories, sizes, webviews, browserEntry: typeof pkg?.browser === 'string', themeLabels,
57+ };
4458 }
4559
4660 // %clave% → texto de package.nls(.<idioma>).json, en todo el manifiesto.
modified web/js/ide.js +6 −0
@@ -86,6 +86,12 @@
8686 // La ruta del fichero activo (o null): el menú la usa para no lanzar acciones
8787 // del editor que no hacen nada sin un fichero abierto.
8888 export function activeFile() { return active; }
89+// Las pestañas abiertas y su lenguaje, y el lenguaje que tendría una ruta: el
90+// panel de extensiones los usa para decir qué ficheros ya se ven distintos.
91+export function openTabs() {
92+ return tabs.filter(t => !t.model.isDisposed()).map(t => ({ path: t.path, language: t.model.getLanguageId(), active: t.path === active }));
93+}
94+export const languageOfPath = p => langOf(p);
8995
9096 export async function openFile(path) {
9197 let tab = tabs.find(t => t.path === path);