@ryanatkn/gro 0.156.0 → 0.157.1

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.
Files changed (46) hide show
  1. package/dist/constants.d.ts +6 -0
  2. package/dist/constants.d.ts.map +1 -1
  3. package/dist/constants.js +6 -0
  4. package/dist/esbuild_plugin_svelte.d.ts.map +1 -1
  5. package/dist/esbuild_plugin_svelte.js +1 -2
  6. package/dist/gro_plugin_sveltekit_app.js +1 -1
  7. package/dist/loader.d.ts.map +1 -1
  8. package/dist/loader.js +1 -2
  9. package/dist/package.d.ts +44 -13
  10. package/dist/package.d.ts.map +1 -1
  11. package/dist/package.gen.js +1 -1
  12. package/dist/package.js +44 -22
  13. package/dist/parse_exports.d.ts +20 -0
  14. package/dist/parse_exports.d.ts.map +1 -0
  15. package/dist/parse_exports.js +65 -0
  16. package/dist/parse_exports_context.d.ts +21 -0
  17. package/dist/parse_exports_context.d.ts.map +1 -0
  18. package/dist/parse_exports_context.js +332 -0
  19. package/dist/parse_imports.d.ts.map +1 -1
  20. package/dist/parse_imports.js +1 -2
  21. package/dist/paths.d.ts +8 -0
  22. package/dist/paths.d.ts.map +1 -1
  23. package/dist/paths.js +6 -3
  24. package/dist/src_json.d.ts +68 -66
  25. package/dist/src_json.d.ts.map +1 -1
  26. package/dist/src_json.js +58 -55
  27. package/dist/test_helpers.d.ts +21 -0
  28. package/dist/test_helpers.d.ts.map +1 -0
  29. package/dist/test_helpers.js +122 -0
  30. package/package.json +21 -13
  31. package/src/lib/constants.ts +6 -0
  32. package/src/lib/esbuild_plugin_svelte.ts +1 -2
  33. package/src/lib/gro_plugin_sveltekit_app.ts +1 -1
  34. package/src/lib/loader.ts +6 -2
  35. package/src/lib/package.gen.ts +1 -1
  36. package/src/lib/package.ts +44 -22
  37. package/src/lib/parse_exports.ts +108 -0
  38. package/src/lib/parse_exports_context.ts +394 -0
  39. package/src/lib/parse_imports.ts +1 -2
  40. package/src/lib/paths.ts +13 -3
  41. package/src/lib/src_json.ts +80 -68
  42. package/src/lib/test_helpers.ts +159 -0
  43. package/dist/svelte_helpers.d.ts +0 -3
  44. package/dist/svelte_helpers.d.ts.map +0 -1
  45. package/dist/svelte_helpers.js +0 -2
  46. package/src/lib/svelte_helpers.ts +0 -2
@@ -1,51 +1,53 @@
1
1
  import { z } from 'zod';
2
2
  import { type Package_Json, type Package_Json_Exports } from './package_json.ts';
3
+ export declare const Src_Module_Declaration_Kind: z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>;
4
+ export type Src_Module_Declaration_Kind = z.infer<typeof Src_Module_Declaration_Kind>;
3
5
  export declare const Src_Module_Declaration: z.ZodObject<{
4
6
  name: z.ZodString;
5
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
7
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
6
8
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
7
9
  name: z.ZodString;
8
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
10
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
9
11
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
10
12
  name: z.ZodString;
11
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
13
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
12
14
  }, z.ZodTypeAny, "passthrough">>;
13
15
  export type Src_Module_Declaration = z.infer<typeof Src_Module_Declaration>;
14
16
  export declare const Src_Module: z.ZodObject<{
15
17
  path: z.ZodString;
16
18
  declarations: z.ZodArray<z.ZodObject<{
17
19
  name: z.ZodString;
18
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
20
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
19
21
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
20
22
  name: z.ZodString;
21
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
23
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
22
24
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
23
25
  name: z.ZodString;
24
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
26
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
25
27
  }, z.ZodTypeAny, "passthrough">>, "many">;
26
28
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
27
29
  path: z.ZodString;
28
30
  declarations: z.ZodArray<z.ZodObject<{
29
31
  name: z.ZodString;
30
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
32
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
31
33
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
32
34
  name: z.ZodString;
33
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
35
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
34
36
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
35
37
  name: z.ZodString;
36
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
38
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
37
39
  }, z.ZodTypeAny, "passthrough">>, "many">;
38
40
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
39
41
  path: z.ZodString;
40
42
  declarations: z.ZodArray<z.ZodObject<{
41
43
  name: z.ZodString;
42
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
44
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
43
45
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
44
46
  name: z.ZodString;
45
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
47
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
46
48
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
47
49
  name: z.ZodString;
48
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
50
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
49
51
  }, z.ZodTypeAny, "passthrough">>, "many">;
50
52
  }, z.ZodTypeAny, "passthrough">>;
