@razorwind/shadcn 0.0.4 → 0.0.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/dist/extract-CHhbobiJ.d.cts +168 -0
- package/dist/extract-CHhbobiJ.d.cts.map +1 -0
- package/dist/extract-CdEg5hNq.d.mts +168 -0
- package/dist/extract-CdEg5hNq.d.mts.map +1 -0
- package/dist/extract-D6s-xjEv.cjs +5 -0
- package/dist/extract-DBbCwIGB.mjs +6 -0
- package/dist/extract-DBbCwIGB.mjs.map +1 -0
- package/dist/extract.cjs +1 -0
- package/dist/extract.d.cts +3 -0
- package/dist/extract.d.mts +3 -0
- package/dist/extract.mjs +1 -0
- package/dist/generate.cjs +1 -0
- package/dist/generate.d.cts +69 -0
- package/dist/generate.d.cts.map +1 -0
- package/dist/generate.d.mts +69 -0
- package/dist/generate.d.mts.map +1 -0
- package/dist/generate.mjs +2 -0
- package/dist/generate.mjs.map +1 -0
- package/dist/index.cjs +1 -5
- package/dist/index.d.cts +3 -185
- package/dist/index.d.mts +3 -185
- package/dist/index.mjs +1 -6
- package/dist/rolldown-runtime-DK3Fl9T5.mjs +1 -0
- package/dist/rolldown-runtime-DWNI8pZO.cjs +1 -0
- package/dist/types-BH0MT5Wk.d.mts +43 -0
- package/dist/types-BH0MT5Wk.d.mts.map +1 -0
- package/dist/types-Jkebh8QA.d.cts +44 -0
- package/dist/types-Jkebh8QA.d.cts.map +1 -0
- package/package.json +32 -4
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs.map +0 -1
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { r as __exportAll, t as ShadcnExtractPluginOptions } from "./types-Jkebh8QA.cjs";
|
|
2
|
+
import { Component, Components } from "@razorwind/core/schema";
|
|
3
|
+
import "shadcn/preset";
|
|
4
|
+
import { configSchema, rawConfigSchema, registryConfigSchema, workspaceConfigSchema } from "shadcn/schema";
|
|
5
|
+
//#region src/registry/shadcn-types.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Infer a Zod 3 schema's output from `parse`'s return type.
|
|
8
|
+
*
|
|
9
|
+
* Avoids `z.infer` / `zod/v3` — this package depends on Zod 4 while shadcn's
|
|
10
|
+
* schemas are typed against Zod 3, and cross-version `infer` triggers
|
|
11
|
+
* "Type instantiation is excessively deep and possibly infinite".
|
|
12
|
+
*/
|
|
13
|
+
type InferShadcnSchema<T> = T extends {
|
|
14
|
+
parse: (...args: never[]) => infer Output;
|
|
15
|
+
} ? Output : never;
|
|
16
|
+
type ShadcnConfig = InferShadcnSchema<typeof configSchema>;
|
|
17
|
+
type ShadcnRawConfig = InferShadcnSchema<typeof rawConfigSchema>;
|
|
18
|
+
type ShadcnRegistryConfig = InferShadcnSchema<typeof registryConfigSchema>;
|
|
19
|
+
type ShadcnWorkspaceConfig = InferShadcnSchema<typeof workspaceConfigSchema>;
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/registry/config.d.ts
|
|
22
|
+
declare const DEFAULT_STYLE = "default";
|
|
23
|
+
declare const DEFAULT_COMPONENTS = "@/components";
|
|
24
|
+
declare const DEFAULT_UTILS = "@/lib/utils";
|
|
25
|
+
declare const DEFAULT_TAILWIND_CSS = "app/globals.css";
|
|
26
|
+
declare const DEFAULT_TAILWIND_CONFIG = "tailwind.config.js";
|
|
27
|
+
declare const DEFAULT_TAILWIND_BASE_COLOR = "slate";
|
|
28
|
+
type RegistryConfig = ShadcnConfig;
|
|
29
|
+
declare function getRegistryConfig(cwd: string): Promise<{
|
|
30
|
+
tailwind: {
|
|
31
|
+
baseColor: string;
|
|
32
|
+
css: string;
|
|
33
|
+
cssVariables: boolean;
|
|
34
|
+
config?: string | undefined;
|
|
35
|
+
prefix?: string | undefined;
|
|
36
|
+
};
|
|
37
|
+
style: string;
|
|
38
|
+
rsc: boolean;
|
|
39
|
+
tsx: boolean;
|
|
40
|
+
aliases: {
|
|
41
|
+
components: string;
|
|
42
|
+
utils: string;
|
|
43
|
+
ui?: string | undefined;
|
|
44
|
+
lib?: string | undefined;
|
|
45
|
+
hooks?: string | undefined;
|
|
46
|
+
};
|
|
47
|
+
resolvedPaths: {
|
|
48
|
+
components: string;
|
|
49
|
+
ui: string;
|
|
50
|
+
utils: string;
|
|
51
|
+
lib: string;
|
|
52
|
+
hooks: string;
|
|
53
|
+
cwd: string;
|
|
54
|
+
tailwindConfig: string;
|
|
55
|
+
tailwindCss: string;
|
|
56
|
+
};
|
|
57
|
+
menuColor?: "default" | "inverted" | "default-translucent" | "inverted-translucent" | undefined;
|
|
58
|
+
menuAccent?: "subtle" | "bold" | undefined;
|
|
59
|
+
iconLibrary?: string | undefined;
|
|
60
|
+
$schema?: string | undefined;
|
|
61
|
+
rtl?: boolean | undefined;
|
|
62
|
+
registries?: Record<string, string | {
|
|
63
|
+
url: string;
|
|
64
|
+
params?: Record<string, string> | undefined;
|
|
65
|
+
headers?: Record<string, string> | undefined;
|
|
66
|
+
}> | undefined;
|
|
67
|
+
} | null>;
|
|
68
|
+
declare const BUILTIN_REGISTRIES: ShadcnRegistryConfig;
|
|
69
|
+
declare function resolveConfigPaths(cwd: string, config: ShadcnRawConfig): Promise<{
|
|
70
|
+
tailwind: {
|
|
71
|
+
baseColor: string;
|
|
72
|
+
css: string;
|
|
73
|
+
cssVariables: boolean;
|
|
74
|
+
config?: string | undefined;
|
|
75
|
+
prefix?: string | undefined;
|
|
76
|
+
};
|
|
77
|
+
style: string;
|
|
78
|
+
rsc: boolean;
|
|
79
|
+
tsx: boolean;
|
|
80
|
+
aliases: {
|
|
81
|
+
components: string;
|
|
82
|
+
utils: string;
|
|
83
|
+
ui?: string | undefined;
|
|
84
|
+
lib?: string | undefined;
|
|
85
|
+
hooks?: string | undefined;
|
|
86
|
+
};
|
|
87
|
+
resolvedPaths: {
|
|
88
|
+
components: string;
|
|
89
|
+
ui: string;
|
|
90
|
+
utils: string;
|
|
91
|
+
lib: string;
|
|
92
|
+
hooks: string;
|
|
93
|
+
cwd: string;
|
|
94
|
+
tailwindConfig: string;
|
|
95
|
+
tailwindCss: string;
|
|
96
|
+
};
|
|
97
|
+
menuColor?: "default" | "inverted" | "default-translucent" | "inverted-translucent" | undefined;
|
|
98
|
+
menuAccent?: "subtle" | "bold" | undefined;
|
|
99
|
+
iconLibrary?: string | undefined;
|
|
100
|
+
$schema?: string | undefined;
|
|
101
|
+
rtl?: boolean | undefined;
|
|
102
|
+
registries?: Record<string, string | {
|
|
103
|
+
url: string;
|
|
104
|
+
params?: Record<string, string> | undefined;
|
|
105
|
+
headers?: Record<string, string> | undefined;
|
|
106
|
+
}> | undefined;
|
|
107
|
+
}>;
|
|
108
|
+
declare function getRawConfig(cwd: string): Promise<ShadcnRawConfig | null>;
|
|
109
|
+
type DeepPartial<T> = { [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P]; };
|
|
110
|
+
/**
|
|
111
|
+
* Creates a config object with sensible defaults.
|
|
112
|
+
* Useful for universal registry items that bypass framework detection.
|
|
113
|
+
*
|
|
114
|
+
* @param partial - Partial config values to override defaults
|
|
115
|
+
* @returns A complete Config object
|
|
116
|
+
*/
|
|
117
|
+
declare function createRegistryConfig(partial?: DeepPartial<RegistryConfig>): RegistryConfig;
|
|
118
|
+
declare namespace extract_d_exports {
|
|
119
|
+
export { BUILTIN_REGISTRIES, DEFAULT_COMPONENTS, DEFAULT_STYLE, DEFAULT_TAILWIND_BASE_COLOR, DEFAULT_TAILWIND_CONFIG, DEFAULT_TAILWIND_CSS, DEFAULT_UTILS, RegistryConfig, ShadcnConfig, ShadcnExtractPluginOptions, ShadcnRawConfig, ShadcnRegistryConfig, ShadcnWorkspaceConfig, createRegistryConfig, _default as default, extractComponentsFromRegistry, getRawConfig, getRegistryConfig, registryItemToComponent, registryItemsToComponents, resolveConfigPaths, toDependencyRecord };
|
|
120
|
+
}
|
|
121
|
+
interface RegistryItemLike {
|
|
122
|
+
name: string;
|
|
123
|
+
title?: string;
|
|
124
|
+
type?: string;
|
|
125
|
+
description?: string;
|
|
126
|
+
categories?: string[];
|
|
127
|
+
dependencies?: string[];
|
|
128
|
+
devDependencies?: string[];
|
|
129
|
+
registryDependencies?: string[];
|
|
130
|
+
files?: unknown[];
|
|
131
|
+
docs?: string;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Convert npm-style dependency strings (`pkg`, `pkg@version`) into a
|
|
135
|
+
* name → version record.
|
|
136
|
+
*/
|
|
137
|
+
declare function toDependencyRecord(deps: string[] | undefined): Record<string, string> | undefined;
|
|
138
|
+
/**
|
|
139
|
+
* Map a single shadcn registry item into a Razorwind {@link Component}.
|
|
140
|
+
*/
|
|
141
|
+
declare function registryItemToComponent(item: RegistryItemLike): Component;
|
|
142
|
+
/**
|
|
143
|
+
* Convert a list of shadcn registry items into a `schema.components` record.
|
|
144
|
+
*/
|
|
145
|
+
declare function registryItemsToComponents(items: RegistryItemLike[] | undefined): Components;
|
|
146
|
+
/**
|
|
147
|
+
* Load a local `registry.json` and map its items into `schema.components`.
|
|
148
|
+
*
|
|
149
|
+
* Returns an empty record when the registry file is missing or unreadable.
|
|
150
|
+
*/
|
|
151
|
+
declare function extractComponentsFromRegistry(registryPath: string): Promise<Components>;
|
|
152
|
+
/**
|
|
153
|
+
* Razorwind plugin: load shadcn `registry.json` items into `schema.components`.
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* ```ts
|
|
157
|
+
* import { defineConfig } from "@razorwind/core";
|
|
158
|
+
* import shadcn from "@razorwind/shadcn/extract";
|
|
159
|
+
*
|
|
160
|
+
* export default defineConfig({
|
|
161
|
+
* plugins: [shadcn()]
|
|
162
|
+
* });
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
165
|
+
declare const _default: any;
|
|
166
|
+
//#endregion
|
|
167
|
+
export { ShadcnWorkspaceConfig as S, getRegistryConfig as _, registryItemsToComponents as a, ShadcnRawConfig as b, DEFAULT_COMPONENTS as c, DEFAULT_TAILWIND_CONFIG as d, DEFAULT_TAILWIND_CSS as f, getRawConfig as g, createRegistryConfig as h, registryItemToComponent as i, DEFAULT_STYLE as l, RegistryConfig as m, extractComponentsFromRegistry as n, toDependencyRecord as o, DEFAULT_UTILS as p, extract_d_exports as r, BUILTIN_REGISTRIES as s, _default as t, DEFAULT_TAILWIND_BASE_COLOR as u, resolveConfigPaths as v, ShadcnRegistryConfig as x, ShadcnConfig as y };
|
|
168
|
+
//# sourceMappingURL=extract-CHhbobiJ.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract-CHhbobiJ.d.cts","names":[],"sources":["../src/registry/shadcn-types.ts","../src/registry/config.ts","../src/extract.ts"],"mappings":";;;;;;;;;;;;KAgCK,kBAAkB,KAAK;EAC1B,WAAW,wBAAwB;IAEjC;KAGQ,eAAe,yBAAyB;KACxC,kBAAkB,yBAAyB;KAC3C,uBAAuB,yBAC1B;KAEG,wBAAwB,yBAC3B;;;cCHI;cACA;cACA;cACA;cACA;cACA;KAmCD,iBAAiB;iBAEP,kBAAkB,cAAW;;;;;IA+MjC;IACV;;;;;;;;IASkB;IAAkC;IAGtD;;;;;;;;;;;;;;;;;;;IAsBS,SAAC;IACH,UAAC;;;cArOD,oBAAoB;iBAIX,mBAAmB,aAAa,QAAQ,kBAAe;;;;;IA6L3D;IACV;;;;;;;;IASkB;IAAkC;IAGtD;;;;;;;;;;;;;;;;;;;IAsBS,SAAC;IACH,UAAC;;;iBAtFQ,aACpB,cACC,QAAQ;KA6IC,YAAY,QACrB,WAAW,KAAK,EAAE,oBAAoB,YAAY,EAAE,MAAM,EAAE;;;;;;;;iBAU/C,qBACd,UAAU,YAAY,kBACrB;;;;UCtUO;EACR;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;;;;iBAOc,mBACd,6BACC;;;;iBAgGa,wBAAwB,MAAM,mBAAmB;;;;iBA2BjD,0BACd,OAAO,iCACN;;;;;;iBAqCmB,8BACpB,uBACC,QAAQ"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { t as ShadcnExtractPluginOptions } from "./types-BH0MT5Wk.mjs";
|
|
2
|
+
import { configSchema, rawConfigSchema, registryConfigSchema, workspaceConfigSchema } from "shadcn/schema";
|
|
3
|
+
import "shadcn/preset";
|
|
4
|
+
import { Component, Components } from "@razorwind/core/schema";
|
|
5
|
+
//#region src/registry/shadcn-types.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Infer a Zod 3 schema's output from `parse`'s return type.
|
|
8
|
+
*
|
|
9
|
+
* Avoids `z.infer` / `zod/v3` — this package depends on Zod 4 while shadcn's
|
|
10
|
+
* schemas are typed against Zod 3, and cross-version `infer` triggers
|
|
11
|
+
* "Type instantiation is excessively deep and possibly infinite".
|
|
12
|
+
*/
|
|
13
|
+
type InferShadcnSchema<T> = T extends {
|
|
14
|
+
parse: (...args: never[]) => infer Output;
|
|
15
|
+
} ? Output : never;
|
|
16
|
+
type ShadcnConfig = InferShadcnSchema<typeof configSchema>;
|
|
17
|
+
type ShadcnRawConfig = InferShadcnSchema<typeof rawConfigSchema>;
|
|
18
|
+
type ShadcnRegistryConfig = InferShadcnSchema<typeof registryConfigSchema>;
|
|
19
|
+
type ShadcnWorkspaceConfig = InferShadcnSchema<typeof workspaceConfigSchema>;
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/registry/config.d.ts
|
|
22
|
+
declare const DEFAULT_STYLE = "default";
|
|
23
|
+
declare const DEFAULT_COMPONENTS = "@/components";
|
|
24
|
+
declare const DEFAULT_UTILS = "@/lib/utils";
|
|
25
|
+
declare const DEFAULT_TAILWIND_CSS = "app/globals.css";
|
|
26
|
+
declare const DEFAULT_TAILWIND_CONFIG = "tailwind.config.js";
|
|
27
|
+
declare const DEFAULT_TAILWIND_BASE_COLOR = "slate";
|
|
28
|
+
type RegistryConfig = ShadcnConfig;
|
|
29
|
+
declare function getRegistryConfig(cwd: string): Promise<{
|
|
30
|
+
tailwind: {
|
|
31
|
+
baseColor: string;
|
|
32
|
+
css: string;
|
|
33
|
+
cssVariables: boolean;
|
|
34
|
+
config?: string | undefined;
|
|
35
|
+
prefix?: string | undefined;
|
|
36
|
+
};
|
|
37
|
+
style: string;
|
|
38
|
+
rsc: boolean;
|
|
39
|
+
tsx: boolean;
|
|
40
|
+
aliases: {
|
|
41
|
+
components: string;
|
|
42
|
+
utils: string;
|
|
43
|
+
ui?: string | undefined;
|
|
44
|
+
lib?: string | undefined;
|
|
45
|
+
hooks?: string | undefined;
|
|
46
|
+
};
|
|
47
|
+
resolvedPaths: {
|
|
48
|
+
components: string;
|
|
49
|
+
ui: string;
|
|
50
|
+
utils: string;
|
|
51
|
+
lib: string;
|
|
52
|
+
hooks: string;
|
|
53
|
+
cwd: string;
|
|
54
|
+
tailwindConfig: string;
|
|
55
|
+
tailwindCss: string;
|
|
56
|
+
};
|
|
57
|
+
menuColor?: "default" | "inverted" | "default-translucent" | "inverted-translucent" | undefined;
|
|
58
|
+
menuAccent?: "subtle" | "bold" | undefined;
|
|
59
|
+
iconLibrary?: string | undefined;
|
|
60
|
+
$schema?: string | undefined;
|
|
61
|
+
rtl?: boolean | undefined;
|
|
62
|
+
registries?: Record<string, string | {
|
|
63
|
+
url: string;
|
|
64
|
+
params?: Record<string, string> | undefined;
|
|
65
|
+
headers?: Record<string, string> | undefined;
|
|
66
|
+
}> | undefined;
|
|
67
|
+
} | null>;
|
|
68
|
+
declare const BUILTIN_REGISTRIES: ShadcnRegistryConfig;
|
|
69
|
+
declare function resolveConfigPaths(cwd: string, config: ShadcnRawConfig): Promise<{
|
|
70
|
+
tailwind: {
|
|
71
|
+
baseColor: string;
|
|
72
|
+
css: string;
|
|
73
|
+
cssVariables: boolean;
|
|
74
|
+
config?: string | undefined;
|
|
75
|
+
prefix?: string | undefined;
|
|
76
|
+
};
|
|
77
|
+
style: string;
|
|
78
|
+
rsc: boolean;
|
|
79
|
+
tsx: boolean;
|
|
80
|
+
aliases: {
|
|
81
|
+
components: string;
|
|
82
|
+
utils: string;
|
|
83
|
+
ui?: string | undefined;
|
|
84
|
+
lib?: string | undefined;
|
|
85
|
+
hooks?: string | undefined;
|
|
86
|
+
};
|
|
87
|
+
resolvedPaths: {
|
|
88
|
+
components: string;
|
|
89
|
+
ui: string;
|
|
90
|
+
utils: string;
|
|
91
|
+
lib: string;
|
|
92
|
+
hooks: string;
|
|
93
|
+
cwd: string;
|
|
94
|
+
tailwindConfig: string;
|
|
95
|
+
tailwindCss: string;
|
|
96
|
+
};
|
|
97
|
+
menuColor?: "default" | "inverted" | "default-translucent" | "inverted-translucent" | undefined;
|
|
98
|
+
menuAccent?: "subtle" | "bold" | undefined;
|
|
99
|
+
iconLibrary?: string | undefined;
|
|
100
|
+
$schema?: string | undefined;
|
|
101
|
+
rtl?: boolean | undefined;
|
|
102
|
+
registries?: Record<string, string | {
|
|
103
|
+
url: string;
|
|
104
|
+
params?: Record<string, string> | undefined;
|
|
105
|
+
headers?: Record<string, string> | undefined;
|
|
106
|
+
}> | undefined;
|
|
107
|
+
}>;
|
|
108
|
+
declare function getRawConfig(cwd: string): Promise<ShadcnRawConfig | null>;
|
|
109
|
+
type DeepPartial<T> = { [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P]; };
|
|
110
|
+
/**
|
|
111
|
+
* Creates a config object with sensible defaults.
|
|
112
|
+
* Useful for universal registry items that bypass framework detection.
|
|
113
|
+
*
|
|
114
|
+
* @param partial - Partial config values to override defaults
|
|
115
|
+
* @returns A complete Config object
|
|
116
|
+
*/
|
|
117
|
+
declare function createRegistryConfig(partial?: DeepPartial<RegistryConfig>): RegistryConfig;
|
|
118
|
+
declare namespace extract_d_exports {
|
|
119
|
+
export { BUILTIN_REGISTRIES, DEFAULT_COMPONENTS, DEFAULT_STYLE, DEFAULT_TAILWIND_BASE_COLOR, DEFAULT_TAILWIND_CONFIG, DEFAULT_TAILWIND_CSS, DEFAULT_UTILS, RegistryConfig, ShadcnConfig, ShadcnExtractPluginOptions, ShadcnRawConfig, ShadcnRegistryConfig, ShadcnWorkspaceConfig, createRegistryConfig, _default as default, extractComponentsFromRegistry, getRawConfig, getRegistryConfig, registryItemToComponent, registryItemsToComponents, resolveConfigPaths, toDependencyRecord };
|
|
120
|
+
}
|
|
121
|
+
interface RegistryItemLike {
|
|
122
|
+
name: string;
|
|
123
|
+
title?: string;
|
|
124
|
+
type?: string;
|
|
125
|
+
description?: string;
|
|
126
|
+
categories?: string[];
|
|
127
|
+
dependencies?: string[];
|
|
128
|
+
devDependencies?: string[];
|
|
129
|
+
registryDependencies?: string[];
|
|
130
|
+
files?: unknown[];
|
|
131
|
+
docs?: string;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Convert npm-style dependency strings (`pkg`, `pkg@version`) into a
|
|
135
|
+
* name → version record.
|
|
136
|
+
*/
|
|
137
|
+
declare function toDependencyRecord(deps: string[] | undefined): Record<string, string> | undefined;
|
|
138
|
+
/**
|
|
139
|
+
* Map a single shadcn registry item into a Razorwind {@link Component}.
|
|
140
|
+
*/
|
|
141
|
+
declare function registryItemToComponent(item: RegistryItemLike): Component;
|
|
142
|
+
/**
|
|
143
|
+
* Convert a list of shadcn registry items into a `schema.components` record.
|
|
144
|
+
*/
|
|
145
|
+
declare function registryItemsToComponents(items: RegistryItemLike[] | undefined): Components;
|
|
146
|
+
/**
|
|
147
|
+
* Load a local `registry.json` and map its items into `schema.components`.
|
|
148
|
+
*
|
|
149
|
+
* Returns an empty record when the registry file is missing or unreadable.
|
|
150
|
+
*/
|
|
151
|
+
declare function extractComponentsFromRegistry(registryPath: string): Promise<Components>;
|
|
152
|
+
/**
|
|
153
|
+
* Razorwind plugin: load shadcn `registry.json` items into `schema.components`.
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* ```ts
|
|
157
|
+
* import { defineConfig } from "@razorwind/core";
|
|
158
|
+
* import shadcn from "@razorwind/shadcn/extract";
|
|
159
|
+
*
|
|
160
|
+
* export default defineConfig({
|
|
161
|
+
* plugins: [shadcn()]
|
|
162
|
+
* });
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
165
|
+
declare const _default: any;
|
|
166
|
+
//#endregion
|
|
167
|
+
export { ShadcnWorkspaceConfig as S, getRegistryConfig as _, registryItemsToComponents as a, ShadcnRawConfig as b, DEFAULT_COMPONENTS as c, DEFAULT_TAILWIND_CONFIG as d, DEFAULT_TAILWIND_CSS as f, getRawConfig as g, createRegistryConfig as h, registryItemToComponent as i, DEFAULT_STYLE as l, RegistryConfig as m, extractComponentsFromRegistry as n, toDependencyRecord as o, DEFAULT_UTILS as p, extract_d_exports as r, BUILTIN_REGISTRIES as s, _default as t, DEFAULT_TAILWIND_BASE_COLOR as u, resolveConfigPaths as v, ShadcnRegistryConfig as x, ShadcnConfig as y };
|
|
168
|
+
//# sourceMappingURL=extract-CdEg5hNq.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract-CdEg5hNq.d.mts","names":[],"sources":["../src/registry/shadcn-types.ts","../src/registry/config.ts","../src/extract.ts"],"mappings":""}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
const e=require("./rolldown-runtime-DWNI8pZO.cjs");let t=require("@power-plant/core"),n=require("@razorwind/core/plugin"),r=require("@stryke/path/join"),i=require("node:fs"),a=require("node:path");a=e.n(a,1);let o=require("shadcn/registry"),s=require("@stryke/fs/tsconfig"),c=require("c12"),l=require("chalk");l=e.n(l,1);let u=require("fast-glob");u=e.n(u,1);let d=require("shadcn/schema");require("shadcn/preset");let f=require("@stryke/fs/json"),ee=require("@stryke/fs/read-file"),p=require("zod");require("@stryke/http/fetch"),require("@stryke/url/helpers");let m=require("@stryke/fs/get-workspace-root"),te=require("tsconfig-paths"),h=require("@stryke/path/is-type");const g=process.env.REGISTRY_URL??`https://ui.shadcn.com/r`,_=g.replace(/\/r\/?$/,``);`${_}`,`${_}`,`${_}`,`${_}`,`${_}`,`${_}`,`${_}`,`${_}`,`${_}`,`${_}`,`${_}`;function v(e){let t=[e];for(;t.length;){let e=t.shift();if(typeof e==`string`){if(e.startsWith(`./`))return e;continue}if(Array.isArray(e)){t.unshift(...e);continue}e&&typeof e==`object`&&t.unshift(...Object.values(e))}return null}function y(e){if(!e.includes(`*`))return`strip_extension`;let t=e.slice(e.indexOf(`*`)+1);return t&&/^\.[^/]+$/.test(t)?`strip_extension`:`preserve_extension`}function b(e,t){let n=t.find(t=>!t.hasWildcard&&t.key===e);if(n)return{path:a.default.resolve(n.rootDir,n.target),matchedAlias:n.key,matchedTarget:n.target,emitMode:n.emitMode};let r=t.filter(e=>e.hasWildcard).sort((e,t)=>t.key.length-e.key.length);for(let t of r){let n=x(e,t.key,{allowBareAliasBase:!0});if(n!==null)return{path:a.default.resolve(t.rootDir,ne(t.target,n)),matchedAlias:t.key,matchedTarget:t.target,emitMode:t.emitMode}}return null}function x(e,t,n={}){if(!t.includes(`*`))return e===t?``:null;let[r,i=``]=t.split(`*`);return r&&e.startsWith(r)&&e.endsWith(i)?i?e.slice(r.length,-i.length):e.slice(r.length):n.allowBareAliasBase&&i===``&&r&&r.endsWith(`/`)&&e===r.slice(0,-1)?``:null}function ne(e,t){if(!e.includes(`*`))return e;let[n,r=``]=e.split(`*`);return t?n?`${n}${t}${r}`:t:n?n.replace(/\/$/,``):``}const S=new Map;async function C(e){let t=a.default.resolve(e),n=S.get(t);if(n)return n;let r=(await w(e))?.imports;if(!r||typeof r!=`object`||Array.isArray(r))return S.set(t,[]),[];let i=[];for(let[e,n]of Object.entries(r)){if(!e.startsWith(`#`))continue;let r=v(n);r&&i.push({key:e,aliasBase:e===`#*`?`#`:e.endsWith(`/*`)?e.slice(0,-2):e,target:r,emitMode:y(r),hasWildcard:e.includes(`*`),rootDir:t})}return S.set(t,i),i}async function re(e,t){return b(e,await C(t))}async function w(e=``){return(0,f.readJsonFile)(a.default.join(e,`package.json`))}p.z.object({compilerOptions:p.z.object({paths:p.z.record(p.z.string(),p.z.string().or(p.z.array(p.z.string())))})});function ie(e){if(e.startsWith(`#`)||e.startsWith(`.`)||(0,h.isAbsolute)(e))return null;let t=e.split(`/`);return e.startsWith(`@`)?t.length<2?null:{packageName:`${t[0]}/${t[1]}`}:{packageName:t[0]}}const T=new Map,E=new Map;function D(e){let t=[],n=!1,r=0;for(let i of e.split(`
|
|
2
|
+
`)){let e=i.trim();if(!e||e.startsWith(`#`))continue;let a=i.match(/^(\s*)([\w-]+)\s*:/);if(a){r=a[1]?.length??0,n=a[2]===`packages`;continue}if(!n)continue;let o=i.match(/^(\s*)-\s*(.+?)\s*(?:#.*)?$/);((!o||o[1]?.length)??r>=0)||t.push(o[2]?.trim().replace(/^["']|["']$/g,``)??``)}return t}async function O(e){let t=[],n=a.default.resolve(e,`pnpm-workspace.yaml`);if((0,i.existsSync)(n)){let e=await(0,ee.readFile)(n);t.push(...D(e))}let o=(0,r.joinPaths)(e,`package.json`);if((0,i.existsSync)(o))try{let e=(await(0,f.readJsonFile)(o)).workspaces,n=Array.isArray(e)?e:e?.packages;Array.isArray(n)&&t.push(...n.filter(e=>!e.startsWith(`!`)))}catch{}return Array.from(new Set(t))}async function k(e){let t=await O(e),n=new Map;if(!t.length)return n;let r=await(0,u.default)(t.map(e=>a.default.posix.join(e.split(a.default.sep).join(`/`),`package.json`)),{cwd:e,ignore:[`**/node_modules/**`]});for(let t of r){let r=a.default.resolve(e,a.default.dirname(t)),i=(await w(r))?.name;i&&n.set(i,{packageName:i,packageRoot:r})}return n}async function A(e,t){let n=(0,m.getWorkspaceRoot)(e);if(!n)return null;let r=T.get(n);if(r?.has(t))return r.get(t)??null;let i=await k(n);return T.set(n,i),i.get(t)??null}function j(e,t){if(t===`.`)return e;let n=t.slice(2).replace(/\/\*$/,``);return n?`${e}/${n}`:e}async function ae(e){let t=`${e.packageRoot}:${e.packageName}`,n=E.get(t);if(n)return n;let r=(await w(e.packageRoot))?.exports;if(!r||typeof r!=`object`||Array.isArray(r))return E.set(t,[]),[];let i=[];for(let[t,n]of Object.entries(r)){if(t!==`.`&&!t.startsWith(`./`))continue;let r=v(n);if(!r)continue;let a=j(e.packageName,t);i.push({key:t.includes(`*`)?`${a}/*`:a,aliasBase:a,target:r,emitMode:y(r),hasWildcard:t.includes(`*`),rootDir:e.packageRoot})}return E.set(t,i),i}async function oe(e,t){let n=ie(e);if(!n?.packageName)return null;let r=await A(t,n.packageName);return r?b(e,await ae(r)):null}async function se(e,t){let n=t.cwd??t.baseUrl??(0,m.getWorkspaceRoot)();if(e.startsWith(`#`)){let t=await re(e,n);if(t)return{path:t.path,source:`package_imports`,matchedAlias:t.matchedAlias,matchedTarget:t.matchedTarget,emitMode:t.emitMode}}let r=await oe(e,n);return r?{path:r.path,source:`workspace_package_exports`,matchedAlias:r.matchedAlias,matchedTarget:r.matchedTarget,emitMode:r.emitMode}:le(e,t)}function ce(e){return/^@[^/]+\/[^/]+(?:\/.*)?$/.test(e)}function le(e,t){let n=(0,te.createMatchPath)(t.baseUrl||t.cwd||(0,m.getWorkspaceRoot)(),t.paths??{})(e,void 0,()=>!0,[`.ts`,`.tsx`,`.jsx`,`.js`,`.css`]);if(!n)return null;let r=ue(e,t.paths??{});return!r&&ce(e)?null:{path:n,source:`tsconfig_paths`,matchedAlias:r?.key??e,matchedTarget:r?.target??n,emitMode:`strip_extension`}}function ue(e,t){for(let[n,r]of Object.entries(t)){let t=Array.isArray(r)?r:[r],i=x(e,n);if(i!==null)return{key:n,target:t[0]?.includes(`*`)&&i!==null?t[0].replace(/\*/g,i):t[0]}}return null}const M=`default`,N=`@/components`,P=`@/lib/utils`,F=`app/globals.css`,I=`tailwind.config.js`,L=`slate`,R=`components.json`,z={configFile:R,dotenv:!1,envName:!1,packageJson:!1,rcFile:!1,extend:!1};async function B(e){let t=e;for(;;){let e=await(0,c.loadConfig)({cwd:t,...z});if(e._configFile)return e;let n=a.default.dirname(t);if(n===t)return null;t=n}}async function V(e){let t=await G(e);return t?(t.iconLibrary||=t.style===`new-york`?`radix`:`lucide`,U(e,t)):null}const H={"@shadcn":`${g}/styles/{style}/{name}.json`};async function U(e,t){t.registries={...H,...t.registries??{}};let n=await(0,s.loadTsConfig)(e);if(!n)throw Error(`Failed to load tsconfig.json.`);let r=await W(`utils`,t.aliases.utils,e,n),i=await W(`components`,t.aliases.components,e,n),o=t.aliases.ui?await W(`ui`,t.aliases.ui,e,n):a.default.resolve(i??e,`ui`),c=t.aliases.lib?await W(`lib`,t.aliases.lib,e,n):a.default.resolve(r??e,`..`),l=t.aliases.hooks?await W(`hooks`,t.aliases.hooks,e,n):a.default.resolve(i??e,`..`,`hooks`);return de(e,{components:i,utils:r,ui:o,lib:c,hooks:l}),d.configSchema.parse({...t,resolvedPaths:{cwd:e,tailwindConfig:t.tailwind.config?a.default.resolve(e,t.tailwind.config):``,tailwindCss:a.default.resolve(e,t.tailwind.css),utils:r,components:i,ui:o,lib:c,hooks:l}})}async function W(e,t,n,i){let o=await se(t,{...i,cwd:n});if(!o?.path||t.startsWith(`#`)&&o.path===(0,r.joinPaths)(n,t))return null;if(e!==`utils`&&(o.source===`package_imports`||o.source===`workspace_package_exports`)){if(!o.matchedAlias.includes(`*`)&&/\/index\.[^/]+$/.test(o.path))return a.default.dirname(o.path);if(o.matchedAlias.includes(`*`)&&/\.[^/]+$/.test(o.path))return o.path.replace(/\.[^/]+$/,``)}return o.path}function de(e,t){let n=[`components`,`ui`,`lib`,`hooks`,`utils`].filter(e=>!t[e]);if(n.length)throw Error([`Could not resolve the following aliases in ${l.default.cyan(e)}: ${l.default.cyan(n.join(`, `))}.`,`Configure path aliases in ${l.default.cyan(`tsconfig.json`)} or imports in ${l.default.cyan(`package.json`)} for this workspace and try again.`].join(`
|
|
3
|
+
`))}async function G(e){let t;try{let n=await B(e);if(!n)return null;t=n.configFile;let r=d.rawConfigSchema.parse(n.config);if(r.registries){for(let e of Object.keys(r.registries))if(e in H)throw Error(`"${e}" is a built-in registry and cannot be overridden.`)}return r}catch(n){let r=t??`${e}/${R}`;throw n instanceof Error&&n.message.includes(`reserved registry`)?n:Error(`Invalid configuration found in ${l.default.cyan(r)}.`)}}function K(e){let t={resolvedPaths:{cwd:process.cwd(),tailwindConfig:``,tailwindCss:``,utils:``,components:``,ui:``,lib:``,hooks:``},style:``,tailwind:{config:``,css:``,baseColor:``,cssVariables:!1},rsc:!1,tsx:!0,aliases:{components:``,utils:``},registries:{...H}};return e?{...t,...e,resolvedPaths:{...t.resolvedPaths,...e.resolvedPaths??{}},tailwind:{...t.tailwind,...e.tailwind??{}},aliases:{...t.aliases,...e.aliases??{}},registries:{...t.registries,...e.registries??{}}}:t}var fe=e.t({BUILTIN_REGISTRIES:()=>H,DEFAULT_COMPONENTS:()=>N,DEFAULT_STYLE:()=>M,DEFAULT_TAILWIND_BASE_COLOR:()=>L,DEFAULT_TAILWIND_CONFIG:()=>I,DEFAULT_TAILWIND_CSS:()=>F,DEFAULT_UTILS:()=>P,createRegistryConfig:()=>K,default:()=>$,extractComponentsFromRegistry:()=>Q,getRawConfig:()=>G,getRegistryConfig:()=>V,registryItemToComponent:()=>X,registryItemsToComponents:()=>Z,resolveConfigPaths:()=>U,toDependencyRecord:()=>J});const q=new Set([`block`,`component`,`ui`,`page`]),pe=new Set([`lib`,`block`,`component`,`ui`,`hook`,`theme`,`page`,`file`,`style`,`base`,`font`,`item`]);function J(e){if(!e?.length)return;let t={};for(let n of e){let e=n.lastIndexOf(`@`);e>0?t[n.slice(0,e)]=n.slice(e+1)||`*`:t[n]=`*`}return t}function Y(e){return e.startsWith(`registry:`)?e.slice(9):e}function me(e){if(!e)return;let t=Y(e);return q.has(t)?t:void 0}function he(e){if(!e)return;let t=Y(e);return pe.has(t)?t:void 0}function ge(e){if(!e?.length)return;let t=[];for(let n of e){if(typeof n==`string`){t.push({path:n,type:`file`});continue}if(!n||typeof n!=`object`)continue;let e=n;if(!e.path)continue;let r=he(e.type)??`file`;t.push({path:e.path,type:r,...e.content?{content:e.content}:{},...e.target?{target:e.target}:{}})}return t.length>0?t:void 0}function X(e){let t=[e.description,e.docs].filter(e=>!!e?.trim()).join(`
|
|
4
|
+
|
|
5
|
+
`),n=me(e.type),r=ge(e.files),i=J(e.dependencies),a=J(e.devDependencies),o=J(e.registryDependencies);return{name:e.name,title:e.title?.trim()||e.name,...n?{type:n}:{},...e.categories?.[0]?{category:e.categories[0]}:{},...e.categories?.length?{tags:[...e.categories]}:{},...t?{description:t}:{},...i?{dependencies:i}:{},...a?{devDependencies:a}:{},...o?{registryDependencies:o}:{},...r?{files:r}:{}}}function Z(e){if(!e?.length)return{};let t={};for(let n of e)n?.name&&(t[n.name]=X(n));return t}function _e(e){return(0,i.existsSync)(e)&&(0,i.statSync)(e).isFile()?{cwd:(0,a.dirname)(e),registryFile:(0,a.basename)(e)}:{cwd:e}}async function Q(e){try{return Z((await(0,o.loadRegistry)(_e(e))).items)}catch{return{}}}var $=(0,n.definePlugin)((e={})=>({name:`shadcn:extract`,extract:async n=>{if(n.components&&Object.keys(n.components).length>0)return n;let i=e.configFile;if(!i){let{cwd:e}=(0,t.useExecution)();i=(0,r.joinPaths)(e,`registry.json`)}let a=await Q(i);return{...n,components:a}}}));Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return U}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return I}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return F}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return V}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return G}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return X}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return K}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return $}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return J}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return H}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return L}});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{t as e}from"./rolldown-runtime-DK3Fl9T5.mjs";import{useExecution as t}from"@power-plant/core";import{definePlugin as n}from"@razorwind/core/plugin";import{joinPaths as r}from"@stryke/path/join";import{existsSync as i,statSync as a}from"node:fs";import o,{basename as s,dirname as c}from"node:path";import{loadRegistry as l}from"shadcn/registry";import{loadTsConfig as u}from"@stryke/fs/tsconfig";import{loadConfig as d}from"c12";import f from"chalk";import ee from"fast-glob";import{configSchema as p,rawConfigSchema as m}from"shadcn/schema";import"shadcn/preset";import{readJsonFile as h}from"@stryke/fs/json";import{readFile as g}from"@stryke/fs/read-file";import{z as _}from"zod";import"@stryke/http/fetch";import"@stryke/url/helpers";import{getWorkspaceRoot as v}from"@stryke/fs/get-workspace-root";import{createMatchPath as te}from"tsconfig-paths";import{isAbsolute as ne}from"@stryke/path/is-type";const y=process.env.REGISTRY_URL??`https://ui.shadcn.com/r`,b=y.replace(/\/r\/?$/,``);`${b}`,`${b}`,`${b}`,`${b}`,`${b}`,`${b}`,`${b}`,`${b}`,`${b}`,`${b}`,`${b}`;function x(e){let t=[e];for(;t.length;){let e=t.shift();if(typeof e==`string`){if(e.startsWith(`./`))return e;continue}if(Array.isArray(e)){t.unshift(...e);continue}e&&typeof e==`object`&&t.unshift(...Object.values(e))}return null}function S(e){if(!e.includes(`*`))return`strip_extension`;let t=e.slice(e.indexOf(`*`)+1);return t&&/^\.[^/]+$/.test(t)?`strip_extension`:`preserve_extension`}function C(e,t){let n=t.find(t=>!t.hasWildcard&&t.key===e);if(n)return{path:o.resolve(n.rootDir,n.target),matchedAlias:n.key,matchedTarget:n.target,emitMode:n.emitMode};let r=t.filter(e=>e.hasWildcard).sort((e,t)=>t.key.length-e.key.length);for(let t of r){let n=w(e,t.key,{allowBareAliasBase:!0});if(n!==null)return{path:o.resolve(t.rootDir,T(t.target,n)),matchedAlias:t.key,matchedTarget:t.target,emitMode:t.emitMode}}return null}function w(e,t,n={}){if(!t.includes(`*`))return e===t?``:null;let[r,i=``]=t.split(`*`);return r&&e.startsWith(r)&&e.endsWith(i)?i?e.slice(r.length,-i.length):e.slice(r.length):n.allowBareAliasBase&&i===``&&r&&r.endsWith(`/`)&&e===r.slice(0,-1)?``:null}function T(e,t){if(!e.includes(`*`))return e;let[n,r=``]=e.split(`*`);return t?n?`${n}${t}${r}`:t:n?n.replace(/\/$/,``):``}const E=new Map;async function re(e){let t=o.resolve(e),n=E.get(t);if(n)return n;let r=(await D(e))?.imports;if(!r||typeof r!=`object`||Array.isArray(r))return E.set(t,[]),[];let i=[];for(let[e,n]of Object.entries(r)){if(!e.startsWith(`#`))continue;let r=x(n);r&&i.push({key:e,aliasBase:e===`#*`?`#`:e.endsWith(`/*`)?e.slice(0,-2):e,target:r,emitMode:S(r),hasWildcard:e.includes(`*`),rootDir:t})}return E.set(t,i),i}async function ie(e,t){return C(e,await re(t))}async function D(e=``){return h(o.join(e,`package.json`))}_.object({compilerOptions:_.object({paths:_.record(_.string(),_.string().or(_.array(_.string())))})});function ae(e){if(e.startsWith(`#`)||e.startsWith(`.`)||ne(e))return null;let t=e.split(`/`);return e.startsWith(`@`)?t.length<2?null:{packageName:`${t[0]}/${t[1]}`}:{packageName:t[0]}}const O=new Map,k=new Map;function oe(e){let t=[],n=!1,r=0;for(let i of e.split(`
|
|
2
|
+
`)){let e=i.trim();if(!e||e.startsWith(`#`))continue;let a=i.match(/^(\s*)([\w-]+)\s*:/);if(a){r=a[1]?.length??0,n=a[2]===`packages`;continue}if(!n)continue;let o=i.match(/^(\s*)-\s*(.+?)\s*(?:#.*)?$/);((!o||o[1]?.length)??r>=0)||t.push(o[2]?.trim().replace(/^["']|["']$/g,``)??``)}return t}async function se(e){let t=[],n=o.resolve(e,`pnpm-workspace.yaml`);if(i(n)){let e=await g(n);t.push(...oe(e))}let a=r(e,`package.json`);if(i(a))try{let e=(await h(a)).workspaces,n=Array.isArray(e)?e:e?.packages;Array.isArray(n)&&t.push(...n.filter(e=>!e.startsWith(`!`)))}catch{}return Array.from(new Set(t))}async function ce(e){let t=await se(e),n=new Map;if(!t.length)return n;let r=await ee(t.map(e=>o.posix.join(e.split(o.sep).join(`/`),`package.json`)),{cwd:e,ignore:[`**/node_modules/**`]});for(let t of r){let r=o.resolve(e,o.dirname(t)),i=(await D(r))?.name;i&&n.set(i,{packageName:i,packageRoot:r})}return n}async function le(e,t){let n=v(e);if(!n)return null;let r=O.get(n);if(r?.has(t))return r.get(t)??null;let i=await ce(n);return O.set(n,i),i.get(t)??null}function ue(e,t){if(t===`.`)return e;let n=t.slice(2).replace(/\/\*$/,``);return n?`${e}/${n}`:e}async function de(e){let t=`${e.packageRoot}:${e.packageName}`,n=k.get(t);if(n)return n;let r=(await D(e.packageRoot))?.exports;if(!r||typeof r!=`object`||Array.isArray(r))return k.set(t,[]),[];let i=[];for(let[t,n]of Object.entries(r)){if(t!==`.`&&!t.startsWith(`./`))continue;let r=x(n);if(!r)continue;let a=ue(e.packageName,t);i.push({key:t.includes(`*`)?`${a}/*`:a,aliasBase:a,target:r,emitMode:S(r),hasWildcard:t.includes(`*`),rootDir:e.packageRoot})}return k.set(t,i),i}async function fe(e,t){let n=ae(e);if(!n?.packageName)return null;let r=await le(t,n.packageName);return r?C(e,await de(r)):null}async function pe(e,t){let n=t.cwd??t.baseUrl??v();if(e.startsWith(`#`)){let t=await ie(e,n);if(t)return{path:t.path,source:`package_imports`,matchedAlias:t.matchedAlias,matchedTarget:t.matchedTarget,emitMode:t.emitMode}}let r=await fe(e,n);return r?{path:r.path,source:`workspace_package_exports`,matchedAlias:r.matchedAlias,matchedTarget:r.matchedTarget,emitMode:r.emitMode}:j(e,t)}function A(e){return/^@[^/]+\/[^/]+(?:\/.*)?$/.test(e)}function j(e,t){let n=te(t.baseUrl||t.cwd||v(),t.paths??{})(e,void 0,()=>!0,[`.ts`,`.tsx`,`.jsx`,`.js`,`.css`]);if(!n)return null;let r=M(e,t.paths??{});return!r&&A(e)?null:{path:n,source:`tsconfig_paths`,matchedAlias:r?.key??e,matchedTarget:r?.target??n,emitMode:`strip_extension`}}function M(e,t){for(let[n,r]of Object.entries(t)){let t=Array.isArray(r)?r:[r],i=w(e,n);if(i!==null)return{key:n,target:t[0]?.includes(`*`)&&i!==null?t[0].replace(/\*/g,i):t[0]}}return null}const N=`default`,P=`@/components`,F=`@/lib/utils`,I=`app/globals.css`,L=`tailwind.config.js`,R=`slate`,z=`components.json`,B={configFile:z,dotenv:!1,envName:!1,packageJson:!1,rcFile:!1,extend:!1};async function me(e){let t=e;for(;;){let e=await d({cwd:t,...B});if(e._configFile)return e;let n=o.dirname(t);if(n===t)return null;t=n}}async function V(e){let t=await G(e);return t?(t.iconLibrary||=t.style===`new-york`?`radix`:`lucide`,U(e,t)):null}const H={"@shadcn":`${y}/styles/{style}/{name}.json`};async function U(e,t){t.registries={...H,...t.registries??{}};let n=await u(e);if(!n)throw Error(`Failed to load tsconfig.json.`);let r=await W(`utils`,t.aliases.utils,e,n),i=await W(`components`,t.aliases.components,e,n),a=t.aliases.ui?await W(`ui`,t.aliases.ui,e,n):o.resolve(i??e,`ui`),s=t.aliases.lib?await W(`lib`,t.aliases.lib,e,n):o.resolve(r??e,`..`),c=t.aliases.hooks?await W(`hooks`,t.aliases.hooks,e,n):o.resolve(i??e,`..`,`hooks`);return he(e,{components:i,utils:r,ui:a,lib:s,hooks:c}),p.parse({...t,resolvedPaths:{cwd:e,tailwindConfig:t.tailwind.config?o.resolve(e,t.tailwind.config):``,tailwindCss:o.resolve(e,t.tailwind.css),utils:r,components:i,ui:a,lib:s,hooks:c}})}async function W(e,t,n,i){let a=await pe(t,{...i,cwd:n});if(!a?.path||t.startsWith(`#`)&&a.path===r(n,t))return null;if(e!==`utils`&&(a.source===`package_imports`||a.source===`workspace_package_exports`)){if(!a.matchedAlias.includes(`*`)&&/\/index\.[^/]+$/.test(a.path))return o.dirname(a.path);if(a.matchedAlias.includes(`*`)&&/\.[^/]+$/.test(a.path))return a.path.replace(/\.[^/]+$/,``)}return a.path}function he(e,t){let n=[`components`,`ui`,`lib`,`hooks`,`utils`].filter(e=>!t[e]);if(n.length)throw Error([`Could not resolve the following aliases in ${f.cyan(e)}: ${f.cyan(n.join(`, `))}.`,`Configure path aliases in ${f.cyan(`tsconfig.json`)} or imports in ${f.cyan(`package.json`)} for this workspace and try again.`].join(`
|
|
3
|
+
`))}async function G(e){let t;try{let n=await me(e);if(!n)return null;t=n.configFile;let r=m.parse(n.config);if(r.registries){for(let e of Object.keys(r.registries))if(e in H)throw Error(`"${e}" is a built-in registry and cannot be overridden.`)}return r}catch(n){let r=t??`${e}/${z}`;throw n instanceof Error&&n.message.includes(`reserved registry`)?n:Error(`Invalid configuration found in ${f.cyan(r)}.`)}}function K(e){let t={resolvedPaths:{cwd:process.cwd(),tailwindConfig:``,tailwindCss:``,utils:``,components:``,ui:``,lib:``,hooks:``},style:``,tailwind:{config:``,css:``,baseColor:``,cssVariables:!1},rsc:!1,tsx:!0,aliases:{components:``,utils:``},registries:{...H}};return e?{...t,...e,resolvedPaths:{...t.resolvedPaths,...e.resolvedPaths??{}},tailwind:{...t.tailwind,...e.tailwind??{}},aliases:{...t.aliases,...e.aliases??{}},registries:{...t.registries,...e.registries??{}}}:t}var ge=e({BUILTIN_REGISTRIES:()=>H,DEFAULT_COMPONENTS:()=>P,DEFAULT_STYLE:()=>N,DEFAULT_TAILWIND_BASE_COLOR:()=>R,DEFAULT_TAILWIND_CONFIG:()=>L,DEFAULT_TAILWIND_CSS:()=>I,DEFAULT_UTILS:()=>F,createRegistryConfig:()=>K,default:()=>$,extractComponentsFromRegistry:()=>Q,getRawConfig:()=>G,getRegistryConfig:()=>V,registryItemToComponent:()=>X,registryItemsToComponents:()=>Z,resolveConfigPaths:()=>U,toDependencyRecord:()=>q});const _e=new Set([`block`,`component`,`ui`,`page`]),ve=new Set([`lib`,`block`,`component`,`ui`,`hook`,`theme`,`page`,`file`,`style`,`base`,`font`,`item`]);function q(e){if(!e?.length)return;let t={};for(let n of e){let e=n.lastIndexOf(`@`);e>0?t[n.slice(0,e)]=n.slice(e+1)||`*`:t[n]=`*`}return t}function J(e){return e.startsWith(`registry:`)?e.slice(9):e}function ye(e){if(!e)return;let t=J(e);return _e.has(t)?t:void 0}function be(e){if(!e)return;let t=J(e);return ve.has(t)?t:void 0}function Y(e){if(!e?.length)return;let t=[];for(let n of e){if(typeof n==`string`){t.push({path:n,type:`file`});continue}if(!n||typeof n!=`object`)continue;let e=n;if(!e.path)continue;let r=be(e.type)??`file`;t.push({path:e.path,type:r,...e.content?{content:e.content}:{},...e.target?{target:e.target}:{}})}return t.length>0?t:void 0}function X(e){let t=[e.description,e.docs].filter(e=>!!e?.trim()).join(`
|
|
4
|
+
|
|
5
|
+
`),n=ye(e.type),r=Y(e.files),i=q(e.dependencies),a=q(e.devDependencies),o=q(e.registryDependencies);return{name:e.name,title:e.title?.trim()||e.name,...n?{type:n}:{},...e.categories?.[0]?{category:e.categories[0]}:{},...e.categories?.length?{tags:[...e.categories]}:{},...t?{description:t}:{},...i?{dependencies:i}:{},...a?{devDependencies:a}:{},...o?{registryDependencies:o}:{},...r?{files:r}:{}}}function Z(e){if(!e?.length)return{};let t={};for(let n of e)n?.name&&(t[n.name]=X(n));return t}function xe(e){return i(e)&&a(e).isFile()?{cwd:c(e),registryFile:s(e)}:{cwd:e}}async function Q(e){try{return Z((await l(xe(e))).items)}catch{return{}}}var $=n((e={})=>({name:`shadcn:extract`,extract:async n=>{if(n.components&&Object.keys(n.components).length>0)return n;let i=e.configFile;if(!i){let{cwd:e}=t();i=r(e,`registry.json`)}let a=await Q(i);return{...n,components:a}}}));export{U as _,Z as a,P as c,L as d,I as f,V as g,G as h,X as i,N as l,K as m,$ as n,q as o,F as p,ge as r,H as s,Q as t,R as u};
|
|
6
|
+
//# sourceMappingURL=extract-DBbCwIGB.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract-DBbCwIGB.mjs","names":[],"sources":[],"mappings":""}
|
package/dist/extract.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./extract-D6s-xjEv.cjs");exports.BUILTIN_REGISTRIES=e.s,exports.DEFAULT_COMPONENTS=e.c,exports.DEFAULT_STYLE=e.l,exports.DEFAULT_TAILWIND_BASE_COLOR=e.u,exports.DEFAULT_TAILWIND_CONFIG=e.d,exports.DEFAULT_TAILWIND_CSS=e.f,exports.DEFAULT_UTILS=e.p,exports.createRegistryConfig=e.m,exports.default=e.n,exports.extractComponentsFromRegistry=e.t,exports.getRawConfig=e.h,exports.getRegistryConfig=e.g,exports.registryItemToComponent=e.i,exports.registryItemsToComponents=e.a,exports.resolveConfigPaths=e._,exports.toDependencyRecord=e.o;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { t as ShadcnExtractPluginOptions } from "./types-Jkebh8QA.cjs";
|
|
2
|
+
import { S as ShadcnWorkspaceConfig, _ as getRegistryConfig, a as registryItemsToComponents, b as ShadcnRawConfig, c as DEFAULT_COMPONENTS, d as DEFAULT_TAILWIND_CONFIG, f as DEFAULT_TAILWIND_CSS, g as getRawConfig, h as createRegistryConfig, i as registryItemToComponent, l as DEFAULT_STYLE, m as RegistryConfig, n as extractComponentsFromRegistry, o as toDependencyRecord, p as DEFAULT_UTILS, s as BUILTIN_REGISTRIES, t as _default, u as DEFAULT_TAILWIND_BASE_COLOR, v as resolveConfigPaths, x as ShadcnRegistryConfig, y as ShadcnConfig } from "./extract-CHhbobiJ.cjs";
|
|
3
|
+
export { BUILTIN_REGISTRIES, DEFAULT_COMPONENTS, DEFAULT_STYLE, DEFAULT_TAILWIND_BASE_COLOR, DEFAULT_TAILWIND_CONFIG, DEFAULT_TAILWIND_CSS, DEFAULT_UTILS, type RegistryConfig, type ShadcnConfig, type ShadcnExtractPluginOptions, type ShadcnRawConfig, type ShadcnRegistryConfig, type ShadcnWorkspaceConfig, createRegistryConfig, _default as default, extractComponentsFromRegistry, getRawConfig, getRegistryConfig, registryItemToComponent, registryItemsToComponents, resolveConfigPaths, toDependencyRecord };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { S as ShadcnWorkspaceConfig, _ as getRegistryConfig, a as registryItemsToComponents, b as ShadcnRawConfig, c as DEFAULT_COMPONENTS, d as DEFAULT_TAILWIND_CONFIG, f as DEFAULT_TAILWIND_CSS, g as getRawConfig, h as createRegistryConfig, i as registryItemToComponent, l as DEFAULT_STYLE, m as RegistryConfig, n as extractComponentsFromRegistry, o as toDependencyRecord, p as DEFAULT_UTILS, s as BUILTIN_REGISTRIES, t as _default, u as DEFAULT_TAILWIND_BASE_COLOR, v as resolveConfigPaths, x as ShadcnRegistryConfig, y as ShadcnConfig } from "./extract-CdEg5hNq.mjs";
|
|
2
|
+
import { t as ShadcnExtractPluginOptions } from "./types-BH0MT5Wk.mjs";
|
|
3
|
+
export { BUILTIN_REGISTRIES, DEFAULT_COMPONENTS, DEFAULT_STYLE, DEFAULT_TAILWIND_BASE_COLOR, DEFAULT_TAILWIND_CONFIG, DEFAULT_TAILWIND_CSS, DEFAULT_UTILS, type RegistryConfig, type ShadcnConfig, type ShadcnExtractPluginOptions, type ShadcnRawConfig, type ShadcnRegistryConfig, type ShadcnWorkspaceConfig, createRegistryConfig, _default as default, extractComponentsFromRegistry, getRawConfig, getRegistryConfig, registryItemToComponent, registryItemsToComponents, resolveConfigPaths, toDependencyRecord };
|
package/dist/extract.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{_ as e,a as t,c as n,d as r,f as i,g as a,h as o,i as s,l as c,m as l,n as u,o as d,p as f,s as p,t as m,u as h}from"./extract-DBbCwIGB.mjs";export{p as BUILTIN_REGISTRIES,n as DEFAULT_COMPONENTS,c as DEFAULT_STYLE,h as DEFAULT_TAILWIND_BASE_COLOR,r as DEFAULT_TAILWIND_CONFIG,i as DEFAULT_TAILWIND_CSS,f as DEFAULT_UTILS,l as createRegistryConfig,u as default,m as extractComponentsFromRegistry,o as getRawConfig,a as getRegistryConfig,s as registryItemToComponent,t as registryItemsToComponents,e as resolveConfigPaths,d as toDependencyRecord};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./rolldown-runtime-DWNI8pZO.cjs");let t=require("@power-plant/core"),n=require("@razorwind/core/plugin"),r=require("@stryke/path/join"),i=require("@razorwind/core/utils");var a=e.t({componentToRegistryItem:()=>u,componentsToRegistryItems:()=>d,default:()=>h,fromDependencyRecord:()=>o,generateRegistryJson:()=>m,renderRegistryJson:()=>f});function o(e){if(!(!e||Object.keys(e).length===0))return Object.entries(e).map(([e,t])=>!t||t===`*`?e:`${e}@${t}`)}function s(e){switch(e){case`block`:case`component`:case`ui`:case`page`:return`registry:${e}`;default:return`registry:component`}}function c(e){return`registry:${e}`}function l(e){if(e?.length)return e.map(e=>{let t=c(e.type),n={path:e.path,type:t};return e.content&&(n.content=e.content),e.target?n.target=e.target:(t===`registry:file`||t===`registry:page`)&&(n.target=e.path),n})}function u(e){let t=e.tags?.length?[...e.tags]:e.category?[e.category]:void 0,n=o(e.dependencies),r=o(e.devDependencies),i=o(e.registryDependencies),a=l(e.files);return{name:e.name,type:s(e.type),...e.title?{title:e.title}:{},...e.description?{description:e.description}:{},...t?{categories:t}:{},...n?{dependencies:n}:{},...r?{devDependencies:r}:{},...i?{registryDependencies:i}:{},...a?{files:a}:{}}}function d(e){return!e||Object.keys(e).length===0?[]:Object.values(e).filter(e=>!!e?.name).map(u).toSorted((e,t)=>e.name.localeCompare(t.name))}function f(e,t={}){let n={$schema:`https://ui.shadcn.com/schema/registry.json`,items:d(e)};return t.name&&(n.name=t.name),t.homepage&&(n.homepage=t.homepage),n}async function p(e){if(e.configFile)return e.configFile;let{cwd:n}=(0,t.useExecution)();return(0,r.joinPaths)(n,`registry.json`)}async function m(e,t={}){if(!e.components||Object.keys(e.components).length===0)return{};let n=await p(t),r=`${JSON.stringify(f(e.components,t),null,2)}\n`;return{[n]:(0,i.createDocument)(n,r,{name:`shadcn:generate`},`json`)}}var h=(0,n.definePlugin)((e={})=>({name:`shadcn:generate`,generate:async t=>m(t,e)}));exports.componentToRegistryItem=u,exports.componentsToRegistryItems=d,exports.default=h,exports.fromDependencyRecord=o,exports.generateRegistryJson=m,exports.renderRegistryJson=f,Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return a}});
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { n as ShadcnGeneratePluginOptions, r as __exportAll } from "./types-Jkebh8QA.cjs";
|
|
2
|
+
import { Component, Components, Schema } from "@razorwind/core/schema";
|
|
3
|
+
import { GeneratorFunctionResult } from "@power-plant/core";
|
|
4
|
+
declare namespace generate_d_exports {
|
|
5
|
+
export { RegistryDocument, RegistryFileLike, RegistryItemLike, ShadcnGeneratePluginOptions, componentToRegistryItem, componentsToRegistryItems, _default as default, fromDependencyRecord, generateRegistryJson, renderRegistryJson };
|
|
6
|
+
}
|
|
7
|
+
type RegistryItemType = "registry:block" | "registry:component" | "registry:ui" | "registry:page";
|
|
8
|
+
type RegistryFileType = "registry:lib" | "registry:block" | "registry:component" | "registry:ui" | "registry:hook" | "registry:theme" | "registry:page" | "registry:file" | "registry:style" | "registry:base" | "registry:font" | "registry:item";
|
|
9
|
+
interface RegistryFileLike {
|
|
10
|
+
path: string;
|
|
11
|
+
type: RegistryFileType;
|
|
12
|
+
content?: string;
|
|
13
|
+
target?: string;
|
|
14
|
+
}
|
|
15
|
+
interface RegistryItemLike {
|
|
16
|
+
name: string;
|
|
17
|
+
title?: string;
|
|
18
|
+
type: RegistryItemType;
|
|
19
|
+
description?: string;
|
|
20
|
+
categories?: string[];
|
|
21
|
+
dependencies?: string[];
|
|
22
|
+
devDependencies?: string[];
|
|
23
|
+
registryDependencies?: string[];
|
|
24
|
+
files?: RegistryFileLike[];
|
|
25
|
+
}
|
|
26
|
+
interface RegistryDocument {
|
|
27
|
+
$schema: string;
|
|
28
|
+
name?: string;
|
|
29
|
+
homepage?: string;
|
|
30
|
+
items: RegistryItemLike[];
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Convert a name → version record back into npm-style dependency strings.
|
|
34
|
+
* Versions of `*` omit the `@version` suffix.
|
|
35
|
+
*/
|
|
36
|
+
declare function fromDependencyRecord(deps: Record<string, string> | undefined): string[] | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Map a Razorwind {@link Component} into a shadcn registry item.
|
|
39
|
+
*/
|
|
40
|
+
declare function componentToRegistryItem(component: Component): RegistryItemLike;
|
|
41
|
+
/**
|
|
42
|
+
* Convert a `schema.components` record into a shadcn registry `items` list.
|
|
43
|
+
*/
|
|
44
|
+
declare function componentsToRegistryItems(components: Components | undefined): RegistryItemLike[];
|
|
45
|
+
/**
|
|
46
|
+
* Build a shadcn `registry.json` document from schema components.
|
|
47
|
+
*/
|
|
48
|
+
declare function renderRegistryJson(components: Components | undefined, options?: Pick<ShadcnGeneratePluginOptions, "name" | "homepage">): RegistryDocument;
|
|
49
|
+
/**
|
|
50
|
+
* Generate a shadcn `registry.json` file from a Razorwind schema.
|
|
51
|
+
*/
|
|
52
|
+
declare function generateRegistryJson(spec: Schema, options?: ShadcnGeneratePluginOptions): Promise<GeneratorFunctionResult<Schema, ShadcnGeneratePluginOptions>>;
|
|
53
|
+
/**
|
|
54
|
+
* Razorwind plugin: generate a shadcn `registry.json` from schema components.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* import { defineConfig } from "@razorwind/core";
|
|
59
|
+
* import shadcn from "@razorwind/shadcn/generate";
|
|
60
|
+
*
|
|
61
|
+
* export default defineConfig({
|
|
62
|
+
* plugins: [shadcn({ name: "acme", homepage: "https://acme.com" })]
|
|
63
|
+
* });
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
declare const _default: any;
|
|
67
|
+
//#endregion
|
|
68
|
+
export { RegistryDocument, RegistryFileLike, RegistryItemLike, type ShadcnGeneratePluginOptions, componentToRegistryItem, componentsToRegistryItems, _default as default, fromDependencyRecord, generateRegistryJson, renderRegistryJson, generate_d_exports as t };
|
|
69
|
+
//# sourceMappingURL=generate.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.d.cts","names":[],"sources":["../src/generate.ts"],"mappings":";;;;;;KAmCK;KAMA;UAcY;EACf;EACA,MAAM;EACN;EACA;;UAGe;EACf;EACA;EACA,MAAM;EACN;EACA;EACA;EACA;EACA;EACA,QAAQ;;UAGO;EACf;EACA;EACA;EACA,OAAO;;;;;;iBAOO,qBACd,MAAM;;;;iBA6DQ,wBAAwB,WAAW,YAAY;;;;iBA8B/C,0BACd,YAAY,yBACX;;;;iBAca,mBACd,YAAY,wBACZ,UAAS,KAAK,oDACb;;;;iBAgCmB,qBACpB,MAAM,QACN,UAAS,8BACR,QAAQ,wBAAwB,QAAQ"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { n as ShadcnGeneratePluginOptions } from "./types-BH0MT5Wk.mjs";
|
|
2
|
+
import { GeneratorFunctionResult } from "@power-plant/core";
|
|
3
|
+
import { Component, Components, Schema } from "@razorwind/core/schema";
|
|
4
|
+
declare namespace generate_d_exports {
|
|
5
|
+
export { RegistryDocument, RegistryFileLike, RegistryItemLike, ShadcnGeneratePluginOptions, componentToRegistryItem, componentsToRegistryItems, _default as default, fromDependencyRecord, generateRegistryJson, renderRegistryJson };
|
|
6
|
+
}
|
|
7
|
+
type RegistryItemType = "registry:block" | "registry:component" | "registry:ui" | "registry:page";
|
|
8
|
+
type RegistryFileType = "registry:lib" | "registry:block" | "registry:component" | "registry:ui" | "registry:hook" | "registry:theme" | "registry:page" | "registry:file" | "registry:style" | "registry:base" | "registry:font" | "registry:item";
|
|
9
|
+
interface RegistryFileLike {
|
|
10
|
+
path: string;
|
|
11
|
+
type: RegistryFileType;
|
|
12
|
+
content?: string;
|
|
13
|
+
target?: string;
|
|
14
|
+
}
|
|
15
|
+
interface RegistryItemLike {
|
|
16
|
+
name: string;
|
|
17
|
+
title?: string;
|
|
18
|
+
type: RegistryItemType;
|
|
19
|
+
description?: string;
|
|
20
|
+
categories?: string[];
|
|
21
|
+
dependencies?: string[];
|
|
22
|
+
devDependencies?: string[];
|
|
23
|
+
registryDependencies?: string[];
|
|
24
|
+
files?: RegistryFileLike[];
|
|
25
|
+
}
|
|
26
|
+
interface RegistryDocument {
|
|
27
|
+
$schema: string;
|
|
28
|
+
name?: string;
|
|
29
|
+
homepage?: string;
|
|
30
|
+
items: RegistryItemLike[];
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Convert a name → version record back into npm-style dependency strings.
|
|
34
|
+
* Versions of `*` omit the `@version` suffix.
|
|
35
|
+
*/
|
|
36
|
+
declare function fromDependencyRecord(deps: Record<string, string> | undefined): string[] | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Map a Razorwind {@link Component} into a shadcn registry item.
|
|
39
|
+
*/
|
|
40
|
+
declare function componentToRegistryItem(component: Component): RegistryItemLike;
|
|
41
|
+
/**
|
|
42
|
+
* Convert a `schema.components` record into a shadcn registry `items` list.
|
|
43
|
+
*/
|
|
44
|
+
declare function componentsToRegistryItems(components: Components | undefined): RegistryItemLike[];
|
|
45
|
+
/**
|
|
46
|
+
* Build a shadcn `registry.json` document from schema components.
|
|
47
|
+
*/
|
|
48
|
+
declare function renderRegistryJson(components: Components | undefined, options?: Pick<ShadcnGeneratePluginOptions, "name" | "homepage">): RegistryDocument;
|
|
49
|
+
/**
|
|
50
|
+
* Generate a shadcn `registry.json` file from a Razorwind schema.
|
|
51
|
+
*/
|
|
52
|
+
declare function generateRegistryJson(spec: Schema, options?: ShadcnGeneratePluginOptions): Promise<GeneratorFunctionResult<Schema, ShadcnGeneratePluginOptions>>;
|
|
53
|
+
/**
|
|
54
|
+
* Razorwind plugin: generate a shadcn `registry.json` from schema components.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* import { defineConfig } from "@razorwind/core";
|
|
59
|
+
* import shadcn from "@razorwind/shadcn/generate";
|
|
60
|
+
*
|
|
61
|
+
* export default defineConfig({
|
|
62
|
+
* plugins: [shadcn({ name: "acme", homepage: "https://acme.com" })]
|
|
63
|
+
* });
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
declare const _default: any;
|
|
67
|
+
//#endregion
|
|
68
|
+
export { RegistryDocument, RegistryFileLike, RegistryItemLike, type ShadcnGeneratePluginOptions, componentToRegistryItem, componentsToRegistryItems, _default as default, fromDependencyRecord, generateRegistryJson, renderRegistryJson, generate_d_exports as t };
|
|
69
|
+
//# sourceMappingURL=generate.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.d.mts","names":[],"sources":["../src/generate.ts"],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{t as e}from"./rolldown-runtime-DK3Fl9T5.mjs";import{useExecution as t}from"@power-plant/core";import{definePlugin as n}from"@razorwind/core/plugin";import{joinPaths as r}from"@stryke/path/join";import{createDocument as i}from"@razorwind/core/utils";var a=e({componentToRegistryItem:()=>u,componentsToRegistryItems:()=>d,default:()=>h,fromDependencyRecord:()=>o,generateRegistryJson:()=>m,renderRegistryJson:()=>f});function o(e){if(!(!e||Object.keys(e).length===0))return Object.entries(e).map(([e,t])=>!t||t===`*`?e:`${e}@${t}`)}function s(e){switch(e){case`block`:case`component`:case`ui`:case`page`:return`registry:${e}`;default:return`registry:component`}}function c(e){return`registry:${e}`}function l(e){if(e?.length)return e.map(e=>{let t=c(e.type),n={path:e.path,type:t};return e.content&&(n.content=e.content),e.target?n.target=e.target:(t===`registry:file`||t===`registry:page`)&&(n.target=e.path),n})}function u(e){let t=e.tags?.length?[...e.tags]:e.category?[e.category]:void 0,n=o(e.dependencies),r=o(e.devDependencies),i=o(e.registryDependencies),a=l(e.files);return{name:e.name,type:s(e.type),...e.title?{title:e.title}:{},...e.description?{description:e.description}:{},...t?{categories:t}:{},...n?{dependencies:n}:{},...r?{devDependencies:r}:{},...i?{registryDependencies:i}:{},...a?{files:a}:{}}}function d(e){return!e||Object.keys(e).length===0?[]:Object.values(e).filter(e=>!!e?.name).map(u).toSorted((e,t)=>e.name.localeCompare(t.name))}function f(e,t={}){let n={$schema:`https://ui.shadcn.com/schema/registry.json`,items:d(e)};return t.name&&(n.name=t.name),t.homepage&&(n.homepage=t.homepage),n}async function p(e){if(e.configFile)return e.configFile;let{cwd:n}=t();return r(n,`registry.json`)}async function m(e,t={}){if(!e.components||Object.keys(e.components).length===0)return{};let n=await p(t),r=`${JSON.stringify(f(e.components,t),null,2)}\n`;return{[n]:i(n,r,{name:`shadcn:generate`},`json`)}}var h=n((e={})=>({name:`shadcn:generate`,generate:async t=>m(t,e)}));export{u as componentToRegistryItem,d as componentsToRegistryItems,h as default,o as fromDependencyRecord,m as generateRegistryJson,f as renderRegistryJson,a as t};
|
|
2
|
+
//# sourceMappingURL=generate.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.mjs","names":[],"sources":[],"mappings":""}
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1 @@
|
|
|
1
|
-
Object.
|
|
2
|
-
|
|
3
|
-
`),n=ne(e.type),r=D(e.files),i=T(e.dependencies),a=T(e.devDependencies),o=T(e.registryDependencies);return{name:e.name,title:e.title?.trim()||e.name,...n?{type:n}:{},...e.categories?.[0]?{category:e.categories[0]}:{},...e.categories?.length?{tags:[...e.categories]}:{},...t?{description:t}:{},...i?{dependencies:i}:{},...a?{devDependencies:a}:{},...o?{registryDependencies:o}:{},...r?{files:r}:{}}}function k(e){if(!e?.length)return{};let t={};for(let n of e)n?.name&&(t[n.name]=O(n));return t}function ie(e){return(0,d.existsSync)(e)&&(0,d.statSync)(e).isFile()?{cwd:(0,f.dirname)(e),registryFile:(0,f.basename)(e)}:{cwd:e}}async function A(e){try{return k((await(0,p.loadRegistry)(ie(e))).items)}catch{return{}}}const j=process.env.REGISTRY_URL??`https://ui.shadcn.com/r`,M=j.replace(/\/r\/?$/,``);`${M}`,`${M}`,`${M}`,`${M}`,`${M}`,`${M}`,`${M}`,`${M}`,`${M}`,`${M}`,`${M}`;function N(e){let t=[e];for(;t.length;){let e=t.shift();if(typeof e==`string`){if(e.startsWith(`./`))return e;continue}if(Array.isArray(e)){t.unshift(...e);continue}e&&typeof e==`object`&&t.unshift(...Object.values(e))}return null}function P(e){if(!e.includes(`*`))return`strip_extension`;let t=e.slice(e.indexOf(`*`)+1);return t&&/^\.[^/]+$/.test(t)?`strip_extension`:`preserve_extension`}function F(e,t){let n=t.find(t=>!t.hasWildcard&&t.key===e);if(n)return{path:f.default.resolve(n.rootDir,n.target),matchedAlias:n.key,matchedTarget:n.target,emitMode:n.emitMode};let r=t.filter(e=>e.hasWildcard).sort((e,t)=>t.key.length-e.key.length);for(let t of r){let n=I(e,t.key,{allowBareAliasBase:!0});if(n!==null)return{path:f.default.resolve(t.rootDir,L(t.target,n)),matchedAlias:t.key,matchedTarget:t.target,emitMode:t.emitMode}}return null}function I(e,t,n={}){if(!t.includes(`*`))return e===t?``:null;let[r,i=``]=t.split(`*`);return r&&e.startsWith(r)&&e.endsWith(i)?i?e.slice(r.length,-i.length):e.slice(r.length):n.allowBareAliasBase&&i===``&&r&&r.endsWith(`/`)&&e===r.slice(0,-1)?``:null}function L(e,t){if(!e.includes(`*`))return e;let[n,r=``]=e.split(`*`);return t?n?`${n}${t}${r}`:t:n?n.replace(/\/$/,``):``}const R=new Map;async function z(e){let t=f.default.resolve(e),n=R.get(t);if(n)return n;let r=(await V(e))?.imports;if(!r||typeof r!=`object`||Array.isArray(r))return R.set(t,[]),[];let i=[];for(let[e,n]of Object.entries(r)){if(!e.startsWith(`#`))continue;let r=N(n);r&&i.push({key:e,aliasBase:e===`#*`?`#`:e.endsWith(`/*`)?e.slice(0,-2):e,target:r,emitMode:P(r),hasWildcard:e.includes(`*`),rootDir:t})}return R.set(t,i),i}async function B(e,t){return F(e,await z(t))}async function V(e=``){return(0,y.readJsonFile)(f.default.join(e,`package.json`))}x.z.object({compilerOptions:x.z.object({paths:x.z.record(x.z.string(),x.z.string().or(x.z.array(x.z.string())))})});function H(e){if(e.startsWith(`#`)||e.startsWith(`.`)||(0,te.isAbsolute)(e))return null;let t=e.split(`/`);return e.startsWith(`@`)?t.length<2?null:{packageName:`${t[0]}/${t[1]}`}:{packageName:t[0]}}const U=new Map,W=new Map;function G(e){let t=[],n=!1,r=0;for(let i of e.split(`
|
|
4
|
-
`)){let e=i.trim();if(!e||e.startsWith(`#`))continue;let a=i.match(/^(\s*)([\w-]+)\s*:/);if(a){r=a[1]?.length??0,n=a[2]===`packages`;continue}if(!n)continue;let o=i.match(/^(\s*)-\s*(.+?)\s*(?:#.*)?$/);((!o||o[1]?.length)??r>=0)||t.push(o[2]?.trim().replace(/^["']|["']$/g,``)??``)}return t}async function K(e){let t=[],n=f.default.resolve(e,`pnpm-workspace.yaml`);if((0,d.existsSync)(n)){let e=await(0,b.readFile)(n);t.push(...G(e))}let r=(0,u.joinPaths)(e,`package.json`);if((0,d.existsSync)(r))try{let e=(await(0,y.readJsonFile)(r)).workspaces,n=Array.isArray(e)?e:e?.packages;Array.isArray(n)&&t.push(...n.filter(e=>!e.startsWith(`!`)))}catch{}return Array.from(new Set(t))}async function q(e){let t=await K(e),n=new Map;if(!t.length)return n;let r=await(0,_.default)(t.map(e=>f.default.posix.join(e.split(f.default.sep).join(`/`),`package.json`)),{cwd:e,ignore:[`**/node_modules/**`]});for(let t of r){let r=f.default.resolve(e,f.default.dirname(t)),i=(await V(r))?.name;i&&n.set(i,{packageName:i,packageRoot:r})}return n}async function J(e,t){let n=(0,S.getWorkspaceRoot)(e);if(!n)return null;let r=U.get(n);if(r?.has(t))return r.get(t)??null;let i=await q(n);return U.set(n,i),i.get(t)??null}function ae(e,t){if(t===`.`)return e;let n=t.slice(2).replace(/\/\*$/,``);return n?`${e}/${n}`:e}async function oe(e){let t=`${e.packageRoot}:${e.packageName}`,n=W.get(t);if(n)return n;let r=(await V(e.packageRoot))?.exports;if(!r||typeof r!=`object`||Array.isArray(r))return W.set(t,[]),[];let i=[];for(let[t,n]of Object.entries(r)){if(t!==`.`&&!t.startsWith(`./`))continue;let r=N(n);if(!r)continue;let a=ae(e.packageName,t);i.push({key:t.includes(`*`)?`${a}/*`:a,aliasBase:a,target:r,emitMode:P(r),hasWildcard:t.includes(`*`),rootDir:e.packageRoot})}return W.set(t,i),i}async function se(e,t){let n=H(e);if(!n?.packageName)return null;let r=await J(t,n.packageName);return r?F(e,await oe(r)):null}async function ce(e,t){let n=t.cwd??t.baseUrl??(0,S.getWorkspaceRoot)();if(e.startsWith(`#`)){let t=await B(e,n);if(t)return{path:t.path,source:`package_imports`,matchedAlias:t.matchedAlias,matchedTarget:t.matchedTarget,emitMode:t.emitMode}}let r=await se(e,n);return r?{path:r.path,source:`workspace_package_exports`,matchedAlias:r.matchedAlias,matchedTarget:r.matchedTarget,emitMode:r.emitMode}:ue(e,t)}function le(e){return/^@[^/]+\/[^/]+(?:\/.*)?$/.test(e)}function ue(e,t){let n=(0,ee.createMatchPath)(t.baseUrl||t.cwd||(0,S.getWorkspaceRoot)(),t.paths??{})(e,void 0,()=>!0,[`.ts`,`.tsx`,`.jsx`,`.js`,`.css`]);if(!n)return null;let r=de(e,t.paths??{});return!r&&le(e)?null:{path:n,source:`tsconfig_paths`,matchedAlias:r?.key??e,matchedTarget:r?.target??n,emitMode:`strip_extension`}}function de(e,t){for(let[n,r]of Object.entries(t)){let t=Array.isArray(r)?r:[r],i=I(e,n);if(i!==null)return{key:n,target:t[0]?.includes(`*`)&&i!==null?t[0].replace(/\*/g,i):t[0]}}return null}const Y=`components.json`,fe={configFile:Y,dotenv:!1,envName:!1,packageJson:!1,rcFile:!1,extend:!1};async function pe(e){let t=e;for(;;){let e=await(0,h.loadConfig)({cwd:t,...fe});if(e._configFile)return e;let n=f.default.dirname(t);if(n===t)return null;t=n}}async function me(e){let t=await $(e);return t?(t.iconLibrary||=t.style===`new-york`?`radix`:`lucide`,Z(e,t)):null}const X={"@shadcn":`${j}/styles/{style}/{name}.json`};async function Z(e,t){t.registries={...X,...t.registries??{}};let n=await(0,m.loadTsConfig)(e);if(!n)throw Error(`Failed to load tsconfig.json.`);let r=await Q(`utils`,t.aliases.utils,e,n),i=await Q(`components`,t.aliases.components,e,n),a=t.aliases.ui?await Q(`ui`,t.aliases.ui,e,n):f.default.resolve(i??e,`ui`),o=t.aliases.lib?await Q(`lib`,t.aliases.lib,e,n):f.default.resolve(r??e,`..`),s=t.aliases.hooks?await Q(`hooks`,t.aliases.hooks,e,n):f.default.resolve(i??e,`..`,`hooks`);return he(e,{components:i,utils:r,ui:a,lib:o,hooks:s}),v.configSchema.parse({...t,resolvedPaths:{cwd:e,tailwindConfig:t.tailwind.config?f.default.resolve(e,t.tailwind.config):``,tailwindCss:f.default.resolve(e,t.tailwind.css),utils:r,components:i,ui:a,lib:o,hooks:s}})}async function Q(e,t,n,r){let i=await ce(t,{...r,cwd:n});if(!i?.path||t.startsWith(`#`)&&i.path===(0,u.joinPaths)(n,t))return null;if(e!==`utils`&&(i.source===`package_imports`||i.source===`workspace_package_exports`)){if(!i.matchedAlias.includes(`*`)&&/\/index\.[^/]+$/.test(i.path))return f.default.dirname(i.path);if(i.matchedAlias.includes(`*`)&&/\.[^/]+$/.test(i.path))return i.path.replace(/\.[^/]+$/,``)}return i.path}function he(e,t){let n=[`components`,`ui`,`lib`,`hooks`,`utils`].filter(e=>!t[e]);if(n.length)throw Error([`Could not resolve the following aliases in ${g.default.cyan(e)}: ${g.default.cyan(n.join(`, `))}.`,`Configure path aliases in ${g.default.cyan(`tsconfig.json`)} or imports in ${g.default.cyan(`package.json`)} for this workspace and try again.`].join(`
|
|
5
|
-
`))}async function $(e){let t;try{let n=await pe(e);if(!n)return null;t=n.configFile;let r=v.rawConfigSchema.parse(n.config);if(r.registries){for(let e of Object.keys(r.registries))if(e in X)throw Error(`"${e}" is a built-in registry and cannot be overridden.`)}return r}catch(n){let r=t??`${e}/${Y}`;throw n instanceof Error&&n.message.includes(`reserved registry`)?n:Error(`Invalid configuration found in ${g.default.cyan(r)}.`)}}function ge(e){let t={resolvedPaths:{cwd:process.cwd(),tailwindConfig:``,tailwindCss:``,utils:``,components:``,ui:``,lib:``,hooks:``},style:``,tailwind:{config:``,css:``,baseColor:``,cssVariables:!1},rsc:!1,tsx:!0,aliases:{components:``,utils:``},registries:{...X}};return e?{...t,...e,resolvedPaths:{...t.resolvedPaths,...e.resolvedPaths??{}},tailwind:{...t.tailwind,...e.tailwind??{}},aliases:{...t.aliases,...e.aliases??{}},registries:{...t.registries,...e.registries??{}}}:t}var _e=(0,l.definePlugin)((e={})=>({name:`razorwind-shadcn`,extract:async(t,n)=>{if(t.components&&Object.keys(t.components).length>0)return t;let r=e.configFile;if(!r){let{cwd:e}=(0,c.useExecution)();r=(0,u.joinPaths)(e,`registry.json`)}let i=await A(r);return{...t,components:i}}}));exports.BUILTIN_REGISTRIES=X,exports.DEFAULT_COMPONENTS=`@/components`,exports.DEFAULT_STYLE=`default`,exports.DEFAULT_TAILWIND_BASE_COLOR=`slate`,exports.DEFAULT_TAILWIND_CONFIG=`tailwind.config.js`,exports.DEFAULT_TAILWIND_CSS=`app/globals.css`,exports.DEFAULT_UTILS=`@/lib/utils`,exports.createRegistryConfig=ge,exports.default=_e,exports.extractComponentsFromRegistry=A,exports.getRawConfig=$,exports.getRegistryConfig=me,exports.registryItemToComponent=O,exports.registryItemsToComponents=k,exports.resolveConfigPaths=Z,exports.toDependencyRecord=T;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./extract-D6s-xjEv.cjs"),t=require("./generate.cjs");Object.defineProperty(exports,"extract",{enumerable:!0,get:function(){return e.r}}),Object.defineProperty(exports,"generate",{enumerable:!0,get:function(){return t.t}});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,185 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "
|
|
3
|
-
|
|
4
|
-
//#region src/extract.d.ts
|
|
5
|
-
type RegistryItemLike = {
|
|
6
|
-
name: string;
|
|
7
|
-
title?: string;
|
|
8
|
-
type?: string;
|
|
9
|
-
description?: string;
|
|
10
|
-
categories?: string[];
|
|
11
|
-
dependencies?: string[];
|
|
12
|
-
devDependencies?: string[];
|
|
13
|
-
registryDependencies?: string[];
|
|
14
|
-
files?: unknown[];
|
|
15
|
-
docs?: string;
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Convert npm-style dependency strings (`pkg`, `pkg@version`) into a
|
|
19
|
-
* name → version record.
|
|
20
|
-
*/
|
|
21
|
-
declare function toDependencyRecord(deps: string[] | undefined): Record<string, string> | undefined;
|
|
22
|
-
/**
|
|
23
|
-
* Map a single shadcn registry item into a Razorwind {@link Component}.
|
|
24
|
-
*/
|
|
25
|
-
declare function registryItemToComponent(item: RegistryItemLike): Component;
|
|
26
|
-
/**
|
|
27
|
-
* Convert a list of shadcn registry items into a `schema.components` record.
|
|
28
|
-
*/
|
|
29
|
-
declare function registryItemsToComponents(items: RegistryItemLike[] | undefined): Components;
|
|
30
|
-
/**
|
|
31
|
-
* Load a local `registry.json` and map its items into `schema.components`.
|
|
32
|
-
*
|
|
33
|
-
* Returns an empty record when the registry file is missing or unreadable.
|
|
34
|
-
*/
|
|
35
|
-
declare function extractComponentsFromRegistry(registryPath: string): Promise<Components>;
|
|
36
|
-
//#endregion
|
|
37
|
-
//#region src/registry/shadcn-types.d.ts
|
|
38
|
-
/**
|
|
39
|
-
* Infer a Zod 3 schema's output from `parse`'s return type.
|
|
40
|
-
*
|
|
41
|
-
* Avoids `z.infer` / `zod/v3` — this package depends on Zod 4 while shadcn's
|
|
42
|
-
* schemas are typed against Zod 3, and cross-version `infer` triggers
|
|
43
|
-
* "Type instantiation is excessively deep and possibly infinite".
|
|
44
|
-
*/
|
|
45
|
-
type InferShadcnSchema<T> = T extends {
|
|
46
|
-
parse: (...args: never[]) => infer Output;
|
|
47
|
-
} ? Output : never;
|
|
48
|
-
type ShadcnConfig = InferShadcnSchema<typeof configSchema>;
|
|
49
|
-
type ShadcnRawConfig = InferShadcnSchema<typeof rawConfigSchema>;
|
|
50
|
-
type ShadcnRegistryConfig = InferShadcnSchema<typeof registryConfigSchema>;
|
|
51
|
-
type ShadcnWorkspaceConfig = InferShadcnSchema<typeof workspaceConfigSchema>;
|
|
52
|
-
//#endregion
|
|
53
|
-
//#region src/registry/config.d.ts
|
|
54
|
-
declare const DEFAULT_STYLE = "default";
|
|
55
|
-
declare const DEFAULT_COMPONENTS = "@/components";
|
|
56
|
-
declare const DEFAULT_UTILS = "@/lib/utils";
|
|
57
|
-
declare const DEFAULT_TAILWIND_CSS = "app/globals.css";
|
|
58
|
-
declare const DEFAULT_TAILWIND_CONFIG = "tailwind.config.js";
|
|
59
|
-
declare const DEFAULT_TAILWIND_BASE_COLOR = "slate";
|
|
60
|
-
type RegistryConfig = ShadcnConfig;
|
|
61
|
-
declare function getRegistryConfig(cwd: string): Promise<{
|
|
62
|
-
tailwind: {
|
|
63
|
-
baseColor: string;
|
|
64
|
-
css: string;
|
|
65
|
-
cssVariables: boolean;
|
|
66
|
-
config?: string | undefined;
|
|
67
|
-
prefix?: string | undefined;
|
|
68
|
-
};
|
|
69
|
-
style: string;
|
|
70
|
-
rsc: boolean;
|
|
71
|
-
tsx: boolean;
|
|
72
|
-
aliases: {
|
|
73
|
-
components: string;
|
|
74
|
-
utils: string;
|
|
75
|
-
ui?: string | undefined;
|
|
76
|
-
lib?: string | undefined;
|
|
77
|
-
hooks?: string | undefined;
|
|
78
|
-
};
|
|
79
|
-
resolvedPaths: {
|
|
80
|
-
components: string;
|
|
81
|
-
ui: string;
|
|
82
|
-
utils: string;
|
|
83
|
-
lib: string;
|
|
84
|
-
hooks: string;
|
|
85
|
-
cwd: string;
|
|
86
|
-
tailwindConfig: string;
|
|
87
|
-
tailwindCss: string;
|
|
88
|
-
};
|
|
89
|
-
menuColor?: "default" | "inverted" | "default-translucent" | "inverted-translucent" | undefined;
|
|
90
|
-
menuAccent?: "subtle" | "bold" | undefined;
|
|
91
|
-
iconLibrary?: string | undefined;
|
|
92
|
-
$schema?: string | undefined;
|
|
93
|
-
rtl?: boolean | undefined;
|
|
94
|
-
registries?: Record<string, string | {
|
|
95
|
-
url: string;
|
|
96
|
-
params?: Record<string, string> | undefined;
|
|
97
|
-
headers?: Record<string, string> | undefined;
|
|
98
|
-
}> | undefined;
|
|
99
|
-
} | null>;
|
|
100
|
-
declare const BUILTIN_REGISTRIES: ShadcnRegistryConfig;
|
|
101
|
-
declare function resolveConfigPaths(cwd: string, config: ShadcnRawConfig): Promise<{
|
|
102
|
-
tailwind: {
|
|
103
|
-
baseColor: string;
|
|
104
|
-
css: string;
|
|
105
|
-
cssVariables: boolean;
|
|
106
|
-
config?: string | undefined;
|
|
107
|
-
prefix?: string | undefined;
|
|
108
|
-
};
|
|
109
|
-
style: string;
|
|
110
|
-
rsc: boolean;
|
|
111
|
-
tsx: boolean;
|
|
112
|
-
aliases: {
|
|
113
|
-
components: string;
|
|
114
|
-
utils: string;
|
|
115
|
-
ui?: string | undefined;
|
|
116
|
-
lib?: string | undefined;
|
|
117
|
-
hooks?: string | undefined;
|
|
118
|
-
};
|
|
119
|
-
resolvedPaths: {
|
|
120
|
-
components: string;
|
|
121
|
-
ui: string;
|
|
122
|
-
utils: string;
|
|
123
|
-
lib: string;
|
|
124
|
-
hooks: string;
|
|
125
|
-
cwd: string;
|
|
126
|
-
tailwindConfig: string;
|
|
127
|
-
tailwindCss: string;
|
|
128
|
-
};
|
|
129
|
-
menuColor?: "default" | "inverted" | "default-translucent" | "inverted-translucent" | undefined;
|
|
130
|
-
menuAccent?: "subtle" | "bold" | undefined;
|
|
131
|
-
iconLibrary?: string | undefined;
|
|
132
|
-
$schema?: string | undefined;
|
|
133
|
-
rtl?: boolean | undefined;
|
|
134
|
-
registries?: Record<string, string | {
|
|
135
|
-
url: string;
|
|
136
|
-
params?: Record<string, string> | undefined;
|
|
137
|
-
headers?: Record<string, string> | undefined;
|
|
138
|
-
}> | undefined;
|
|
139
|
-
}>;
|
|
140
|
-
declare function getRawConfig(cwd: string): Promise<ShadcnRawConfig | null>;
|
|
141
|
-
type DeepPartial<T> = { [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P]; };
|
|
142
|
-
/**
|
|
143
|
-
* Creates a config object with sensible defaults.
|
|
144
|
-
* Useful for universal registry items that bypass framework detection.
|
|
145
|
-
*
|
|
146
|
-
* @param partial - Partial config values to override defaults
|
|
147
|
-
* @returns A complete Config object
|
|
148
|
-
*/
|
|
149
|
-
declare function createRegistryConfig(partial?: DeepPartial<RegistryConfig>): RegistryConfig;
|
|
150
|
-
//#endregion
|
|
151
|
-
//#region src/index.d.ts
|
|
152
|
-
interface ShadcnPluginOptions {
|
|
153
|
-
/**
|
|
154
|
-
* The path to the shadcn `registry.json` file.
|
|
155
|
-
*
|
|
156
|
-
* @default "registry.json"
|
|
157
|
-
* @example
|
|
158
|
-
* ```ts
|
|
159
|
-
* import { defineConfig } from "@razorwind/core";
|
|
160
|
-
* import shadcn from "@razorwind/shadcn";
|
|
161
|
-
*
|
|
162
|
-
* export default defineConfig({
|
|
163
|
-
* plugins: [shadcn({ configFile: "components/registry.json" })]
|
|
164
|
-
* });
|
|
165
|
-
* ```
|
|
166
|
-
*/
|
|
167
|
-
configFile?: string;
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Razorwind plugin: load shadcn `registry.json` items into `schema.components`.
|
|
171
|
-
*
|
|
172
|
-
* @example
|
|
173
|
-
* ```ts
|
|
174
|
-
* import { defineConfig } from "@razorwind/core";
|
|
175
|
-
* import shadcn from "@razorwind/shadcn";
|
|
176
|
-
*
|
|
177
|
-
* export default defineConfig({
|
|
178
|
-
* plugins: [shadcn()]
|
|
179
|
-
* });
|
|
180
|
-
* ```
|
|
181
|
-
*/
|
|
182
|
-
declare const _default: any;
|
|
183
|
-
//#endregion
|
|
184
|
-
export { BUILTIN_REGISTRIES, DEFAULT_COMPONENTS, DEFAULT_STYLE, DEFAULT_TAILWIND_BASE_COLOR, DEFAULT_TAILWIND_CONFIG, DEFAULT_TAILWIND_CSS, DEFAULT_UTILS, type RegistryConfig, type ShadcnConfig, ShadcnPluginOptions, type ShadcnRawConfig, type ShadcnRegistryConfig, type ShadcnWorkspaceConfig, createRegistryConfig, _default as default, extractComponentsFromRegistry, getRawConfig, getRegistryConfig, registryItemToComponent, registryItemsToComponents, resolveConfigPaths, toDependencyRecord };
|
|
185
|
-
//# sourceMappingURL=index.d.cts.map
|
|
1
|
+
import { r as extract_d_exports } from "./extract-CHhbobiJ.cjs";
|
|
2
|
+
import { t as generate_d_exports } from "./generate.cjs";
|
|
3
|
+
export { extract_d_exports as extract, generate_d_exports as generate };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,185 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "
|
|
3
|
-
|
|
4
|
-
//#region src/extract.d.ts
|
|
5
|
-
type RegistryItemLike = {
|
|
6
|
-
name: string;
|
|
7
|
-
title?: string;
|
|
8
|
-
type?: string;
|
|
9
|
-
description?: string;
|
|
10
|
-
categories?: string[];
|
|
11
|
-
dependencies?: string[];
|
|
12
|
-
devDependencies?: string[];
|
|
13
|
-
registryDependencies?: string[];
|
|
14
|
-
files?: unknown[];
|
|
15
|
-
docs?: string;
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Convert npm-style dependency strings (`pkg`, `pkg@version`) into a
|
|
19
|
-
* name → version record.
|
|
20
|
-
*/
|
|
21
|
-
declare function toDependencyRecord(deps: string[] | undefined): Record<string, string> | undefined;
|
|
22
|
-
/**
|
|
23
|
-
* Map a single shadcn registry item into a Razorwind {@link Component}.
|
|
24
|
-
*/
|
|
25
|
-
declare function registryItemToComponent(item: RegistryItemLike): Component;
|
|
26
|
-
/**
|
|
27
|
-
* Convert a list of shadcn registry items into a `schema.components` record.
|
|
28
|
-
*/
|
|
29
|
-
declare function registryItemsToComponents(items: RegistryItemLike[] | undefined): Components;
|
|
30
|
-
/**
|
|
31
|
-
* Load a local `registry.json` and map its items into `schema.components`.
|
|
32
|
-
*
|
|
33
|
-
* Returns an empty record when the registry file is missing or unreadable.
|
|
34
|
-
*/
|
|
35
|
-
declare function extractComponentsFromRegistry(registryPath: string): Promise<Components>;
|
|
36
|
-
//#endregion
|
|
37
|
-
//#region src/registry/shadcn-types.d.ts
|
|
38
|
-
/**
|
|
39
|
-
* Infer a Zod 3 schema's output from `parse`'s return type.
|
|
40
|
-
*
|
|
41
|
-
* Avoids `z.infer` / `zod/v3` — this package depends on Zod 4 while shadcn's
|
|
42
|
-
* schemas are typed against Zod 3, and cross-version `infer` triggers
|
|
43
|
-
* "Type instantiation is excessively deep and possibly infinite".
|
|
44
|
-
*/
|
|
45
|
-
type InferShadcnSchema<T> = T extends {
|
|
46
|
-
parse: (...args: never[]) => infer Output;
|
|
47
|
-
} ? Output : never;
|
|
48
|
-
type ShadcnConfig = InferShadcnSchema<typeof configSchema>;
|
|
49
|
-
type ShadcnRawConfig = InferShadcnSchema<typeof rawConfigSchema>;
|
|
50
|
-
type ShadcnRegistryConfig = InferShadcnSchema<typeof registryConfigSchema>;
|
|
51
|
-
type ShadcnWorkspaceConfig = InferShadcnSchema<typeof workspaceConfigSchema>;
|
|
52
|
-
//#endregion
|
|
53
|
-
//#region src/registry/config.d.ts
|
|
54
|
-
declare const DEFAULT_STYLE = "default";
|
|
55
|
-
declare const DEFAULT_COMPONENTS = "@/components";
|
|
56
|
-
declare const DEFAULT_UTILS = "@/lib/utils";
|
|
57
|
-
declare const DEFAULT_TAILWIND_CSS = "app/globals.css";
|
|
58
|
-
declare const DEFAULT_TAILWIND_CONFIG = "tailwind.config.js";
|
|
59
|
-
declare const DEFAULT_TAILWIND_BASE_COLOR = "slate";
|
|
60
|
-
type RegistryConfig = ShadcnConfig;
|
|
61
|
-
declare function getRegistryConfig(cwd: string): Promise<{
|
|
62
|
-
tailwind: {
|
|
63
|
-
baseColor: string;
|
|
64
|
-
css: string;
|
|
65
|
-
cssVariables: boolean;
|
|
66
|
-
config?: string | undefined;
|
|
67
|
-
prefix?: string | undefined;
|
|
68
|
-
};
|
|
69
|
-
style: string;
|
|
70
|
-
rsc: boolean;
|
|
71
|
-
tsx: boolean;
|
|
72
|
-
aliases: {
|
|
73
|
-
components: string;
|
|
74
|
-
utils: string;
|
|
75
|
-
ui?: string | undefined;
|
|
76
|
-
lib?: string | undefined;
|
|
77
|
-
hooks?: string | undefined;
|
|
78
|
-
};
|
|
79
|
-
resolvedPaths: {
|
|
80
|
-
components: string;
|
|
81
|
-
ui: string;
|
|
82
|
-
utils: string;
|
|
83
|
-
lib: string;
|
|
84
|
-
hooks: string;
|
|
85
|
-
cwd: string;
|
|
86
|
-
tailwindConfig: string;
|
|
87
|
-
tailwindCss: string;
|
|
88
|
-
};
|
|
89
|
-
menuColor?: "default" | "inverted" | "default-translucent" | "inverted-translucent" | undefined;
|
|
90
|
-
menuAccent?: "subtle" | "bold" | undefined;
|
|
91
|
-
iconLibrary?: string | undefined;
|
|
92
|
-
$schema?: string | undefined;
|
|
93
|
-
rtl?: boolean | undefined;
|
|
94
|
-
registries?: Record<string, string | {
|
|
95
|
-
url: string;
|
|
96
|
-
params?: Record<string, string> | undefined;
|
|
97
|
-
headers?: Record<string, string> | undefined;
|
|
98
|
-
}> | undefined;
|
|
99
|
-
} | null>;
|
|
100
|
-
declare const BUILTIN_REGISTRIES: ShadcnRegistryConfig;
|
|
101
|
-
declare function resolveConfigPaths(cwd: string, config: ShadcnRawConfig): Promise<{
|
|
102
|
-
tailwind: {
|
|
103
|
-
baseColor: string;
|
|
104
|
-
css: string;
|
|
105
|
-
cssVariables: boolean;
|
|
106
|
-
config?: string | undefined;
|
|
107
|
-
prefix?: string | undefined;
|
|
108
|
-
};
|
|
109
|
-
style: string;
|
|
110
|
-
rsc: boolean;
|
|
111
|
-
tsx: boolean;
|
|
112
|
-
aliases: {
|
|
113
|
-
components: string;
|
|
114
|
-
utils: string;
|
|
115
|
-
ui?: string | undefined;
|
|
116
|
-
lib?: string | undefined;
|
|
117
|
-
hooks?: string | undefined;
|
|
118
|
-
};
|
|
119
|
-
resolvedPaths: {
|
|
120
|
-
components: string;
|
|
121
|
-
ui: string;
|
|
122
|
-
utils: string;
|
|
123
|
-
lib: string;
|
|
124
|
-
hooks: string;
|
|
125
|
-
cwd: string;
|
|
126
|
-
tailwindConfig: string;
|
|
127
|
-
tailwindCss: string;
|
|
128
|
-
};
|
|
129
|
-
menuColor?: "default" | "inverted" | "default-translucent" | "inverted-translucent" | undefined;
|
|
130
|
-
menuAccent?: "subtle" | "bold" | undefined;
|
|
131
|
-
iconLibrary?: string | undefined;
|
|
132
|
-
$schema?: string | undefined;
|
|
133
|
-
rtl?: boolean | undefined;
|
|
134
|
-
registries?: Record<string, string | {
|
|
135
|
-
url: string;
|
|
136
|
-
params?: Record<string, string> | undefined;
|
|
137
|
-
headers?: Record<string, string> | undefined;
|
|
138
|
-
}> | undefined;
|
|
139
|
-
}>;
|
|
140
|
-
declare function getRawConfig(cwd: string): Promise<ShadcnRawConfig | null>;
|
|
141
|
-
type DeepPartial<T> = { [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P]; };
|
|
142
|
-
/**
|
|
143
|
-
* Creates a config object with sensible defaults.
|
|
144
|
-
* Useful for universal registry items that bypass framework detection.
|
|
145
|
-
*
|
|
146
|
-
* @param partial - Partial config values to override defaults
|
|
147
|
-
* @returns A complete Config object
|
|
148
|
-
*/
|
|
149
|
-
declare function createRegistryConfig(partial?: DeepPartial<RegistryConfig>): RegistryConfig;
|
|
150
|
-
//#endregion
|
|
151
|
-
//#region src/index.d.ts
|
|
152
|
-
interface ShadcnPluginOptions {
|
|
153
|
-
/**
|
|
154
|
-
* The path to the shadcn `registry.json` file.
|
|
155
|
-
*
|
|
156
|
-
* @default "registry.json"
|
|
157
|
-
* @example
|
|
158
|
-
* ```ts
|
|
159
|
-
* import { defineConfig } from "@razorwind/core";
|
|
160
|
-
* import shadcn from "@razorwind/shadcn";
|
|
161
|
-
*
|
|
162
|
-
* export default defineConfig({
|
|
163
|
-
* plugins: [shadcn({ configFile: "components/registry.json" })]
|
|
164
|
-
* });
|
|
165
|
-
* ```
|
|
166
|
-
*/
|
|
167
|
-
configFile?: string;
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Razorwind plugin: load shadcn `registry.json` items into `schema.components`.
|
|
171
|
-
*
|
|
172
|
-
* @example
|
|
173
|
-
* ```ts
|
|
174
|
-
* import { defineConfig } from "@razorwind/core";
|
|
175
|
-
* import shadcn from "@razorwind/shadcn";
|
|
176
|
-
*
|
|
177
|
-
* export default defineConfig({
|
|
178
|
-
* plugins: [shadcn()]
|
|
179
|
-
* });
|
|
180
|
-
* ```
|
|
181
|
-
*/
|
|
182
|
-
declare const _default: any;
|
|
183
|
-
//#endregion
|
|
184
|
-
export { BUILTIN_REGISTRIES, DEFAULT_COMPONENTS, DEFAULT_STYLE, DEFAULT_TAILWIND_BASE_COLOR, DEFAULT_TAILWIND_CONFIG, DEFAULT_TAILWIND_CSS, DEFAULT_UTILS, type RegistryConfig, type ShadcnConfig, ShadcnPluginOptions, type ShadcnRawConfig, type ShadcnRegistryConfig, type ShadcnWorkspaceConfig, createRegistryConfig, _default as default, extractComponentsFromRegistry, getRawConfig, getRegistryConfig, registryItemToComponent, registryItemsToComponents, resolveConfigPaths, toDependencyRecord };
|
|
185
|
-
//# sourceMappingURL=index.d.mts.map
|
|
1
|
+
import { r as extract_d_exports } from "./extract-CdEg5hNq.mjs";
|
|
2
|
+
import { t as generate_d_exports } from "./generate.mjs";
|
|
3
|
+
export { extract_d_exports as extract, generate_d_exports as generate };
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
import{
|
|
2
|
-
|
|
3
|
-
`),n=b(e.type),r=ae(e.files),i=v(e.dependencies),a=v(e.devDependencies),o=v(e.registryDependencies);return{name:e.name,title:e.title?.trim()||e.name,...n?{type:n}:{},...e.categories?.[0]?{category:e.categories[0]}:{},...e.categories?.length?{tags:[...e.categories]}:{},...t?{description:t}:{},...i?{dependencies:i}:{},...a?{devDependencies:a}:{},...o?{registryDependencies:o}:{},...r?{files:r}:{}}}function C(e){if(!e?.length)return{};let t={};for(let n of e)n?.name&&(t[n.name]=S(n));return t}function w(e){return r(e)&&i(e).isFile()?{cwd:s(e),registryFile:o(e)}:{cwd:e}}async function T(e){try{return C((await c(w(e))).items)}catch{return{}}}const E=process.env.REGISTRY_URL??`https://ui.shadcn.com/r`,D=E.replace(/\/r\/?$/,``);`${D}`,`${D}`,`${D}`,`${D}`,`${D}`,`${D}`,`${D}`,`${D}`,`${D}`,`${D}`,`${D}`;function O(e){let t=[e];for(;t.length;){let e=t.shift();if(typeof e==`string`){if(e.startsWith(`./`))return e;continue}if(Array.isArray(e)){t.unshift(...e);continue}e&&typeof e==`object`&&t.unshift(...Object.values(e))}return null}function k(e){if(!e.includes(`*`))return`strip_extension`;let t=e.slice(e.indexOf(`*`)+1);return t&&/^\.[^/]+$/.test(t)?`strip_extension`:`preserve_extension`}function A(e,t){let n=t.find(t=>!t.hasWildcard&&t.key===e);if(n)return{path:a.resolve(n.rootDir,n.target),matchedAlias:n.key,matchedTarget:n.target,emitMode:n.emitMode};let r=t.filter(e=>e.hasWildcard).sort((e,t)=>t.key.length-e.key.length);for(let t of r){let n=j(e,t.key,{allowBareAliasBase:!0});if(n!==null)return{path:a.resolve(t.rootDir,M(t.target,n)),matchedAlias:t.key,matchedTarget:t.target,emitMode:t.emitMode}}return null}function j(e,t,n={}){if(!t.includes(`*`))return e===t?``:null;let[r,i=``]=t.split(`*`);return r&&e.startsWith(r)&&e.endsWith(i)?i?e.slice(r.length,-i.length):e.slice(r.length):n.allowBareAliasBase&&i===``&&r&&r.endsWith(`/`)&&e===r.slice(0,-1)?``:null}function M(e,t){if(!e.includes(`*`))return e;let[n,r=``]=e.split(`*`);return t?n?`${n}${t}${r}`:t:n?n.replace(/\/$/,``):``}const N=new Map;async function P(e){let t=a.resolve(e),n=N.get(t);if(n)return n;let r=(await I(e))?.imports;if(!r||typeof r!=`object`||Array.isArray(r))return N.set(t,[]),[];let i=[];for(let[e,n]of Object.entries(r)){if(!e.startsWith(`#`))continue;let r=O(n);r&&i.push({key:e,aliasBase:e===`#*`?`#`:e.endsWith(`/*`)?e.slice(0,-2):e,target:r,emitMode:k(r),hasWildcard:e.includes(`*`),rootDir:t})}return N.set(t,i),i}async function F(e,t){return A(e,await P(t))}async function I(e=``){return f(a.join(e,`package.json`))}m.object({compilerOptions:m.object({paths:m.record(m.string(),m.string().or(m.array(m.string())))})});function L(e){if(e.startsWith(`#`)||e.startsWith(`.`)||ie(e))return null;let t=e.split(`/`);return e.startsWith(`@`)?t.length<2?null:{packageName:`${t[0]}/${t[1]}`}:{packageName:t[0]}}const R=new Map,z=new Map;function B(e){let t=[],n=!1,r=0;for(let i of e.split(`
|
|
4
|
-
`)){let e=i.trim();if(!e||e.startsWith(`#`))continue;let a=i.match(/^(\s*)([\w-]+)\s*:/);if(a){r=a[1]?.length??0,n=a[2]===`packages`;continue}if(!n)continue;let o=i.match(/^(\s*)-\s*(.+?)\s*(?:#.*)?$/);((!o||o[1]?.length)??r>=0)||t.push(o[2]?.trim().replace(/^["']|["']$/g,``)??``)}return t}async function V(e){let t=[],i=a.resolve(e,`pnpm-workspace.yaml`);if(r(i)){let e=await p(i);t.push(...B(e))}let o=n(e,`package.json`);if(r(o))try{let e=(await f(o)).workspaces,n=Array.isArray(e)?e:e?.packages;Array.isArray(n)&&t.push(...n.filter(e=>!e.startsWith(`!`)))}catch{}return Array.from(new Set(t))}async function H(e){let t=await V(e),n=new Map;if(!t.length)return n;let r=await u(t.map(e=>a.posix.join(e.split(a.sep).join(`/`),`package.json`)),{cwd:e,ignore:[`**/node_modules/**`]});for(let t of r){let r=a.resolve(e,a.dirname(t)),i=(await I(r))?.name;i&&n.set(i,{packageName:i,packageRoot:r})}return n}async function U(e,t){let n=h(e);if(!n)return null;let r=R.get(n);if(r?.has(t))return r.get(t)??null;let i=await H(n);return R.set(n,i),i.get(t)??null}function W(e,t){if(t===`.`)return e;let n=t.slice(2).replace(/\/\*$/,``);return n?`${e}/${n}`:e}async function G(e){let t=`${e.packageRoot}:${e.packageName}`,n=z.get(t);if(n)return n;let r=(await I(e.packageRoot))?.exports;if(!r||typeof r!=`object`||Array.isArray(r))return z.set(t,[]),[];let i=[];for(let[t,n]of Object.entries(r)){if(t!==`.`&&!t.startsWith(`./`))continue;let r=O(n);if(!r)continue;let a=W(e.packageName,t);i.push({key:t.includes(`*`)?`${a}/*`:a,aliasBase:a,target:r,emitMode:k(r),hasWildcard:t.includes(`*`),rootDir:e.packageRoot})}return z.set(t,i),i}async function K(e,t){let n=L(e);if(!n?.packageName)return null;let r=await U(t,n.packageName);return r?A(e,await G(r)):null}async function q(e,t){let n=t.cwd??t.baseUrl??h();if(e.startsWith(`#`)){let t=await F(e,n);if(t)return{path:t.path,source:`package_imports`,matchedAlias:t.matchedAlias,matchedTarget:t.matchedTarget,emitMode:t.emitMode}}let r=await K(e,n);return r?{path:r.path,source:`workspace_package_exports`,matchedAlias:r.matchedAlias,matchedTarget:r.matchedTarget,emitMode:r.emitMode}:se(e,t)}function oe(e){return/^@[^/]+\/[^/]+(?:\/.*)?$/.test(e)}function se(e,t){let n=re(t.baseUrl||t.cwd||h(),t.paths??{})(e,void 0,()=>!0,[`.ts`,`.tsx`,`.jsx`,`.js`,`.css`]);if(!n)return null;let r=ce(e,t.paths??{});return!r&&oe(e)?null:{path:n,source:`tsconfig_paths`,matchedAlias:r?.key??e,matchedTarget:r?.target??n,emitMode:`strip_extension`}}function ce(e,t){for(let[n,r]of Object.entries(t)){let t=Array.isArray(r)?r:[r],i=j(e,n);if(i!==null)return{key:n,target:t[0]?.includes(`*`)&&i!==null?t[0].replace(/\*/g,i):t[0]}}return null}const le=`default`,ue=`@/components`,de=`@/lib/utils`,fe=`app/globals.css`,pe=`tailwind.config.js`,J=`slate`,Y=`components.json`,me={configFile:Y,dotenv:!1,envName:!1,packageJson:!1,rcFile:!1,extend:!1};async function he(e){let t=e;for(;;){let e=await te({cwd:t,...me});if(e._configFile)return e;let n=a.dirname(t);if(n===t)return null;t=n}}async function ge(e){let t=await $(e);return t?(t.iconLibrary||=t.style===`new-york`?`radix`:`lucide`,Z(e,t)):null}const X={"@shadcn":`${E}/styles/{style}/{name}.json`};async function Z(e,t){t.registries={...X,...t.registries??{}};let n=await ee(e);if(!n)throw Error(`Failed to load tsconfig.json.`);let r=await Q(`utils`,t.aliases.utils,e,n),i=await Q(`components`,t.aliases.components,e,n),o=t.aliases.ui?await Q(`ui`,t.aliases.ui,e,n):a.resolve(i??e,`ui`),s=t.aliases.lib?await Q(`lib`,t.aliases.lib,e,n):a.resolve(r??e,`..`),c=t.aliases.hooks?await Q(`hooks`,t.aliases.hooks,e,n):a.resolve(i??e,`..`,`hooks`);return _e(e,{components:i,utils:r,ui:o,lib:s,hooks:c}),ne.parse({...t,resolvedPaths:{cwd:e,tailwindConfig:t.tailwind.config?a.resolve(e,t.tailwind.config):``,tailwindCss:a.resolve(e,t.tailwind.css),utils:r,components:i,ui:o,lib:s,hooks:c}})}async function Q(e,t,r,i){let o=await q(t,{...i,cwd:r});if(!o?.path||t.startsWith(`#`)&&o.path===n(r,t))return null;if(e!==`utils`&&(o.source===`package_imports`||o.source===`workspace_package_exports`)){if(!o.matchedAlias.includes(`*`)&&/\/index\.[^/]+$/.test(o.path))return a.dirname(o.path);if(o.matchedAlias.includes(`*`)&&/\.[^/]+$/.test(o.path))return o.path.replace(/\.[^/]+$/,``)}return o.path}function _e(e,t){let n=[`components`,`ui`,`lib`,`hooks`,`utils`].filter(e=>!t[e]);if(n.length)throw Error([`Could not resolve the following aliases in ${l.cyan(e)}: ${l.cyan(n.join(`, `))}.`,`Configure path aliases in ${l.cyan(`tsconfig.json`)} or imports in ${l.cyan(`package.json`)} for this workspace and try again.`].join(`
|
|
5
|
-
`))}async function $(e){let t;try{let n=await he(e);if(!n)return null;t=n.configFile;let r=d.parse(n.config);if(r.registries){for(let e of Object.keys(r.registries))if(e in X)throw Error(`"${e}" is a built-in registry and cannot be overridden.`)}return r}catch(n){let r=t??`${e}/${Y}`;throw n instanceof Error&&n.message.includes(`reserved registry`)?n:Error(`Invalid configuration found in ${l.cyan(r)}.`)}}function ve(e){let t={resolvedPaths:{cwd:process.cwd(),tailwindConfig:``,tailwindCss:``,utils:``,components:``,ui:``,lib:``,hooks:``},style:``,tailwind:{config:``,css:``,baseColor:``,cssVariables:!1},rsc:!1,tsx:!0,aliases:{components:``,utils:``},registries:{...X}};return e?{...t,...e,resolvedPaths:{...t.resolvedPaths,...e.resolvedPaths??{}},tailwind:{...t.tailwind,...e.tailwind??{}},aliases:{...t.aliases,...e.aliases??{}},registries:{...t.registries,...e.registries??{}}}:t}var ye=t((t={})=>({name:`razorwind-shadcn`,extract:async(r,i)=>{if(r.components&&Object.keys(r.components).length>0)return r;let a=t.configFile;if(!a){let{cwd:t}=e();a=n(t,`registry.json`)}let o=await T(a);return{...r,components:o}}}));export{X as BUILTIN_REGISTRIES,ue as DEFAULT_COMPONENTS,le as DEFAULT_STYLE,J as DEFAULT_TAILWIND_BASE_COLOR,pe as DEFAULT_TAILWIND_CONFIG,fe as DEFAULT_TAILWIND_CSS,de as DEFAULT_UTILS,ve as createRegistryConfig,ye as default,T as extractComponentsFromRegistry,$ as getRawConfig,ge as getRegistryConfig,S as registryItemToComponent,C as registryItemsToComponents,Z as resolveConfigPaths,v as toDependencyRecord};
|
|
6
|
-
//# sourceMappingURL=index.mjs.map
|
|
1
|
+
import{r as e}from"./extract-DBbCwIGB.mjs";import{t}from"./generate.mjs";export{e as extract,t as generate};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};export{t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return o}});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
//#region src/types.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Options for the Razorwind shadcn extract plugin.
|
|
4
|
+
*/
|
|
5
|
+
interface ShadcnExtractPluginOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Path to the shadcn `registry.json` file.
|
|
8
|
+
*
|
|
9
|
+
* @defaultValue `"registry.json"`
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { defineConfig } from "@razorwind/core";
|
|
13
|
+
* import shadcn from "@razorwind/shadcn/extract";
|
|
14
|
+
*
|
|
15
|
+
* export default defineConfig({
|
|
16
|
+
* plugins: [shadcn({ configFile: "components/registry.json" })]
|
|
17
|
+
* });
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
configFile?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Options for the Razorwind shadcn generate plugin.
|
|
24
|
+
*/
|
|
25
|
+
interface ShadcnGeneratePluginOptions {
|
|
26
|
+
/**
|
|
27
|
+
* Output path for the generated `registry.json` file.
|
|
28
|
+
*
|
|
29
|
+
* @defaultValue `"registry.json"`
|
|
30
|
+
*/
|
|
31
|
+
configFile?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Registry `name` field written into `registry.json`.
|
|
34
|
+
*/
|
|
35
|
+
name?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Registry `homepage` field written into `registry.json`.
|
|
38
|
+
*/
|
|
39
|
+
homepage?: string;
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
export { ShadcnGeneratePluginOptions as n, ShadcnExtractPluginOptions as t };
|
|
43
|
+
//# sourceMappingURL=types-BH0MT5Wk.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-BH0MT5Wk.d.mts","names":[],"sources":["../src/types.ts"],"mappings":""}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
//#endregion
|
|
2
|
+
//#region src/types.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Options for the Razorwind shadcn extract plugin.
|
|
5
|
+
*/
|
|
6
|
+
interface ShadcnExtractPluginOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Path to the shadcn `registry.json` file.
|
|
9
|
+
*
|
|
10
|
+
* @defaultValue `"registry.json"`
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { defineConfig } from "@razorwind/core";
|
|
14
|
+
* import shadcn from "@razorwind/shadcn/extract";
|
|
15
|
+
*
|
|
16
|
+
* export default defineConfig({
|
|
17
|
+
* plugins: [shadcn({ configFile: "components/registry.json" })]
|
|
18
|
+
* });
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
configFile?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Options for the Razorwind shadcn generate plugin.
|
|
25
|
+
*/
|
|
26
|
+
interface ShadcnGeneratePluginOptions {
|
|
27
|
+
/**
|
|
28
|
+
* Output path for the generated `registry.json` file.
|
|
29
|
+
*
|
|
30
|
+
* @defaultValue `"registry.json"`
|
|
31
|
+
*/
|
|
32
|
+
configFile?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Registry `name` field written into `registry.json`.
|
|
35
|
+
*/
|
|
36
|
+
name?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Registry `homepage` field written into `registry.json`.
|
|
39
|
+
*/
|
|
40
|
+
homepage?: string;
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
export { ShadcnGeneratePluginOptions as n, __exportAll as r, ShadcnExtractPluginOptions as t };
|
|
44
|
+
//# sourceMappingURL=types-Jkebh8QA.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-Jkebh8QA.d.cts","names":[],"sources":["../src/types.ts"],"mappings":";;;;;UAqBiB;;;;;;;;;;;;;;;EAef;;;;;UAMe;;;;;;EAMf;;;;EAKA;;;;EAKA"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@razorwind/shadcn",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "Razorwind Shadcn
|
|
5
|
+
"description": "Razorwind Shadcn plugin that can create Shadcn UI registry files from design tokens/components or read a Shadcn UI registry file and return the design tokens/components.",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "github",
|
|
8
8
|
"url": "https://github.com/storm-software/razorwind.git",
|
|
@@ -43,6 +43,34 @@
|
|
|
43
43
|
"default": "./dist/index.mjs"
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
|
+
"./extract": {
|
|
47
|
+
"require": {
|
|
48
|
+
"types": "./dist/extract.d.cts",
|
|
49
|
+
"default": "./dist/extract.cjs"
|
|
50
|
+
},
|
|
51
|
+
"import": {
|
|
52
|
+
"types": "./dist/extract.d.mts",
|
|
53
|
+
"default": "./dist/extract.mjs"
|
|
54
|
+
},
|
|
55
|
+
"default": {
|
|
56
|
+
"types": "./dist/extract.d.mts",
|
|
57
|
+
"default": "./dist/extract.mjs"
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
"./generate": {
|
|
61
|
+
"require": {
|
|
62
|
+
"types": "./dist/generate.d.cts",
|
|
63
|
+
"default": "./dist/generate.cjs"
|
|
64
|
+
},
|
|
65
|
+
"import": {
|
|
66
|
+
"types": "./dist/generate.d.mts",
|
|
67
|
+
"default": "./dist/generate.mjs"
|
|
68
|
+
},
|
|
69
|
+
"default": {
|
|
70
|
+
"types": "./dist/generate.d.mts",
|
|
71
|
+
"default": "./dist/generate.mjs"
|
|
72
|
+
}
|
|
73
|
+
},
|
|
46
74
|
"./package.json": "./package.json"
|
|
47
75
|
},
|
|
48
76
|
"main": "./dist/index.cjs",
|
|
@@ -52,7 +80,7 @@
|
|
|
52
80
|
"dependencies": {
|
|
53
81
|
"@power-plant/core": "^0.0.37",
|
|
54
82
|
"@power-plant/dtcg-schema": "^0.0.1",
|
|
55
|
-
"@razorwind/core": "^0.0.
|
|
83
|
+
"@razorwind/core": "^0.0.9",
|
|
56
84
|
"@stryke/fs": "^0.33.99",
|
|
57
85
|
"@stryke/path": "^0.29.25",
|
|
58
86
|
"@stryke/types": "^0.12.26",
|
|
@@ -69,5 +97,5 @@
|
|
|
69
97
|
"typescript": "^6.0.3"
|
|
70
98
|
},
|
|
71
99
|
"publishConfig": { "access": "public" },
|
|
72
|
-
"gitHead": "
|
|
100
|
+
"gitHead": "6ca83196e6028c6c051887e6390dbd62dd3b0582"
|
|
73
101
|
}
|
package/dist/index.d.cts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/extract.ts","../src/registry/shadcn-types.ts","../src/registry/config.ts","../src/index.ts"],"mappings":";;;;KA4CK;EACH;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;;;;iBAOc,mBACd,6BACC;;;;iBA4Fa,wBAAwB,MAAM,mBAAmB;;;;iBA2BjD,0BACd,OAAO,iCACN;;;;;;iBAwCmB,8BACpB,uBACC,QAAQ;;;;;;;;;;KClMN,kBAAkB,KAAK;EAC1B,WAAW,wBAAwB;IAEjC;KAGQ,eAAe,yBAAyB;KACxC,kBAAkB,yBAAyB;KAC3C,uBAAuB,yBAC1B;KAEG,wBAAwB,yBAC3B;;;cCHI;cACA;cACA;cACA;cACA;cACA;KAmCD,iBAAiB;iBAEP,kBAAkB,cAAW;;;;;IA+MjC;IACV;;;;;;;;IASkB;IAAkC;IAGtD;;;;;;;;;;;;;;;;;;;IAsBS,SAAC;IACH,UAAC;;;cArOD,oBAAoB;iBAIX,mBAAmB,aAAa,QAAQ,kBAAe;;;;;IA6L3D;IACV;;;;;;;;IASkB;IAAkC;IAGtD;;;;;;;;;;;;;;;;;;;IAsBS,SAAC;IACH,UAAC;;;iBAtFQ,aACpB,cACC,QAAQ;KA6IC,YAAY,QACrB,WAAW,KAAK,EAAE,oBAAoB,YAAY,EAAE,MAAM,EAAE;;;;;;;;iBAU/C,qBACd,UAAU,YAAY,kBACrB;;;UC1Vc;;;;;;;;;;;;;;;EAef"}
|
package/dist/index.d.mts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/extract.ts","../src/registry/shadcn-types.ts","../src/registry/config.ts","../src/index.ts"],"mappings":""}
|
package/dist/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":[],"mappings":""}
|