@fuzdev/fuz_util 0.42.0

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 (135) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +83 -0
  3. package/dist/array.d.ts +15 -0
  4. package/dist/array.d.ts.map +1 -0
  5. package/dist/array.js +25 -0
  6. package/dist/async.d.ts +62 -0
  7. package/dist/async.d.ts.map +1 -0
  8. package/dist/async.js +147 -0
  9. package/dist/colors.d.ts +41 -0
  10. package/dist/colors.d.ts.map +1 -0
  11. package/dist/colors.js +106 -0
  12. package/dist/counter.d.ts +7 -0
  13. package/dist/counter.d.ts.map +1 -0
  14. package/dist/counter.js +7 -0
  15. package/dist/deep_equal.d.ts +18 -0
  16. package/dist/deep_equal.d.ts.map +1 -0
  17. package/dist/deep_equal.js +152 -0
  18. package/dist/dom.d.ts +35 -0
  19. package/dist/dom.d.ts.map +1 -0
  20. package/dist/dom.js +95 -0
  21. package/dist/error.d.ts +15 -0
  22. package/dist/error.d.ts.map +1 -0
  23. package/dist/error.js +18 -0
  24. package/dist/fetch.d.ts +81 -0
  25. package/dist/fetch.d.ts.map +1 -0
  26. package/dist/fetch.js +162 -0
  27. package/dist/fs.d.ts +34 -0
  28. package/dist/fs.d.ts.map +1 -0
  29. package/dist/fs.js +73 -0
  30. package/dist/function.d.ts +27 -0
  31. package/dist/function.d.ts.map +1 -0
  32. package/dist/function.js +21 -0
  33. package/dist/git.d.ts +132 -0
  34. package/dist/git.d.ts.map +1 -0
  35. package/dist/git.js +288 -0
  36. package/dist/id.d.ts +18 -0
  37. package/dist/id.d.ts.map +1 -0
  38. package/dist/id.js +18 -0
  39. package/dist/iterator.d.ts +5 -0
  40. package/dist/iterator.d.ts.map +1 -0
  41. package/dist/iterator.js +9 -0
  42. package/dist/json.d.ts +30 -0
  43. package/dist/json.d.ts.map +1 -0
  44. package/dist/json.js +44 -0
  45. package/dist/library_json.d.ts +42 -0
  46. package/dist/library_json.d.ts.map +1 -0
  47. package/dist/library_json.js +76 -0
  48. package/dist/log.d.ts +188 -0
  49. package/dist/log.d.ts.map +1 -0
  50. package/dist/log.js +393 -0
  51. package/dist/map.d.ts +12 -0
  52. package/dist/map.d.ts.map +1 -0
  53. package/dist/map.js +14 -0
  54. package/dist/maths.d.ts +85 -0
  55. package/dist/maths.d.ts.map +1 -0
  56. package/dist/maths.js +87 -0
  57. package/dist/object.d.ts +46 -0
  58. package/dist/object.d.ts.map +1 -0
  59. package/dist/object.js +89 -0
  60. package/dist/package_json.d.ts +90 -0
  61. package/dist/package_json.d.ts.map +1 -0
  62. package/dist/package_json.js +112 -0
  63. package/dist/path.d.ts +63 -0
  64. package/dist/path.d.ts.map +1 -0
  65. package/dist/path.js +83 -0
  66. package/dist/print.d.ts +52 -0
  67. package/dist/print.d.ts.map +1 -0
  68. package/dist/print.js +89 -0
  69. package/dist/process.d.ts +77 -0
  70. package/dist/process.d.ts.map +1 -0
  71. package/dist/process.js +148 -0
  72. package/dist/random.d.ts +25 -0
  73. package/dist/random.d.ts.map +1 -0
  74. package/dist/random.js +35 -0
  75. package/dist/random_alea.d.ts +23 -0
  76. package/dist/random_alea.d.ts.map +1 -0
  77. package/dist/random_alea.js +95 -0
  78. package/dist/regexp.d.ts +12 -0
  79. package/dist/regexp.d.ts.map +1 -0
  80. package/dist/regexp.js +16 -0
  81. package/dist/result.d.ts +64 -0
  82. package/dist/result.d.ts.map +1 -0
  83. package/dist/result.js +48 -0
  84. package/dist/source_json.d.ts +375 -0
  85. package/dist/source_json.d.ts.map +1 -0
  86. package/dist/source_json.js +189 -0
  87. package/dist/string.d.ts +51 -0
  88. package/dist/string.d.ts.map +1 -0
  89. package/dist/string.js +92 -0
  90. package/dist/throttle.d.ts +26 -0
  91. package/dist/throttle.d.ts.map +1 -0
  92. package/dist/throttle.js +53 -0
  93. package/dist/timings.d.ts +33 -0
  94. package/dist/timings.d.ts.map +1 -0
  95. package/dist/timings.js +75 -0
  96. package/dist/types.d.ts +77 -0
  97. package/dist/types.d.ts.map +1 -0
  98. package/dist/types.js +10 -0
  99. package/dist/url.d.ts +10 -0
  100. package/dist/url.d.ts.map +1 -0
  101. package/dist/url.js +8 -0
  102. package/package.json +125 -0
  103. package/src/lib/array.ts +30 -0
  104. package/src/lib/async.ts +182 -0
  105. package/src/lib/colors.ts +132 -0
  106. package/src/lib/counter.ts +11 -0
  107. package/src/lib/deep_equal.ts +155 -0
  108. package/src/lib/dom.ts +108 -0
  109. package/src/lib/error.ts +22 -0
  110. package/src/lib/fetch.ts +231 -0
  111. package/src/lib/fs.ts +128 -0
  112. package/src/lib/function.ts +32 -0
  113. package/src/lib/git.ts +390 -0
  114. package/src/lib/id.ts +30 -0
  115. package/src/lib/iterator.ts +8 -0
  116. package/src/lib/json.ts +61 -0
  117. package/src/lib/library_json.ts +122 -0
  118. package/src/lib/log.ts +469 -0
  119. package/src/lib/map.ts +18 -0
  120. package/src/lib/maths.ts +91 -0
  121. package/src/lib/object.ts +110 -0
  122. package/src/lib/package_json.ts +135 -0
  123. package/src/lib/path.ts +137 -0
  124. package/src/lib/print.ts +111 -0
  125. package/src/lib/process.ts +207 -0
  126. package/src/lib/random.ts +48 -0
  127. package/src/lib/random_alea.ts +107 -0
  128. package/src/lib/regexp.ts +17 -0
  129. package/src/lib/result.ts +67 -0
  130. package/src/lib/source_json.ts +209 -0
  131. package/src/lib/string.ts +99 -0
  132. package/src/lib/throttle.ts +70 -0
  133. package/src/lib/timings.ts +93 -0
  134. package/src/lib/types.ts +99 -0
  135. package/src/lib/url.ts +14 -0
