@hanzo/docs-cli 1.1.1 → 1.2.2

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.
@@ -1,181 +1,179 @@
1
- import { z } from 'zod';
2
- import { Project, SourceFile } from 'ts-morph';
3
- import { Registry as Registry$1 } from 'shadcn/schema';
1
+ import { z } from "zod";
2
+ import { Project, SourceFile } from "ts-morph";
4
3
 
4
+ //#region src/registry/schema.d.ts
5
5
  type NamespaceType = (typeof namespaces)[number];
6
6
  type CompiledComponent = z.input<typeof componentSchema>;
7
7
  declare const namespaces: readonly ["components", "lib", "css", "route", "ui", "block"];
8
- declare const indexSchema: z.ZodObject<{
9
- name: z.ZodString;
10
- title: z.ZodOptional<z.ZodString>;
11
- description: z.ZodOptional<z.ZodString>;
12
- }, z.core.$strip>;
13
8
  declare const componentSchema: z.ZodObject<{
9
+ name: z.ZodString;
10
+ title: z.ZodOptional<z.ZodString>;
11
+ description: z.ZodOptional<z.ZodString>;
12
+ files: z.ZodArray<z.ZodObject<{
13
+ type: z.ZodLiteral<"components" | "lib" | "css" | "route" | "ui" | "block">;
14
+ path: z.ZodString;
15
+ target: z.ZodOptional<z.ZodString>;
16
+ content: z.ZodString;
17
+ }, z.core.$strip>>;
18
+ dependencies: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNull]>>;
19
+ devDependencies: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNull]>>;
20
+ subComponents: z.ZodDefault<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodObject<{
21
+ type: z.ZodLiteral<"http">;
22
+ baseUrl: z.ZodString;
23
+ component: z.ZodString;
24
+ }, z.core.$strip>]>>>;
25
+ }, z.core.$strip>;
26
+ declare const registryInfoSchema: z.ZodObject<{
27
+ variables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
28
+ description: z.ZodOptional<z.ZodString>;
29
+ default: z.ZodOptional<z.ZodUnknown>;
30
+ }, z.core.$strip>>>;
31
+ env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
32
+ indexes: z.ZodDefault<z.ZodArray<z.ZodObject<{
14
33
  name: z.ZodString;
15
34
  title: z.ZodOptional<z.ZodString>;
16
35
  description: z.ZodOptional<z.ZodString>;
17
- files: z.ZodArray<z.ZodObject<{
18
- type: z.ZodLiteral<"components" | "lib" | "css" | "route" | "ui" | "block">;
19
- path: z.ZodString;
20
- target: z.ZodOptional<z.ZodString>;
21
- content: z.ZodString;
22
- }, z.core.$strip>>;
23
- dependencies: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNull]>>;
24
- devDependencies: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNull]>>;
25
- subComponents: z.ZodDefault<z.ZodArray<z.ZodString>>;
36
+ }, z.core.$strip>>>;
37
+ registries: z.ZodOptional<z.ZodArray<z.ZodString>>;
26
38
  }, z.core.$strip>;
27
-
39
+ //#endregion
40
+ //#region src/build/compiler.d.ts
28
41
  type OnResolve = (reference: SourceReference) => Reference;
29
42
  interface CompiledRegistry {
30
- name: string;
31
- index: z.input<typeof indexSchema>[];
32
- components: CompiledComponent[];
33
- switchables?: Record<string, Switchable>;
43
+ name: string;
44
+ components: CompiledComponent[];
45
+ info: z.output<typeof registryInfoSchema>;
34
46
  }
35
47
  interface ComponentFile {
36
- type: NamespaceType;
37
- path: string;
38
- target?: string;
39
- }
40
- interface Switchable {
41
- specifier: string;
42
- members: Record<string, string>;
48
+ type: NamespaceType;
49
+ path: string;
50
+ target?: string;
43
51
  }
44
52
  interface Component {
45
- name: string;
46
- title?: string;
47
- description?: string;
48
- files: ComponentFile[];
49
- /**
50
- * Don't list the component in registry index file
51
- */
52
- unlisted?: boolean;
53
- /**
54
- * Map imported file paths, inherit from registry if not defined.
55
- */
56
- onResolve?: OnResolve;
53
+ name: string;
54
+ title?: string;
55
+ description?: string;
56
+ files: ComponentFile[];
57
+ /**
58
+ * Don't list the component in registry index file
59
+ */
60
+ unlisted?: boolean;
61
+ /**
62
+ * Map imported file paths, inherit from registry if not defined.
63
+ */
64
+ onResolve?: OnResolve;
57
65
  }
58
66
  interface PackageJson {
59
- dependencies?: Record<string, string>;
60
- devDependencies?: Record<string, string>;
67
+ dependencies?: Record<string, string>;
68
+ devDependencies?: Record<string, string>;
61
69
  }