51
53
  export type Src_Module = z.infer<typeof Src_Module>;
@@ -53,37 +55,37 @@ export declare const Src_Modules: z.ZodRecord<z.ZodString, z.ZodObject<{
53
55
  path: z.ZodString;
54
56
  declarations: z.ZodArray<z.ZodObject<{
55
57
  name: z.ZodString;
56
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
58
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
57
59
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
58
60
  name: z.ZodString;
59
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
61
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
60
62
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
61
63
  name: z.ZodString;
62
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
64
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
63
65
  }, z.ZodTypeAny, "passthrough">>, "many">;
64
66
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
65
67
  path: z.ZodString;
66
68
  declarations: z.ZodArray<z.ZodObject<{
67
69
  name: z.ZodString;
68
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
70
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
69
71
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
70
72
  name: z.ZodString;
71
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
73
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
72
74
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
73
75
  name: z.ZodString;
74
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
76
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
75
77
  }, z.ZodTypeAny, "passthrough">>, "many">;
76
78
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
77
79
  path: z.ZodString;
78
80
  declarations: z.ZodArray<z.ZodObject<{
79
81
  name: z.ZodString;
80
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
82
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
81
83
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
82
84
  name: z.ZodString;
83
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
85
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
84
86
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
85
87
  name: z.ZodString;
86
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
88
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
87
89
  }, z.ZodTypeAny, "passthrough">>, "many">;
88
90
  }, z.ZodTypeAny, "passthrough">>>;
89
91
  export type Src_Modules = z.infer<typeof Src_Modules>;
@@ -97,61 +99,61 @@ export declare const Src_Json: z.ZodObject<{
97
99
  path: z.ZodString;
98
100
  declarations: z.ZodArray<z.ZodObject<{
99
101
  name: z.ZodString;
100
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
102
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
101
103
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
102
104
  name: z.ZodString;
103
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
105
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
104
106
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
105
107
  name: z.ZodString;
106
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
108
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
107
109
  }, z.ZodTypeAny, "passthrough">>, "many">;
108
110
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
109
111
  path: z.ZodString;
110
112
  declarations: z.ZodArray<z.ZodObject<{
111
113
  name: z.ZodString;
112
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
114
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
113
115
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
114
116
  name: z.ZodString;
115
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
117
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
116
118
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
117
119
  name: z.ZodString;
118
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
120
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
119
121
  }, z.ZodTypeAny, "passthrough">>, "many">;
120
122
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
121
123
  path: z.ZodString;
122
124
  declarations: z.ZodArray<z.ZodObject<{
123
125
  name: z.ZodString;
124
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
126
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
125
127
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
126
128
  name: z.ZodString;
127
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
129
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
128
130
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
129
131
  name: z.ZodString;
130
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
132
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
131
133
  }, z.ZodTypeAny, "passthrough">>, "many">;
132
134
  }, z.ZodTypeAny, "passthrough">>>, Record<string, z.objectOutputType<{
133
135
  path: z.ZodString;
134
136
  declarations: z.ZodArray<z.ZodObject<{
135
137
  name: z.ZodString;
136
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
138
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
137
139
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
138
140
  name: z.ZodString;
139
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
141
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
140
142
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
141
143
  name: z.ZodString;
142
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
144
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
143
145
  }, z.ZodTypeAny, "passthrough">>, "many">;
144
146
  }, z.ZodTypeAny, "passthrough">> | undefined, Record<string, z.objectInputType<{
145
147
  path: z.ZodString;
146
148
  declarations: z.ZodArray<z.ZodObject<{
147
149
  name: z.ZodString;
148
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
150
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
149
151
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
150
152
  name: z.ZodString;
151
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
153
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
152
154
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
153
155
  name: z.ZodString;
154
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
156
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
155
157
  }, z.ZodTypeAny, "passthrough">>, "many">;
156
158
  }, z.ZodTypeAny, "passthrough">>>>;
