@modularcore/registry 0.2.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build-registry.d.ts.map +1 -1
- package/dist/build-registry.js +37 -2
- package/dist/build-registry.js.map +1 -1
- package/dist/dependency-usage.d.ts +35 -0
- package/dist/dependency-usage.d.ts.map +1 -0
- package/dist/dependency-usage.js +67 -0
- package/dist/dependency-usage.js.map +1 -0
- package/dist/framework-catalog.d.ts +70 -0
- package/dist/framework-catalog.d.ts.map +1 -0
- package/dist/framework-catalog.js +137 -0
- package/dist/framework-catalog.js.map +1 -0
- package/dist/framework-files.d.ts +19 -0
- package/dist/framework-files.d.ts.map +1 -0
- package/dist/framework-files.js +73 -0
- package/dist/framework-files.js.map +1 -0
- package/dist/index.d.ts +9 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/schema.d.ts +35 -0
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +0 -4
- package/dist/schema.js.map +1 -1
- package/dist/schema.zod.d.ts +87 -2
- package/dist/schema.zod.d.ts.map +1 -1
- package/dist/schema.zod.js +71 -2
- package/dist/schema.zod.js.map +1 -1
- package/dist/ui-coverage.d.ts +59 -0
- package/dist/ui-coverage.d.ts.map +1 -0
- package/dist/ui-coverage.js +143 -0
- package/dist/ui-coverage.js.map +1 -0
- package/package.json +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-registry.d.ts","sourceRoot":"","sources":["../src/build-registry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build-registry.d.ts","sourceRoot":"","sources":["../src/build-registry.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAIV,kBAAkB,EACnB,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,oBAAoB;IACnC,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,kBAAkB,EAAE,CAAC;IAClC,cAAc,EAAE,MAAM,EAAE,CAAC;CAC1B;AA6JD;;;;;;GAMG;AACH,wBAAsB,aAAa,CAAC,EAClC,YAAY,EACZ,SAAS,GACV,EAAE,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAiEtD"}
|
package/dist/build-registry.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
|
-
import { mkdir, mkdtemp, readFile, readdir, realpath, rename, rm, stat, writeFile, } from 'node:fs/promises';
|
|
3
|
-
import { dirname, join, resolve, sep } from 'node:path';
|
|
2
|
+
import { copyFile, mkdir, mkdtemp, readFile, readdir, realpath, rename, rm, stat, writeFile, } from 'node:fs/promises';
|
|
3
|
+
import { dirname, extname, join, resolve, sep } from 'node:path';
|
|
4
|
+
import { buildFrameworkCatalog } from './framework-catalog.js';
|
|
4
5
|
import { registryDescriptorSchema } from './schema.zod.js';
|
|
5
6
|
import { buildTarball } from './tarball.js';
|
|
6
7
|
async function findComponentDirs(packagesRoot) {
|
|
@@ -84,6 +85,30 @@ async function buildEntry(descriptor, componentDir) {
|
|
|
84
85
|
}
|
|
85
86
|
return { ...descriptor, files };
|
|
86
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* Formatos admitidos para la captura. **SVG queda fuera a propósito**: servido desde nuestro
|
|
90
|
+
* dominio con su propio `Content-Type`, un SVG abierto directamente ejecuta el script que lleve
|
|
91
|
+
* dentro, y estas imágenes las aporta quien contribuye.
|
|
92
|
+
*/
|
|
93
|
+
const PREVIEW_EXTENSIONS = ['.png', '.jpg', '.jpeg', '.webp'];
|
|
94
|
+
/**
|
|
95
|
+
* Copia la captura del componente junto a los demás artefactos y devuelve el `preview` con la URL
|
|
96
|
+
* ya servible, que es lo que el catálogo consume. El nombre de destino se deriva del componente,
|
|
97
|
+
* así que dos paquetes no pueden pisarse.
|
|
98
|
+
*/
|
|
99
|
+
async function copyPreview(descriptor, componentDir, tmpRoot) {
|
|
100
|
+
if (!descriptor.preview)
|
|
101
|
+
return undefined;
|
|
102
|
+
const extension = extname(descriptor.preview.image).toLowerCase();
|
|
103
|
+
if (!PREVIEW_EXTENSIONS.includes(extension)) {
|
|
104
|
+
throw new Error(`"${descriptor.name}": la captura debe ser ${PREVIEW_EXTENSIONS.join(', ')} y es "${extension || 'sin extensión'}"`);
|
|
105
|
+
}
|
|
106
|
+
const componentRealDir = await realpath(componentDir);
|
|
107
|
+
const source = await assertSafeSourcePath(componentRealDir, descriptor.preview.image);
|
|
108
|
+
const fileName = `${descriptor.name}-preview${extension}`;
|
|
109
|
+
await copyFile(source, join(tmpRoot, fileName));
|
|
110
|
+
return { image: `/registry/${fileName}`, alt: descriptor.preview.alt };
|
|
111
|
+
}
|
|
87
112
|
function toIndexEntry(descriptor) {
|
|
88
113
|
return {
|
|
89
114
|
name: descriptor.name,
|
|
@@ -91,6 +116,8 @@ function toIndexEntry(descriptor) {
|
|
|
91
116
|
category: descriptor.category,
|
|
92
117
|
version: descriptor.version,
|
|
93
118
|
frameworks: descriptor.frameworks,
|
|
119
|
+
...(descriptor.ui ? { ui: descriptor.ui } : {}),
|
|
120
|
+
...(descriptor.preview ? { preview: descriptor.preview } : {}),
|
|
94
121
|
description: descriptor.description,
|
|
95
122
|
};
|
|
96
123
|
}
|
|
@@ -124,12 +151,14 @@ export async function buildRegistry({ packagesRoot, outputDir, }) {
|
|
|
124
151
|
}
|
|
125
152
|
const entries = [];
|
|
126
153
|
const seenNames = new Set();
|
|
154
|
+
const componentDirByName = new Map();
|
|
127
155
|
for (const componentDir of componentDirs) {
|
|
128
156
|
const descriptor = await loadDescriptor(componentDir);
|
|
129
157
|
if (seenNames.has(descriptor.name)) {
|
|
130
158
|
throw new Error(`Duplicate component name "${descriptor.name}" across packages/*`);
|
|
131
159
|
}
|
|
132
160
|
seenNames.add(descriptor.name);
|
|
161
|
+
componentDirByName.set(descriptor.name, componentDir);
|
|
133
162
|
entries.push(await buildEntry(descriptor, componentDir));
|
|
134
163
|
}
|
|
135
164
|
// Stage on the same filesystem/volume as `outputDir` (not the OS tmpdir): the final
|
|
@@ -141,6 +170,9 @@ export async function buildRegistry({ packagesRoot, outputDir, }) {
|
|
|
141
170
|
try {
|
|
142
171
|
const publicIndex = [];
|
|
143
172
|
for (const entry of entries) {
|
|
173
|
+
const preview = await copyPreview(entry, componentDirByName.get(entry.name), tmpRoot);
|
|
174
|
+
if (preview)
|
|
175
|
+
entry.preview = preview;
|
|
144
176
|
await writeFile(join(tmpRoot, `${entry.name}.json`), JSON.stringify(entry, null, 2), 'utf8');
|
|
145
177
|
const tarball = await buildTarball(entry.files);
|
|
146
178
|
await writeFile(join(tmpRoot, `${entry.name}.tar.gz`), tarball);
|
|
@@ -149,6 +181,9 @@ export async function buildRegistry({ packagesRoot, outputDir, }) {
|
|
|
149
181
|
}
|
|
150
182
|
}
|
|
151
183
|
await writeFile(join(tmpRoot, 'index.json'), JSON.stringify(publicIndex, null, 2), 'utf8');
|
|
184
|
+
// El catálogo de frameworks, reunido de todos los componentes: es lo que permite a la CLI
|
|
185
|
+
// detectar y ofrecer un framework que ningún código nuestro conoce.
|
|
186
|
+
await writeFile(join(tmpRoot, 'frameworks.json'), JSON.stringify(buildFrameworkCatalog(entries), null, 2), 'utf8');
|
|
152
187
|
await validateBuildOutput(tmpRoot, entries.map((entry) => entry.name));
|
|
153
188
|
await rm(outputDir, { recursive: true, force: true });
|
|
154
189
|
await rename(tmpRoot, outputDir);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-registry.js","sourceRoot":"","sources":["../src/build-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,KAAK,EACL,OAAO,EACP,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,MAAM,EACN,EAAE,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EAAE,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACtD,MAAM,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QAEjC,OAAO;YACL,SAAS;YACT,WAAW;YACX,cAAc,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC;SACnD,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACpD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Qué dependencias npm necesita de verdad lo que se instala.
|
|
3
|
+
*
|
|
4
|
+
* Los ficheros se recortan al framework del proyecto (ver `framework-files.ts`), pero las
|
|
5
|
+
* dependencias no lo hacían: `media-picker` declara `bits-ui` —una librería de componentes que
|
|
6
|
+
* sólo existe para Svelte— y `@radix-ui/*` —sólo para React—, así que instalarlo en un proyecto
|
|
7
|
+
* React metía `bits-ui` en su `package.json` aunque ni un solo fichero de Svelte llegara a
|
|
8
|
+
* escribirse. Y como esos paquetes declaran su framework como peer, la instalación podía fallar
|
|
9
|
+
* con ERESOLVE justo después de que el usuario confirmara.
|
|
10
|
+
*
|
|
11
|
+
* La pertenencia no se declara en el descriptor: se deduce de quién importa qué, que es la
|
|
12
|
+
* verdad, no una etiqueta que alguien tenga que acordarse de mantener.
|
|
13
|
+
*/
|
|
14
|
+
export interface FileWithContent {
|
|
15
|
+
path: string;
|
|
16
|
+
content: string;
|
|
17
|
+
}
|
|
18
|
+
/** Paquetes npm que estos ficheros importan de forma estática. */
|
|
19
|
+
export declare function npmImportsOf(files: FileWithContent[]): Set<string>;
|
|
20
|
+
/**
|
|
21
|
+
* Recorta `dependencies` a las que hacen falta para los ficheros que se van a escribir.
|
|
22
|
+
*
|
|
23
|
+
* Una dependencia que **ningún** fichero del componente importa se conserva: no hay forma de
|
|
24
|
+
* saber a quién sirve —puede cargarse dinámicamente, o ser una herramienta— y quitarla rompería
|
|
25
|
+
* la instalación. Ante la duda, sobra una dependencia antes que falte una, igual que con los
|
|
26
|
+
* ficheros.
|
|
27
|
+
*
|
|
28
|
+
* @param dependencies Las declaradas por el componente, con su rango (`bits-ui@^2.18.2`).
|
|
29
|
+
* @param selected Los ficheros que se van a escribir, ya recortados al framework del proyecto.
|
|
30
|
+
* @param all Todos los ficheros del componente, para distinguir «de otro framework» de «de nadie».
|
|
31
|
+
*/
|
|
32
|
+
export declare function dependenciesForFiles(dependencies: string[], selected: FileWithContent[], all: FileWithContent[]): string[];
|
|
33
|
+
/** `bits-ui@^2.18.2` → `bits-ui`; `@radix-ui/react-toggle@^1.1.18` → `@radix-ui/react-toggle`. */
|
|
34
|
+
export declare function dependencyNameOf(dependency: string): string;
|
|
35
|
+
//# sourceMappingURL=dependency-usage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dependency-usage.d.ts","sourceRoot":"","sources":["../src/dependency-usage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAOH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAaD,kEAAkE;AAClE,wBAAgB,YAAY,CAAC,KAAK,EAAE,eAAe,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,CAclE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAClC,YAAY,EAAE,MAAM,EAAE,EACtB,QAAQ,EAAE,eAAe,EAAE,EAC3B,GAAG,EAAE,eAAe,EAAE,GACrB,MAAM,EAAE,CAQV;AAED,kGAAkG;AAClG,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAG3D"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Qué dependencias npm necesita de verdad lo que se instala.
|
|
3
|
+
*
|
|
4
|
+
* Los ficheros se recortan al framework del proyecto (ver `framework-files.ts`), pero las
|
|
5
|
+
* dependencias no lo hacían: `media-picker` declara `bits-ui` —una librería de componentes que
|
|
6
|
+
* sólo existe para Svelte— y `@radix-ui/*` —sólo para React—, así que instalarlo en un proyecto
|
|
7
|
+
* React metía `bits-ui` en su `package.json` aunque ni un solo fichero de Svelte llegara a
|
|
8
|
+
* escribirse. Y como esos paquetes declaran su framework como peer, la instalación podía fallar
|
|
9
|
+
* con ERESOLVE justo después de que el usuario confirmara.
|
|
10
|
+
*
|
|
11
|
+
* La pertenencia no se declara en el descriptor: se deduce de quién importa qué, que es la
|
|
12
|
+
* verdad, no una etiqueta que alguien tenga que acordarse de mantener.
|
|
13
|
+
*/
|
|
14
|
+
/** Import de un paquete npm: cualquiera que no empiece por `.` (relativo) ni sea `node:`. */
|
|
15
|
+
const BARE_IMPORT_PATTERN = /(?:from|import)\s+['"]([^.'"][^'"]*)['"]/g;
|
|
16
|
+
const BLOCK_COMMENT = /\/\*[\s\S]*?\*\//g;
|
|
17
|
+
const LINE_COMMENT = /(^|[^:])\/\/.*$/gm;
|
|
18
|
+
/** `@scope/pkg/sub/path` → `@scope/pkg`; `pkg/sub` → `pkg`. */
|
|
19
|
+
function packageNameOf(specifier) {
|
|
20
|
+
const segments = specifier.split('/');
|
|
21
|
+
return specifier.startsWith('@') ? segments.slice(0, 2).join('/') : segments[0];
|
|
22
|
+
}
|
|
23
|
+
/** Los ejemplos dentro de un JSDoc importan desde el punto de vista del proyecto de destino. */
|
|
24
|
+
function stripComments(source) {
|
|
25
|
+
return source.replace(BLOCK_COMMENT, '').replace(LINE_COMMENT, '$1');
|
|
26
|
+
}
|
|
27
|
+
/** Paquetes npm que estos ficheros importan de forma estática. */
|
|
28
|
+
export function npmImportsOf(files) {
|
|
29
|
+
const imported = new Set();
|
|
30
|
+
for (const file of files) {
|
|
31
|
+
// Un `@import "tailwindcss"` de una hoja de estilo no es una dependencia npm del componente.
|
|
32
|
+
if (file.path.endsWith('.css'))
|
|
33
|
+
continue;
|
|
34
|
+
for (const [, specifier] of stripComments(file.content).matchAll(BARE_IMPORT_PATTERN)) {
|
|
35
|
+
if (!specifier || specifier.startsWith('node:'))
|
|
36
|
+
continue;
|
|
37
|
+
imported.add(packageNameOf(specifier));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return imported;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Recorta `dependencies` a las que hacen falta para los ficheros que se van a escribir.
|
|
44
|
+
*
|
|
45
|
+
* Una dependencia que **ningún** fichero del componente importa se conserva: no hay forma de
|
|
46
|
+
* saber a quién sirve —puede cargarse dinámicamente, o ser una herramienta— y quitarla rompería
|
|
47
|
+
* la instalación. Ante la duda, sobra una dependencia antes que falte una, igual que con los
|
|
48
|
+
* ficheros.
|
|
49
|
+
*
|
|
50
|
+
* @param dependencies Las declaradas por el componente, con su rango (`bits-ui@^2.18.2`).
|
|
51
|
+
* @param selected Los ficheros que se van a escribir, ya recortados al framework del proyecto.
|
|
52
|
+
* @param all Todos los ficheros del componente, para distinguir «de otro framework» de «de nadie».
|
|
53
|
+
*/
|
|
54
|
+
export function dependenciesForFiles(dependencies, selected, all) {
|
|
55
|
+
const neededHere = npmImportsOf(selected);
|
|
56
|
+
const usedAnywhere = npmImportsOf(all);
|
|
57
|
+
return dependencies.filter((dependency) => {
|
|
58
|
+
const name = dependencyNameOf(dependency);
|
|
59
|
+
return neededHere.has(name) || !usedAnywhere.has(name);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
/** `bits-ui@^2.18.2` → `bits-ui`; `@radix-ui/react-toggle@^1.1.18` → `@radix-ui/react-toggle`. */
|
|
63
|
+
export function dependencyNameOf(dependency) {
|
|
64
|
+
const at = dependency.lastIndexOf('@');
|
|
65
|
+
return at > 0 ? dependency.slice(0, at) : dependency;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=dependency-usage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dependency-usage.js","sourceRoot":"","sources":["../src/dependency-usage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,6FAA6F;AAC7F,MAAM,mBAAmB,GAAG,2CAA2C,CAAC;AACxE,MAAM,aAAa,GAAG,mBAAmB,CAAC;AAC1C,MAAM,YAAY,GAAG,mBAAmB,CAAC;AAOzC,+DAA+D;AAC/D,SAAS,aAAa,CAAC,SAAiB;IACtC,MAAM,QAAQ,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACtC,OAAO,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAE,CAAC;AACnF,CAAC;AAED,gGAAgG;AAChG,SAAS,aAAa,CAAC,MAAc;IACnC,OAAO,MAAM,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;AACvE,CAAC;AAED,kEAAkE;AAClE,MAAM,UAAU,YAAY,CAAC,KAAwB;IACnD,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAC;IAEnC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,6FAA6F;QAC7F,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;YAAE,SAAS;QAEzC,KAAK,MAAM,CAAC,EAAE,SAAS,CAAC,IAAI,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,mBAAmB,CAAC,EAAE,CAAC;YACtF,IAAI,CAAC,SAAS,IAAI,SAAS,CAAC,UAAU,CAAC,OAAO,CAAC;gBAAE,SAAS;YAC1D,QAAQ,CAAC,GAAG,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,oBAAoB,CAClC,YAAsB,EACtB,QAA2B,EAC3B,GAAsB;IAEtB,MAAM,UAAU,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC;IAC1C,MAAM,YAAY,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;IAEvC,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE;QACxC,MAAM,IAAI,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC;QAC1C,OAAO,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;AACL,CAAC;AAED,kGAAkG;AAClG,MAAM,UAAU,gBAAgB,CAAC,UAAkB;IACjD,MAAM,EAAE,GAAG,UAAU,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IACvC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;AACvD,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Qué frameworks existen, y qué sabe el registry de cada uno.
|
|
3
|
+
*
|
|
4
|
+
* Los seis de casa vienen definidos aquí, pero **la lista no es cerrada**: un componente puede
|
|
5
|
+
* traer el suyo en `frameworkDefs` y el registry lo entiende sin que nadie toque este fichero.
|
|
6
|
+
* Alguien que aporte un componente en Solid o Qwik no se topa con una lista blanca que sólo el
|
|
7
|
+
* mantenimiento puede ampliar; la revisión de su PR es el control, no el código.
|
|
8
|
+
*
|
|
9
|
+
* Lo que una definición aporta es lo que el registry y la CLI no pueden adivinar: en qué fichero
|
|
10
|
+
* se escribe su UI, cómo se reconoce un proyecto suyo, y dónde van las cosas al instalar.
|
|
11
|
+
*/
|
|
12
|
+
export interface FrameworkDefinition {
|
|
13
|
+
/** Nombre para mostrar en el catálogo y en los prompts. */
|
|
14
|
+
title: string;
|
|
15
|
+
/**
|
|
16
|
+
* Extensión de sus componentes de UI (`.tsx`, `.svelte`). Omitida, el framework no tiene UI de
|
|
17
|
+
* referencia propia y se sirve con snippets, como `blade` y `vanilla`.
|
|
18
|
+
*/
|
|
19
|
+
uiExtension?: string;
|
|
20
|
+
/** Dependencia que delata un proyecto suyo: `solid-js` para Solid, `react` para React. */
|
|
21
|
+
detect?: {
|
|
22
|
+
npm?: string;
|
|
23
|
+
composer?: string;
|
|
24
|
+
};
|
|
25
|
+
/** Peer que `add` exigirá al instalar en un proyecto suyo. */
|
|
26
|
+
peer?: string;
|
|
27
|
+
/** Rutas por defecto que `init` propone. */
|
|
28
|
+
paths?: {
|
|
29
|
+
components: string;
|
|
30
|
+
lib: string;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Framework cuyo *binding* hereda. `blade` se apoya en `vanilla` porque sus plantillas montan
|
|
34
|
+
* ese mismo código. Alcanza a `adapters/`, nunca a `snippets/`.
|
|
35
|
+
*/
|
|
36
|
+
basedOn?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Directorio bajo `snippets/` que le pertenece, cuando no coincide con su nombre: la isla de
|
|
39
|
+
* Astro vive en `snippets/astro/` y sirve al framework `vanilla`.
|
|
40
|
+
*/
|
|
41
|
+
snippetDirectory?: string;
|
|
42
|
+
}
|
|
43
|
+
/** Los que trae el registry de fábrica. Un componente puede añadir los suyos. */
|
|
44
|
+
export declare const BUILTIN_FRAMEWORKS: Record<string, FrameworkDefinition>;
|
|
45
|
+
/** Sirve a cualquier proyecto: `assertCompatible` lo trata como comodín. */
|
|
46
|
+
export declare const AGNOSTIC_FRAMEWORK = "agnostic";
|
|
47
|
+
export interface DescriptorWithFrameworks {
|
|
48
|
+
frameworks: string[];
|
|
49
|
+
frameworkDefs?: Record<string, FrameworkDefinition>;
|
|
50
|
+
}
|
|
51
|
+
export declare class FrameworkConflictError extends Error {
|
|
52
|
+
}
|
|
53
|
+
/** `Object.hasOwn` y no un acceso directo: `catalog['constructor']` sería siempre verdadero. */
|
|
54
|
+
export declare function isDefined(catalog: Record<string, FrameworkDefinition>, name: string): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Reúne los frameworks de casa con los que declaren los componentes.
|
|
57
|
+
*
|
|
58
|
+
* Las definiciones de casa mandan siempre: un componente no puede redefinir qué es React para
|
|
59
|
+
* todo el catálogo. Entre dos aportadas, en cambio, una discrepancia es un conflicto y se
|
|
60
|
+
* denuncia, porque resolverla por orden de llegada dejaría al perdedor con sus ficheros sin dueño.
|
|
61
|
+
*/
|
|
62
|
+
export declare function buildFrameworkCatalog(descriptors: DescriptorWithFrameworks[]): Record<string, FrameworkDefinition>;
|
|
63
|
+
/**
|
|
64
|
+
* Los frameworks que este descriptor puede usar: los de casa más los que él mismo declara. Es lo
|
|
65
|
+
* que necesita el recorte de ficheros para saber que `ui/solid/` es de alguien.
|
|
66
|
+
*/
|
|
67
|
+
export declare function frameworksKnownTo(descriptor: DescriptorWithFrameworks): Record<string, FrameworkDefinition>;
|
|
68
|
+
/** Frameworks declarados que nadie define: ni de casa, ni en el propio descriptor. */
|
|
69
|
+
export declare function undefinedFrameworks(descriptor: DescriptorWithFrameworks): string[];
|
|
70
|
+
//# sourceMappingURL=framework-catalog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"framework-catalog.d.ts","sourceRoot":"","sources":["../src/framework-catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,MAAM,WAAW,mBAAmB;IAClC,2DAA2D;IAC3D,KAAK,EAAE,MAAM,CAAC;I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|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Qué frameworks existen, y qué sabe el registry de cada uno.
|
|
3
|
+
*
|
|
4
|
+
* Los seis de casa vienen definidos aquí, pero **la lista no es cerrada**: un componente puede
|
|
5
|
+
* traer el suyo en `frameworkDefs` y el registry lo entiende sin que nadie toque este fichero.
|
|
6
|
+
* Alguien que aporte un componente en Solid o Qwik no se topa con una lista blanca que sólo el
|
|
7
|
+
* mantenimiento puede ampliar; la revisión de su PR es el control, no el código.
|
|
8
|
+
*
|
|
9
|
+
* Lo que una definición aporta es lo que el registry y la CLI no pueden adivinar: en qué fichero
|
|
10
|
+
* se escribe su UI, cómo se reconoce un proyecto suyo, y dónde van las cosas al instalar.
|
|
11
|
+
*/
|
|
12
|
+
/** Los que trae el registry de fábrica. Un componente puede añadir los suyos. */
|
|
13
|
+
export const BUILTIN_FRAMEWORKS = {
|
|
14
|
+
react: {
|
|
15
|
+
title: 'React',
|
|
16
|
+
uiExtension: '.tsx',
|
|
17
|
+
detect: { npm: 'react' },
|
|
18
|
+
peer: 'react',
|
|
19
|
+
paths: { components: 'src/components', lib: 'src/lib/modularcore' },
|
|
20
|
+
},
|
|
21
|
+
svelte: {
|
|
22
|
+
title: 'Svelte',
|
|
23
|
+
uiExtension: '.svelte',
|
|
24
|
+
detect: { npm: 'svelte' },
|
|
25
|
+
peer: 'svelte',
|
|
26
|
+
paths: { components: 'src/components', lib: 'src/lib/modularcore' },
|
|
27
|
+
},
|
|
28
|
+
vue: {
|
|
29
|
+
title: 'Vue',
|
|
30
|
+
uiExtension: '.vue',
|
|
31
|
+
detect: { npm: 'vue' },
|
|
32
|
+
peer: 'vue',
|
|
33
|
+
paths: { components: 'src/components', lib: 'src/lib/modularcore' },
|
|
34
|
+
},
|
|
35
|
+
angular: {
|
|
36
|
+
title: 'Angular',
|
|
37
|
+
uiExtension: '.component.ts',
|
|
38
|
+
detect: { npm: '@angular/core' },
|
|
39
|
+
peer: '@angular/core',
|
|
40
|
+
paths: { components: 'src/components', lib: 'src/lib/modularcore' },
|
|
41
|
+
},
|
|
42
|
+
blade: {
|
|
43
|
+
title: 'Blade',
|
|
44
|
+
detect: { composer: 'laravel/framework' },
|
|
45
|
+
basedOn: 'vanilla',
|
|
46
|
+
snippetDirectory: 'laravel',
|
|
47
|
+
paths: { components: 'resources/views/components', lib: 'resources/js/modularcore' },
|
|
48
|
+
},
|
|
49
|
+
vanilla: {
|
|
50
|
+
title: 'Sin framework (Astro, HTMX, Rails…)',
|
|
51
|
+
detect: { npm: 'astro' },
|
|
52
|
+
snippetDirectory: 'astro',
|
|
53
|
+
paths: { components: 'src/components', lib: 'src/lib/modularcore' },
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
/** Sirve a cualquier proyecto: `assertCompatible` lo trata como comodín. */
|
|
57
|
+
export const AGNOSTIC_FRAMEWORK = 'agnostic';
|
|
58
|
+
export class FrameworkConflictError extends Error {
|
|
59
|
+
}
|
|
60
|
+
/** `Object.hasOwn` y no un acceso directo: `catalog['constructor']` sería siempre verdadero. */
|
|
61
|
+
export function isDefined(catalog, name) {
|
|
62
|
+
return Object.hasOwn(catalog, name);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Reúne los frameworks de casa con los que declaren los componentes.
|
|
66
|
+
*
|
|
67
|
+
* Las definiciones de casa mandan siempre: un componente no puede redefinir qué es React para
|
|
68
|
+
* todo el catálogo. Entre dos aportadas, en cambio, una discrepancia es un conflicto y se
|
|
69
|
+
* denuncia, porque resolverla por orden de llegada dejaría al perdedor con sus ficheros sin dueño.
|
|
70
|
+
*/
|
|
71
|
+
export function buildFrameworkCatalog(descriptors) {
|
|
72
|
+
// Sin prototipo: así `catalog['toString']` no devuelve una función heredada y un descriptor no
|
|
73
|
+
// puede colar `constructor` como si fuera un framework definido.
|
|
74
|
+
const catalog = Object.assign(Object.create(null), BUILTIN_FRAMEWORKS);
|
|
75
|
+
// Los de casa reservan ya su carpeta: un framework aportado no puede quedarse con `laravel`
|
|
76
|
+
// ni con `astro`, que perderían sus snippets en favor de Blade o de `vanilla`.
|
|
77
|
+
const snippetOwners = new Map();
|
|
78
|
+
// Dos frameworks con el mismo marcador de detección hacen que `init` deje de auto-detectar y
|
|
79
|
+
// pregunte siempre; con el mismo peer, `assertCompatible` no sabría a cuál corresponde.
|
|
80
|
+
const markerOwners = new Map();
|
|
81
|
+
for (const [name, definition] of Object.entries(BUILTIN_FRAMEWORKS)) {
|
|
82
|
+
snippetOwners.set(definition.snippetDirectory ?? name, name);
|
|
83
|
+
for (const marker of [definition.detect?.npm, definition.detect?.composer, definition.peer]) {
|
|
84
|
+
if (marker)
|
|
85
|
+
markerOwners.set(marker, name);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
for (const descriptor of descriptors) {
|
|
89
|
+
for (const [name, definition] of Object.entries(descriptor.frameworkDefs ?? {})) {
|
|
90
|
+
// Un componente no redefine uno de casa: la definición de React es la misma para todos.
|
|
91
|
+
if (Object.hasOwn(BUILTIN_FRAMEWORKS, name))
|
|
92
|
+
continue;
|
|
93
|
+
const previous = catalog[name];
|
|
94
|
+
if (previous) {
|
|
95
|
+
// Dos componentes definiendo el mismo framework de forma distinta es un conflicto real,
|
|
96
|
+
// no algo que resolver en silencio por orden de llegada: el que pierda vería sus
|
|
97
|
+
// ficheros sin dueño y su UI dada por no cubierta.
|
|
98
|
+
if (JSON.stringify(previous) !== JSON.stringify(definition)) {
|
|
99
|
+
throw new FrameworkConflictError(`Dos componentes definen "${name}" de forma distinta. Unifica la definición en ambos descriptores.`);
|
|
100
|
+
}
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
const directory = definition.snippetDirectory ?? name;
|
|
104
|
+
const owner = snippetOwners.get(directory);
|
|
105
|
+
if (owner) {
|
|
106
|
+
throw new FrameworkConflictError(`"${name}" y "${owner}" reclaman los snippets de "${directory}". Cada carpeta de snippets tiene un solo dueño.`);
|
|
107
|
+
}
|
|
108
|
+
snippetOwners.set(directory, name);
|
|
109
|
+
for (const marker of [definition.detect?.npm, definition.detect?.composer, definition.peer]) {
|
|
110
|
+
if (!marker)
|
|
111
|
+
continue;
|
|
112
|
+
const markerOwner = markerOwners.get(marker);
|
|
113
|
+
// Que un framework use el mismo paquete para detectarse y como peer es lo normal
|
|
114
|
+
// —Solid se reconoce por `solid-js` y lo exige como peer—, así que sólo choca con otros.
|
|
115
|
+
if (markerOwner && markerOwner !== name) {
|
|
116
|
+
throw new FrameworkConflictError(`"${name}" y "${markerOwner}" usan ambos "${marker}" para detectarse o como peer. Cada marcador identifica a un solo framework.`);
|
|
117
|
+
}
|
|
118
|
+
markerOwners.set(marker, name);
|
|
119
|
+
}
|
|
120
|
+
catalog[name] = definition;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return catalog;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Los frameworks que este descriptor puede usar: los de casa más los que él mismo declara. Es lo
|
|
127
|
+
* que necesita el recorte de ficheros para saber que `ui/solid/` es de alguien.
|
|
128
|
+
*/
|
|
129
|
+
export function frameworksKnownTo(descriptor) {
|
|
130
|
+
return buildFrameworkCatalog([descriptor]);
|
|
131
|
+
}
|
|
132
|
+
/** Frameworks declarados que nadie define: ni de casa, ni en el propio descriptor. */
|
|
133
|
+
export function undefinedFrameworks(descriptor) {
|
|
134
|
+
const known = frameworksKnownTo(descriptor);
|
|
135
|
+
return descriptor.frameworks.filter((framework) => framework !== AGNOSTIC_FRAMEWORK && !isDefined(known, framework));
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=framework-catalog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"framework-catalog.js","sourceRoot":"","sources":["../src/framework-catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AA4BH,iFAAiF;AACjF,MAAM,CAAC,MAAM,kBAAkB,GAAwC;IACrE,KAAK,EAAE;QACL,KAAK,EAAE,OAAO;QACd,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BACJ,CAAC;gBACD,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YACjC,CAAC;YAED,OAAO,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC;QAC7B,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAC/B,UAAoC;IAEpC,OAAO,qBAAqB,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC;AAC7C,CAAC;AAED,sFAAsF;AACtF,MAAM,UAAU,mBAAmB,CAAC,UAAoC;IACtE,MAAM,KAAK,GAAG,iBAAiB,CAAC,UAAU,CAAC,CAAC;IAC5C,OAAO,UAAU,CAAC,UAAU,CAAC,MAAM,CACjC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,KAAK,kBAAkB,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,CAChF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { FrameworkDefinition } from './framework-catalog.js';
|
|
2
|
+
/**
|
|
3
|
+
* El framework al que pertenece un fichero del descriptor, o `null` si sirve a todos.
|
|
4
|
+
*
|
|
5
|
+
* Se lee del `path` —la estructura dentro del paquete— y no del `target`, que para los snippets
|
|
6
|
+
* apunta a un árbol distinto en el proyecto de destino.
|
|
7
|
+
*/
|
|
8
|
+
export declare function frameworkOfFile(path: string, catalog?: Record<string, FrameworkDefinition>): string | null;
|
|
9
|
+
/**
|
|
10
|
+
* Los ficheros que un proyecto de `framework` necesita: los compartidos más los suyos.
|
|
11
|
+
*
|
|
12
|
+
* Un componente `agnostic` no tiene adaptadores que separar, y un proyecto cuyo framework no
|
|
13
|
+
* conocemos recibe el descriptor entero: filtrar con información incompleta arriesga dejarlo sin
|
|
14
|
+
* ficheros que sí necesita.
|
|
15
|
+
*/
|
|
16
|
+
export declare function selectFilesForFramework<T extends {
|
|
17
|
+
path: string;
|
|
18
|
+
}>(files: T[], framework: string, catalog?: Record<string, FrameworkDefinition>): T[];
|
|
19
|
+
//# sourceMappingURL=framework-files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"framework-files.d.ts","sourceRoot":"","sources":["../src/framework-files.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAelE;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAsB,GAChE,MAAM,GAAG,IAAI,CAiCf;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,SAAS;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,EAChE,KAAK,EAAE,CAAC,EAAE,EACV,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAsB,GAChE,CAAC,EAAE,CAeL"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { AGNOSTIC_FRAMEWORK, BUILTIN_FRAMEWORKS, isDefined } from './framework-catalog.js';
|
|
2
|
+
/**
|
|
3
|
+
* Un descriptor enumera los ficheros de todos sus adaptadores a la vez, porque el registry sirve
|
|
4
|
+
* un único catálogo para cualquier proyecto. Al instalar, en cambio, sólo tienen sentido los del
|
|
5
|
+
* framework elegido: escribir los demás deja en el proyecto módulos que importan runtimes que no
|
|
6
|
+
* están instalados, y el `tsc` del consumidor falla justo después de un `add` que terminó bien.
|
|
7
|
+
*
|
|
8
|
+
* Qué framework sirve cada fichero se deduce de la convención de rutas del monorepo, que los cinco
|
|
9
|
+
* descriptores actuales siguen sin excepción. Un fichero que no encaje en ninguna regla se
|
|
10
|
+
* considera compartido y se escribe siempre: ante la duda, sobra un fichero antes que falte uno.
|
|
11
|
+
*/
|
|
12
|
+
const FRAMEWORK_ROOTS = ['adapters', 'ui'];
|
|
13
|
+
/**
|
|
14
|
+
* El framework al que pertenece un fichero del descriptor, o `null` si sirve a todos.
|
|
15
|
+
*
|
|
16
|
+
* Se lee del `path` —la estructura dentro del paquete— y no del `target`, que para los snippets
|
|
17
|
+
* apunta a un árbol distinto en el proyecto de destino.
|
|
18
|
+
*/
|
|
19
|
+
export function frameworkOfFile(path, catalog = BUILTIN_FRAMEWORKS) {
|
|
20
|
+
const [root, second] = path.split('/');
|
|
21
|
+
if (!root || !second)
|
|
22
|
+
return null;
|
|
23
|
+
// Con sólo dos segmentos el segundo es el propio fichero (`ui/vanilla-styles.css`), no un
|
|
24
|
+
// directorio de framework. Ojo justamente con ese: es la presentación de estilo «CSS plano»,
|
|
25
|
+
// un eje distinto, y lo comparten las cuatro presentaciones de todos los frameworks.
|
|
26
|
+
if (path.split('/').length < 3)
|
|
27
|
+
return null;
|
|
28
|
+
if (root === 'snippets') {
|
|
29
|
+
// Un snippet toma el nombre de la herramienta a la que sirve —`snippets/laravel/` para
|
|
30
|
+
// Blade, `snippets/astro/` para una página sin framework—, así que el dueño se busca por
|
|
31
|
+
// ese directorio y no por el nombre del framework.
|
|
32
|
+
const owner = Object.entries(catalog).find(([name, definition]) => (definition.snippetDirectory ?? name) === second);
|
|
33
|
+
return owner?.[0] ?? null;
|
|
34
|
+
}
|
|
35
|
+
// `vanilla` nombra dos ejes distintos: un framework (una página sin ninguno) y una presentación
|
|
36
|
+
// de estilo (CSS plano). Bajo `ui/` manda el segundo, así que `ui/vanilla/…` es marcado
|
|
37
|
+
// compartido y no el framework: tratarlo como framework lo borraría de toda instalación de
|
|
38
|
+
// React o Svelte, que es justo donde se usa.
|
|
39
|
+
if (root === 'ui') {
|
|
40
|
+
// Sólo cuenta como framework quien tiene UI propia. `vanilla` no la tiene, así que
|
|
41
|
+
// `ui/vanilla/` es la presentación de CSS plano y no el framework sin framework.
|
|
42
|
+
return isDefined(catalog, second) && catalog[second]?.uiExtension ? second : null;
|
|
43
|
+
}
|
|
44
|
+
if (FRAMEWORK_ROOTS.includes(root)) {
|
|
45
|
+
return isDefined(catalog, second) ? second : null;
|
|
46
|
+
}
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Los ficheros que un proyecto de `framework` necesita: los compartidos más los suyos.
|
|
51
|
+
*
|
|
52
|
+
* Un componente `agnostic` no tiene adaptadores que separar, y un proyecto cuyo framework no
|
|
53
|
+
* conocemos recibe el descriptor entero: filtrar con información incompleta arriesga dejarlo sin
|
|
54
|
+
* ficheros que sí necesita.
|
|
55
|
+
*/
|
|
56
|
+
export function selectFilesForFramework(files, framework, catalog = BUILTIN_FRAMEWORKS) {
|
|
57
|
+
if (framework === AGNOSTIC_FRAMEWORK)
|
|
58
|
+
return files;
|
|
59
|
+
// Un framework que este catálogo no conoce recibe el descriptor entero: recortar con
|
|
60
|
+
// información incompleta arriesga dejarlo sin ficheros que sí necesita.
|
|
61
|
+
if (!isDefined(catalog, framework))
|
|
62
|
+
return files;
|
|
63
|
+
const base = catalog[framework].basedOn;
|
|
64
|
+
const bases = new Set(base ? [base] : []);
|
|
65
|
+
return files.filter((file) => {
|
|
66
|
+
const owner = frameworkOfFile(file.path, catalog);
|
|
67
|
+
if (owner === null || owner === framework)
|
|
68
|
+
return true;
|
|
69
|
+
// Lo heredado se limita a los adaptadores del framework base.
|
|
70
|
+
return bases.has(owner) && file.path.startsWith('adapters/');
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=framework-files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"framework-files.js","sourceRoot":"","sources":["../src/framework-files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAI3F;;;;;;;;;GASG;AAEH,MAAM,eAAe,GAAG,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;AAE3C;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAC7B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AAU,EACV,SAAiB,EACjB,UAA+C,kBAAkB;IAEjE,IAAI,SAAS,KAAK,kBAAkB;QAAE,OAAO,KAAK,CAAC;IACnD,qFAAqF;IACrF,wEAAwE;IACxE,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,SAAS,CAAC;QAAE,OAAO,KAAK,CAAC;IAEjD,MAAM,IAAI,GAAG,OAAO,CAAC,SAAS,CAAE,CAAC,OAAO,CAAC;IACzC,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAE1C,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;QAC3B,MAAM,KAAK,GAAG,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAClD,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;YAAE,OAAO,IAAI,CAAC;QACvD,8DAA8D;QAC9D,OAAO,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IAC/D,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { AGNOSTIC_FRAMEWORK, BUILTIN_FRAMEWORKS, FrameworkConflictError, buildFrameworkCatalog, frameworksKnownTo, isDefined, undefinedFrameworks, } from './framework-catalog.js';
|
|
2
|
+
export type { FrameworkDefinition } from './framework-catalog.js';
|
|
3
|
+
export { dependenciesForFiles, dependencyNameOf, npmImportsOf } from './dependency-usage.js';
|
|
4
|
+
export type { FileWithContent } from './dependency-usage.js';
|
|
5
|
+
export { PRESENTATIONS, findCoverageMismatches, locateUiFile, readActualCoverage, } from './ui-coverage.js';
|
|
6
|
+
export type { Presentation, UiCoverage } from './ui-coverage.js';
|
|
7
|
+
export { frameworkOfFile, selectFilesForFramework } from './framework-files.js';
|
|
8
|
+
export type { ComponentType, PreviewImage, EnvVariableDescriptor, FileEncoding, RegistryDescriptor, RegistryEntry, RegistryFileDescriptor, RegistryFileWithContent, RegistryIndexEntry, SupportedFramework, Visibility, } from './schema.js';
|
|
9
|
+
export { frameworkCatalogSchema } from './schema.zod.js';
|
|
2
10
|
export { envVariableSchema, fileEncodingSchema, registryDescriptorSchema, registryEntrySchema, registryFileSchema, registryFileWithContentSchema, registryIndexEntrySchema, visibilitySchema, } from './schema.zod.js';
|
|
3
11
|
export type { RegistryDescriptorInput, RegistryDescriptorParsed } from './schema.zod.js';
|
|
4
12
|
export { buildRegistry } from './build-registry.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,aAAa,EACb,qBAAqB,EACrB,YAAY,EACZ,kBAAkB,EAClB,aAAa,EACb,sBAAsB,EACtB,uBAAuB,EACvB,kBAAkB,EAClB,kBAAkB,EAClB,UAAU,GACX,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,wBAAwB,EACxB,mBAAmB,EACnB,kBAAkB,EAClB,6BAA6B,EAC7B,wBAAwB,EACxB,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAEzF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,YAAY,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAEtF,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AACrF,YAAY,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAA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,CAAC;AAE5C,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AACrF,YAAY,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
export { AGNOSTIC_FRAMEWORK, BUILTIN_FRAMEWORKS, FrameworkConflictError, buildFrameworkCatalog, frameworksKnownTo, isDefined, undefinedFrameworks, } from './framework-catalog.js';
|
|
2
|
+
export { dependenciesForFiles, dependencyNameOf, npmImportsOf } from './dependency-usage.js';
|
|
3
|
+
export { PRESENTATIONS, findCoverageMismatches, locateUiFile, readActualCoverage, } from './ui-coverage.js';
|
|
4
|
+
export { frameworkOfFile, selectFilesForFramework } from './framework-files.js';
|
|
5
|
+
export { frameworkCatalogSchema } from './schema.zod.js';
|
|
1
6
|
export { envVariableSchema, fileEncodingSchema, registryDescriptorSchema, registryEntrySchema, registryFileSchema, registryFileWithContentSchema, registryIndexEntrySchema, visibilitySchema, } from './schema.zod.js';
|
|
2
7
|
export { buildRegistry } from './build-registry.js';
|
|
3
8
|
export { buildTarball } from './tarball.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,sBAAsB,EACtB,qBAAqB,EACrB,iBAAiB,EACjB,SAAS,EACT,mBAAmB,GACpB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAG7F,OAAO,EACL,aAAa,EACb,sBAAsB,EACtB,YAAY,EACZ,kBAAkB,GACnB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAgBhF,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,wBAAwB,EACxB,mBAAmB,EACnB,kBAAkB,EAClB,6BAA6B,EAC7B,wBAAwB,EACxB,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/schema.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { FrameworkDefinition } from './framework-catalog.js';
|
|
2
|
+
import type { UiCoverage } from './ui-coverage.js';
|
|
1
3
|
/**
|
|
2
4
|
* Descriptor types for a ModularCore registry component (`modularcore.json`).
|
|
3
5
|
* Runtime validation lives in `schema.zod.ts`; keep both in sync.
|
|
@@ -5,6 +7,15 @@
|
|
|
5
7
|
/** Extensible component kind. New kinds (e.g. `agent-tool`) can be added without breaking existing descriptors. */
|
|
6
8
|
export type ComponentType = 'frontend-component' | 'headless-core' | 'snippet' | (string & {});
|
|
7
9
|
export type SupportedFramework = 'react' | 'svelte' | (string & {});
|
|
10
|
+
export interface PreviewImage {
|
|
11
|
+
/**
|
|
12
|
+
* En el descriptor, la ruta dentro del paquete (`preview/media-picker.png`). En lo que sirve el
|
|
13
|
+
* registry, la URL ya servible: `buildRegistry` copia el fichero y reescribe este campo.
|
|
14
|
+
*/
|
|
15
|
+
image: string;
|
|
16
|
+
/** Texto alternativo. Obligatorio: la captura es contenido, no decoración. */
|
|
17
|
+
alt: string;
|
|
18
|
+
}
|
|
8
19
|
/** `internal` components are built and locally resolvable but excluded from the public `index.json`. */
|
|
9
20
|
export type Visibility = 'public' | 'internal';
|
|
10
21
|
export type FileEncoding = 'utf8' | 'base64';
|
|
@@ -29,6 +40,26 @@ export interface RegistryDescriptor {
|
|
|
29
40
|
type: ComponentType;
|
|
30
41
|
category: string;
|
|
31
42
|
frameworks: SupportedFramework[];
|
|
43
|
+
/**
|
|
44
|
+
* Cobertura de la UI de referencia por framework. `frameworks` dice dónde se puede instalar
|
|
45
|
+
* —núcleo y adaptador—; esto dice dónde hay además componentes de interfaz, y qué falta por
|
|
46
|
+
* adaptar. Ver `ui-coverage.ts`.
|
|
47
|
+
*/
|
|
48
|
+
ui?: Record<string, UiCoverage>;
|
|
49
|
+
/**
|
|
50
|
+
* Frameworks que este componente aporta al catálogo, para los que el registry no trae
|
|
51
|
+
* definición de casa. Permite traer un componente en Solid o Qwik sin tocar código nuestro.
|
|
52
|
+
*/
|
|
53
|
+
frameworkDefs?: Record<string, FrameworkDefinition>;
|
|
54
|
+
/**
|
|
55
|
+
* Una captura del componente en funcionamiento, para el catálogo y para quien revise la
|
|
56
|
+
* aportación: nadie puede ejecutar un componente de un framework que no tiene instalado, pero
|
|
57
|
+
* sí ver qué hace.
|
|
58
|
+
*
|
|
59
|
+
* No va en `files[]` a propósito: aquello es lo que la CLI copia al proyecto de quien instala,
|
|
60
|
+
* y una captura no pinta nada en su `src/`.
|
|
61
|
+
*/
|
|
62
|
+
preview?: PreviewImage;
|
|
32
63
|
visibility: Visibility;
|
|
33
64
|
/** Semver ranges keyed by peer framework, e.g. `{ "react": ">=18" }`. Gates `add` (Phase 3) before writing runes/hooks. */
|
|
34
65
|
peerDependencies: Record<string, string>;
|
|
@@ -53,6 +84,10 @@ export interface RegistryIndexEntry {
|
|
|
53
84
|
category: string;
|
|
54
85
|
version: string;
|
|
55
86
|
frameworks: SupportedFramework[];
|
|
87
|
+
/** Cobertura de la UI de referencia, para que el catálogo distinga «instalable» de «con UI». */
|
|
88
|
+
ui?: Record<string, UiCoverage>;
|
|
89
|
+
/** Captura del componente, con la URL ya servible que produce `buildRegistry`. */
|
|
90
|
+
preview?: PreviewImage;
|
|
56
91
|
description?: string;
|
|
57
92
|
}
|
|
58
93
|
//# sourceMappingURL=schema.d.ts.map
|
package/dist/schema.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,mHAAmH;AACnH,MAAM,MAAM,aAAa,GAAG,oBAAoB,GAAG,eAAe,GAAG,SAAS,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAE/F,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,QAAQ,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAEpE,wGAAwG;AACxG,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,UAAU,CAAC;AAE/C,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,QAAQ,CAAC;AAE7C,MAAM,WAAW,qBAAqB;IACpC,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,sBAAsB;IACrC,mGAAmG;IACnG,IAAI,EAAE,MAAM,CAAC;IACb,mGAAmG;IACnG,MAAM,EAAE,MAAM,CAAC;IACf,kFAAkF;IAClF,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,YAAY,CAAC;CACxB;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,aAAa,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,kBAAkB,EAAE,CAAC;IACjC,UAAU,EAAE,UAAU,CAAC;IACvB,2HAA2H;IAC3H,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,YAAY,EAAE,MAAM,EAAE,CAAC;IACv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SAAQ,IAAI,CAAC,kBAAkB,EAAE,OAAO,CAAC;IACtE,KAAK,EAAE,uBAAuB,EAAE,CAAC;CAClC;AAED,qGAAqG;AACrG,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,kBAAkB,EAAE,CAAC;IACjC,gGAAgG;IAChG,EAAE,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAChC,kFAAkF;IAClF,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB"}
|
package/dist/schema.js
CHANGED
package/dist/schema.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":""}
|
package/dist/schema.zod.d.ts
CHANGED
|
@@ -37,6 +37,34 @@ export declare const registryDescriptorSchema: z.ZodObject<{
|
|
|
37
37
|
}>, z.ZodString]>;
|
|
38
38
|
category: z.ZodString;
|
|
39
39
|
frameworks: z.ZodArray<z.ZodString>;
|
|
40
|
+
preview: z.ZodOptional<z.ZodObject<{
|
|
41
|
+
image: z.ZodString;
|
|
42
|
+
alt: z.ZodString;
|
|
43
|
+
}, z.core.$strip>>;
|
|
44
|
+
frameworkDefs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
45
|
+
title: z.ZodString;
|
|
46
|
+
uiExtension: z.ZodOptional<z.ZodString>;
|
|
47
|
+
detect: z.ZodOptional<z.ZodObject<{
|
|
48
|
+
npm: z.ZodOptional<z.ZodString>;
|
|
49
|
+
composer: z.ZodOptional<z.ZodString>;
|
|
50
|
+
}, z.core.$strip>>;
|
|
51
|
+
peer: z.ZodOptional<z.ZodString>;
|
|
52
|
+
paths: z.ZodOptional<z.ZodObject<{
|
|
53
|
+
components: z.ZodString;
|
|
54
|
+
lib: z.ZodString;
|
|
55
|
+
}, z.core.$strip>>;
|
|
56
|
+
basedOn: z.ZodOptional<z.ZodString>;
|
|
57
|
+
snippetDirectory: z.ZodOptional<z.ZodString>;
|
|
58
|
+
}, z.core.$strip>>>;
|
|
59
|
+
ui: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
60
|
+
presentations: z.ZodArray<z.ZodEnum<{
|
|
61
|
+
vanilla: "vanilla";
|
|
62
|
+
headless: "headless";
|
|
63
|
+
tailwind: "tailwind";
|
|
64
|
+
shadcn: "shadcn";
|
|
65
|
+
}>>;
|
|
66
|
+
missing: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
67
|
+
}, z.core.$strip>>>;
|
|
40
68
|
visibility: z.ZodDefault<z.ZodEnum<{
|
|
41
69
|
public: "public";
|
|
42
70
|
internal: "internal";
|
|
@@ -73,21 +101,45 @@ export declare const registryFileWithContentSchema: z.ZodObject<{
|
|
|
73
101
|
content: z.ZodString;
|
|
74
102
|
}, z.core.$strip>;
|
|
75
103
|
export declare const registryEntrySchema: z.ZodObject<{
|
|
104
|
+
name: z.ZodString;
|
|
76
105
|
type: z.ZodUnion<readonly [z.ZodEnum<{
|
|
77
106
|
"frontend-component": "frontend-component";
|
|
78
107
|
"headless-core": "headless-core";
|
|
79
108
|
snippet: "snippet";
|
|
80
109
|
}>, z.ZodString]>;
|
|
81
110
|
description: z.ZodOptional<z.ZodString>;
|
|
111
|
+
title: z.ZodString;
|
|
82
112
|
visibility: z.ZodDefault<z.ZodEnum<{
|
|
83
113
|
public: "public";
|
|
84
114
|
internal: "internal";
|
|
85
115
|
}>>;
|
|
86
|
-
name: z.ZodString;
|
|
87
116
|
version: z.ZodString;
|
|
88
|
-
title: z.ZodString;
|
|
89
117
|
category: z.ZodString;
|
|
90
118
|
frameworks: z.ZodArray<z.ZodString>;
|
|
119
|
+
frameworkDefs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
120
|
+
title: z.ZodString;
|
|
121
|
+
uiExtension: z.ZodOptional<z.ZodString>;
|
|
122
|
+
detect: z.ZodOptional<z.ZodObject<{
|
|
123
|
+
npm: z.ZodOptional<z.ZodString>;
|
|
124
|
+
composer: z.ZodOptional<z.ZodString>;
|
|
125
|
+
}, z.core.$strip>>;
|
|
126
|
+
peer: z.ZodOptional<z.ZodString>;
|
|
127
|
+
paths: z.ZodOptional<z.ZodObject<{
|
|
128
|
+
components: z.ZodString;
|
|
129
|
+
lib: z.ZodString;
|
|
130
|
+
}, z.core.$strip>>;
|
|
131
|
+
basedOn: z.ZodOptional<z.ZodString>;
|
|
132
|
+
snippetDirectory: z.ZodOptional<z.ZodString>;
|
|
133
|
+
}, z.core.$strip>>>;
|
|
134
|
+
ui: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
135
|
+
presentations: z.ZodArray<z.ZodEnum<{
|
|
136
|
+
vanilla: "vanilla";
|
|
137
|
+
headless: "headless";
|
|
138
|
+
tailwind: "tailwind";
|
|
139
|
+
shadcn: "shadcn";
|
|
140
|
+
}>>;
|
|
141
|
+
missing: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
142
|
+
}, z.core.$strip>>>;
|
|
91
143
|
peerDependencies: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
92
144
|
dependencies: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
93
145
|
registryDependencies: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
@@ -106,6 +158,10 @@ export declare const registryEntrySchema: z.ZodObject<{
|
|
|
106
158
|
}>;
|
|
107
159
|
content: z.ZodString;
|
|
108
160
|
}, z.core.$strip>>;
|
|
161
|
+
preview: z.ZodOptional<z.ZodObject<{
|
|
162
|
+
image: z.ZodString;
|
|
163
|
+
alt: z.ZodString;
|
|
164
|
+
}, z.core.$strip>>;
|
|
109
165
|
}, z.core.$strip>;
|
|
110
166
|
export declare const registryIndexEntrySchema: z.ZodObject<{
|
|
111
167
|
name: z.ZodString;
|
|
@@ -113,6 +169,35 @@ export declare const registryIndexEntrySchema: z.ZodObject<{
|
|
|
113
169
|
category: z.ZodString;
|
|
114
170
|
version: z.ZodString;
|
|
115
171
|
frameworks: z.ZodArray<z.ZodString>;
|
|
172
|
+
preview: z.ZodOptional<z.ZodObject<{
|
|
173
|
+
image: z.ZodString;
|
|
174
|
+
alt: z.ZodString;
|
|
175
|
+
}, z.core.$strip>>;
|
|
176
|
+
ui: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
177
|
+
presentations: z.ZodArray<z.ZodEnum<{
|
|
178
|
+
vanilla: "vanilla";
|
|
179
|
+
headless: "headless";
|
|
180
|
+
tailwind: "tailwind";
|
|
181
|
+
shadcn: "shadcn";
|
|
182
|
+
}>>;
|
|
183
|
+
missing: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
184
|
+
}, z.core.$strip>>>;
|
|
116
185
|
description: z.ZodOptional<z.ZodString>;
|
|
117
186
|
}, z.core.$strip>;
|
|
187
|
+
/** Catálogo de frameworks servido en `frameworks.json`, con las mismas reglas que el descriptor. */
|
|
188
|
+
export declare const frameworkCatalogSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
189
|
+
title: z.ZodString;
|
|
190
|
+
uiExtension: z.ZodOptional<z.ZodString>;
|
|
191
|
+
detect: z.ZodOptional<z.ZodObject<{
|
|
192
|
+
npm: z.ZodOptional<z.ZodString>;
|
|
193
|
+
composer: z.ZodOptional<z.ZodString>;
|
|
194
|
+
}, z.core.$strip>>;
|
|
195
|
+
peer: z.ZodOptional<z.ZodString>;
|
|
196
|
+
paths: z.ZodOptional<z.ZodObject<{
|
|
197
|
+
components: z.ZodString;
|
|
198
|
+
lib: z.ZodString;
|
|
199
|
+
}, z.core.$strip>>;
|
|
200
|
+
basedOn: z.ZodOptional<z.ZodString>;
|
|
201
|
+
snippetDirectory: z.ZodOptional<z.ZodString>;
|
|
202
|
+
}, z.core.$strip>>;
|
|
118
203
|
//# sourceMappingURL=schema.zod.d.ts.map
|
package/dist/schema.zod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.zod.d.ts","sourceRoot":"","sources":["../src/schema.zod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAoBxB,eAAO,MAAM,iBAAiB;;;;iBAI5B,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;EAA6B,CAAC;AAE7D,eAAO,MAAM,kBAAkB;;;;;;;;iBAK7B,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;iBAG9B,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;GAAmD,CAAC;
|
|
1
|
+
{"version":3,"file":"schema.zod.d.ts","sourceRoot":"","sources":["../src/schema.zod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAoBxB,eAAO,MAAM,iBAAiB;;;;iBAI5B,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;EAA6B,CAAC;AAE7D,eAAO,MAAM,kBAAkB;;;;;;;;iBAK7B,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;iBAG9B,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;GAAmD,CAAC;AAgCjF,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAiCnC,CAAC;AAEH,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAC/E,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAEjF,eAAO,MAAM,6BAA6B;;;;;;;;;iBAExC,CAAC;AAkBH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAK5B,CAAC;AAEL,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;iBAiBnC,CAAC;AAEH,oGAAoG;AACpG,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;kBAAyD,CAAC"}
|
package/dist/schema.zod.js
CHANGED
|
@@ -35,6 +35,35 @@ export const componentTypeSchema = z.union([
|
|
|
35
35
|
z.string().min(1),
|
|
36
36
|
]);
|
|
37
37
|
export const visibilitySchema = z.enum(['public', 'internal']).default('public');
|
|
38
|
+
/**
|
|
39
|
+
* Las reglas de una definición de framework, compartidas por el descriptor y por el catálogo que
|
|
40
|
+
* el registry sirve. Tenerlas por duplicado dejaba el segundo mucho más laxo: aceptaba rutas
|
|
41
|
+
* vacías, y `init` acababa escribiendo `paths.components: ""`, con lo que todo `add` posterior
|
|
42
|
+
* remapeaba los ficheros a la raíz del proyecto.
|
|
43
|
+
*/
|
|
44
|
+
const frameworkDefinitionSchema = z.object({
|
|
45
|
+
title: z.string().min(1),
|
|
46
|
+
// Una extensión de verdad: uno o más tramos `.algo`, admitiendo dígitos y guiones
|
|
47
|
+
// (`.component.ts`, `.vue`). El patrón anterior aceptaba `..` y rechazaba `.mjs2`.
|
|
48
|
+
uiExtension: z
|
|
49
|
+
.string()
|
|
50
|
+
.regex(/^(?:\.[a-z0-9-]+)+$/i, {
|
|
51
|
+
message: 'uiExtension debe ser como ".tsx" o ".component.ts"',
|
|
52
|
+
})
|
|
53
|
+
.optional(),
|
|
54
|
+
// Con al menos una forma de reconocerlo: un `detect` vacío, o con cadenas vacías, no
|
|
55
|
+
// detecta nada y deja al framework inservible para `init`.
|
|
56
|
+
detect: z
|
|
57
|
+
.object({ npm: z.string().min(1).optional(), composer: z.string().min(1).optional() })
|
|
58
|
+
.refine((value) => value.npm !== undefined || value.composer !== undefined, {
|
|
59
|
+
message: 'detect debe declarar npm o composer',
|
|
60
|
+
})
|
|
61
|
+
.optional(),
|
|
62
|
+
peer: z.string().min(1).optional(),
|
|
63
|
+
paths: z.object({ components: z.string().min(1), lib: z.string().min(1) }).optional(),
|
|
64
|
+
basedOn: z.string().min(1).optional(),
|
|
65
|
+
snippetDirectory: z.string().min(1).optional(),
|
|
66
|
+
});
|
|
38
67
|
export const registryDescriptorSchema = z.object({
|
|
39
68
|
name: z
|
|
40
69
|
.string()
|
|
@@ -45,6 +74,19 @@ export const registryDescriptorSchema = z.object({
|
|
|
45
74
|
type: componentTypeSchema,
|
|
46
75
|
category: z.string().min(1),
|
|
47
76
|
frameworks: z.array(z.string().min(1)).min(1),
|
|
77
|
+
preview: z
|
|
78
|
+
.object({
|
|
79
|
+
image: safeRelativePathSchema,
|
|
80
|
+
alt: z.string().min(1),
|
|
81
|
+
})
|
|
82
|
+
.optional(),
|
|
83
|
+
frameworkDefs: z.record(z.string().min(1), frameworkDefinitionSchema).optional(),
|
|
84
|
+
ui: z
|
|
85
|
+
.record(z.string().min(1), z.object({
|
|
86
|
+
presentations: z.array(z.enum(['headless', 'tailwind', 'shadcn', 'vanilla'])),
|
|
87
|
+
missing: z.array(z.string().min(1)).optional(),
|
|
88
|
+
}))
|
|
89
|
+
.optional(),
|
|
48
90
|
visibility: visibilitySchema,
|
|
49
91
|
peerDependencies: z.record(z.string(), z.string()).default({}),
|
|
50
92
|
dependencies: z.array(z.string()).default([]),
|
|
@@ -56,15 +98,42 @@ export const registryDescriptorSchema = z.object({
|
|
|
56
98
|
export const registryFileWithContentSchema = registryFileSchema.extend({
|
|
57
99
|
content: z.string(),
|
|
58
100
|
});
|
|
101
|
+
/**
|
|
102
|
+
* `preview.image` tiene dos formas según dónde se lea, y por eso hay dos esquemas.
|
|
103
|
+
*
|
|
104
|
+
* En el descriptor es una ruta dentro del paquete (`preview/rating.png`), validada como cualquier
|
|
105
|
+
* otra ruta. En lo que sirve el registry es ya la URL servible, porque `buildRegistry` copia el
|
|
106
|
+
* fichero y reescribe el campo. Validar la segunda con las reglas de la primera rechazaba la
|
|
107
|
+
* salida del propio build: en cuanto un componente declarase una captura, el cliente del registry
|
|
108
|
+
* habría dejado de poder leer el índice entero.
|
|
109
|
+
*/
|
|
110
|
+
const servedPreviewSchema = z.object({
|
|
111
|
+
image: z.string().regex(/^\/registry\/[a-z0-9-]+\.(?:png|jpg|jpeg|webp)$/i, {
|
|
112
|
+
message: 'Served preview must be a /registry/{name}-preview.{ext} URL',
|
|
113
|
+
}),
|
|
114
|
+
alt: z.string().min(1),
|
|
115
|
+
});
|
|
59
116
|
export const registryEntrySchema = registryDescriptorSchema
|
|
60
|
-
.omit({ files: true })
|
|
61
|
-
.extend({
|
|
117
|
+
.omit({ files: true, preview: true })
|
|
118
|
+
.extend({
|
|
119
|
+
files: z.array(registryFileWithContentSchema).min(1),
|
|
120
|
+
preview: servedPreviewSchema.optional(),
|
|
121
|
+
});
|
|
62
122
|
export const registryIndexEntrySchema = z.object({
|
|
63
123
|
name: z.string(),
|
|
64
124
|
title: z.string(),
|
|
65
125
|
category: z.string(),
|
|
66
126
|
version: z.string(),
|
|
67
127
|
frameworks: z.array(z.string()),
|
|
128
|
+
preview: servedPreviewSchema.optional(),
|
|
129
|
+
ui: z
|
|
130
|
+
.record(z.string().min(1), z.object({
|
|
131
|
+
presentations: z.array(z.enum(['headless', 'tailwind', 'shadcn', 'vanilla'])),
|
|
132
|
+
missing: z.array(z.string().min(1)).optional(),
|
|
133
|
+
}))
|
|
134
|
+
.optional(),
|
|
68
135
|
description: z.string().optional(),
|
|
69
136
|
});
|
|
137
|
+
/** Catálogo de frameworks servido en `frameworks.json`, con las mismas reglas que el descriptor. */
|
|
138
|
+
export const frameworkCatalogSchema = z.record(z.string().min(1), frameworkDefinitionSchema);
|
|
70
139
|
//# sourceMappingURL=schema.zod.js.map
|
package/dist/schema.zod.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.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,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/C,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;IACjB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;IACpB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,UAAU,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAC/B,OAAO,EAAE,mBAAmB,CAAC,QAAQ,EAAE;IACvC,EAAE,EAAE,CAAC;SACF,MAAM,CACL,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EACjB,CAAC,CAAC,MAAM,CAAC;QACP,aAAa,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC;QAC7E,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;KAC/C,CAAC,CACH;SACA,QAAQ,EAAE;IACb,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACnC,CAAC,CAAC;AAEH,oGAAoG;AACpG,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,yBAAyB,CAAC,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { FrameworkDefinition } from './framework-catalog.js';
|
|
2
|
+
/**
|
|
3
|
+
* Cobertura de la UI de referencia por framework.
|
|
4
|
+
*
|
|
5
|
+
* Un componente puede instalarse en cualquier framework que declare en `frameworks` —eso sólo
|
|
6
|
+
* exige núcleo y adaptador—, pero la UI de referencia es otra cosa: se escribe una vez por
|
|
7
|
+
* framework y por presentación, y es justo donde el trabajo se queda a medias sin que nada lo
|
|
8
|
+
* note. Así se declaró `vue` durante meses sin un solo componente de interfaz.
|
|
9
|
+
*
|
|
10
|
+
* `ui` en el descriptor declara esa cobertura, y las brechas conocidas van escritas con nombre y
|
|
11
|
+
* apellido. La comprobación no exige paridad completa —un colaborador entrega los frameworks que
|
|
12
|
+
* puede y el mantenimiento completa el resto— sino que lo declarado sea exactamente lo que hay:
|
|
13
|
+
* una brecha nueva que nadie declare hace fallar la comprobación.
|
|
14
|
+
*/
|
|
15
|
+
/** Las cuatro presentaciones en las que se escribe cada componente de UI. */
|
|
16
|
+
export declare const PRESENTATIONS: readonly ["headless", "tailwind", "shadcn", "vanilla"];
|
|
17
|
+
export type Presentation = (typeof PRESENTATIONS)[number];
|
|
18
|
+
export interface UiCoverage {
|
|
19
|
+
/** Presentaciones que este framework cubre. Vacío: el framework no trae UI de referencia. */
|
|
20
|
+
presentations: Presentation[];
|
|
21
|
+
/**
|
|
22
|
+
* Componentes que otros frameworks sí tienen y este todavía no, por nombre. Es deuda del
|
|
23
|
+
* mantenimiento, no un rechazo al colaborador que aportó el resto.
|
|
24
|
+
*/
|
|
25
|
+
missing?: string[];
|
|
26
|
+
}
|
|
27
|
+
export interface DescribedFile {
|
|
28
|
+
path: string;
|
|
29
|
+
}
|
|
30
|
+
export interface ComponentLocation {
|
|
31
|
+
framework: string;
|
|
32
|
+
presentation: Presentation;
|
|
33
|
+
component: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Sitúa un fichero de UI en el eje framework × presentación × componente, o devuelve `null` si no
|
|
37
|
+
* es UI de referencia (el núcleo, una hoja de estilos suelta, un snippet).
|
|
38
|
+
*
|
|
39
|
+
* `ui/<framework>/<Componente>` es la presentación headless; `ui/<framework>/<presentación>/…` es
|
|
40
|
+
* cada una de las otras tres.
|
|
41
|
+
*/
|
|
42
|
+
export declare function locateUiFile(path: string, catalog?: Record<string, FrameworkDefinition>): ComponentLocation | null;
|
|
43
|
+
export type ActualCoverage = Map<string, Map<Presentation, Set<string>>>;
|
|
44
|
+
/** Cobertura real que se desprende de los ficheros que el descriptor enumera. */
|
|
45
|
+
export declare function readActualCoverage(files: DescribedFile[], catalog?: Record<string, FrameworkDefinition>): ActualCoverage;
|
|
46
|
+
export interface CoverageMismatch {
|
|
47
|
+
framework: string;
|
|
48
|
+
problem: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Compara lo declarado en `ui` con lo que hay, y describe cada discrepancia en una línea legible.
|
|
52
|
+
*
|
|
53
|
+
* Un componente presente sólo en la presentación headless de *todos* los frameworks —los de
|
|
54
|
+
* apoyo, como `ModernSelect`— no cuenta como brecha: la comparación se hace presentación a
|
|
55
|
+
* presentación, así que sólo salta cuando un framework se queda atrás respecto de otro en la
|
|
56
|
+
* misma presentación.
|
|
57
|
+
*/
|
|
58
|
+
export declare function findCoverageMismatches(declared: Record<string, UiCoverage>, files: DescribedFile[], frameworks: string[], catalog?: Record<string, FrameworkDefinition>): CoverageMismatch[];
|
|
59
|
+
//# sourceMappingURL=ui-coverage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui-coverage.d.ts","sourceRoot":"","sources":["../src/ui-coverage.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAElE;;;;;;;;;;;;GAYG;AAEH,6EAA6E;AAC7E,eAAO,MAAM,aAAa,wDAAyD,CAAC;AAEpF,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAE1D,MAAM,WAAW,UAAU;IACzB,6FAA6F;IAC7F,aAAa,EAAE,YAAY,EAAE,CAAC;IAC9B;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAWD,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,YAAY,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAsB,GAChE,iBAAiB,GAAG,IAAI,CAoB1B;AAED,MAAM,MAAM,cAAc,GAAG,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAEzE,iFAAiF;AACjF,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,aAAa,EAAE,EACtB,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAsB,GAChE,cAAc,CAehB;AAED,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,EACpC,KAAK,EAAE,aAAa,EAAE,EACtB,UAAU,EAAE,MAAM,EAAE,EACpB,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAsB,GAChE,gBAAgB,EAAE,CAuEpB"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { BUILTIN_FRAMEWORKS } from './framework-catalog.js';
|
|
2
|
+
/**
|
|
3
|
+
* Cobertura de la UI de referencia por framework.
|
|
4
|
+
*
|
|
5
|
+
* Un componente puede instalarse en cualquier framework que declare en `frameworks` —eso sólo
|
|
6
|
+
* exige núcleo y adaptador—, pero la UI de referencia es otra cosa: se escribe una vez por
|
|
7
|
+
* framework y por presentación, y es justo donde el trabajo se queda a medias sin que nada lo
|
|
8
|
+
* note. Así se declaró `vue` durante meses sin un solo componente de interfaz.
|
|
9
|
+
*
|
|
10
|
+
* `ui` en el descriptor declara esa cobertura, y las brechas conocidas van escritas con nombre y
|
|
11
|
+
* apellido. La comprobación no exige paridad completa —un colaborador entrega los frameworks que
|
|
12
|
+
* puede y el mantenimiento completa el resto— sino que lo declarado sea exactamente lo que hay:
|
|
13
|
+
* una brecha nueva que nadie declare hace fallar la comprobación.
|
|
14
|
+
*/
|
|
15
|
+
/** Las cuatro presentaciones en las que se escribe cada componente de UI. */
|
|
16
|
+
export const PRESENTATIONS = ['headless', 'tailwind', 'shadcn', 'vanilla'];
|
|
17
|
+
/** Extensiones de la UI de referencia, tomadas del catálogo: un framework aportado trae la suya. */
|
|
18
|
+
function uiExtensionsOf(catalog) {
|
|
19
|
+
const extensions = {};
|
|
20
|
+
for (const [name, definition] of Object.entries(catalog)) {
|
|
21
|
+
if (definition.uiExtension)
|
|
22
|
+
extensions[name] = definition.uiExtension;
|
|
23
|
+
}
|
|
24
|
+
return extensions;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Sitúa un fichero de UI en el eje framework × presentación × componente, o devuelve `null` si no
|
|
28
|
+
* es UI de referencia (el núcleo, una hoja de estilos suelta, un snippet).
|
|
29
|
+
*
|
|
30
|
+
* `ui/<framework>/<Componente>` es la presentación headless; `ui/<framework>/<presentación>/…` es
|
|
31
|
+
* cada una de las otras tres.
|
|
32
|
+
*/
|
|
33
|
+
export function locateUiFile(path, catalog = BUILTIN_FRAMEWORKS) {
|
|
34
|
+
const segments = path.split('/');
|
|
35
|
+
if (segments[0] !== 'ui' || segments.length < 3)
|
|
36
|
+
return null;
|
|
37
|
+
const framework = segments[1];
|
|
38
|
+
const extensions = uiExtensionsOf(catalog);
|
|
39
|
+
if (!framework || !(framework in extensions))
|
|
40
|
+
return null;
|
|
41
|
+
const extension = extensions[framework];
|
|
42
|
+
const last = segments[segments.length - 1];
|
|
43
|
+
if (!last.endsWith(extension))
|
|
44
|
+
return null;
|
|
45
|
+
const component = last.slice(0, -extension.length);
|
|
46
|
+
if (segments.length === 3)
|
|
47
|
+
return { framework, presentation: 'headless', component };
|
|
48
|
+
const presentation = segments[2];
|
|
49
|
+
if (!PRESENTATIONS.includes(presentation))
|
|
50
|
+
return null;
|
|
51
|
+
return { framework, presentation: presentation, component };
|
|
52
|
+
}
|
|
53
|
+
/** Cobertura real que se desprende de los ficheros que el descriptor enumera. */
|
|
54
|
+
export function readActualCoverage(files, catalog = BUILTIN_FRAMEWORKS) {
|
|
55
|
+
const coverage = new Map();
|
|
56
|
+
for (const file of files) {
|
|
57
|
+
const located = locateUiFile(file.path, catalog);
|
|
58
|
+
if (!located)
|
|
59
|
+
continue;
|
|
60
|
+
const byPresentation = coverage.get(located.framework) ?? new Map();
|
|
61
|
+
const components = byPresentation.get(located.presentation) ?? new Set();
|
|
62
|
+
components.add(located.component);
|
|
63
|
+
byPresentation.set(located.presentation, components);
|
|
64
|
+
coverage.set(located.framework, byPresentation);
|
|
65
|
+
}
|
|
66
|
+
return coverage;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Compara lo declarado en `ui` con lo que hay, y describe cada discrepancia en una línea legible.
|
|
70
|
+
*
|
|
71
|
+
* Un componente presente sólo en la presentación headless de *todos* los frameworks —los de
|
|
72
|
+
* apoyo, como `ModernSelect`— no cuenta como brecha: la comparación se hace presentación a
|
|
73
|
+
* presentación, así que sólo salta cuando un framework se queda atrás respecto de otro en la
|
|
74
|
+
* misma presentación.
|
|
75
|
+
*/
|
|
76
|
+
export function findCoverageMismatches(declared, files, frameworks, catalog = BUILTIN_FRAMEWORKS) {
|
|
77
|
+
const actual = readActualCoverage(files, catalog);
|
|
78
|
+
const extensions = uiExtensionsOf(catalog);
|
|
79
|
+
const mismatches = [];
|
|
80
|
+
for (const framework of frameworks) {
|
|
81
|
+
if (!extensions[framework])
|
|
82
|
+
continue; // blade y vanilla se sirven con snippets, no con UI.
|
|
83
|
+
if (!declared[framework]) {
|
|
84
|
+
mismatches.push({
|
|
85
|
+
framework,
|
|
86
|
+
problem: `declarado en "frameworks" pero ausente de "ui": di qué cobertura tiene, aunque sea ninguna`,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
// Un framework con ficheros de UI y sin entrada en `ui` no lo veía ninguna de las
|
|
91
|
+
// comprobaciones siguientes, que recorren lo declarado: la brecha se colaba justo por donde este
|
|
92
|
+
// módulo promete no dejar pasar ninguna. Y esos ficheros no se instalan en ningún sitio, porque
|
|
93
|
+
// ningún proyecto puede declarar un framework que el componente no soporta.
|
|
94
|
+
for (const framework of actual.keys()) {
|
|
95
|
+
if (declared[framework])
|
|
96
|
+
continue;
|
|
97
|
+
mismatches.push({
|
|
98
|
+
framework,
|
|
99
|
+
problem: `hay ficheros en ui/${framework}/ y el descriptor no lo declara ni en "frameworks" ni en "ui": nadie los instalaría`,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
for (const [framework, coverage] of Object.entries(declared)) {
|
|
103
|
+
const byPresentation = actual.get(framework) ?? new Map();
|
|
104
|
+
const present = PRESENTATIONS.filter((p) => (byPresentation.get(p)?.size ?? 0) > 0);
|
|
105
|
+
const declaredPresentations = [...coverage.presentations].sort();
|
|
106
|
+
if (JSON.stringify(present.slice().sort()) !== JSON.stringify(declaredPresentations)) {
|
|
107
|
+
mismatches.push({
|
|
108
|
+
framework,
|
|
109
|
+
problem: `declara las presentaciones [${declaredPresentations.join(', ')}] y en el paquete hay [${present.join(', ')}]`,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
// Una brecha es un componente que otro framework sí tiene en esa misma presentación.
|
|
114
|
+
for (const [framework, coverage] of Object.entries(declared)) {
|
|
115
|
+
if (coverage.presentations.length === 0)
|
|
116
|
+
continue;
|
|
117
|
+
const byPresentation = actual.get(framework) ?? new Map();
|
|
118
|
+
const gaps = new Set();
|
|
119
|
+
for (const presentation of coverage.presentations) {
|
|
120
|
+
const mine = byPresentation.get(presentation) ?? new Set();
|
|
121
|
+
for (const [other, otherCoverage] of actual) {
|
|
122
|
+
if (other === framework)
|
|
123
|
+
continue;
|
|
124
|
+
if (!declared[other]?.presentations.includes(presentation))
|
|
125
|
+
continue;
|
|
126
|
+
for (const component of otherCoverage.get(presentation) ?? []) {
|
|
127
|
+
if (!mine.has(component))
|
|
128
|
+
gaps.add(component);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
const declaredMissing = [...(coverage.missing ?? [])].sort();
|
|
133
|
+
const actualMissing = [...gaps].sort();
|
|
134
|
+
if (JSON.stringify(declaredMissing) !== JSON.stringify(actualMissing)) {
|
|
135
|
+
mismatches.push({
|
|
136
|
+
framework,
|
|
137
|
+
problem: `declara que le faltan [${declaredMissing.join(', ') || '—'}] y en realidad le faltan [${actualMissing.join(', ') || '—'}]`,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return mismatches;
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=ui-coverage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui-coverage.js","sourceRoot":"","sources":["../src/ui-coverage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAI5D;;;;;;;;;;;;GAYG;AAEH,6EAA6E;AAC7E,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,CAAU,CAAC;AAcpF,oGAAoG;AACpG,SAAS,cAAc,CAAC,OAA4C;IAClE,MAAM,UAAU,GAA2B,EAAE,CAAC;IAC9C,KAAK,MAAM,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACzD,IAAI,UAAU,CAAC,WAAW;YAAE,UAAU,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,WAAW,CAAC;IACxE,CAAC;IACD,OA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,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modularcore/registry",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -17,6 +17,11 @@
|
|
|
17
17
|
"files": [
|
|
18
18
|
"dist"
|
|
19
19
|
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsc -p tsconfig.json",
|
|
22
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
23
|
+
"test": "vitest run"
|
|
24
|
+
},
|
|
20
25
|
"dependencies": {
|
|
21
26
|
"tar-stream": "^3.2.0",
|
|
22
27
|
"zod": "^4.4.3"
|
|
@@ -24,10 +29,5 @@
|
|
|
24
29
|
"devDependencies": {
|
|
25
30
|
"@types/node": "^22.13.0",
|
|
26
31
|
"@types/tar-stream": "^3.1.4"
|
|
27
|
-
},
|
|
28
|
-
"scripts": {
|
|
29
|
-
"build": "tsc -p tsconfig.json",
|
|
30
|
-
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
31
|
-
"test": "vitest run"
|
|
32
32
|
}
|
|
33
|
-
}
|
|
33
|
+
}
|