trix-ui 0.2.8 → 0.2.9
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/__tests__/contracts/registry.test.d.ts +1 -0
- package/dist/__tests__/contracts/registry.test.js +42 -0
- package/dist/__tests__/contracts/registry.test.js.map +1 -0
- package/dist/__tests__/e2e/cli.test.d.ts +1 -0
- package/dist/__tests__/e2e/cli.test.js +67 -0
- package/dist/__tests__/e2e/cli.test.js.map +1 -0
- package/dist/__tests__/helpers/fs.d.ts +5 -0
- package/dist/__tests__/helpers/fs.js +26 -0
- package/dist/__tests__/helpers/fs.js.map +1 -0
- package/dist/__tests__/integration/commands.integration.test.d.ts +1 -0
- package/dist/__tests__/integration/commands.integration.test.js +184 -0
- package/dist/__tests__/integration/commands.integration.test.js.map +1 -0
- package/dist/commands/__tests__/add-composite.test.d.ts +2 -0
- package/dist/commands/__tests__/add-composite.test.js +171 -0
- package/dist/commands/__tests__/add-composite.test.js.map +1 -0
- package/dist/commands/__tests__/add-entry.mocks.d.ts +23 -0
- package/dist/commands/__tests__/add-entry.mocks.js +64 -0
- package/dist/commands/__tests__/add-entry.mocks.js.map +1 -0
- package/dist/commands/__tests__/add-section.test.d.ts +2 -0
- package/dist/commands/__tests__/add-section.test.js +191 -0
- package/dist/commands/__tests__/add-section.test.js.map +1 -0
- package/dist/commands/__tests__/add-wrapper.test.d.ts +2 -0
- package/dist/commands/__tests__/add-wrapper.test.js +171 -0
- package/dist/commands/__tests__/add-wrapper.test.js.map +1 -0
- package/dist/commands/__tests__/cli-mocks.d.ts +1 -0
- package/dist/commands/__tests__/cli-mocks.js +24 -0
- package/dist/commands/__tests__/cli-mocks.js.map +1 -0
- package/dist/commands/__tests__/doctor.mocks.d.ts +6 -0
- package/dist/commands/__tests__/doctor.mocks.js +20 -0
- package/dist/commands/__tests__/doctor.mocks.js.map +1 -0
- package/dist/commands/__tests__/doctor.test.d.ts +2 -0
- package/dist/commands/__tests__/doctor.test.js +80 -0
- package/dist/commands/__tests__/doctor.test.js.map +1 -0
- package/dist/commands/__tests__/list.mocks.d.ts +8 -0
- package/dist/commands/__tests__/list.mocks.js +20 -0
- package/dist/commands/__tests__/list.mocks.js.map +1 -0
- package/dist/commands/__tests__/list.test.d.ts +2 -0
- package/dist/commands/__tests__/list.test.js +60 -0
- package/dist/commands/__tests__/list.test.js.map +1 -0
- package/dist/commands/__tests__/remove.mocks.d.ts +9 -0
- package/dist/commands/__tests__/remove.mocks.js +26 -0
- package/dist/commands/__tests__/remove.mocks.js.map +1 -0
- package/dist/commands/__tests__/remove.test.d.ts +2 -0
- package/dist/commands/__tests__/remove.test.js +116 -0
- package/dist/commands/__tests__/remove.test.js.map +1 -0
- package/dist/commands/add/__tests__/add.mocks.d.ts +19 -19
- package/dist/commands/add/__tests__/add.mocks.js +59 -59
- package/dist/commands/add/__tests__/add.test.d.ts +2 -2
- package/dist/commands/add/__tests__/add.test.js +140 -140
- package/dist/commands/add/analysis.d.ts +4 -4
- package/dist/commands/add/analysis.js +56 -56
- package/dist/commands/add/command.d.ts +2 -2
- package/dist/commands/add/command.js +202 -202
- package/dist/commands/add/config.d.ts +2 -2
- package/dist/commands/add/config.js +11 -11
- package/dist/commands/add/install.d.ts +27 -27
- package/dist/commands/add/install.js +80 -80
- package/dist/commands/add/package-manager.d.ts +1 -1
- package/dist/commands/add/package-manager.js +4 -4
- package/dist/commands/add/project-files.d.ts +2 -2
- package/dist/commands/add/project-files.js +17 -17
- package/dist/commands/add/prompts.d.ts +3 -3
- package/dist/commands/add/prompts.js +28 -28
- package/dist/commands/add/registry.d.ts +4 -4
- package/dist/commands/add/registry.js +6 -6
- package/dist/commands/add/types.d.ts +33 -33
- package/dist/commands/add/types.js +1 -1
- package/dist/commands/add/ui.d.ts +4 -4
- package/dist/commands/add/ui.js +55 -55
- package/dist/commands/add/validation.d.ts +3 -3
- package/dist/commands/add/validation.js +30 -30
- package/dist/commands/add-collection.d.ts +1 -1
- package/dist/commands/add-collection.js +1 -1
- package/dist/commands/add-composite.d.ts +2 -2
- package/dist/commands/add-composite.js +201 -201
- package/dist/commands/add-section.d.ts +2 -2
- package/dist/commands/add-section.js +201 -201
- package/dist/commands/add-wrapper.d.ts +2 -2
- package/dist/commands/add-wrapper.js +201 -201
- package/dist/commands/add.d.ts +1 -1
- package/dist/commands/add.js +1 -1
- package/dist/commands/build.d.ts +2 -2
- package/dist/commands/doctor.d.ts +2 -2
- package/dist/commands/doctor.js +67 -67
- package/dist/commands/init/__tests__/init.mocks.d.ts +24 -0
- package/dist/commands/init/__tests__/init.mocks.js +84 -0
- package/dist/commands/init/__tests__/init.mocks.js.map +1 -0
- package/dist/commands/init/__tests__/init.test.d.ts +2 -0
- package/dist/commands/init/__tests__/init.test.js +283 -0
- package/dist/commands/init/__tests__/init.test.js.map +1 -0
- package/dist/commands/init/__tests__/tailwind.test.d.ts +1 -0
- package/dist/commands/init/__tests__/tailwind.test.js +56 -0
- package/dist/commands/init/__tests__/tailwind.test.js.map +1 -0
- package/dist/commands/init/__tests__/tsconfig.test.d.ts +1 -0
- package/dist/commands/init/__tests__/tsconfig.test.js +108 -0
- package/dist/commands/init/__tests__/tsconfig.test.js.map +1 -0
- package/dist/commands/init/__tests__/vite.test.d.ts +1 -0
- package/dist/commands/init/__tests__/vite.test.js +66 -0
- package/dist/commands/init/__tests__/vite.test.js.map +1 -0
- package/dist/commands/init/command.d.ts +2 -2
- package/dist/commands/init/command.js +114 -114
- package/dist/commands/init/config.d.ts +2 -2
- package/dist/commands/init/config.js +25 -25
- package/dist/commands/init/constants.d.ts +3 -3
- package/dist/commands/init/constants.js +105 -105
- package/dist/commands/init/dependencies.d.ts +5 -5
- package/dist/commands/init/dependencies.js +52 -52
- package/dist/commands/init/filesystem.d.ts +1 -1
- package/dist/commands/init/filesystem.js +10 -10
- package/dist/commands/init/lockfile.d.ts +1 -1
- package/dist/commands/init/lockfile.js +1 -1
- package/dist/commands/init/package-json.d.ts +6 -6
- package/dist/commands/init/package-json.js +18 -18
- package/dist/commands/init/project-files.d.ts +8 -0
- package/dist/commands/init/project-files.js +37 -0
- package/dist/commands/init/project-files.js.map +1 -0
- package/dist/commands/init/project.d.ts +3 -3
- package/dist/commands/init/project.js +97 -97
- package/dist/commands/init/style-imports.d.ts +9 -0
- package/dist/commands/init/style-imports.js +218 -0
- package/dist/commands/init/style-imports.js.map +1 -0
- package/dist/commands/init/tailwind.d.ts +3 -3
- package/dist/commands/init/tailwind.js +34 -34
- package/dist/commands/init/templates.d.ts +3 -3
- package/dist/commands/init/templates.js +15 -15
- package/dist/commands/init/tsconfig.d.ts +2 -2
- package/dist/commands/init/tsconfig.js +273 -273
- package/dist/commands/init/types.d.ts +33 -33
- package/dist/commands/init/types.js +1 -1
- package/dist/commands/init/ui.d.ts +3 -3
- package/dist/commands/init/ui.js +33 -33
- package/dist/commands/init/vite.d.ts +23 -0
- package/dist/commands/init/vite.js +347 -0
- package/dist/commands/init/vite.js.map +1 -0
- package/dist/commands/init.d.ts +1 -1
- package/dist/commands/init.js +1 -1
- package/dist/commands/list.d.ts +2 -2
- package/dist/commands/list.js +62 -62
- package/dist/commands/remove.d.ts +2 -2
- package/dist/commands/remove.js +93 -93
- package/dist/commands/shared/add-collection.d.ts +50 -50
- package/dist/commands/shared/add-collection.js +206 -206
- package/dist/commands/shared/list-entries.d.ts +6 -6
- package/dist/commands/shared/list-entries.js +12 -12
- package/dist/commands/shared/name-utils.d.ts +1 -1
- package/dist/commands/shared/name-utils.js +13 -13
- package/dist/commands/shared/remove-entries.d.ts +16 -16
- package/dist/commands/shared/remove-entries.js +41 -41
- package/dist/icons/index.d.ts +1 -1
- package/dist/icons/index.js +1 -1
- package/dist/icons/libraries.d.ts +37 -37
- package/dist/icons/libraries.js +34 -34
- package/dist/index.d.ts +2 -2
- package/dist/index.js +30 -30
- package/dist/lib/__tests__/config.test.d.ts +1 -0
- package/dist/lib/__tests__/config.test.js +49 -0
- package/dist/lib/__tests__/config.test.js.map +1 -0
- package/dist/lib/__tests__/install.test.d.ts +1 -0
- package/dist/lib/__tests__/install.test.js +149 -0
- package/dist/lib/__tests__/install.test.js.map +1 -0
- package/dist/lib/__tests__/lockfile.test.d.ts +1 -0
- package/dist/lib/__tests__/lockfile.test.js +89 -0
- package/dist/lib/__tests__/lockfile.test.js.map +1 -0
- package/dist/lib/__tests__/paths.test.d.ts +1 -0
- package/dist/lib/__tests__/paths.test.js +39 -0
- package/dist/lib/__tests__/paths.test.js.map +1 -0
- package/dist/lib/__tests__/registry.test.d.ts +1 -0
- package/dist/lib/__tests__/registry.test.js +76 -0
- package/dist/lib/__tests__/registry.test.js.map +1 -0
- package/dist/lib/config.d.ts +45 -45
- package/dist/lib/config.js +97 -97
- package/dist/lib/fs.d.ts +76 -76
- package/dist/lib/fs.js +302 -302
- package/dist/lib/highlighter.d.ts +6 -6
- package/dist/lib/highlighter.js +7 -7
- package/dist/lib/install.d.ts +19 -19
- package/dist/lib/install.js +55 -55
- package/dist/lib/lockfile.d.ts +63 -63
- package/dist/lib/lockfile.js +173 -173
- package/dist/lib/logger.d.ts +8 -8
- package/dist/lib/logger.js +41 -41
- package/dist/lib/paths.d.ts +14 -14
- package/dist/lib/paths.js +31 -31
- package/dist/lib/registry.d.ts +35 -35
- package/dist/lib/registry.js +180 -180
- package/dist/schema/index.d.ts +1128 -1128
- package/dist/schema/index.js +238 -238
- package/dist/styles/create-style-map.d.ts +4 -4
- package/dist/styles/create-style-map.js +68 -68
- package/dist/styles/transform-style-map.d.ts +3 -3
- package/dist/styles/transform-style-map.js +428 -428
- package/dist/styles/transform.d.ts +10 -10
- package/dist/styles/transform.js +15 -15
- package/dist/utils/index.d.ts +6 -6
- package/dist/utils/index.js +5 -5
- package/dist/utils/transformers/transform-icons.d.ts +2 -2
- package/dist/utils/transformers/transform-icons.js +164 -164
- package/dist/utils/transformers/transform-menu.d.ts +2 -2
- package/dist/utils/transformers/transform-menu.js +39 -39
- package/dist/utils/transformers/transform-render.d.ts +2 -2
- package/dist/utils/transformers/transform-render.js +97 -97
- package/dist/utils/transformers/types.d.ts +14 -14
- package/dist/utils/transformers/types.js +1 -1
- package/package.json +1 -1
package/dist/schema/index.js
CHANGED
|
@@ -1,239 +1,239 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
// Note: if you edit the schema here, you must also edit the schema in the
|
|
3
|
-
// apps/v4/public/schema/registry-item.json file.
|
|
4
|
-
export const registryConfigItemSchema = z.union([
|
|
5
|
-
// Simple string format: "https://example.com/{name}.json"
|
|
6
|
-
z.string().refine((s) => s.includes("{name}"), {
|
|
7
|
-
message: "Registry URL must include {name} placeholder",
|
|
8
|
-
}),
|
|
9
|
-
// Advanced object format with auth options
|
|
10
|
-
z.object({
|
|
11
|
-
url: z.string().refine((s) => s.includes("{name}"), {
|
|
12
|
-
message: "Registry URL must include {name} placeholder",
|
|
13
|
-
}),
|
|
14
|
-
params: z.record(z.string(), z.string()).optional(),
|
|
15
|
-
headers: z.record(z.string(), z.string()).optional(),
|
|
16
|
-
}),
|
|
17
|
-
]);
|
|
18
|
-
export const registryConfigSchema = z.record(z.string().refine((key) => key.startsWith("@"), {
|
|
19
|
-
message: "Registry names must start with @ (e.g., @v0, @acme)",
|
|
20
|
-
}), registryConfigItemSchema);
|
|
21
|
-
export const rawConfigSchema = z
|
|
22
|
-
.object({
|
|
23
|
-
$schema: z.string().optional(),
|
|
24
|
-
style: z.string(),
|
|
25
|
-
rsc: z.coerce.boolean().default(false),
|
|
26
|
-
tsx: z.coerce.boolean().default(true),
|
|
27
|
-
tailwind: z.object({
|
|
28
|
-
config: z.string().optional(),
|
|
29
|
-
css: z.string(),
|
|
30
|
-
baseColor: z.string(),
|
|
31
|
-
cssVariables: z.boolean().default(true),
|
|
32
|
-
prefix: z.string().default("").optional(),
|
|
33
|
-
}),
|
|
34
|
-
iconLibrary: z.string().optional(),
|
|
35
|
-
menuColor: z.enum(["default", "inverted"]).default("default").optional(),
|
|
36
|
-
menuAccent: z.enum(["subtle", "bold"]).default("subtle").optional(),
|
|
37
|
-
aliases: z.object({
|
|
38
|
-
components: z.string(),
|
|
39
|
-
utils: z.string(),
|
|
40
|
-
ui: z.string().optional(),
|
|
41
|
-
lib: z.string().optional(),
|
|
42
|
-
hooks: z.string().optional(),
|
|
43
|
-
}),
|
|
44
|
-
registries: registryConfigSchema.optional(),
|
|
45
|
-
})
|
|
46
|
-
.strict();
|
|
47
|
-
const rawConfigSchemaDeepPartial = rawConfigSchema
|
|
48
|
-
.partial()
|
|
49
|
-
.extend({
|
|
50
|
-
tailwind: rawConfigSchema.shape.tailwind.partial().optional(),
|
|
51
|
-
aliases: rawConfigSchema.shape.aliases.partial().optional(),
|
|
52
|
-
});
|
|
53
|
-
export const configSchema = rawConfigSchema.extend({
|
|
54
|
-
resolvedPaths: z.object({
|
|
55
|
-
cwd: z.string(),
|
|
56
|
-
tailwindConfig: z.string(),
|
|
57
|
-
tailwindCss: z.string(),
|
|
58
|
-
utils: z.string(),
|
|
59
|
-
components: z.string(),
|
|
60
|
-
lib: z.string(),
|
|
61
|
-
hooks: z.string(),
|
|
62
|
-
ui: z.string(),
|
|
63
|
-
}),
|
|
64
|
-
});
|
|
65
|
-
// TODO: type the key.
|
|
66
|
-
// Okay for now since I don't want a breaking change.
|
|
67
|
-
export const workspaceConfigSchema = z.record(z.string(), configSchema);
|
|
68
|
-
export const registryItemTypeSchema = z.enum([
|
|
69
|
-
"registry:lib",
|
|
70
|
-
"registry:block",
|
|
71
|
-
"registry:component",
|
|
72
|
-
"registry:ui",
|
|
73
|
-
"registry:hook",
|
|
74
|
-
"registry:page",
|
|
75
|
-
"registry:file",
|
|
76
|
-
"registry:theme",
|
|
77
|
-
"registry:style",
|
|
78
|
-
"registry:item",
|
|
79
|
-
"registry:base",
|
|
80
|
-
"registry:font",
|
|
81
|
-
// Internal use only.
|
|
82
|
-
"registry:example",
|
|
83
|
-
"registry:internal",
|
|
84
|
-
]);
|
|
85
|
-
export const registryItemFileSchema = z.discriminatedUnion("type", [
|
|
86
|
-
// Target is required for registry:file and registry:page
|
|
87
|
-
z.object({
|
|
88
|
-
path: z.string(),
|
|
89
|
-
content: z.string().optional(),
|
|
90
|
-
type: z.enum(["registry:file", "registry:page"]),
|
|
91
|
-
target: z.string(),
|
|
92
|
-
}),
|
|
93
|
-
z.object({
|
|
94
|
-
path: z.string(),
|
|
95
|
-
content: z.string().optional(),
|
|
96
|
-
type: registryItemTypeSchema.exclude(["registry:file", "registry:page"]),
|
|
97
|
-
target: z.string().optional(),
|
|
98
|
-
}),
|
|
99
|
-
]);
|
|
100
|
-
export const registryItemTailwindSchema = z.object({
|
|
101
|
-
config: z
|
|
102
|
-
.object({
|
|
103
|
-
content: z.array(z.string()).optional(),
|
|
104
|
-
theme: z.record(z.string(), z.any()).optional(),
|
|
105
|
-
plugins: z.array(z.string()).optional(),
|
|
106
|
-
})
|
|
107
|
-
.optional(),
|
|
108
|
-
});
|
|
109
|
-
export const registryItemCssVarsSchema = z.object({
|
|
110
|
-
theme: z.record(z.string(), z.string()).optional(),
|
|
111
|
-
light: z.record(z.string(), z.string()).optional(),
|
|
112
|
-
dark: z.record(z.string(), z.string()).optional(),
|
|
113
|
-
});
|
|
114
|
-
// Recursive type for CSS properties that supports empty objects at any level.
|
|
115
|
-
const cssValueSchema = z.lazy(() => z.union([
|
|
116
|
-
z.string(),
|
|
117
|
-
z.array(z.union([z.string(), z.record(z.string(), z.string())])),
|
|
118
|
-
z.record(z.string(), cssValueSchema),
|
|
119
|
-
]));
|
|
120
|
-
export const registryItemCssSchema = z.record(z.string(), cssValueSchema);
|
|
121
|
-
export const registryItemEnvVarsSchema = z.record(z.string(), z.string());
|
|
122
|
-
// Font metadata schema for registry:font items.
|
|
123
|
-
export const registryItemFontSchema = z.object({
|
|
124
|
-
family: z.string(),
|
|
125
|
-
provider: z.literal("google"),
|
|
126
|
-
import: z.string(),
|
|
127
|
-
variable: z.string(),
|
|
128
|
-
weight: z.array(z.string()).optional(),
|
|
129
|
-
subsets: z.array(z.string()).optional(),
|
|
130
|
-
});
|
|
131
|
-
// Common fields shared by all registry items.
|
|
132
|
-
export const registryItemCommonSchema = z.object({
|
|
133
|
-
$schema: z.string().optional(),
|
|
134
|
-
extends: z.string().optional(),
|
|
135
|
-
name: z.string(),
|
|
136
|
-
title: z.string().optional(),
|
|
137
|
-
author: z.string().min(2).optional(),
|
|
138
|
-
description: z.string().optional(),
|
|
139
|
-
dependencies: z.array(z.string()).optional(),
|
|
140
|
-
devDependencies: z.array(z.string()).optional(),
|
|
141
|
-
registryDependencies: z.array(z.string()).optional(),
|
|
142
|
-
files: z.array(registryItemFileSchema).optional(),
|
|
143
|
-
tailwind: registryItemTailwindSchema.optional(),
|
|
144
|
-
cssVars: registryItemCssVarsSchema.optional(),
|
|
145
|
-
css: registryItemCssSchema.optional(),
|
|
146
|
-
envVars: registryItemEnvVarsSchema.optional(),
|
|
147
|
-
meta: z.record(z.string(), z.any()).optional(),
|
|
148
|
-
docs: z.string().optional(),
|
|
149
|
-
categories: z.array(z.string()).optional(),
|
|
150
|
-
});
|
|
151
|
-
// registry:base has a config field, registry:font has a font field.
|
|
152
|
-
export const registryItemSchema = z.discriminatedUnion("type", [
|
|
153
|
-
registryItemCommonSchema.extend({
|
|
154
|
-
type: z.literal("registry:base"),
|
|
155
|
-
config: rawConfigSchemaDeepPartial.optional(),
|
|
156
|
-
}),
|
|
157
|
-
registryItemCommonSchema.extend({
|
|
158
|
-
type: z.literal("registry:font"),
|
|
159
|
-
font: registryItemFontSchema,
|
|
160
|
-
}),
|
|
161
|
-
registryItemCommonSchema.extend({
|
|
162
|
-
type: registryItemTypeSchema.exclude(["registry:base", "registry:font"]),
|
|
163
|
-
}),
|
|
164
|
-
]);
|
|
165
|
-
export const registrySchema = z.object({
|
|
166
|
-
name: z.string(),
|
|
167
|
-
homepage: z.string(),
|
|
168
|
-
items: z.array(registryItemSchema),
|
|
169
|
-
});
|
|
170
|
-
export const registryIndexSchema = z.array(registryItemSchema);
|
|
171
|
-
export const stylesSchema = z.array(z.object({
|
|
172
|
-
name: z.string(),
|
|
173
|
-
label: z.string(),
|
|
174
|
-
}));
|
|
175
|
-
export const iconsSchema = z.record(z.string(), z.record(z.string(), z.string()));
|
|
176
|
-
export const registryBaseColorSchema = z.object({
|
|
177
|
-
inlineColors: z.object({
|
|
178
|
-
light: z.record(z.string(), z.string()),
|
|
179
|
-
dark: z.record(z.string(), z.string()),
|
|
180
|
-
}),
|
|
181
|
-
cssVars: registryItemCssVarsSchema,
|
|
182
|
-
cssVarsV4: registryItemCssVarsSchema.optional(),
|
|
183
|
-
inlineColorsTemplate: z.string(),
|
|
184
|
-
cssVarsTemplate: z.string(),
|
|
185
|
-
});
|
|
186
|
-
export const registryResolvedItemsTreeSchema = registryItemCommonSchema
|
|
187
|
-
.pick({
|
|
188
|
-
dependencies: true,
|
|
189
|
-
devDependencies: true,
|
|
190
|
-
files: true,
|
|
191
|
-
tailwind: true,
|
|
192
|
-
cssVars: true,
|
|
193
|
-
css: true,
|
|
194
|
-
envVars: true,
|
|
195
|
-
docs: true,
|
|
196
|
-
})
|
|
197
|
-
.extend({
|
|
198
|
-
fonts: z
|
|
199
|
-
.array(registryItemCommonSchema.extend({
|
|
200
|
-
type: z.literal("registry:font"),
|
|
201
|
-
font: registryItemFontSchema,
|
|
202
|
-
}))
|
|
203
|
-
.optional(),
|
|
204
|
-
});
|
|
205
|
-
export const searchResultItemSchema = z.object({
|
|
206
|
-
name: z.string(),
|
|
207
|
-
type: z.string().optional(),
|
|
208
|
-
description: z.string().optional(),
|
|
209
|
-
registry: z.string(),
|
|
210
|
-
addCommandArgument: z.string(),
|
|
211
|
-
});
|
|
212
|
-
export const searchResultsSchema = z.object({
|
|
213
|
-
pagination: z.object({
|
|
214
|
-
total: z.number(),
|
|
215
|
-
offset: z.number(),
|
|
216
|
-
limit: z.number(),
|
|
217
|
-
hasMore: z.boolean(),
|
|
218
|
-
}),
|
|
219
|
-
items: z.array(searchResultItemSchema),
|
|
220
|
-
});
|
|
221
|
-
export const registriesIndexSchema = z.record(z.string().regex(/^@[a-zA-Z0-9][a-zA-Z0-9-_]*$/), z.string());
|
|
222
|
-
export const presetSchema = z.object({
|
|
223
|
-
name: z.string(),
|
|
224
|
-
title: z.string(),
|
|
225
|
-
description: z.string(),
|
|
226
|
-
base: z.string(),
|
|
227
|
-
style: z.string(),
|
|
228
|
-
baseColor: z.string(),
|
|
229
|
-
theme: z.string(),
|
|
230
|
-
iconLibrary: z.string(),
|
|
231
|
-
font: z.string(),
|
|
232
|
-
menuAccent: z.enum(["subtle", "bold"]),
|
|
233
|
-
menuColor: z.enum(["default", "inverted"]),
|
|
234
|
-
radius: z.string(),
|
|
235
|
-
});
|
|
236
|
-
export const configJsonSchema = z.object({
|
|
237
|
-
presets: z.array(presetSchema),
|
|
238
|
-
});
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
// Note: if you edit the schema here, you must also edit the schema in the
|
|
3
|
+
// apps/v4/public/schema/registry-item.json file.
|
|
4
|
+
export const registryConfigItemSchema = z.union([
|
|
5
|
+
// Simple string format: "https://example.com/{name}.json"
|
|
6
|
+
z.string().refine((s) => s.includes("{name}"), {
|
|
7
|
+
message: "Registry URL must include {name} placeholder",
|
|
8
|
+
}),
|
|
9
|
+
// Advanced object format with auth options
|
|
10
|
+
z.object({
|
|
11
|
+
url: z.string().refine((s) => s.includes("{name}"), {
|
|
12
|
+
message: "Registry URL must include {name} placeholder",
|
|
13
|
+
}),
|
|
14
|
+
params: z.record(z.string(), z.string()).optional(),
|
|
15
|
+
headers: z.record(z.string(), z.string()).optional(),
|
|
16
|
+
}),
|
|
17
|
+
]);
|
|
18
|
+
export const registryConfigSchema = z.record(z.string().refine((key) => key.startsWith("@"), {
|
|
19
|
+
message: "Registry names must start with @ (e.g., @v0, @acme)",
|
|
20
|
+
}), registryConfigItemSchema);
|
|
21
|
+
export const rawConfigSchema = z
|
|
22
|
+
.object({
|
|
23
|
+
$schema: z.string().optional(),
|
|
24
|
+
style: z.string(),
|
|
25
|
+
rsc: z.coerce.boolean().default(false),
|
|
26
|
+
tsx: z.coerce.boolean().default(true),
|
|
27
|
+
tailwind: z.object({
|
|
28
|
+
config: z.string().optional(),
|
|
29
|
+
css: z.string(),
|
|
30
|
+
baseColor: z.string(),
|
|
31
|
+
cssVariables: z.boolean().default(true),
|
|
32
|
+
prefix: z.string().default("").optional(),
|
|
33
|
+
}),
|
|
34
|
+
iconLibrary: z.string().optional(),
|
|
35
|
+
menuColor: z.enum(["default", "inverted"]).default("default").optional(),
|
|
36
|
+
menuAccent: z.enum(["subtle", "bold"]).default("subtle").optional(),
|
|
37
|
+
aliases: z.object({
|
|
38
|
+
components: z.string(),
|
|
39
|
+
utils: z.string(),
|
|
40
|
+
ui: z.string().optional(),
|
|
41
|
+
lib: z.string().optional(),
|
|
42
|
+
hooks: z.string().optional(),
|
|
43
|
+
}),
|
|
44
|
+
registries: registryConfigSchema.optional(),
|
|
45
|
+
})
|
|
46
|
+
.strict();
|
|
47
|
+
const rawConfigSchemaDeepPartial = rawConfigSchema
|
|
48
|
+
.partial()
|
|
49
|
+
.extend({
|
|
50
|
+
tailwind: rawConfigSchema.shape.tailwind.partial().optional(),
|
|
51
|
+
aliases: rawConfigSchema.shape.aliases.partial().optional(),
|
|
52
|
+
});
|
|
53
|
+
export const configSchema = rawConfigSchema.extend({
|
|
54
|
+
resolvedPaths: z.object({
|
|
55
|
+
cwd: z.string(),
|
|
56
|
+
tailwindConfig: z.string(),
|
|
57
|
+
tailwindCss: z.string(),
|
|
58
|
+
utils: z.string(),
|
|
59
|
+
components: z.string(),
|
|
60
|
+
lib: z.string(),
|
|
61
|
+
hooks: z.string(),
|
|
62
|
+
ui: z.string(),
|
|
63
|
+
}),
|
|
64
|
+
});
|
|
65
|
+
// TODO: type the key.
|
|
66
|
+
// Okay for now since I don't want a breaking change.
|
|
67
|
+
export const workspaceConfigSchema = z.record(z.string(), configSchema);
|
|
68
|
+
export const registryItemTypeSchema = z.enum([
|
|
69
|
+
"registry:lib",
|
|
70
|
+
"registry:block",
|
|
71
|
+
"registry:component",
|
|
72
|
+
"registry:ui",
|
|
73
|
+
"registry:hook",
|
|
74
|
+
"registry:page",
|
|
75
|
+
"registry:file",
|
|
76
|
+
"registry:theme",
|
|
77
|
+
"registry:style",
|
|
78
|
+
"registry:item",
|
|
79
|
+
"registry:base",
|
|
80
|
+
"registry:font",
|
|
81
|
+
// Internal use only.
|
|
82
|
+
"registry:example",
|
|
83
|
+
"registry:internal",
|
|
84
|
+
]);
|
|
85
|
+
export const registryItemFileSchema = z.discriminatedUnion("type", [
|
|
86
|
+
// Target is required for registry:file and registry:page
|
|
87
|
+
z.object({
|
|
88
|
+
path: z.string(),
|
|
89
|
+
content: z.string().optional(),
|
|
90
|
+
type: z.enum(["registry:file", "registry:page"]),
|
|
91
|
+
target: z.string(),
|
|
92
|
+
}),
|
|
93
|
+
z.object({
|
|
94
|
+
path: z.string(),
|
|
95
|
+
content: z.string().optional(),
|
|
96
|
+
type: registryItemTypeSchema.exclude(["registry:file", "registry:page"]),
|
|
97
|
+
target: z.string().optional(),
|
|
98
|
+
}),
|
|
99
|
+
]);
|
|
100
|
+
export const registryItemTailwindSchema = z.object({
|
|
101
|
+
config: z
|
|
102
|
+
.object({
|
|
103
|
+
content: z.array(z.string()).optional(),
|
|
104
|
+
theme: z.record(z.string(), z.any()).optional(),
|
|
105
|
+
plugins: z.array(z.string()).optional(),
|
|
106
|
+
})
|
|
107
|
+
.optional(),
|
|
108
|
+
});
|
|
109
|
+
export const registryItemCssVarsSchema = z.object({
|
|
110
|
+
theme: z.record(z.string(), z.string()).optional(),
|
|
111
|
+
light: z.record(z.string(), z.string()).optional(),
|
|
112
|
+
dark: z.record(z.string(), z.string()).optional(),
|
|
113
|
+
});
|
|
114
|
+
// Recursive type for CSS properties that supports empty objects at any level.
|
|
115
|
+
const cssValueSchema = z.lazy(() => z.union([
|
|
116
|
+
z.string(),
|
|
117
|
+
z.array(z.union([z.string(), z.record(z.string(), z.string())])),
|
|
118
|
+
z.record(z.string(), cssValueSchema),
|
|
119
|
+
]));
|
|
120
|
+
export const registryItemCssSchema = z.record(z.string(), cssValueSchema);
|
|
121
|
+
export const registryItemEnvVarsSchema = z.record(z.string(), z.string());
|
|
122
|
+
// Font metadata schema for registry:font items.
|
|
123
|
+
export const registryItemFontSchema = z.object({
|
|
124
|
+
family: z.string(),
|
|
125
|
+
provider: z.literal("google"),
|
|
126
|
+
import: z.string(),
|
|
127
|
+
variable: z.string(),
|
|
128
|
+
weight: z.array(z.string()).optional(),
|
|
129
|
+
subsets: z.array(z.string()).optional(),
|
|
130
|
+
});
|
|
131
|
+
// Common fields shared by all registry items.
|
|
132
|
+
export const registryItemCommonSchema = z.object({
|
|
133
|
+
$schema: z.string().optional(),
|
|
134
|
+
extends: z.string().optional(),
|
|
135
|
+
name: z.string(),
|
|
136
|
+
title: z.string().optional(),
|
|
137
|
+
author: z.string().min(2).optional(),
|
|
138
|
+
description: z.string().optional(),
|
|
139
|
+
dependencies: z.array(z.string()).optional(),
|
|
140
|
+
devDependencies: z.array(z.string()).optional(),
|
|
141
|
+
registryDependencies: z.array(z.string()).optional(),
|
|
142
|
+
files: z.array(registryItemFileSchema).optional(),
|
|
143
|
+
tailwind: registryItemTailwindSchema.optional(),
|
|
144
|
+
cssVars: registryItemCssVarsSchema.optional(),
|
|
145
|
+
css: registryItemCssSchema.optional(),
|
|
146
|
+
envVars: registryItemEnvVarsSchema.optional(),
|
|
147
|
+
meta: z.record(z.string(), z.any()).optional(),
|
|
148
|
+
docs: z.string().optional(),
|
|
149
|
+
categories: z.array(z.string()).optional(),
|
|
150
|
+
});
|
|
151
|
+
// registry:base has a config field, registry:font has a font field.
|
|
152
|
+
export const registryItemSchema = z.discriminatedUnion("type", [
|
|
153
|
+
registryItemCommonSchema.extend({
|
|
154
|
+
type: z.literal("registry:base"),
|
|
155
|
+
config: rawConfigSchemaDeepPartial.optional(),
|
|
156
|
+
}),
|
|
157
|
+
registryItemCommonSchema.extend({
|
|
158
|
+
type: z.literal("registry:font"),
|
|
159
|
+
font: registryItemFontSchema,
|
|
160
|
+
}),
|
|
161
|
+
registryItemCommonSchema.extend({
|
|
162
|
+
type: registryItemTypeSchema.exclude(["registry:base", "registry:font"]),
|
|
163
|
+
}),
|
|
164
|
+
]);
|
|
165
|
+
export const registrySchema = z.object({
|
|
166
|
+
name: z.string(),
|
|
167
|
+
homepage: z.string(),
|
|
168
|
+
items: z.array(registryItemSchema),
|
|
169
|
+
});
|
|
170
|
+
export const registryIndexSchema = z.array(registryItemSchema);
|
|
171
|
+
export const stylesSchema = z.array(z.object({
|
|
172
|
+
name: z.string(),
|
|
173
|
+
label: z.string(),
|
|
174
|
+
}));
|
|
175
|
+
export const iconsSchema = z.record(z.string(), z.record(z.string(), z.string()));
|
|
176
|
+
export const registryBaseColorSchema = z.object({
|
|
177
|
+
inlineColors: z.object({
|
|
178
|
+
light: z.record(z.string(), z.string()),
|
|
179
|
+
dark: z.record(z.string(), z.string()),
|
|
180
|
+
}),
|
|
181
|
+
cssVars: registryItemCssVarsSchema,
|
|
182
|
+
cssVarsV4: registryItemCssVarsSchema.optional(),
|
|
183
|
+
inlineColorsTemplate: z.string(),
|
|
184
|
+
cssVarsTemplate: z.string(),
|
|
185
|
+
});
|
|
186
|
+
export const registryResolvedItemsTreeSchema = registryItemCommonSchema
|
|
187
|
+
.pick({
|
|
188
|
+
dependencies: true,
|
|
189
|
+
devDependencies: true,
|
|
190
|
+
files: true,
|
|
191
|
+
tailwind: true,
|
|
192
|
+
cssVars: true,
|
|
193
|
+
css: true,
|
|
194
|
+
envVars: true,
|
|
195
|
+
docs: true,
|
|
196
|
+
})
|
|
197
|
+
.extend({
|
|
198
|
+
fonts: z
|
|
199
|
+
.array(registryItemCommonSchema.extend({
|
|
200
|
+
type: z.literal("registry:font"),
|
|
201
|
+
font: registryItemFontSchema,
|
|
202
|
+
}))
|
|
203
|
+
.optional(),
|
|
204
|
+
});
|
|
205
|
+
export const searchResultItemSchema = z.object({
|
|
206
|
+
name: z.string(),
|
|
207
|
+
type: z.string().optional(),
|
|
208
|
+
description: z.string().optional(),
|
|
209
|
+
registry: z.string(),
|
|
210
|
+
addCommandArgument: z.string(),
|
|
211
|
+
});
|
|
212
|
+
export const searchResultsSchema = z.object({
|
|
213
|
+
pagination: z.object({
|
|
214
|
+
total: z.number(),
|
|
215
|
+
offset: z.number(),
|
|
216
|
+
limit: z.number(),
|
|
217
|
+
hasMore: z.boolean(),
|
|
218
|
+
}),
|
|
219
|
+
items: z.array(searchResultItemSchema),
|
|
220
|
+
});
|
|
221
|
+
export const registriesIndexSchema = z.record(z.string().regex(/^@[a-zA-Z0-9][a-zA-Z0-9-_]*$/), z.string());
|
|
222
|
+
export const presetSchema = z.object({
|
|
223
|
+
name: z.string(),
|
|
224
|
+
title: z.string(),
|
|
225
|
+
description: z.string(),
|
|
226
|
+
base: z.string(),
|
|
227
|
+
style: z.string(),
|
|
228
|
+
baseColor: z.string(),
|
|
229
|
+
theme: z.string(),
|
|
230
|
+
iconLibrary: z.string(),
|
|
231
|
+
font: z.string(),
|
|
232
|
+
menuAccent: z.enum(["subtle", "bold"]),
|
|
233
|
+
menuColor: z.enum(["default", "inverted"]),
|
|
234
|
+
radius: z.string(),
|
|
235
|
+
});
|
|
236
|
+
export const configJsonSchema = z.object({
|
|
237
|
+
presets: z.array(presetSchema),
|
|
238
|
+
});
|
|
239
239
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export declare const styleMapSchema: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
3
|
-
export type StyleMap = z.infer<typeof styleMapSchema>;
|
|
4
|
-
export declare function createStyleMap(input: string): Record<string, string>;
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const styleMapSchema: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
3
|
+
export type StyleMap = z.infer<typeof styleMapSchema>;
|
|
4
|
+
export declare function createStyleMap(input: string): Record<string, string>;
|
|
@@ -1,69 +1,69 @@
|
|
|
1
|
-
import postcss from "postcss";
|
|
2
|
-
import selectorParser from "postcss-selector-parser";
|
|
3
|
-
import { z } from "zod";
|
|
4
|
-
const CN_PREFIX = "cn-";
|
|
5
|
-
export const styleMapSchema = z.record(z.string().startsWith(CN_PREFIX), z.string());
|
|
6
|
-
export function createStyleMap(input) {
|
|
7
|
-
const root = postcss.parse(input);
|
|
8
|
-
const result = {};
|
|
9
|
-
root.walkRules((rule) => {
|
|
10
|
-
const selectors = rule.selectors ?? [];
|
|
11
|
-
if (selectors.length === 0) {
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
const tailwindClasses = extractTailwindClasses(rule);
|
|
15
|
-
if (!tailwindClasses) {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
for (const selector of selectors) {
|
|
19
|
-
const normalizedSelector = normalizeSelector(selector);
|
|
20
|
-
selectorParser((selectorsRoot) => {
|
|
21
|
-
selectorsRoot.each((sel) => {
|
|
22
|
-
const targetClass = findSubjectClass(sel);
|
|
23
|
-
if (!targetClass) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
const className = targetClass.value;
|
|
27
|
-
if (!className.startsWith(CN_PREFIX)) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
result[className] = result[className]
|
|
31
|
-
? `${tailwindClasses} ${result[className]}`
|
|
32
|
-
: tailwindClasses;
|
|
33
|
-
});
|
|
34
|
-
}).processSync(normalizedSelector);
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
return styleMapSchema.parse(result);
|
|
38
|
-
}
|
|
39
|
-
function normalizeSelector(selector) {
|
|
40
|
-
return selector.replace(/\s*&\s*/g, "").trim();
|
|
41
|
-
}
|
|
42
|
-
function extractTailwindClasses(rule) {
|
|
43
|
-
const classes = [];
|
|
44
|
-
for (const node of rule.nodes || []) {
|
|
45
|
-
if (node.type === "atrule" && node.name === "apply") {
|
|
46
|
-
const value = node.params.trim();
|
|
47
|
-
if (value) {
|
|
48
|
-
classes.push(value);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
if (classes.length === 0) {
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
return classes.join(" ");
|
|
56
|
-
}
|
|
57
|
-
function findSubjectClass(selector) {
|
|
58
|
-
const classNodes = [];
|
|
59
|
-
selector.walkClasses((classNode) => {
|
|
60
|
-
if (classNode.value.startsWith(CN_PREFIX)) {
|
|
61
|
-
classNodes.push(classNode);
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
if (classNodes.length === 0) {
|
|
65
|
-
return null;
|
|
66
|
-
}
|
|
67
|
-
return classNodes[classNodes.length - 1];
|
|
68
|
-
}
|
|
1
|
+
import postcss from "postcss";
|
|
2
|
+
import selectorParser from "postcss-selector-parser";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
const CN_PREFIX = "cn-";
|
|
5
|
+
export const styleMapSchema = z.record(z.string().startsWith(CN_PREFIX), z.string());
|
|
6
|
+
export function createStyleMap(input) {
|
|
7
|
+
const root = postcss.parse(input);
|
|
8
|
+
const result = {};
|
|
9
|
+
root.walkRules((rule) => {
|
|
10
|
+
const selectors = rule.selectors ?? [];
|
|
11
|
+
if (selectors.length === 0) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const tailwindClasses = extractTailwindClasses(rule);
|
|
15
|
+
if (!tailwindClasses) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
for (const selector of selectors) {
|
|
19
|
+
const normalizedSelector = normalizeSelector(selector);
|
|
20
|
+
selectorParser((selectorsRoot) => {
|
|
21
|
+
selectorsRoot.each((sel) => {
|
|
22
|
+
const targetClass = findSubjectClass(sel);
|
|
23
|
+
if (!targetClass) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const className = targetClass.value;
|
|
27
|
+
if (!className.startsWith(CN_PREFIX)) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
result[className] = result[className]
|
|
31
|
+
? `${tailwindClasses} ${result[className]}`
|
|
32
|
+
: tailwindClasses;
|
|
33
|
+
});
|
|
34
|
+
}).processSync(normalizedSelector);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
return styleMapSchema.parse(result);
|
|
38
|
+
}
|
|
39
|
+
function normalizeSelector(selector) {
|
|
40
|
+
return selector.replace(/\s*&\s*/g, "").trim();
|
|
41
|
+
}
|
|
42
|
+
function extractTailwindClasses(rule) {
|
|
43
|
+
const classes = [];
|
|
44
|
+
for (const node of rule.nodes || []) {
|
|
45
|
+
if (node.type === "atrule" && node.name === "apply") {
|
|
46
|
+
const value = node.params.trim();
|
|
47
|
+
if (value) {
|
|
48
|
+
classes.push(value);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (classes.length === 0) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
return classes.join(" ");
|
|
56
|
+
}
|
|
57
|
+
function findSubjectClass(selector) {
|
|
58
|
+
const classNodes = [];
|
|
59
|
+
selector.walkClasses((classNode) => {
|
|
60
|
+
if (classNode.value.startsWith(CN_PREFIX)) {
|
|
61
|
+
classNodes.push(classNode);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
if (classNodes.length === 0) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
return classNodes[classNodes.length - 1];
|
|
68
|
+
}
|
|
69
69
|
//# sourceMappingURL=create-style-map.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { TransformerStyle } from "./transform.js";
|
|
2
|
-
import { type SourceFile } from "ts-morph";
|
|
3
|
-
export declare const transformStyleMap: TransformerStyle<SourceFile>;
|
|
1
|
+
import { TransformerStyle } from "./transform.js";
|
|
2
|
+
import { type SourceFile } from "ts-morph";
|
|
3
|
+
export declare const transformStyleMap: TransformerStyle<SourceFile>;
|