157
159
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
@@ -161,61 +163,61 @@ export declare const Src_Json: z.ZodObject<{
161
163
  path: z.ZodString;
162
164
  declarations: z.ZodArray<z.ZodObject<{
163
165
  name: z.ZodString;
164
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
166
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
165
167
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
166
168
  name: z.ZodString;
167
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
169
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
168
170
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
169
171
  name: z.ZodString;
170
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
172
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
171
173
  }, z.ZodTypeAny, "passthrough">>, "many">;
172
174
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
173
175
  path: z.ZodString;
174
176
  declarations: z.ZodArray<z.ZodObject<{
175
177
  name: z.ZodString;
176
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
178
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
177
179
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
178
180
  name: z.ZodString;
179
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
181
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
180
182
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
181
183
  name: z.ZodString;
182
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
184
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
183
185
  }, z.ZodTypeAny, "passthrough">>, "many">;
184
186
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
185
187
  path: z.ZodString;
186
188
  declarations: z.ZodArray<z.ZodObject<{
187
189
  name: z.ZodString;
188
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
190
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
189
191
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
190
192
  name: z.ZodString;
191
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
193
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
192
194
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
193
195
  name: z.ZodString;
194
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
196
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
195
197
  }, z.ZodTypeAny, "passthrough">>, "many">;
196
198
  }, z.ZodTypeAny, "passthrough">>>, Record<string, z.objectOutputType<{
197
199
  path: z.ZodString;
198
200
  declarations: z.ZodArray<z.ZodObject<{
199
201
  name: z.ZodString;
200
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
202
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
201
203
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
202
204
  name: z.ZodString;
203
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
205
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
204
206
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
205
207
  name: z.ZodString;
206
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
208
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
207
209
  }, z.ZodTypeAny, "passthrough">>, "many">;
208
210
  }, z.ZodTypeAny, "passthrough">> | undefined, Record<string, z.objectInputType<{
209
211
  path: z.ZodString;
210
212
  declarations: z.ZodArray<z.ZodObject<{
211
213
  name: z.ZodString;
212
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
214
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
213
215
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
214
216
  name: z.ZodString;
215
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
217
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
216
218
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
217
219
  name: z.ZodString;
218
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
220
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
219
221
  }, z.ZodTypeAny, "passthrough">>, "many">;
220
222
  }, z.ZodTypeAny, "passthrough">>>>;
221
223
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
@@ -225,61 +227,61 @@ export declare const Src_Json: z.ZodObject<{
225
227
  path: z.ZodString;
226
228
  declarations: z.ZodArray<z.ZodObject<{
227
229
  name: z.ZodString;
228
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
230
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
229
231
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
230
232
  name: z.ZodString;
231
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
233
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
232
234
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
233
235
  name: z.ZodString;
234
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
236
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
235
237
  }, z.ZodTypeAny, "passthrough">>, "many">;
236
238
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
237
239
  path: z.ZodString;
238
240
  declarations: z.ZodArray<z.ZodObject<{
239
241
  name: z.ZodString;
240
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
242
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
241
243
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
242
244
  name: z.ZodString;
243
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
245
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
244
246
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
245
247
  name: z.ZodString;
246
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
248
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
247
249
  }, z.ZodTypeAny, "passthrough">>, "many">;
248
250
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
249
251
  path: z.ZodString;
250
252
  declarations: z.ZodArray<z.ZodObject<{
251
253
  name: z.ZodString;
252
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
254
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
253
255
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
254
256
  name: z.ZodString;
255
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
257
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
256
258
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
257
259
  name: z.ZodString;
258
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
260
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
259
261
  }, z.ZodTypeAny, "passthrough">>, "many">;
260
262
  }, z.ZodTypeAny, "passthrough">>>, Record<string, z.objectOutputType<{
261
263
  path: z.ZodString;
262
264
  declarations: z.ZodArray<z.ZodObject<{
263
265
  name: z.ZodString;
264
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
266
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
265
267
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
266
268
  name: z.ZodString;
267
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
269
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
268
270
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
269
271
  name: z.ZodString;
270
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
272
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
271
273
  }, z.ZodTypeAny, "passthrough">>, "many">;
272
274
  }, z.ZodTypeAny, "passthrough">> | undefined, Record<string, z.objectInputType<{
273
275
  path: z.ZodString;
274
276
  declarations: z.ZodArray<z.ZodObject<{
275
277
  name: z.ZodString;
276
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
278
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
277
279
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
278
280
  name: z.ZodString;
279
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
281
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
280
282
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
281
283
  name: z.ZodString;
282
- kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
284
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class", "component", "json", "css"]>>;
283
285
  }, z.ZodTypeAny, "passthrough">>, "many">;
284
286
  }, z.ZodTypeAny, "passthrough">>>>;
