orbital-ds 0.25.0 → 0.27.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/AGENTS.md +273 -273
- package/components.manifest.json +221 -4
- package/dist/styles.css +5 -0
- package/dist/ui/filter-bar.d.ts +4 -2
- package/dist/ui/page-header.d.ts +5 -2
- package/docs/CONTRACT.md +224 -224
- package/package.json +1 -1
- package/scripts/cli.mjs +6 -1
- package/scripts/doctor.mjs +7 -0
- package/scripts/manifest.mjs +100 -85
package/scripts/manifest.mjs
CHANGED
|
@@ -1,85 +1,100 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Manifiesto de componentes de orbital-ds (`components.manifest.json`).
|
|
4
|
-
*
|
|
5
|
-
* Lo leen los agentes de IA (qué hay, cómo se importa, qué `data-slot` expone,
|
|
6
|
-
* qué dependencias opcionales pide) y `pnpm check:ds` lo usa como HUELLA de la API
|
|
7
|
-
* pública: si desaparece un componente o un export respecto al manifiesto
|
|
8
|
-
* commiteado, doctor falla salvo que se haga una versión mayor.
|
|
9
|
-
*
|
|
10
|
-
* node scripts/manifest.mjs # regenera components.manifest.json
|
|
11
|
-
*/
|
|
12
|
-
import { readFileSync, readdirSync, writeFileSync, existsSync } from 'node:fs';
|
|
13
|
-
import { join, dirname, resolve } from 'node:path';
|
|
14
|
-
import { fileURLToPath } from 'node:url';
|
|
15
|
-
|
|
16
|
-
const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
|
17
|
-
const UI = join(ROOT, 'src/ui');
|
|
18
|
-
|
|
19
|
-
// Dependencias que SIEMPRE están (peers obligatorios): no se listan como opcionales.
|
|
20
|
-
const REQUIRED = new Set([
|
|
21
|
-
'react', 'react-dom', 'class-variance-authority', 'clsx', 'tailwind-merge', 'lucide-react',
|
|
22
|
-
]);
|
|
23
|
-
|
|
24
|
-
function parseExports(src) {
|
|
25
|
-
const names = new Set();
|
|
26
|
-
for (const m of src.matchAll(/export\s*\{([^}]*)\}/g)) {
|
|
27
|
-
for (const part of m[1].split(',')) {
|
|
28
|
-
const n = part.trim().split(/\s+as\s+/i).pop()?.trim();
|
|
29
|
-
if (n) names.add(n);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
for (const m of src.matchAll(/export\s+(?:async\s+)?(?:function|const|class)\s+([A-Za-z0-9_]+)/g)) names.add(m[1]);
|
|
33
|
-
return [...names].sort();
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function parseSlots(src) {
|
|
37
|
-
return [...new Set([...src.matchAll(/data-slot="([a-z0-9-]+)"/g)].map((m) => m[1]))].sort();
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/** Reglas de uso escritas en el componente con `@note …` (una por línea): van al manifiesto. */
|
|
41
|
-
function parseNotes(src) {
|
|
42
|
-
return [...src.matchAll(/@note\s+([^\r\n]+)/g)].map((m) => m[1].replace(/\s*\*\/\s*$/, '').trim());
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
components
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Manifiesto de componentes de orbital-ds (`components.manifest.json`).
|
|
4
|
+
*
|
|
5
|
+
* Lo leen los agentes de IA (qué hay, cómo se importa, qué `data-slot` expone,
|
|
6
|
+
* qué dependencias opcionales pide) y `pnpm check:ds` lo usa como HUELLA de la API
|
|
7
|
+
* pública: si desaparece un componente o un export respecto al manifiesto
|
|
8
|
+
* commiteado, doctor falla salvo que se haga una versión mayor.
|
|
9
|
+
*
|
|
10
|
+
* node scripts/manifest.mjs # regenera components.manifest.json
|
|
11
|
+
*/
|
|
12
|
+
import { readFileSync, readdirSync, writeFileSync, existsSync } from 'node:fs';
|
|
13
|
+
import { join, dirname, resolve } from 'node:path';
|
|
14
|
+
import { fileURLToPath } from 'node:url';
|
|
15
|
+
|
|
16
|
+
const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
|
17
|
+
const UI = join(ROOT, 'src/ui');
|
|
18
|
+
|
|
19
|
+
// Dependencias que SIEMPRE están (peers obligatorios): no se listan como opcionales.
|
|
20
|
+
const REQUIRED = new Set([
|
|
21
|
+
'react', 'react-dom', 'class-variance-authority', 'clsx', 'tailwind-merge', 'lucide-react',
|
|
22
|
+
]);
|
|
23
|
+
|
|
24
|
+
function parseExports(src) {
|
|
25
|
+
const names = new Set();
|
|
26
|
+
for (const m of src.matchAll(/export\s*\{([^}]*)\}/g)) {
|
|
27
|
+
for (const part of m[1].split(',')) {
|
|
28
|
+
const n = part.trim().split(/\s+as\s+/i).pop()?.trim();
|
|
29
|
+
if (n) names.add(n);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
for (const m of src.matchAll(/export\s+(?:async\s+)?(?:function|const|class)\s+([A-Za-z0-9_]+)/g)) names.add(m[1]);
|
|
33
|
+
return [...names].sort();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function parseSlots(src) {
|
|
37
|
+
return [...new Set([...src.matchAll(/data-slot="([a-z0-9-]+)"/g)].map((m) => m[1]))].sort();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Reglas de uso escritas en el componente con `@note …` (una por línea): van al manifiesto. */
|
|
41
|
+
function parseNotes(src) {
|
|
42
|
+
return [...src.matchAll(/@note\s+([^\r\n]+)/g)].map((m) => m[1].replace(/\s*\*\/\s*$/, '').trim());
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Presets: valores del tipo XPreset, el valor por defecto (preset = "x") y, si la cabecera del
|
|
47
|
+
* componente lo describe (una línea "valor intención"), su intención. Es el catálogo que lee un agente.
|
|
48
|
+
*/
|
|
49
|
+
function parsePresets(src) {
|
|
50
|
+
const t = src.match(/type\s+\w*Preset\s*=\s*((?:"[a-z-]+"\s*\|?\s*)+);?/);
|
|
51
|
+
if (!t) return null;
|
|
52
|
+
const values = [...t[1].matchAll(/"([a-z-]+)"/g)].map((m) => m[1]);
|
|
53
|
+
const def = src.match(/^\s*preset\s*=\s*"([a-z-]+)",?\s*$/m)?.[1] ?? null;
|
|
54
|
+
const intent = {};
|
|
55
|
+
for (const m of src.matchAll(/^\s*\*\s+([a-z-]+)\s{2,}(\S[^\r\n]*)$/gm)) if (values.includes(m[1])) intent[m[1]] = m[2].trim();
|
|
56
|
+
return { values, default: def, ...(Object.keys(intent).length ? { intent } : {}) };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function parseOptionalPeers(src) {
|
|
60
|
+
const peers = new Set();
|
|
61
|
+
for (const m of src.matchAll(/from\s+"([^"]+)"/g)) {
|
|
62
|
+
const spec = m[1];
|
|
63
|
+
if (spec.startsWith('.')) continue;
|
|
64
|
+
const pkg = spec.startsWith('@') ? spec.split('/').slice(0, 2).join('/') : spec.split('/')[0];
|
|
65
|
+
if (pkg === '@base-ui/react' || REQUIRED.has(pkg)) continue;
|
|
66
|
+
peers.add(pkg);
|
|
67
|
+
}
|
|
68
|
+
return [...peers].sort();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function buildManifest() {
|
|
72
|
+
const components = {};
|
|
73
|
+
for (const f of readdirSync(UI).filter((n) => n.endsWith('.tsx')).sort()) {
|
|
74
|
+
const src = readFileSync(join(UI, f), 'utf8');
|
|
75
|
+
const name = f.replace(/\.tsx$/, '');
|
|
76
|
+
components[name] = {
|
|
77
|
+
import: `orbital-ds/ui/${name}`,
|
|
78
|
+
exports: parseExports(src),
|
|
79
|
+
slots: parseSlots(src),
|
|
80
|
+
optionalPeers: parseOptionalPeers(src),
|
|
81
|
+
...(parsePresets(src) ? { presets: parsePresets(src) } : {}),
|
|
82
|
+
...(parseNotes(src).length ? { notes: parseNotes(src) } : {}),
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
const pkg = JSON.parse(readFileSync(join(ROOT, 'package.json'), 'utf8'));
|
|
86
|
+
return {
|
|
87
|
+
package: pkg.name,
|
|
88
|
+
version: pkg.version,
|
|
89
|
+
engine: '@base-ui/react',
|
|
90
|
+
docs: ['README.md', 'docs/CONTRACT.md', 'AGENTS.md', 'contract.json'],
|
|
91
|
+
components,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
|
96
|
+
const out = join(ROOT, 'components.manifest.json');
|
|
97
|
+
const manifest = buildManifest();
|
|
98
|
+
writeFileSync(out, JSON.stringify(manifest, null, 2) + '\n');
|
|
99
|
+
console.log(`manifest: ${Object.keys(manifest.components).length} componentes → components.manifest.json`);
|
|
100
|
+
}
|