62
- interface Registry {
63
- name: string;
64
- packageJson: string | PackageJson;
65
- tsconfigPath: string;
66
- components: Component[];
67
- switchables?: Record<string, Switchable>;
68
- /**
69
- * The directory of registry, used to resolve relative paths
70
- */
71
- dir: string;
72
- /**
73
- * Map import paths of components
74
- */
75
- onResolve?: OnResolve;
76
- /**
77
- * When a referenced file is not found in component files, this function is called.
78
- * @returns file, or `false` to mark as external.
79
- */
80
- onUnknownFile?: (absolutePath: string) => ComponentFile | false | undefined;
81
- dependencies?: Record<string, string | null>;
82
- devDependencies?: Record<string, string | null>;
70
+ interface Registry extends Omit<z.input<typeof registryInfoSchema>, 'indexes'> {
71
+ name: string;
72
+ packageJson: string | PackageJson;
73
+ tsconfigPath: string;
74
+ components: Component[];
75
+ /**
76
+ * The directory of registry, used to resolve relative paths
77
+ */
78
+ dir: string;
79
+ /**
80
+ * Map import paths of components
81
+ */
82
+ onResolve?: OnResolve;
83
+ /**
84
+ * When a referenced file is not found in component files, this function is called.
85
+ * @returns file, or `false` to mark as external.
86
+ */
87
+ onUnknownFile?: (absolutePath: string) => ComponentFile | false | undefined;
88
+ dependencies?: Record<string, string | null>;
89
+ devDependencies?: Record<string, string | null>;
83
90
  }
84
91
  declare class RegistryCompiler {
85
- readonly raw: Registry;
86
- readonly project: Project;
87
- resolver: RegistryResolver;
88
- constructor(registry: Registry);
89
- private readPackageJson;
90
- createSourceFile(file: string): Promise<SourceFile>;
91
- compile(): Promise<CompiledRegistry>;
92
+ readonly raw: Registry;
93
+ readonly project: Project;
94
+ resolver: RegistryResolver;
95
+ constructor(registry: Registry);
96
+ private readPackageJson;
97
+ createSourceFile(file: string): Promise<SourceFile>;
98
+ compile(): Promise<CompiledRegistry>;
92
99
  }
93
100
  declare class RegistryResolver {
94
- private readonly compiler;
95
- private readonly deps;
96
- private readonly devDeps;
97
- private readonly fileToComponent;
98
- constructor(compiler: RegistryCompiler, packageJson?: PackageJson);
99
- getDepFromSpecifier(specifier: string): string;
100
- getDepInfo(name: string): {
101
- type: 'runtime' | 'dev';
102
- name: string;
103
- version: string | null;
104
- } | undefined;
105
- getComponentByName(name: string): Component | undefined;
106
- getSubComponent(file: string): {
107
- component: Component;
108
- file: ComponentFile;
109
- } | undefined;
101
+ private readonly compiler;
102
+ private readonly deps;
103
+ private readonly devDeps;
104
+ private readonly fileToComponent;
105
+ constructor(compiler: RegistryCompiler, packageJson?: PackageJson);
106
+ getDepFromSpecifier(specifier: string): string;
107
+ getDepInfo(name: string): {
108
+ type: 'runtime' | 'dev';
109
+ name: string;
110
+ version: string | null;
111
+ } | undefined;
112
+ getComponentByName(name: string): Component | undefined;
113
+ getSubComponent(file: string): {
114
+ component: Component;
115
+ file: ComponentFile;
116
+ } | undefined;
110
117
  }
111
118
  type SourceReference = {
112
- type: 'file';
113
- /**
114
- * Absolute path
115
- */
116
- file: string;
119
+ type: 'file';
120
+ /**
121
+ * Absolute path
122
+ */
123
+ file: string;
117
124
  } | {
118
- type: 'dependency';
119
- dep: string;
120
- specifier: string;
125
+ type: 'dependency';
126
+ dep: string;
127
+ specifier: string;
121
128
  } | {
122
- type: 'sub-component';
123
- resolved: {
124
- type: 'local';
125
- component: Component;
126
- file: ComponentFile;
127
- } | {
128
- type: 'remote';
129
- component: Component;
130
- file: ComponentFile;
131
- registryName: string;
132
- };
129
+ type: 'sub-component';
130
+ resolved: {
131
+ type: 'local';
132
+ component: Component;
133
+ file: ComponentFile;
134
+ } | {
135
+ type: 'remote';
136
+ component: Component;
137
+ file: ComponentFile;
138
+ registryName: string;
139
+ };
133
140
  };
134
141
  type Reference = SourceReference | {
135
- type: 'custom';
136
- specifier: string;
142
+ type: 'custom';
143
+ specifier: string;
137
144
  };
138
145
  declare class ComponentCompiler {
139
- private readonly compiler;
140
- private readonly component;
141
- private readonly processedFiles;
142
- private readonly registry;
143
- private readonly subComponents;
144
- private readonly devDependencies;
145
- private readonly dependencies;
146
- constructor(compiler: RegistryCompiler, component: Component);
147
- private toImportPath;
148
- build(): Promise<CompiledComponent>;
149
- private buildFileAndDeps;
150
- private resolveImport;
151
- private buildFile;
146
+ private readonly compiler;
147
+ private readonly component;
148
+ private readonly processedFiles;
149
+ private readonly registry;
150
+ private readonly subComponents;
151
+ private readonly devDependencies;
152
+ private readonly dependencies;
153
+ constructor(compiler: RegistryCompiler, component: Component);
154
+ private toImportPath;
155
+ build(): Promise<CompiledComponent>;
156
+ private buildFileAndDeps;
157
+ private resolveImport;
158
+ private buildFile;
152
159
  }
153
-
154
- declare function toShadcnRegistry(out: CompiledRegistry, baseUrl: string): {
155
- registry: Registry$1;
156
- index: Registry$1;
157
- };
158
-
159
- declare function combineRegistry(...items: CompiledRegistry[]): CompiledRegistry;
160
- declare function writeShadcnRegistry(out: CompiledRegistry, options: {
161
- dir: string;
162
- /**
163
- * Remove previous outputs
164
- *
165
- * @defaultValue false
166
- */
167
- cleanDir?: boolean;
168
- baseUrl: string;
169
- }): Promise<void>;
170
- declare function writeFumadocsRegistry(out: CompiledRegistry, options: {
171
- dir: string;
172
- /**
173
- * Remove previous outputs
174
- *
175
- * @defaultValue false
176
- */
177
- cleanDir?: boolean;
178
- log?: boolean;
160
+ declare function resolveFromRemote(r: Registry, component: string, selectFile: (file: ComponentFile) => boolean): Reference | undefined;
161
+ //#endregion
162
+ //#region src/build/index.d.ts
163
+ interface MonoRegistry extends CompiledRegistry {
164
+ registries: CompiledRegistry[];
165
+ }
166
+ declare function combineRegistry(root: CompiledRegistry, ...items: CompiledRegistry[]): MonoRegistry;
167
+ declare function writeFumadocsRegistry(out: CompiledRegistry | MonoRegistry, options: {
168
+ dir: string;
169
+ /**
170
+ * Remove previous outputs
171
+ *
172
+ * @defaultValue false
173
+ */
174
+ cleanDir?: boolean;
175
+ log?: boolean;
179
176
  }): Promise<void>;
180
-
181
- export { type CompiledRegistry, type Component, ComponentCompiler, type ComponentFile, type OnResolve, type PackageJson, type Reference, type Registry, RegistryCompiler, type SourceReference, type Switchable, combineRegistry, toShadcnRegistry, writeFumadocsRegistry, writeShadcnRegistry };
177
+ //#endregion
178
+ export { CompiledRegistry, Component, ComponentCompiler, ComponentFile, MonoRegistry, OnResolve, PackageJson, Reference, Registry, RegistryCompiler, SourceReference, combineRegistry, resolveFromRemote, writeFumadocsRegistry };
179
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/registry/schema.ts","../../src/build/compiler.ts","../../src/build/index.ts"],"sourcesContent":[],"mappings":";;;;KAEY,aAAA,WAAwB;KAExB,iBAAA,GAAoB,CAAA,CAAE,aAAa;cAMlC;cAqBA,iBAAe,CAAA,CAAA;;;;;;;;;;;;;;;;EAAA,CAAA,eAAA,CAAA,CAAA,CAAA,CAAA,CAAA;CAAA,eAAA,CAAA;AAaf,cAAA,kBAoBX,EApB6B,CAAA,CAAA,SAoB7B,CAAA;;;;;;;;;;;;;;;KCpDU,SAAA,eAAwB,oBAAoB;ADV5C,UCYK,gBAAA,CDZmB;EAExB,IAAA,EAAA,MAAA;EAMC,UAAA,ECMC,iBDNyE,EAAA;EAqB1E,IAAA,ECdL,CAAA,CAAE,MDcG,CAAA,OCdW,kBDyBtB,CAAA;;UCtBe,aAAA;QACT;;;;UAKS,SAAA;;;;SAIR;;;;;;;;cAUK;;UAGG,WAAA;iBACA;oBACG;;UAGH,QAAA,SAAiB,KAAK,CAAA,CAAE,aAAa;;wBAE9B;;cAEV;;;;;EDrBc;;AAa5B;cCkBc;;;;;4CAK8B;iBAE3B;oBACG;;cAGP,gBAAA;gBACG;oBACI;YACP;wBAEW;;kCAgBa,QAAA;aAOlB,QAAQ;;cAqCrB,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