285
287
  }, z.ZodTypeAny, "passthrough">>;
@@ -1 +1 @@
1
- {"version":3,"file":"src_json.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/src_json.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAOtB,OAAO,EAEN,KAAK,YAAY,EACjB,KAAK,oBAAoB,EACzB,MAAM,mBAAmB,CAAC;AAG3B,eAAO,MAAM,sBAAsB;;;;;;;;;gCAQpB,CAAC;AAChB,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAG5E,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAKR,CAAC;AAChB,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAGpD,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iCAAuB,CAAC;AAChD,M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- import { Project } from 'ts-morph';
2
+ import { join, extname } from 'node:path';
3
+ import { ensure_end, strip_start } from '@ryanatkn/belt/string.js';
5
4
  import { existsSync } from 'node:fs';
5
+ import ts from 'typescript';
6
6
  import { paths, replace_extension } from "./paths.js";
7
7
  import { transform_empty_object_to_undefined, } from "./package_json.js";
8
+ import { parse_exports } from "./parse_exports.js";
9
+ export const Src_Module_Declaration_Kind = z.enum([
10
+ 'type',
11
+ 'function',
12
+ 'variable',
13
+ 'class',
14
+ 'component',
15
+ 'json',
16
+ 'css',
17
+ ]);
8
18
  // TODO @many rename to prefix with `Src_Json_`?
9
19
  export const Src_Module_Declaration = z
10
20
  .object({
11
21
  name: z.string(), // the export identifier
12
22
  // TODO these are poorly named, and they're somewhat redundant with `kind`,
13
23
  // they were added to distinguish `VariableDeclaration` functions and non-functions
14
- kind: z.enum(['type', 'function', 'variable', 'class']).nullable(),
24
+ kind: Src_Module_Declaration_Kind.nullable(),
15
25
  // code: z.string(), // TODO experiment with `getType().getText()`, some of them return the same as `name`
16
26
  })
17
27
  .passthrough();
@@ -46,62 +56,55 @@ export const serialize_src_json = (src_json) => {
46
56
  export const to_src_modules = (exports, lib_path = paths.lib) => {
47
57
  if (!exports)
48
58
  return;
49
- const project = new Project();
50
- project.addSourceFilesAtPaths(join(lib_path, '**/*.ts'));
51
- return Object.fromEntries(Object.entries(exports).map(([k, _v]) => {
52
- // TODO hacky - doesn't handle any but the typical mappings, also add a helper?
59
+ // Prepare a list of files to analyze
60
+ const file_paths = [];
61
+ for (const [k, _v] of Object.entries(exports)) {
62
+ // Handle different file types
53
63
  const source_file_path = k === '.' || k === './'
54
64
  ? 'index.ts'
55
65
  : strip_start(k.endsWith('.js') ? replace_extension(k, '.ts') : k, './');
56
- if (!source_file_path.endsWith('.ts')) {
57
- // TODO support more than just TypeScript - maybe use @sveltejs/language-tools,
58
- // see how @sveltejs/package generates types, or maybe use its generated declaration files with ts-morph
59
- const src_module = { path: source_file_path, declarations: [] };
60
- return [k, src_module];
61
- }
62
66
  const source_file_id = join(lib_path, source_file_path);
67
+ // Check if file exists
63
68
  if (!existsSync(source_file_id)) {
64
- throw Error(`Failed to infer source file from package.json export path ${k} - the inferred file ${source_file_id} does not exist`);
65
- }
66
- const declarations = [];
67
- const source_file = project.getSourceFile(source_file_id);
68
- if (source_file) {
69
- for (const [name, decls] of source_file.getExportedDeclarations()) {
70
- // TODO how to correctly handle multiples?
71
- for (const decl of decls) {
72
- // TODO helper
73
- const decl_type = decl.getType();
74
- const k = decl.getKindName();
75
- const kind = k === 'InterfaceDeclaration' || k === 'TypeAliasDeclaration'
76
- ? 'type'
77
- : k === 'ClassDeclaration'
78
- ? 'class'
79
- : k === 'VariableDeclaration'
80
- ? decl_type.getCallSignatures().length
81
- ? 'function'
82
- : 'variable' // TODO name?
83
- : null;
84
- // TODO
85
- // const code =
86
- // k === 'InterfaceDeclaration' || k === 'TypeAliasDeclaration'
87
- // ? decl_type.getText(source_file) // TODO
88
- // : decl_type.getText(source_file);
89
- const found = declarations.find((d) => d.name === name);
90
- if (found) {
91
- // TODO hacky, this only was added to prevent `TypeAliasDeclaration` from overriding `VariableDeclaration`
92
- if (found.kind === 'type') {
93
- found.kind = kind;
94
- // found.code = code;
95
- }
96
- }
97
- else {
98
- // TODO more
99
- declarations.push({ name, kind }); // code
100
- }
101
- }
69
+ // Handle non-TypeScript files (Svelte, CSS, JSON)
70
+ const extension = extname(source_file_id);
71
+ if (extension === '.svelte' || extension === '.css' || extension === '.json') {
72
+ file_paths.push({ export_key: k, file_path: source_file_id });
73
+ continue;
102
74
  }
75
+ throw Error(`Failed to infer source file from package.json export path ${k} - the inferred file ${source_file_id} does not exist`);
103
76
  }
104
- const src_module = { path: source_file_path, declarations };
105
- return [k, src_module];
106
- }));
77
+ file_paths.push({ export_key: k, file_path: source_file_id });
78
+ }
79
+ // Create a TypeScript program for all TypeScript files
80
+ const ts_files = file_paths
81
+ .filter(({ file_path }) => file_path.endsWith('.ts') || file_path.endsWith('.tsx'))
82
+ .map(({ file_path }) => file_path);
83
+ let program;
84
+ if (ts_files.length > 0) {
85
+ program = ts.createProgram(ts_files,
86
+ // TODO get from tsconfig?
87
+ {
88
+ target: ts.ScriptTarget.ESNext,
89
+ module: ts.ModuleKind.ESNext,
90
+ moduleResolution: ts.ModuleResolutionKind.NodeNext,
91
+ verbatimModuleSyntax: true,
92
+ isolatedModules: true,
93
+ });
94
+ }
95
+ const result = {};
96
+ // Process each file
97
+ for (const { export_key, file_path } of file_paths) {
98
+ const relative_path = file_path.replace(ensure_end(lib_path, '/'), '');
99
+ // Use parse_exports for all file types
100
+ const declarations = parse_exports(file_path, program).map(({ name, kind }) => ({
101
+ name,
102
+ kind: kind,
103
+ }));
104
+ result[export_key] = {
105
+ path: relative_path,
106
+ declarations,
107
+ };
108
+ }
109
+ return result;
107
110
  };
@@ -0,0 +1,21 @@
1
+ import ts from 'typescript';
2
+ export declare const SOME_PUBLIC_ENV_VAR_NAME = "PUBLIC_SOME_PUBLIC_ENV_VAR";
3
+ export declare const SOME_PUBLIC_ENV_VAR_VALUE = "SOME_PUBLIC_ENV_VAR";
4
+ /**
5
+ * Hacky global helper to init the test env.
6
+ *
7
+ * @returns boolean indicating if the env file was created or not
8
+ */
9
+ export declare const init_test_env: (dir?: string, env_filename?: string) => boolean;
10
+ /**
11
+ * Creates a TypeScript environment for testing.
12
+ * Change to `typescript-go` when it's more ready.
13
+ * @see https://github.com/microsoft/typescript-go?tab=readme-ov-file#what-works-so-far
14
+ */
15
+ export declare const create_ts_test_env: (source_code: string, dir?: string, virtual_files?: Record<string, string>) => {
16
+ source_file: ts.SourceFile;
17
+ checker: ts.TypeChecker;
18
+ program: ts.Program;
19
+ exports: Array<ts.Symbol>;
20
+ };
21
+ //# sourceMappingURL=test_helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test_helpers.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/test_helpers.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,eAAO,MAAM,wBAAwB,+BAA+B,CAAC;AACrE,eAAO,MAAM,yBAAyB,wBAAwB,CAAC;AAM/D;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,YAAmB,EAAE,qBAAqB,KAAG,OA6B1E,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAC9B,aAAa,MAAM,EACnB,MAAK,MAAsB,EAC3B,gBAAe,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,KACxC;IACF,WAAW,EAAE,EAAE,CAAC,UAAU,CAAC;IAC3B,OAAO,EAAE,EAAE,CAAC,WAAW,CAAC;IACxB,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC;IACpB,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;CAkG1B,CAAC"}