@g3nomaly/ui 0.3.3 → 0.3.5
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/README.md +49 -26
- package/dist/cli/adapter.d.ts +25 -8
- package/dist/cli/adapter.d.ts.map +1 -1
- package/dist/cli/adapter.js +34 -20
- package/dist/cli/adapter.js.map +1 -1
- package/dist/cli/afterInstall.d.ts +26 -0
- package/dist/cli/afterInstall.d.ts.map +1 -0
- package/dist/cli/afterInstall.js +54 -0
- package/dist/cli/afterInstall.js.map +1 -0
- package/dist/cli/commands/add.d.ts +8 -2
- package/dist/cli/commands/add.d.ts.map +1 -1
- package/dist/cli/commands/add.js +10 -5
- package/dist/cli/commands/add.js.map +1 -1
- package/dist/cli/commands/index.d.ts +1 -0
- package/dist/cli/commands/index.d.ts.map +1 -1
- package/dist/cli/commands/index.js +1 -0
- package/dist/cli/commands/index.js.map +1 -1
- package/dist/cli/commands/init.d.ts +16 -5
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +59 -13
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/ls.d.ts +1 -1
- package/dist/cli/commands/ls.js +1 -1
- package/dist/cli/commands/ls.js.map +1 -1
- package/dist/cli/commands/manifest.js +1 -1
- package/dist/cli/commands/manifest.js.map +1 -1
- package/dist/cli/commands/source.d.ts +4 -1
- package/dist/cli/commands/source.d.ts.map +1 -1
- package/dist/cli/commands/source.js +29 -2
- package/dist/cli/commands/source.js.map +1 -1
- package/dist/cli/commands/sourceInit.d.ts +9 -0
- package/dist/cli/commands/sourceInit.d.ts.map +1 -0
- package/dist/cli/commands/sourceInit.js +78 -0
- package/dist/cli/commands/sourceInit.js.map +1 -0
- package/dist/cli/commands/update.d.ts +10 -3
- package/dist/cli/commands/update.d.ts.map +1 -1
- package/dist/cli/commands/update.js +9 -4
- package/dist/cli/commands/update.js.map +1 -1
- package/dist/cli/index.js +17 -6
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/localSources.d.ts +12 -0
- package/dist/cli/localSources.d.ts.map +1 -0
- package/dist/cli/localSources.js +49 -0
- package/dist/cli/localSources.js.map +1 -0
- package/dist/cli/npmDependencies.d.ts +11 -0
- package/dist/cli/npmDependencies.d.ts.map +1 -0
- package/dist/cli/npmDependencies.js +73 -0
- package/dist/cli/npmDependencies.js.map +1 -0
- package/dist/cli/packageFiles.d.ts +15 -0
- package/dist/cli/packageFiles.d.ts.map +1 -0
- package/dist/cli/packageFiles.js +54 -0
- package/dist/cli/packageFiles.js.map +1 -0
- package/dist/cli/themeTokens.d.ts +12 -0
- package/dist/cli/themeTokens.d.ts.map +1 -0
- package/dist/cli/themeTokens.js +60 -0
- package/dist/cli/themeTokens.js.map +1 -0
- package/dist/packages/dependencies.d.ts +48 -0
- package/dist/packages/dependencies.d.ts.map +1 -0
- package/dist/packages/dependencies.js +66 -0
- package/dist/packages/dependencies.js.map +1 -0
- package/dist/packages/install.d.ts +30 -0
- package/dist/packages/install.d.ts.map +1 -0
- package/dist/packages/install.js +54 -0
- package/dist/packages/install.js.map +1 -0
- package/dist/packages/localPack.d.ts +48 -0
- package/dist/packages/localPack.d.ts.map +1 -0
- package/dist/packages/localPack.js +72 -0
- package/dist/packages/localPack.js.map +1 -0
- package/dist/registry/adapters/shadcn.adapter.d.ts +32 -7
- package/dist/registry/adapters/shadcn.adapter.d.ts.map +1 -1
- package/dist/registry/adapters/shadcn.adapter.js +75 -20
- package/dist/registry/adapters/shadcn.adapter.js.map +1 -1
- package/dist/registry/adapters/shadcnImports.d.ts +10 -0
- package/dist/registry/adapters/shadcnImports.d.ts.map +1 -0
- package/dist/registry/adapters/shadcnImports.js +18 -0
- package/dist/registry/adapters/shadcnImports.js.map +1 -0
- package/dist/registry/componentsJson.d.ts +6 -1
- package/dist/registry/componentsJson.d.ts.map +1 -1
- package/dist/registry/componentsJson.js +34 -1
- package/dist/registry/componentsJson.js.map +1 -1
- package/dist/registry/index.d.ts +1 -1
- package/dist/registry/index.d.ts.map +1 -1
- package/dist/registry/index.js +1 -1
- package/dist/registry/index.js.map +1 -1
- package/dist/registry/manifest.d.ts +2 -13
- package/dist/registry/manifest.d.ts.map +1 -1
- package/dist/registry/manifest.js +4 -76
- package/dist/registry/manifest.js.map +1 -1
- package/dist/registry/packageExports.d.ts +9 -0
- package/dist/registry/packageExports.d.ts.map +1 -0
- package/dist/registry/packageExports.js +50 -0
- package/dist/registry/packageExports.js.map +1 -0
- package/dist/registry/packageImports.d.ts +23 -0
- package/dist/registry/packageImports.d.ts.map +1 -0
- package/dist/registry/packageImports.js +51 -0
- package/dist/registry/packageImports.js.map +1 -0
- package/dist/registry/readSource.d.ts +4 -2
- package/dist/registry/readSource.d.ts.map +1 -1
- package/dist/registry/readSource.js +27 -3
- package/dist/registry/readSource.js.map +1 -1
- package/dist/registry/types.d.ts +86 -3
- package/dist/registry/types.d.ts.map +1 -1
- package/dist/registry/types.js +46 -3
- package/dist/registry/types.js.map +1 -1
- package/dist/sources/builtins.d.ts +1 -5
- package/dist/sources/builtins.d.ts.map +1 -1
- package/dist/sources/builtins.js +2 -7
- package/dist/sources/builtins.js.map +1 -1
- package/dist/theme/cssVars.d.ts +43 -0
- package/dist/theme/cssVars.d.ts.map +1 -0
- package/dist/theme/cssVars.js +107 -0
- package/dist/theme/cssVars.js.map +1 -0
- package/dist/theme/detectCssFile.d.ts +9 -0
- package/dist/theme/detectCssFile.d.ts.map +1 -0
- package/dist/theme/detectCssFile.js +41 -0
- package/dist/theme/detectCssFile.js.map +1 -0
- package/package.json +8 -21
- package/template/build.ts +32 -0
- package/template/package.json +22 -0
- package/template/src/components/example/Example.css +20 -0
- package/template/src/components/example/Example.tsx +26 -0
- package/template/src/components/example/example.meta.ts +69 -0
- package/dist/components/basic/Card.css +0 -32
- package/dist/components/basic/Card.debug.ts +0 -5
- package/dist/components/basic/Card.tsx +0 -31
- package/dist/components/basic/CardFooter.css +0 -16
- package/dist/components/basic/CardFooter.debug.ts +0 -5
- package/dist/components/basic/CardFooter.tsx +0 -29
- package/dist/components/basic/CardHeader.css +0 -14
- package/dist/components/basic/CardHeader.debug.ts +0 -5
- package/dist/components/basic/CardHeader.tsx +0 -29
- package/dist/components/basic/card.meta.ts +0 -14
- package/dist/components/basic/cardfooter.meta.ts +0 -14
- package/dist/components/basic/cardheader.meta.ts +0 -14
- package/dist/components/input/Button.css +0 -34
- package/dist/components/input/Button.debug.ts +0 -5
- package/dist/components/input/Button.tsx +0 -28
- package/dist/components/input/button.meta.ts +0 -14
- package/dist/components.json +0 -138
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/registry/index.ts"],"names":[],"mappings":"AACA,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5G,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACzE,YAAY,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/registry/index.ts"],"names":[],"mappings":"AACA,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5G,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACzE,YAAY,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/registry/index.js
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
export * from "./types";
|
|
3
3
|
export { COMPONENTS_DIR, COMPONENTS_JSON, readComponentsJson, writeComponentsJson } from "./componentsJson";
|
|
4
4
|
export { readComponentSource, filterFiles, groupOf } from "./readSource";
|
|
5
|
-
export { uiManifestPath,
|
|
5
|
+
export { uiManifestPath, SHADCN_SOURCE } from "./manifest";
|
|
6
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/registry/index.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5G,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEzE,OAAO,EAAE,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/registry/index.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5G,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEzE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -1,21 +1,10 @@
|
|
|
1
1
|
/** Source name shadcn components are recorded under. */
|
|
2
2
|
export declare const SHADCN_SOURCE = "shadcn";
|
|
3
3
|
/**
|
|
4
|
-
* @brief Path of the project's
|
|
4
|
+
* @brief Path of the project's component manifest.
|
|
5
5
|
*
|
|
6
6
|
* @param projectRoot - Absolute project root, e.g. `/home/me/app`.
|
|
7
|
-
* @returns absolute path, e.g. `/home/me/app/.g3n
|
|
7
|
+
* @returns absolute path, e.g. `/home/me/app/.g3n/ui.json`
|
|
8
8
|
*/
|
|
9
9
|
export declare function uiManifestPath(projectRoot: string): string;
|
|
10
|
-
/**
|
|
11
|
-
* @brief Rewrites a manifest from before the shared `{ sources, entries }` shape:
|
|
12
|
-
* a flat `.g3nui-manifest.json`, or a `.g3nui-manifest.ts` whose `registry`
|
|
13
|
-
* export becomes the JSON file and is then deleted. Does nothing when the
|
|
14
|
-
* manifest is already in the shared shape or does not exist.
|
|
15
|
-
*
|
|
16
|
-
* @param projectRoot - Absolute project root, e.g. `/home/me/app`.
|
|
17
|
-
* @returns the path that was migrated, or `null` when nothing changed
|
|
18
|
-
* @throws {Error} When a legacy manifest does not match the old entry shape.
|
|
19
|
-
*/
|
|
20
|
-
export declare function migrateLegacyManifest(projectRoot: string): Promise<string | null>;
|
|
21
10
|
//# sourceMappingURL=manifest.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../src/registry/manifest.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../src/registry/manifest.ts"],"names":[],"mappings":"AAMA,wDAAwD;AACxD,eAAO,MAAM,aAAa,WAAW,CAAC;AAEtC;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAE1D"}
|
|
@@ -1,88 +1,16 @@
|
|
|
1
1
|
// packages/ui/src/registry/manifest.ts
|
|
2
|
-
import fs from "node:fs";
|
|
3
2
|
import path from "node:path";
|
|
4
|
-
import { z } from "zod";
|
|
5
|
-
import { COMPONENTS_DIR } from "./componentsJson";
|
|
6
|
-
import { groupOf } from "./readSource";
|
|
7
|
-
import { ComponentFileSchema } from "./types";
|
|
8
3
|
const MANIFEST_DIR = ".g3n";
|
|
9
|
-
const
|
|
4
|
+
const MANIFEST_FILE = "ui.json";
|
|
10
5
|
/** Source name shadcn components are recorded under. */
|
|
11
6
|
export const SHADCN_SOURCE = "shadcn";
|
|
12
|
-
/** An entry as manifests before the shared `{ sources, entries }` shape recorded it. */
|
|
13
|
-
const LegacyEntrySchema = z.object({
|
|
14
|
-
name: z.string().min(1),
|
|
15
|
-
description: z.string().optional(),
|
|
16
|
-
version: z.string().optional(),
|
|
17
|
-
category: z.string().optional(),
|
|
18
|
-
group: z.string().optional(),
|
|
19
|
-
author: z.string().optional(),
|
|
20
|
-
packageOrigin: z.string().optional(),
|
|
21
|
-
registryDependencies: z.array(z.string()).optional(),
|
|
22
|
-
files: z.array(ComponentFileSchema).min(1),
|
|
23
|
-
});
|
|
24
7
|
/**
|
|
25
|
-
* @brief Path of the project's
|
|
8
|
+
* @brief Path of the project's component manifest.
|
|
26
9
|
*
|
|
27
10
|
* @param projectRoot - Absolute project root, e.g. `/home/me/app`.
|
|
28
|
-
* @returns absolute path, e.g. `/home/me/app/.g3n
|
|
11
|
+
* @returns absolute path, e.g. `/home/me/app/.g3n/ui.json`
|
|
29
12
|
*/
|
|
30
13
|
export function uiManifestPath(projectRoot) {
|
|
31
|
-
return path.join(projectRoot, MANIFEST_DIR,
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* @brief Converts one legacy entry to the shared shape, taking its origin from `packageOrigin`.
|
|
35
|
-
*
|
|
36
|
-
* @param entry - Legacy entry as `LegacyEntrySchema` parses it.
|
|
37
|
-
* @returns The entry with `group` and `origin` set, as `ComponentMeta` holds them.
|
|
38
|
-
*/
|
|
39
|
-
function migrateEntry(entry) {
|
|
40
|
-
const { packageOrigin, group, ...rest } = entry;
|
|
41
|
-
const shadcn = packageOrigin === SHADCN_SOURCE;
|
|
42
|
-
return {
|
|
43
|
-
...rest,
|
|
44
|
-
group: group ?? groupOf(entry),
|
|
45
|
-
origin: shadcn ? { source: SHADCN_SOURCE, dir: "" } : { source: "g3nui", dir: COMPONENTS_DIR, version: entry.version },
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* @brief Writes legacy entries as a shared-shape manifest at the JSON path.
|
|
50
|
-
*
|
|
51
|
-
* @param projectRoot - Absolute project root, e.g. `/home/me/app`.
|
|
52
|
-
* @param legacy - Parsed flat manifest: legacy entries keyed by component key.
|
|
53
|
-
*/
|
|
54
|
-
function writeMigrated(projectRoot, legacy) {
|
|
55
|
-
const entries = Object.fromEntries(Object.entries(z.record(z.string(), LegacyEntrySchema).parse(legacy)).map(([key, entry]) => [key, migrateEntry(entry)]));
|
|
56
|
-
fs.mkdirSync(path.join(projectRoot, MANIFEST_DIR), { recursive: true });
|
|
57
|
-
fs.writeFileSync(uiManifestPath(projectRoot), JSON.stringify({ sources: {}, entries }, null, 2) + "\n");
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* @brief Rewrites a manifest from before the shared `{ sources, entries }` shape:
|
|
61
|
-
* a flat `.g3nui-manifest.json`, or a `.g3nui-manifest.ts` whose `registry`
|
|
62
|
-
* export becomes the JSON file and is then deleted. Does nothing when the
|
|
63
|
-
* manifest is already in the shared shape or does not exist.
|
|
64
|
-
*
|
|
65
|
-
* @param projectRoot - Absolute project root, e.g. `/home/me/app`.
|
|
66
|
-
* @returns the path that was migrated, or `null` when nothing changed
|
|
67
|
-
* @throws {Error} When a legacy manifest does not match the old entry shape.
|
|
68
|
-
*/
|
|
69
|
-
export async function migrateLegacyManifest(projectRoot) {
|
|
70
|
-
const jsonPath = uiManifestPath(projectRoot);
|
|
71
|
-
const tsPath = path.join(projectRoot, MANIFEST_DIR, `${MANIFEST_BASE}.ts`);
|
|
72
|
-
if (fs.existsSync(jsonPath)) {
|
|
73
|
-
const raw = JSON.parse(fs.readFileSync(jsonPath, "utf8"));
|
|
74
|
-
const shared = typeof raw === "object" && raw !== null && ("entries" in raw || "sources" in raw);
|
|
75
|
-
if (shared)
|
|
76
|
-
return null;
|
|
77
|
-
writeMigrated(projectRoot, raw);
|
|
78
|
-
return jsonPath;
|
|
79
|
-
}
|
|
80
|
-
if (fs.existsSync(tsPath)) {
|
|
81
|
-
const legacy = z.object({ registry: z.unknown() }).parse(await import(tsPath));
|
|
82
|
-
writeMigrated(projectRoot, legacy.registry);
|
|
83
|
-
fs.rmSync(tsPath);
|
|
84
|
-
return tsPath;
|
|
85
|
-
}
|
|
86
|
-
return null;
|
|
14
|
+
return path.join(projectRoot, MANIFEST_DIR, MANIFEST_FILE);
|
|
87
15
|
}
|
|
88
16
|
//# sourceMappingURL=manifest.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../../src/registry/manifest.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,OAAO,
|
|
1
|
+
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../../src/registry/manifest.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,MAAM,YAAY,GAAI,MAAM,CAAC;AAC7B,MAAM,aAAa,GAAG,SAAS,CAAC;AAEhC,wDAAwD;AACxD,MAAM,CAAC,MAAM,aAAa,GAAG,QAAQ,CAAC;AAEtC;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,WAAmB;IAChD,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,YAAY,EAAE,aAAa,CAAC,CAAC;AAC7D,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @brief Files that stay in the package but that its `exports` field does not reach, so an app cannot import them.
|
|
3
|
+
*
|
|
4
|
+
* @param packageRoot - Absolute folder holding the package's `package.json`.
|
|
5
|
+
* @param files - Files to check, relative to the package root, e.g. `dist/components/graph/graphStore.ts`.
|
|
6
|
+
* @returns The files no export reaches, as given.
|
|
7
|
+
*/
|
|
8
|
+
export declare function unexportedFiles(packageRoot: string, files: readonly string[]): string[];
|
|
9
|
+
//# sourceMappingURL=packageExports.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packageExports.d.ts","sourceRoot":"","sources":["../../src/registry/packageExports.ts"],"names":[],"mappings":"AAkCA;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,EAAE,CAOvF"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// packages/ui/src/registry/packageExports.ts
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
const PackageExportsSchema = z.object({ name: z.string().min(1), exports: z.unknown().optional() });
|
|
6
|
+
/**
|
|
7
|
+
* @brief Every target path an `exports` field maps to, through nested conditions such as `import` or `types`.
|
|
8
|
+
*
|
|
9
|
+
* @param exports - The `exports` value, or one of its branches.
|
|
10
|
+
* @returns Target paths, e.g. `./dist/components/*.ts`.
|
|
11
|
+
*/
|
|
12
|
+
function exportTargets(exports) {
|
|
13
|
+
if (typeof exports === "string")
|
|
14
|
+
return [exports];
|
|
15
|
+
if (Array.isArray(exports))
|
|
16
|
+
return exports.flatMap(exportTargets);
|
|
17
|
+
if (typeof exports === "object" && exports !== null)
|
|
18
|
+
return Object.values(exports).flatMap(exportTargets);
|
|
19
|
+
return [];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* @brief Whether an export target reaches a file: equal to it, or a `*` pattern that matches it.
|
|
23
|
+
*
|
|
24
|
+
* @param target - Export target, e.g. `./dist/components/*.ts`.
|
|
25
|
+
* @param file - Path of the file from the package root, starting with `./`.
|
|
26
|
+
*/
|
|
27
|
+
function reaches(target, file) {
|
|
28
|
+
const star = target.indexOf("*");
|
|
29
|
+
if (star === -1)
|
|
30
|
+
return target === file;
|
|
31
|
+
const prefix = target.slice(0, star);
|
|
32
|
+
const suffix = target.slice(star + 1);
|
|
33
|
+
return file.length >= prefix.length + suffix.length && file.startsWith(prefix) && file.endsWith(suffix);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* @brief Files that stay in the package but that its `exports` field does not reach, so an app cannot import them.
|
|
37
|
+
*
|
|
38
|
+
* @param packageRoot - Absolute folder holding the package's `package.json`.
|
|
39
|
+
* @param files - Files to check, relative to the package root, e.g. `dist/components/graph/graphStore.ts`.
|
|
40
|
+
* @returns The files no export reaches, as given.
|
|
41
|
+
*/
|
|
42
|
+
export function unexportedFiles(packageRoot, files) {
|
|
43
|
+
const manifest = PackageExportsSchema.parse(JSON.parse(fs.readFileSync(path.join(packageRoot, "package.json"), "utf8")));
|
|
44
|
+
const targets = exportTargets(manifest.exports);
|
|
45
|
+
return files.filter((file) => {
|
|
46
|
+
const relative = `./${file.split(path.sep).join("/")}`;
|
|
47
|
+
return !targets.some((target) => reaches(target, relative));
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=packageExports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packageExports.js","sourceRoot":"","sources":["../../src/registry/packageExports.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;AAEpG;;;;;GAKG;AACH,SAAS,aAAa,CAAC,OAAgB;IACrC,IAAI,OAAO,OAAO,KAAK,QAAQ;QAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAClD,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;QAAE,OAAO,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IAClE,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,aAA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AC;AACL,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @brief A package a file imports that its package does not declare as a peer.
|
|
3
|
+
*
|
|
4
|
+
* @property file - Path of the importing file from the package root, e.g. `dist/components/dock/layout.ts`.
|
|
5
|
+
* @property pkg - Name of the imported package, e.g. `react` or `@tanstack/store`.
|
|
6
|
+
*/
|
|
7
|
+
export interface UndeclaredImport {
|
|
8
|
+
file: string;
|
|
9
|
+
pkg: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* @brief Packages the files import at runtime that the package's `peerDependencies` lack.
|
|
13
|
+
*
|
|
14
|
+
* Files marked `install: "package"` run inside the app, so every package they import must come from the
|
|
15
|
+
* app's own install: a package installed beside them would load a second copy, such as a second React.
|
|
16
|
+
* Type-only imports are left out, since they are gone at runtime, and so are imports of the package itself.
|
|
17
|
+
*
|
|
18
|
+
* @param packageRoot - Absolute folder holding the package's `package.json`.
|
|
19
|
+
* @param files - Files to scan, relative to the package root.
|
|
20
|
+
* @returns One entry per file and package that is not a peer, in file order.
|
|
21
|
+
*/
|
|
22
|
+
export declare function undeclaredImports(packageRoot: string, files: readonly string[]): UndeclaredImport[];
|
|
23
|
+
//# sourceMappingURL=packageImports.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packageImports.d.ts","sourceRoot":"","sources":["../../src/registry/packageImports.ts"],"names":[],"mappings":"AAcA;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAG,MAAM,CAAC;CACd;AAiBD;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,gBAAgB,EAAE,CAYnG"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// packages/ui/src/registry/packageImports.ts
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import { builtinModules } from "node:module";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
const PackagePeersSchema = z.object({
|
|
7
|
+
name: z.string().min(1),
|
|
8
|
+
peerDependencies: z.record(z.string(), z.string()).optional(),
|
|
9
|
+
});
|
|
10
|
+
/** Node and Bun built-ins, which need no install. */
|
|
11
|
+
const BUILTINS = new Set(builtinModules);
|
|
12
|
+
/**
|
|
13
|
+
* @brief The package an import path names, or `null` for a path that needs no package: a relative
|
|
14
|
+
* path, a built-in such as `node:fs` or `bun:test`.
|
|
15
|
+
*
|
|
16
|
+
* @param specifier - The import path as written, e.g. `@tanstack/store/vanilla`.
|
|
17
|
+
* @returns The package name, e.g. `@tanstack/store`.
|
|
18
|
+
*/
|
|
19
|
+
function packageOf(specifier) {
|
|
20
|
+
if (specifier.startsWith(".") || specifier.startsWith("/"))
|
|
21
|
+
return null;
|
|
22
|
+
if (specifier.startsWith("node:") || specifier.startsWith("bun:") || specifier === "bun")
|
|
23
|
+
return null;
|
|
24
|
+
const [first = "", second] = specifier.split("/");
|
|
25
|
+
const name = first.startsWith("@") && second !== undefined ? `${first}/${second}` : first;
|
|
26
|
+
return BUILTINS.has(name) ? null : name;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* @brief Packages the files import at runtime that the package's `peerDependencies` lack.
|
|
30
|
+
*
|
|
31
|
+
* Files marked `install: "package"` run inside the app, so every package they import must come from the
|
|
32
|
+
* app's own install: a package installed beside them would load a second copy, such as a second React.
|
|
33
|
+
* Type-only imports are left out, since they are gone at runtime, and so are imports of the package itself.
|
|
34
|
+
*
|
|
35
|
+
* @param packageRoot - Absolute folder holding the package's `package.json`.
|
|
36
|
+
* @param files - Files to scan, relative to the package root.
|
|
37
|
+
* @returns One entry per file and package that is not a peer, in file order.
|
|
38
|
+
*/
|
|
39
|
+
export function undeclaredImports(packageRoot, files) {
|
|
40
|
+
const manifest = PackagePeersSchema.parse(JSON.parse(fs.readFileSync(path.join(packageRoot, "package.json"), "utf8")));
|
|
41
|
+
const peers = manifest.peerDependencies ?? {};
|
|
42
|
+
const transpiler = new Bun.Transpiler({ loader: "tsx" });
|
|
43
|
+
return files.flatMap((file) => {
|
|
44
|
+
const imports = transpiler.scanImports(fs.readFileSync(path.join(packageRoot, file), "utf8"));
|
|
45
|
+
const packages = new Set(imports.map((entry) => packageOf(entry.path)));
|
|
46
|
+
return [...packages]
|
|
47
|
+
.filter((pkg) => pkg !== null && pkg !== manifest.name && peers[pkg] === undefined)
|
|
48
|
+
.map((pkg) => ({ file, pkg }));
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=packageImports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packageImports.js","sourceRoot":"","sources":["../../src/registry/packageImports.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IAClC,IAAI,EAAc,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACnC,gBAAgB,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;CAC9D,CAAC,CAAC;AAEH,qDAAqD;AACrD,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,CAAC;AAazC;;;;;;GAMG;AACH,SAAS,SAAS,CAAC,SAAiB;IAClC,IAAI,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IAC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EAAE,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACxE,OAAO,CAAC,GAAG,QAAQ,CAAC;aACjB,MAAM,CAAC,CAAC,GAAG,EAAiB,EAAE,CAAC,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,QAAQ,CAAC,IAAI,IAAI,KAAK,CAAC,GAAG,CAAC,KAAK,SAAS,CAAC;aACjG,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -27,8 +27,10 @@ export declare function filterFiles(files: readonly ComponentFile[], flags: Comp
|
|
|
27
27
|
export declare function groupOf(meta: Pick<PackagedComponent, "category" | "files">): string;
|
|
28
28
|
/**
|
|
29
29
|
* @brief Reader for a source that is a component package: its `dist/components.json`,
|
|
30
|
-
* with the files the flags leave out dropped.
|
|
31
|
-
*
|
|
30
|
+
* with the files the flags leave out dropped. Files marked `install: "package"`
|
|
31
|
+
* move to `packageFiles`: they are never written, and the source package becomes
|
|
32
|
+
* a runtime dependency of the component, since its files import them by package
|
|
33
|
+
* path. Handed to `loadSourceRegistry` by every g3n-ui command.
|
|
32
34
|
*
|
|
33
35
|
* @param flags - Which optional files to keep.
|
|
34
36
|
* @returns Reader that yields the package's components, skipping any left with no files.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readSource.d.ts","sourceRoot":"","sources":["../../src/registry/readSource.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"readSource.d.ts","sourceRoot":"","sources":["../../src/registry/readSource.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAG3D,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE/E;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC,YAAY,EAAE,OAAO,CAAC;IACtB,WAAW,EAAG,OAAO,CAAC;CACvB;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,SAAS,aAAa,EAAE,EAAE,KAAK,EAAE,kBAAkB,GAAG,aAAa,EAAE,CAMvG;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,iBAAiB,EAAE,UAAU,GAAG,OAAO,CAAC,GAAG,MAAM,CAInF;AAaD;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,kBAAkB,GAAG,UAAU,CAAC,aAAa,CAAC,CA6BxF"}
|
|
@@ -27,10 +27,23 @@ export function groupOf(meta) {
|
|
|
27
27
|
const first = meta.files[0]?.path ?? "";
|
|
28
28
|
return first.includes("/") ? first.split("/")[0] ?? "unknown" : "unknown";
|
|
29
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* @brief The source package as an npm dependency of the app, for a component whose files import from it.
|
|
32
|
+
*
|
|
33
|
+
* @param checkout - The source's checkout.
|
|
34
|
+
* @returns `<package>@^<version>`, or `null` when the source is not an npm package and so cannot be imported from.
|
|
35
|
+
*/
|
|
36
|
+
function packageDependency(checkout) {
|
|
37
|
+
if (checkout.spec.kind !== "npm")
|
|
38
|
+
return null;
|
|
39
|
+
return checkout.version === undefined ? checkout.spec.package : `${checkout.spec.package}@^${checkout.version}`;
|
|
40
|
+
}
|
|
30
41
|
/**
|
|
31
42
|
* @brief Reader for a source that is a component package: its `dist/components.json`,
|
|
32
|
-
* with the files the flags leave out dropped.
|
|
33
|
-
*
|
|
43
|
+
* with the files the flags leave out dropped. Files marked `install: "package"`
|
|
44
|
+
* move to `packageFiles`: they are never written, and the source package becomes
|
|
45
|
+
* a runtime dependency of the component, since its files import them by package
|
|
46
|
+
* path. Handed to `loadSourceRegistry` by every g3n-ui command.
|
|
34
47
|
*
|
|
35
48
|
* @param flags - Which optional files to keep.
|
|
36
49
|
* @returns Reader that yields the package's components, skipping any left with no files.
|
|
@@ -39,19 +52,30 @@ export function readComponentSource(flags) {
|
|
|
39
52
|
return async (checkout) => {
|
|
40
53
|
const entries = [];
|
|
41
54
|
const warnings = [];
|
|
55
|
+
const ownPackage = packageDependency(checkout);
|
|
56
|
+
const unreachable = [];
|
|
42
57
|
for (const [key, meta] of Object.entries(readComponentsJson(checkout.dir))) {
|
|
43
|
-
const
|
|
58
|
+
const packageFiles = meta.files.filter((file) => file.install === "package");
|
|
59
|
+
const files = filterFiles(meta.files.filter((file) => file.install !== "package"), flags);
|
|
44
60
|
if (files.length === 0) {
|
|
45
61
|
warnings.push(`${key} has no files left after filtering, skipped`);
|
|
46
62
|
continue;
|
|
47
63
|
}
|
|
64
|
+
if (packageFiles.length > 0 && ownPackage === null)
|
|
65
|
+
unreachable.push(key);
|
|
66
|
+
const dependencies = packageFiles.length > 0 && ownPackage !== null ? [...(meta.dependencies ?? []), ownPackage] : meta.dependencies;
|
|
48
67
|
entries.push([key, {
|
|
49
68
|
...meta,
|
|
50
69
|
group: groupOf(meta),
|
|
51
70
|
origin: { source: checkout.name, dir: COMPONENTS_DIR, commit: checkout.commit, version: checkout.version },
|
|
52
71
|
files,
|
|
72
|
+
...(dependencies === undefined ? {} : { dependencies }),
|
|
73
|
+
...(packageFiles.length === 0 ? {} : { packageFiles }),
|
|
53
74
|
}]);
|
|
54
75
|
}
|
|
76
|
+
if (unreachable.length > 0) {
|
|
77
|
+
warnings.push(`${unreachable.join(", ")} import files that stay in the package, which only resolve when the source is installed with \`bun add\`, from npm, git, a workspace or a folder, and registered as \`npm:<package>\``);
|
|
78
|
+
}
|
|
55
79
|
return { entries, warnings };
|
|
56
80
|
};
|
|
57
81
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readSource.js","sourceRoot":"","sources":["../../src/registry/readSource.ts"],"names":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AC,CAAC,GAAG,EAAE;oBACjB,GAAG,IAAI;oBACP,KAAK,EAAG,OAAO,CAAC,IAAI,CAAC;oBACrB,MAAM,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAC,IAAI,EAAE,GAAG,EAAE,cAAc,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE;oBAC1G,KAAK;oBACL,GAAG,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC;oBACvD,GAAG,CAAC,YAAY,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC;iBACvD,CAAC,CAAC,CAAC;QACN,CAAC;QACD,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC3B,QAAQ,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,uLAAuL,CAAC,CAAC;QAClO,CAAC;QACD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;IAC/B,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/registry/types.d.ts
CHANGED
|
@@ -9,7 +9,19 @@ export declare const ComponentFileTypeSchema: z.ZodEnum<{
|
|
|
9
9
|
}>;
|
|
10
10
|
/** Kind of a component file: `component`, `style`, `util`, `hook`, `type` or `meta`. */
|
|
11
11
|
export type ComponentFileType = z.infer<typeof ComponentFileTypeSchema>;
|
|
12
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* @brief How a file reaches the app: `copy` (the default) writes it into the app for the user to own;
|
|
14
|
+
* `package` keeps it in the source package, where the component imports it from by package path.
|
|
15
|
+
*/
|
|
16
|
+
export declare const FileInstallSchema: z.ZodEnum<{
|
|
17
|
+
copy: "copy";
|
|
18
|
+
package: "package";
|
|
19
|
+
}>;
|
|
20
|
+
/**
|
|
21
|
+
* @brief One file of a component; `path` is relative to the components directory, e.g. `basic/Card.tsx`.
|
|
22
|
+
*
|
|
23
|
+
* @property install - `package` for a file that stays in the source package, such as a store; absent to copy it.
|
|
24
|
+
*/
|
|
13
25
|
export declare const ComponentFileSchema: z.ZodObject<{
|
|
14
26
|
path: z.ZodString;
|
|
15
27
|
hash: z.ZodOptional<z.ZodString>;
|
|
@@ -22,16 +34,44 @@ export declare const ComponentFileSchema: z.ZodObject<{
|
|
|
22
34
|
type: "type";
|
|
23
35
|
util: "util";
|
|
24
36
|
}>;
|
|
37
|
+
install: z.ZodOptional<z.ZodEnum<{
|
|
38
|
+
copy: "copy";
|
|
39
|
+
package: "package";
|
|
40
|
+
}>>;
|
|
25
41
|
}, z.core.$strip>;
|
|
26
42
|
/** A file of a component: the base file entry plus its `ComponentFileType`. */
|
|
27
43
|
export type ComponentFile = z.infer<typeof ComponentFileSchema>;
|
|
44
|
+
/**
|
|
45
|
+
* @brief npm packages a component's files import, each as `name` or `name@range`, e.g. `radix-ui` or
|
|
46
|
+
* `recharts@3.8.0`, the way shadcn lists them.
|
|
47
|
+
*/
|
|
48
|
+
export declare const NpmDependenciesSchema: z.ZodArray<z.ZodString>;
|
|
49
|
+
/**
|
|
50
|
+
* @brief Theme tokens a component needs in the app's global stylesheet, in shadcn's `cssVars` format:
|
|
51
|
+
* names without the leading `--`, e.g. `{ light: { sidebar: "oklch(0.98 0 0)" } }`.
|
|
52
|
+
*
|
|
53
|
+
* @property theme - Tokens for the `@theme inline` block.
|
|
54
|
+
* @property light - Tokens for the `:root` block.
|
|
55
|
+
* @property dark - Tokens for the `.dark` block.
|
|
56
|
+
*/
|
|
57
|
+
export declare const CssVarsSchema: z.ZodObject<{
|
|
58
|
+
theme: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
59
|
+
light: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
60
|
+
dark: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
61
|
+
}, z.core.$strip>;
|
|
62
|
+
/** Theme tokens a component needs, the type `CssVarsSchema` parses. */
|
|
63
|
+
export type CssVars = z.infer<typeof CssVarsSchema>;
|
|
28
64
|
/**
|
|
29
65
|
* @brief A component as it ships: what a `*.meta.ts` file declares and what
|
|
30
66
|
* `dist/components.json` holds per component, before a source reads it.
|
|
31
67
|
*
|
|
32
68
|
* @property version - Set at build time from the package version.
|
|
33
69
|
* @property registryDependencies - Keys of components this one needs installed beside it, e.g. `button`.
|
|
34
|
-
* @property
|
|
70
|
+
* @property dependencies - npm packages the app needs at runtime for this component, e.g. `radix-ui`.
|
|
71
|
+
* @property devDependencies - npm packages the app needs at build time only, e.g. `@types/d3`.
|
|
72
|
+
* @property cssVars - Theme tokens the component needs in the app's global stylesheet.
|
|
73
|
+
* @property files - Files of the component, each with its path and `ComponentFileType`; `install: "package"`
|
|
74
|
+
* marks one that stays in the package.
|
|
35
75
|
*/
|
|
36
76
|
export declare const PackagedComponentSchema: z.ZodObject<{
|
|
37
77
|
name: z.ZodString;
|
|
@@ -40,6 +80,13 @@ export declare const PackagedComponentSchema: z.ZodObject<{
|
|
|
40
80
|
category: z.ZodOptional<z.ZodString>;
|
|
41
81
|
author: z.ZodOptional<z.ZodString>;
|
|
42
82
|
registryDependencies: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
83
|
+
dependencies: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
84
|
+
devDependencies: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
85
|
+
cssVars: z.ZodOptional<z.ZodObject<{
|
|
86
|
+
theme: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
87
|
+
light: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
88
|
+
dark: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
89
|
+
}, z.core.$strip>>;
|
|
43
90
|
files: z.ZodArray<z.ZodObject<{
|
|
44
91
|
path: z.ZodString;
|
|
45
92
|
hash: z.ZodOptional<z.ZodString>;
|
|
@@ -52,17 +99,25 @@ export declare const PackagedComponentSchema: z.ZodObject<{
|
|
|
52
99
|
type: "type";
|
|
53
100
|
util: "util";
|
|
54
101
|
}>;
|
|
102
|
+
install: z.ZodOptional<z.ZodEnum<{
|
|
103
|
+
copy: "copy";
|
|
104
|
+
package: "package";
|
|
105
|
+
}>>;
|
|
55
106
|
}, z.core.$strip>>;
|
|
56
107
|
}, z.core.$strip>;
|
|
57
108
|
/** A component as it ships, the type `PackagedComponentSchema` parses. */
|
|
58
109
|
export type PackagedComponent = z.infer<typeof PackagedComponentSchema>;
|
|
59
110
|
/**
|
|
60
111
|
* @brief One installable component, read from a source by `readComponentSource`
|
|
61
|
-
* or the shadcn adapter, and written per install into the
|
|
112
|
+
* or the shadcn adapter, and written per install into the ui manifest by
|
|
62
113
|
* the `add` and `update` commands.
|
|
63
114
|
*
|
|
64
115
|
* @property group - Display group: the category, or the first folder of the first file, e.g. `basic`.
|
|
116
|
+
* @property dependencies - npm packages the app needs at runtime for this component.
|
|
117
|
+
* @property devDependencies - npm packages the app needs at build time only.
|
|
118
|
+
* @property cssVars - Theme tokens the component needs in the app's global stylesheet.
|
|
65
119
|
* @property files - Files the install writes, each with its path and `ComponentFileType`.
|
|
120
|
+
* @property packageFiles - Files that stay in the source package, imported from it by package path; never written.
|
|
66
121
|
*/
|
|
67
122
|
export declare const ComponentMetaSchema: z.ZodObject<{
|
|
68
123
|
name: z.ZodString;
|
|
@@ -79,6 +134,13 @@ export declare const ComponentMetaSchema: z.ZodObject<{
|
|
|
79
134
|
group: z.ZodString;
|
|
80
135
|
category: z.ZodOptional<z.ZodString>;
|
|
81
136
|
author: z.ZodOptional<z.ZodString>;
|
|
137
|
+
dependencies: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
138
|
+
devDependencies: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
139
|
+
cssVars: z.ZodOptional<z.ZodObject<{
|
|
140
|
+
theme: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
141
|
+
light: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
142
|
+
dark: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
143
|
+
}, z.core.$strip>>;
|
|
82
144
|
files: z.ZodArray<z.ZodObject<{
|
|
83
145
|
path: z.ZodString;
|
|
84
146
|
hash: z.ZodOptional<z.ZodString>;
|
|
@@ -91,7 +153,28 @@ export declare const ComponentMetaSchema: z.ZodObject<{
|
|
|
91
153
|
type: "type";
|
|
92
154
|
util: "util";
|
|
93
155
|
}>;
|
|
156
|
+
install: z.ZodOptional<z.ZodEnum<{
|
|
157
|
+
copy: "copy";
|
|
158
|
+
package: "package";
|
|
159
|
+
}>>;
|
|
94
160
|
}, z.core.$strip>>;
|
|
161
|
+
packageFiles: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
162
|
+
path: z.ZodString;
|
|
163
|
+
hash: z.ZodOptional<z.ZodString>;
|
|
164
|
+
version: z.ZodOptional<z.ZodString>;
|
|
165
|
+
type: z.ZodEnum<{
|
|
166
|
+
component: "component";
|
|
167
|
+
hook: "hook";
|
|
168
|
+
meta: "meta";
|
|
169
|
+
style: "style";
|
|
170
|
+
type: "type";
|
|
171
|
+
util: "util";
|
|
172
|
+
}>;
|
|
173
|
+
install: z.ZodOptional<z.ZodEnum<{
|
|
174
|
+
copy: "copy";
|
|
175
|
+
package: "package";
|
|
176
|
+
}>>;
|
|
177
|
+
}, z.core.$strip>>>;
|
|
95
178
|
}, z.core.$strip>;
|
|
96
179
|
/** One installable component, the type `ComponentMetaSchema` parses. */
|
|
97
180
|
export type ComponentMeta = z.infer<typeof ComponentMetaSchema>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/registry/types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CA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