@@ -0,0 +1,375 @@
1
+ /**
2
+ * Metadata types for library source code analysis.
3
+ *
4
+ * These types represent the structure of `src/lib/` exports,
5
+ * extracted at build time via TypeScript compiler analysis.
6
+ * Used for generating API documentation and enabling code search.
7
+ *
8
+ * Hierarchy: SourceJson → ModuleJson → DeclarationJson
9
+ */
10
+ import { z } from 'zod';
11
+ /**
12
+ * The kind of exported declaration.
13
+ */
14
+ export declare const DeclarationKind: z.ZodEnum<{
15
+ function: "function";
16
+ type: "type";
17
+ json: "json";
18
+ variable: "variable";
19
+ class: "class";
20
+ constructor: "constructor";
21
+ component: "component";
22
+ css: "css";
23
+ }>;
24
+ export type DeclarationKind = z.infer<typeof DeclarationKind>;
25
+ /**
26
+ * Generic type parameter information.
27
+ */
28
+ export declare const GenericParamInfo: z.ZodObject<{
29
+ /** Parameter name like `T`. */
30
+ name: z.ZodString;
31
+ /** Constraint like `string` from `T extends string`. */
32
+ constraint: z.ZodOptional<z.ZodString>;
33
+ /** Default type like `unknown` from `T = unknown`. */
34
+ default_type: z.ZodOptional<z.ZodString>;
35
+ }, z.core.$loose>;
36
+ export type GenericParamInfo = z.infer<typeof GenericParamInfo>;
37
+ /**
38
+ * Parameter information for functions and methods.
39
+ *
40
+ * Kept distinct from ComponentPropInfo despite structural similarity.
41
+ * Function parameters form a tuple with positional semantics:
42
+ * calling order matters (`fn(a, b)` vs `fn(b, a)`),
43
+ * may include rest parameters and destructuring patterns.
44
+ */
45
+ export declare const ParameterInfo: z.ZodObject<{
46
+ name: z.ZodString;
47
+ type: z.ZodString;
48
+ optional: z.ZodOptional<z.ZodBoolean>;
49
+ description: z.ZodOptional<z.ZodString>;
50
+ default_value: z.ZodOptional<z.ZodString>;
51
+ }, z.core.$loose>;
52
+ export type ParameterInfo = z.infer<typeof ParameterInfo>;
53
+ /**
54
+ * Component prop information for Svelte components.
55
+ *
56
+ * Kept distinct from ParameterInfo despite structural similarity.
57
+ * Component props are named attributes with different semantics:
58
+ * no positional order when passing (`<Foo {a} {b} />` = `<Foo {b} {a} />`),
59
+ * support two-way binding via `$bindable` rune.
60
+ */
61
+ export declare const ComponentPropInfo: z.ZodObject<{
62
+ name: z.ZodString;
63
+ type: z.ZodString;
64
+ optional: z.ZodOptional<z.ZodBoolean>;
65
+ description: z.ZodOptional<z.ZodString>;
66
+ default_value: z.ZodOptional<z.ZodString>;
67
+ bindable: z.ZodOptional<z.ZodBoolean>;
68
+ }, z.core.$loose>;
69
+ export type ComponentPropInfo = z.infer<typeof ComponentPropInfo>;
70
+ /**
71
+ * Metadata for an exported declaration (function, type, class, component, etc.).
72
+ *
73
+ * Extracted from TypeScript source and JSDoc/TSDoc comments at build time.
74
+ */
75
+ export declare const DeclarationJson: z.ZodObject<{
76
+ /** The exported name. */
77
+ name: z.ZodString;
78
+ kind: z.ZodEnum<{
79
+ function: "function";
80
+ type: "type";
81
+ json: "json";
82
+ variable: "variable";
83
+ class: "class";
84
+ constructor: "constructor";
85
+ component: "component";
86
+ css: "css";
87
+ }>;
88
+ /** JSDoc/TSDoc comment in mdz format. */
89
+ doc_comment: z.ZodOptional<z.ZodString>;
90
+ /** Full TypeScript type signature. */
91
+ type_signature: z.ZodOptional<z.ZodString>;
92
+ /** TypeScript modifiers like `readonly`, `private`, or `static`. */
93
+ modifiers: z.ZodOptional<z.ZodArray<z.ZodString>>;
94
+ /** 1-indexed line number in source file. */
95
+ source_line: z.ZodOptional<z.ZodNumber>;
96
+ /** Function/method parameters. */
97
+ parameters: z.ZodOptional<z.ZodArray<z.ZodObject<{
98
+ name: z.ZodString;
99
+ type: z.ZodString;
100
+ optional: z.ZodOptional<z.ZodBoolean>;
101
+ description: z.ZodOptional<z.ZodString>;
102
+ default_value: z.ZodOptional<z.ZodString>;
103
+ }, z.core.$loose>>>;
104
+ /** Function/method return type. */
105
+ return_type: z.ZodOptional<z.ZodString>;
106
+ /** Return value description from `@returns` tag. */
107
+ return_description: z.ZodOptional<z.ZodString>;
108
+ /** Generic type parameters like `<T, U>`. */
109
+ generic_params: z.ZodOptional<z.ZodArray<z.ZodObject<{
110
+ /** Parameter name like `T`. */
111
+ name: z.ZodString;
112
+ /** Constraint like `string` from `T extends string`. */
113
+ constraint: z.ZodOptional<z.ZodString>;
114
+ /** Default type like `unknown` from `T = unknown`. */
115
+ default_type: z.ZodOptional<z.ZodString>;
116
+ }, z.core.$loose>>>;
117
+ /** Code examples from `@example` tags. */
118
+ examples: z.ZodOptional<z.ZodArray<z.ZodString>>;
119
+ /** Deprecation message from `@deprecated` tag. */
120
+ deprecated_message: z.ZodOptional<z.ZodString>;
121
+ /** Related items from `@see` tags, in mdz format. */
122
+ see_also: z.ZodOptional<z.ZodArray<z.ZodString>>;
123
+ /** Exceptions from `@throws` tags. */
124
+ throws: z.ZodOptional<z.ZodArray<z.ZodObject<{
125
+ type: z.ZodOptional<z.ZodString>;
126
+ description: z.ZodString;
127
+ }, z.core.$loose>>>;
128
+ /** Version introduced, from `@since` tag. */
129
+ since: z.ZodOptional<z.ZodString>;
130
+ /** Extended classes/interfaces. */
131
+ extends: z.ZodOptional<z.ZodArray<z.ZodString>>;
132
+ /** Implemented interfaces. */
133
+ implements: z.ZodOptional<z.ZodArray<z.ZodString>>;
134
+ /** Class or interface members (recursive). */
135
+ readonly members: z.ZodOptional<z.ZodArray<z.ZodObject</*elided*/ any, z.core.$loose>>>;
136
+ /** Type/interface properties (recursive). */
137
+ readonly properties: z.ZodOptional<z.ZodArray<z.ZodObject</*elided*/ any, z.core.$loose>>>;
138
+ /** Svelte component props. */
139
+ props: z.ZodOptional<z.ZodArray<z.ZodObject<{
140
+ name: z.ZodString;
141
+ type: z.ZodString;
142
+ optional: z.ZodOptional<z.ZodBoolean>;
143
+ description: z.ZodOptional<z.ZodString>;
144
+ default_value: z.ZodOptional<z.ZodString>;
145
+ bindable: z.ZodOptional<z.ZodBoolean>;
146
+ }, z.core.$loose>>>;
147
+ /**
148
+ * Module paths (relative to src/lib) that re-export this declaration.
149
+ * The canonical location is this module's `declarations` array.
150
+ */
151
+ also_exported_from: z.ZodOptional<z.ZodArray<z.ZodString>>;
152
+ /**
153
+ * For renamed re-exports (`export {foo as bar}`), the original declaration.
154
+ */
155
+ alias_of: z.ZodOptional<z.ZodObject<{
156
+ module: z.ZodString;
157
+ name: z.ZodString;
158
+ }, z.core.$strip>>;
159
+ }, z.core.$loose>;
160
+ export type DeclarationJson = z.infer<typeof DeclarationJson>;
161
+ /**
162
+ * A source file in `src/lib/` with its exported declarations.
163
+ */
164
+ export declare const ModuleJson: z.ZodObject<{
165
+ /** Path relative to src/lib (e.g., `helpers.ts`). */
166
+ path: z.ZodString;
167
+ declarations: z.ZodOptional<z.ZodArray<z.ZodObject<{
168
+ /** The exported name. */
169
+ name: z.ZodString;
170
+ kind: z.ZodEnum<{
171
+ function: "function";
172
+ type: "type";
173
+ json: "json";
174
+ variable: "variable";
175
+ class: "class";
176
+ constructor: "constructor";
177
+ component: "component";
178
+ css: "css";
179
+ }>;
180
+ /** JSDoc/TSDoc comment in mdz format. */
181
+ doc_comment: z.ZodOptional<z.ZodString>;
182
+ /** Full TypeScript type signature. */
183
+ type_signature: z.ZodOptional<z.ZodString>;
184
+ /** TypeScript modifiers like `readonly`, `private`, or `static`. */
185
+ modifiers: z.ZodOptional<z.ZodArray<z.ZodString>>;
186
+ /** 1-indexed line number in source file. */
187
+ source_line: z.ZodOptional<z.ZodNumber>;
188
+ /** Function/method parameters. */
189
+ parameters: z.ZodOptional<z.ZodArray<z.ZodObject<{
190
+ name: z.ZodString;
191
+ type: z.ZodString;
192
+ optional: z.ZodOptional<z.ZodBoolean>;
193
+ description: z.ZodOptional<z.ZodString>;
194
+ default_value: z.ZodOptional<z.ZodString>;
195
+ }, z.core.$loose>>>;
196
+ /** Function/method return type. */
197
+ return_type: z.ZodOptional<z.ZodString>;
198
+ /** Return value description from `@returns` tag. */
199
+ return_description: z.ZodOptional<z.ZodString>;
200
+ /** Generic type parameters like `<T, U>`. */
201
+ generic_params: z.ZodOptional<z.ZodArray<z.ZodObject<{
202
+ /** Parameter name like `T`. */
203
+ name: z.ZodString;
204
+ /** Constraint like `string` from `T extends string`. */
205
+ constraint: z.ZodOptional<z.ZodString>;
206
+ /** Default type like `unknown` from `T = unknown`. */
207
+ default_type: z.ZodOptional<z.ZodString>;
208
+ }, z.core.$loose>>>;
209
+ /** Code examples from `@example` tags. */
210
+ examples: z.ZodOptional<z.ZodArray<z.ZodString>>;
211
+ /** Deprecation message from `@deprecated` tag. */
212
+ deprecated_message: z.ZodOptional<z.ZodString>;
213
+ /** Related items from `@see` tags, in mdz format. */
214
+ see_also: z.ZodOptional<z.ZodArray<z.ZodString>>;
215
+ /** Exceptions from `@throws` tags. */
216
+ throws: z.ZodOptional<z.ZodArray<z.ZodObject<{
217
+ type: z.ZodOptional<z.ZodString>;
218
+ description: z.ZodString;
219
+ }, z.core.$loose>>>;
220
+ /** Version introduced, from `@since` tag. */
221
+ since: z.ZodOptional<z.ZodString>;
222
+ /** Extended classes/interfaces. */
223
+ extends: z.ZodOptional<z.ZodArray<z.ZodString>>;
224
+ /** Implemented interfaces. */
225
+ implements: z.ZodOptional<z.ZodArray<z.ZodString>>;
226
+ /** Class or interface members (recursive). */
227
+ readonly members: z.ZodOptional<z.ZodArray<z.ZodObject</*elided*/ any, z.core.$loose>>>;
228
+ /** Type/interface properties (recursive). */
229
+ readonly properties: z.ZodOptional<z.ZodArray<z.ZodObject</*elided*/ any, z.core.$loose>>>;
230
+ /** Svelte component props. */
231
+ props: z.ZodOptional<z.ZodArray<z.ZodObject<{
232
+ name: z.ZodString;
233
+ type: z.ZodString;
234
+ optional: z.ZodOptional<z.ZodBoolean>;
235
+ description: z.ZodOptional<z.ZodString>;
236
+ default_value: z.ZodOptional<z.ZodString>;
237
+ bindable: z.ZodOptional<z.ZodBoolean>;
238
+ }, z.core.$loose>>>;
239
+ /**
240
+ * Module paths (relative to src/lib) that re-export this declaration.
241
+ * The canonical location is this module's `declarations` array.
242
+ */
243
+ also_exported_from: z.ZodOptional<z.ZodArray<z.ZodString>>;
244
+ /**
245
+ * For renamed re-exports (`export {foo as bar}`), the original declaration.
246
+ */
247
+ alias_of: z.ZodOptional<z.ZodObject<{
248
+ module: z.ZodString;
249
+ name: z.ZodString;
250
+ }, z.core.$strip>>;
251
+ }, z.core.$loose>>>;
252
+ /** File-level JSDoc comment. */
253
+ module_comment: z.ZodOptional<z.ZodString>;
254
+ /** Modules this imports (paths relative to src/lib). */
255
+ dependencies: z.ZodOptional<z.ZodArray<z.ZodString>>;
256
+ /** Modules that import this (paths relative to src/lib). */
257
+ dependents: z.ZodOptional<z.ZodArray<z.ZodString>>;
258
+ }, z.core.$loose>;
259
+ export type ModuleJson = z.infer<typeof ModuleJson>;
260
+ /**
261
+ * Metadata for a library's `src/lib/` exports.
262
+ */
263
+ export declare const SourceJson: z.ZodObject<{
264
+ name: z.ZodString;
265
+ version: z.ZodString;
266
+ modules: z.ZodOptional<z.ZodArray<z.ZodObject<{
267
+ /** Path relative to src/lib (e.g., `helpers.ts`). */
268
+ path: z.ZodString;
269
+ declarations: z.ZodOptional<z.ZodArray<z.ZodObject<{
270
+ /** The exported name. */
271
+ name: z.ZodString;
272
+ kind: z.ZodEnum<{
273
+ function: "function";
274
+ type: "type";
275
+ json: "json";
276
+ variable: "variable";
277
+ class: "class";
278
+ constructor: "constructor";
279
+ component: "component";
280
+ css: "css";
281
+ }>;
282
+ /** JSDoc/TSDoc comment in mdz format. */
283
+ doc_comment: z.ZodOptional<z.ZodString>;
284
+ /** Full TypeScript type signature. */
285
+ type_signature: z.ZodOptional<z.ZodString>;
286
+ /** TypeScript modifiers like `readonly`, `private`, or `static`. */
287
+ modifiers: z.ZodOptional<z.ZodArray<z.ZodString>>;
288
+ /** 1-indexed line number in source file. */
289
+ source_line: z.ZodOptional<z.ZodNumber>;
290
+ /** Function/method parameters. */
291
+ parameters: z.ZodOptional<z.ZodArray<z.ZodObject<{
292
+ name: z.ZodString;
293
+ type: z.ZodString;
294
+ optional: z.ZodOptional<z.ZodBoolean>;
295
+ description: z.ZodOptional<z.ZodString>;
296
+ default_value: z.ZodOptional<z.ZodString>;
297
+ }, z.core.$loose>>>;
298
+ /** Function/method return type. */
299
+ return_type: z.ZodOptional<z.ZodString>;
300
+ /** Return value description from `@returns` tag. */
301
+ return_description: z.ZodOptional<z.ZodString>;
302
+ /** Generic type parameters like `<T, U>`. */
303
+ generic_params: z.ZodOptional<z.ZodArray<z.ZodObject<{
304
+ /** Parameter name like `T`. */
305
+ name: z.ZodString;
306
+ /** Constraint like `string` from `T extends string`. */
307
+ constraint: z.ZodOptional<z.ZodString>;
308
+ /** Default type like `unknown` from `T = unknown`. */
309
+ default_type: z.ZodOptional<z.ZodString>;
310
+ }, z.core.$loose>>>;
311
+ /** Code examples from `@example` tags. */
312
+ examples: z.ZodOptional<z.ZodArray<z.ZodString>>;
313
+ /** Deprecation message from `@deprecated` tag. */
314
+ deprecated_message: z.ZodOptional<z.ZodString>;
315
+ /** Related items from `@see` tags, in mdz format. */
316
+ see_also: z.ZodOptional<z.ZodArray<z.ZodString>>;
317
+ /** Exceptions from `@throws` tags. */
318
+ throws: z.ZodOptional<z.ZodArray<z.ZodObject<{
319
+ type: z.ZodOptional<z.ZodString>;
320
+ description: z.ZodString;
321
+ }, z.core.$loose>>>;
322
+ /** Version introduced, from `@since` tag. */
323
+ since: z.ZodOptional<z.ZodString>;
324
+ /** Extended classes/interfaces. */
325
+ extends: z.ZodOptional<z.ZodArray<z.ZodString>>;
326
+ /** Implemented interfaces. */
327
+ implements: z.ZodOptional<z.ZodArray<z.ZodString>>;
328
+ /** Class or interface members (recursive). */
329
+ readonly members: z.ZodOptional<z.ZodArray<z.ZodObject</*elided*/ any, z.core.$loose>>>;
330
+ /** Type/interface properties (recursive). */
331
+ readonly properties: z.ZodOptional<z.ZodArray<z.ZodObject</*elided*/ any, z.core.$loose>>>;
332
+ /** Svelte component props. */
333
+ props: z.ZodOptional<z.ZodArray<z.ZodObject<{
334
+ name: z.ZodString;
335
+ type: z.ZodString;
336
+ optional: z.ZodOptional<z.ZodBoolean>;
337
+ description: z.ZodOptional<z.ZodString>;
338
+ default_value: z.ZodOptional<z.ZodString>;
339
+ bindable: z.ZodOptional<z.ZodBoolean>;
340
+ }, z.core.$loose>>>;
341
+ /**
342
+ * Module paths (relative to src/lib) that re-export this declaration.
343
+ * The canonical location is this module's `declarations` array.
344
+ */
345
+ also_exported_from: z.ZodOptional<z.ZodArray<z.ZodString>>;
346
+ /**
347
+ * For renamed re-exports (`export {foo as bar}`), the original declaration.
348
+ */
349
+ alias_of: z.ZodOptional<z.ZodObject<{
350
+ module: z.ZodString;
351
+ name: z.ZodString;
352
+ }, z.core.$strip>>;
353
+ }, z.core.$loose>>>;
354
+ /** File-level JSDoc comment. */
355
+ module_comment: z.ZodOptional<z.ZodString>;
356
+ /** Modules this imports (paths relative to src/lib). */
357
+ dependencies: z.ZodOptional<z.ZodArray<z.ZodString>>;
358
+ /** Modules that import this (paths relative to src/lib). */
359
+ dependents: z.ZodOptional<z.ZodArray<z.ZodString>>;
360
+ }, z.core.$loose>>>;
361
+ }, z.core.$loose>;
362
+ export type SourceJson = z.infer<typeof SourceJson>;
363
+ /**
364
+ * Format declaration name with generic parameters for display.
365
+ * @example declaration_get_display_name({name: 'Map', kind: 'type', generic_params: [{name: 'K'}, {name: 'V'}]})
366
+ * // => 'Map<K, V>'
367
+ */
368
+ export declare const declaration_get_display_name: (declaration: DeclarationJson) => string;
369
+ /**
370
+ * Generate TypeScript import statement for a declaration.
371
+ * @example declaration_generate_import({name: 'Foo', kind: 'type'}, 'foo.ts', '@pkg/lib')
372
+ * // => "import type {Foo} from '@pkg/lib/foo.js';"
373
+ */
374
+ export declare const declaration_generate_import: (declaration: DeclarationJson, module_path: string, library_name: string) => string;
375
+ //# sourceMappingURL=source_json.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source_json.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/source_json.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;;;;;EAS1B,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAE9D;;GAEG;AACH,eAAO,MAAM,gBAAgB;IAC5B,+BAA+B;;IAE/B,wDAAw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
2
+ * Metadata types for library source code analysis.
3
+ *
4
+ * These types represent the structure of `src/lib/` exports,
5
+ * extracted at build time via TypeScript compiler analysis.
6
+ * Used for generating API documentation and enabling code search.
7
+ *
8
+ * Hierarchy: SourceJson → ModuleJson → DeclarationJson
9
+ */
10
+ import { z } from 'zod';
11
+ /**
12
+ * The kind of exported declaration.
13
+ */
14
+ export const DeclarationKind = z.enum([
15
+ 'type',
16
+ 'function',
17
+ 'variable',
18
+ 'class',
19
+ 'constructor',
20
+ 'component',
21
+ 'json',
22
+ 'css',
23
+ ]);
24
+ /**
25
+ * Generic type parameter information.
26
+ */
27
+ export const GenericParamInfo = z.looseObject({
28
+ /** Parameter name like `T`. */
29
+ name: z.string(),
30
+ /** Constraint like `string` from `T extends string`. */
31
+ constraint: z.string().optional(),
32
+ /** Default type like `unknown` from `T = unknown`. */
33
+ default_type: z.string().optional(),
34
+ });
35
+ /**
36
+ * Parameter information for functions and methods.
37
+ *
38
+ * Kept distinct from ComponentPropInfo despite structural similarity.
39
+ * Function parameters form a tuple with positional semantics:
40
+ * calling order matters (`fn(a, b)` vs `fn(b, a)`),
41
+ * may include rest parameters and destructuring patterns.
42
+ */
43
+ export const ParameterInfo = z.looseObject({
44
+ name: z.string(),
45
+ type: z.string(),
46
+ optional: z.boolean().optional(),
47
+ description: z.string().optional(),
48
+ default_value: z.string().optional(),
49
+ });
50
+ /**
51
+ * Component prop information for Svelte components.
52
+ *
53
+ * Kept distinct from ParameterInfo despite structural similarity.
54
+ * Component props are named attributes with different semantics:
55
+ * no positional order when passing (`<Foo {a} {b} />` = `<Foo {b} {a} />`),
56
+ * support two-way binding via `$bindable` rune.
57
+ */
58
+ export const ComponentPropInfo = z.looseObject({
59
+ name: z.string(),
60
+ type: z.string(),
61
+ optional: z.boolean().optional(),
62
+ description: z.string().optional(),
63
+ default_value: z.string().optional(),
64
+ bindable: z.boolean().optional(),
65
+ });
66
+ /**
67
+ * Metadata for an exported declaration (function, type, class, component, etc.).
68
+ *
69
+ * Extracted from TypeScript source and JSDoc/TSDoc comments at build time.
70
+ */
71
+ export const DeclarationJson = z.looseObject({
72
+ /** The exported name. */
73
+ name: z.string(),
74
+ kind: DeclarationKind,
75
+ /** JSDoc/TSDoc comment in mdz format. */
76
+ doc_comment: z.string().optional(),
77
+ /** Full TypeScript type signature. */
78
+ type_signature: z.string().optional(),
79
+ /** TypeScript modifiers like `readonly`, `private`, or `static`. */
80
+ modifiers: z.array(z.string()).optional(),
81
+ /** 1-indexed line number in source file. */
82
+ source_line: z.number().optional(),
83
+ /** Function/method parameters. */
84
+ parameters: z.array(ParameterInfo).optional(),
85
+ /** Function/method return type. */
86
+ return_type: z.string().optional(),
87
+ /** Return value description from `@returns` tag. */
88
+ return_description: z.string().optional(),
89
+ /** Generic type parameters like `<T, U>`. */
90
+ generic_params: z.array(GenericParamInfo).optional(),
91
+ /** Code examples from `@example` tags. */
92
+ examples: z.array(z.string()).optional(),
93
+ /** Deprecation message from `@deprecated` tag. */
94
+ deprecated_message: z.string().optional(),
95
+ /** Related items from `@see` tags, in mdz format. */
96
+ see_also: z.array(z.string()).optional(),
97
+ /** Exceptions from `@throws` tags. */
98
+ throws: z.array(z.looseObject({ type: z.string().optional(), description: z.string() })).optional(),
99
+ /** Version introduced, from `@since` tag. */
100
+ since: z.string().optional(),
101
+ /** Extended classes/interfaces. */
102
+ extends: z.array(z.string()).optional(),
103
+ /** Implemented interfaces. */
104
+ implements: z.array(z.string()).optional(),
105
+ /** Class or interface members (recursive). */
106
+ get members() {
107
+ return z.array(DeclarationJson).optional();
108
+ },
109
+ /** Type/interface properties (recursive). */
110
+ get properties() {
111
+ return z.array(DeclarationJson).optional();
112
+ },
113
+ /** Svelte component props. */
114
+ props: z.array(ComponentPropInfo).optional(),
115
+ /**
116
+ * Module paths (relative to src/lib) that re-export this declaration.
117
+ * The canonical location is this module's `declarations` array.
118
+ */
119
+ also_exported_from: z.array(z.string()).optional(),
120
+ /**
121
+ * For renamed re-exports (`export {foo as bar}`), the original declaration.
122
+ */
123
+ alias_of: z
124
+ .object({
125
+ module: z.string(),
126
+ name: z.string(),
127
+ })
128
+ .optional(),
129
+ });
130
+ /**
131
+ * A source file in `src/lib/` with its exported declarations.
132
+ */
133
+ export const ModuleJson = z.looseObject({
134
+ /** Path relative to src/lib (e.g., `helpers.ts`). */
135
+ path: z.string(),
136
+ declarations: z.array(DeclarationJson).optional(),
137
+ /** File-level JSDoc comment. */
138
+ module_comment: z.string().optional(),
139
+ /** Modules this imports (paths relative to src/lib). */
140
+ dependencies: z.array(z.string()).optional(),
141
+ /** Modules that import this (paths relative to src/lib). */
142
+ dependents: z.array(z.string()).optional(),
143
+ });
144
+ /**
145
+ * Metadata for a library's `src/lib/` exports.
146
+ */
147
+ export const SourceJson = z.looseObject({
148
+ name: z.string(),
149
+ version: z.string(),
150
+ modules: z.array(ModuleJson).optional(),
151
+ });
152
+ /**
153
+ * Format declaration name with generic parameters for display.
154
+ * @example declaration_get_display_name({name: 'Map', kind: 'type', generic_params: [{name: 'K'}, {name: 'V'}]})
155
+ * // => 'Map<K, V>'
156
+ */
157
+ export const declaration_get_display_name = (declaration) => {
158
+ if (!declaration.generic_params?.length)
159
+ return declaration.name;
160
+ const params = declaration.generic_params.map((p) => {
161
+ let param = p.name;
162
+ if (p.constraint)
163
+ param += ` extends ${p.constraint}`;
164
+ if (p.default_type)
165
+ param += ` = ${p.default_type}`;
166
+ return param;
167
+ });
168
+ return `${declaration.name}<${params.join(', ')}>`;
169
+ };
170
+ /**
171
+ * Generate TypeScript import statement for a declaration.
172
+ * @example declaration_generate_import({name: 'Foo', kind: 'type'}, 'foo.ts', '@pkg/lib')
173
+ * // => "import type {Foo} from '@pkg/lib/foo.js';"
174
+ */
175
+ export const declaration_generate_import = (declaration, module_path, library_name) => {
176
+ const js_path = module_path.replace(/\.ts$/, '.js');
177
+ const specifier = `${library_name}/${js_path}`;
178
+ // Handle default exports by converting module name to PascalCase
179
+ if (declaration.name === 'default') {
180
+ const module_name = module_path.replace(/\.(js|ts|svelte)$/, '');
181
+ const pascal_case = module_name
182
+ .split(/[-_]/)
183
+ .map((part) => part.charAt(0).toUpperCase() + part.slice(1))
184
+ .join('');
185
+ return `import ${pascal_case} from '${specifier}';`;
186
+ }
187
+ const import_keyword = declaration.kind === 'type' ? 'import type' : 'import';
188
+ return `${import_keyword} {${declaration.name}} from '${specifier}';`;
189
+ };
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Truncates a string to a maximum length, adding a suffix if needed that defaults to `...`.
3
+ */
4
+ export declare const truncate: (str: string, maxLength: number, suffix?: string) => string;
5
+ /**
6
+ * Removes characters inclusive of `stripped`.
7
+ */
8
+ export declare const strip_start: (source: string, stripped: string) => string;
9
+ /**
10
+ * Removes characters inclusive of `stripped`.
11
+ */
12
+ export declare const strip_end: (source: string, stripped: string) => string;
13
+ /**
14
+ * Removes characters inclusive of `stripped`.
15
+ */
16
+ export declare const strip_after: (source: string, stripped: string) => string;
17
+ /**
18
+ * Removes characters inclusive of `stripped`.
19
+ */
20
+ export declare const strip_before: (source: string, stripped: string) => string;
21
+ /**
22
+ * Adds the substring `ensured` to the start of the `source` string if it's not already present.
23
+ */
24
+ export declare const ensure_start: (source: string, ensured: string) => string;
25
+ /**
26
+ * Adds the substring `ensured` to the end of the `source` string if it's not already present.
27
+ */
28
+ export declare const ensure_end: (source: string, ensured: string) => string;
29
+ /**
30
+ * Removes leading and trailing spaces from each line of a string.
31
+ */
32
+ export declare const deindent: (str: string) => string;
33
+ /**
34
+ * Returns a plural suffix based on a count.
35
+ */
36
+ export declare const plural: (count: number | undefined | null, suffix?: string) => string;
37
+ /**
38
+ * Returns the count of graphemes in a string, the individually rendered characters.
39
+ */
40
+ export declare const count_graphemes: (str: string) => number;
41
+ /**
42
+ * Strips ANSI escape sequences from a string
43
+ */
44
+ export declare const strip_ansi: (str: string) => string;
45
+ /**
46
+ * Stringifies a value like `JSON.stringify` but with some corner cases handled better.
47
+ *
48
+ * @source https://2ality.com/2025/04/stringification-javascript.html
49
+ */
50
+ export declare const stringify: (value: unknown) => string;
51
+ //# sourceMappingURL=string.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/string.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,QAAQ,GAAI,KAAK,MAAM,EAAE,WAAW,MAAM,EAAE,eAAc,KAAG,MAMzE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW,GAAI,QAAQ,MAAM,EAAE,UAAU,MAAM,KAAG,MAG9D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,SAAS,GAAI,QAAQ,MAAM,EAAE,UAAU,MAAM,KAAG,MAG5D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW,GAAI,QAAQ,MAAM,EAAE,UAAU,MAAM,KAAG,MAK9D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,GAAI,QAAQ,MAAM,EAAE,UAAU,MAAM,KAAG,MAK/D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,GAAI,QAAQ,MAAM,EAAE,SAAS,MAAM,KAAG,MAG9D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU,GAAI,QAAQ,MAAM,EAAE,SAAS,MAAM,KAAG,MAG5D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,QAAQ,GAAI,KAAK,MAAM,KAAG,MAK1B,CAAC;AAEd;;GAEG;AACH,eAAO,MAAM,MAAM,GAAI,OAAO,MAAM,GAAG,SAAS,GAAG,IAAI,EAAE,eAAY,KAAG,MAC9C,CAAC;AAE3B;;GAEG;AACH,eAAO,MAAM,eAAe,GAAI,KAAK,MAAM,KAAG,MACI,CAAC;AAEnD;;GAEG;AACH,eAAO,MAAM,UAAU,GAAI,KAAK,MAAM,KAAG,MAAsD,CAAC;AAEhG;;;;GAIG;AACH,eAAO,MAAM,SAAS,GAAI,OAAO,OAAO,KAAG,MACwC,CAAC"}