@texturehq/edges 1.5.1 → 1.5.3

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.
@@ -23,13 +23,19 @@ function extractJSDoc(content, functionName) {
23
23
  // Look for JSDoc block immediately before the function/const declaration
24
24
  const patterns = [
25
25
  // Function declaration: /** ... */ export function name OR export async function name
26
- new RegExp(`\\/\\*\\*([^*]|\\*(?!\\/))*\\*\\/\\s*export\\s+(?:async\\s+)?function\\s+${functionName}\\b`, "s"),
26
+ new RegExp(
27
+ `\\/\\*\\*([^*]|\\*(?!\\/))*\\*\\/\\s*export\\s+(?:async\\s+)?function\\s+${functionName}\\b`,
28
+ "s"
29
+ ),
27
30
  // Arrow function: /** ... */ export const name =
28
31
  new RegExp(`\\/\\*\\*([^*]|\\*(?!\\/))*\\*\\/\\s*export\\s+const\\s+${functionName}\\s*=`, "s"),
29
32
  // Type export: /** ... */ export type name
30
33
  new RegExp(`\\/\\*\\*([^*]|\\*(?!\\/))*\\*\\/\\s*export\\s+type\\s+${functionName}\\b`, "s"),
31
34
  // Interface export: /** ... */ export interface name
32
- new RegExp(`\\/\\*\\*([^*]|\\*(?!\\/))*\\*\\/\\s*export\\s+interface\\s+${functionName}\\b`, "s"),
35
+ new RegExp(
36
+ `\\/\\*\\*([^*]|\\*(?!\\/))*\\*\\/\\s*export\\s+interface\\s+${functionName}\\b`,
37
+ "s"
38
+ ),
33
39
  ];
34
40
 
35
41
  for (const pattern of patterns) {
@@ -56,7 +62,10 @@ function extractJSDoc(content, functionName) {
56
62
  */
57
63
  function extractParams(content, functionName) {
58
64
  const patterns = [
59
- new RegExp(`\\/\\*\\*([^*]|\\*(?!\\/))*\\*\\/\\s*export\\s+(?:async\\s+)?function\\s+${functionName}\\b`, "s"),
65
+ new RegExp(
66
+ `\\/\\*\\*([^*]|\\*(?!\\/))*\\*\\/\\s*export\\s+(?:async\\s+)?function\\s+${functionName}\\b`,
67
+ "s"
68
+ ),
60
69
  new RegExp(`\\/\\*\\*([^*]|\\*(?!\\/))*\\*\\/\\s*export\\s+const\\s+${functionName}\\s*=`, "s"),
61
70
  ];
62
71
 
@@ -89,7 +98,10 @@ function extractParams(content, functionName) {
89
98
  */
90
99
  function extractReturns(content, functionName) {
91
100
  const patterns = [
92
- new RegExp(`\\/\\*\\*([^*]|\\*(?!\\/))*\\*\\/\\s*export\\s+(?:async\\s+)?function\\s+${functionName}\\b`, "s"),
101
+ new RegExp(
102
+ `\\/\\*\\*([^*]|\\*(?!\\/))*\\*\\/\\s*export\\s+(?:async\\s+)?function\\s+${functionName}\\b`,
103
+ "s"
104
+ ),
93
105
  new RegExp(`\\/\\*\\*([^*]|\\*(?!\\/))*\\*\\/\\s*export\\s+const\\s+${functionName}\\s*=`, "s"),
94
106
  ];
95
107
 
@@ -119,7 +131,10 @@ function extractReturns(content, functionName) {
119
131
  */
120
132
  function extractExample(content, functionName) {
121
133
  const patterns = [
122
- new RegExp(`\\/\\*\\*([^*]|\\*(?!\\/))*\\*\\/\\s*export\\s+(?:async\\s+)?function\\s+${functionName}\\b`, "s"),
134
+ new RegExp(
135
+ `\\/\\*\\*([^*]|\\*(?!\\/))*\\*\\/\\s*export\\s+(?:async\\s+)?function\\s+${functionName}\\b`,
136
+ "s"
137
+ ),
123
138
  new RegExp(`\\/\\*\\*([^*]|\\*(?!\\/))*\\*\\/\\s*export\\s+const\\s+${functionName}\\s*=`, "s"),
124
139
  ];
125
140
 
@@ -137,7 +152,10 @@ function extractExample(content, functionName) {
137
152
  .join("\n")
138
153
  .trim();
139
154
  // Remove ```typescript and ``` markers if present
140
- return example.replace(/^```\w*\n?/, "").replace(/\n?```$/, "").trim();
155
+ return example
156
+ .replace(/^```\w*\n?/, "")
157
+ .replace(/\n?```$/, "")
158
+ .trim();
141
159
  }
142
160
  }
143
161
  }
@@ -153,7 +171,7 @@ function extractExports(filePath) {
153
171
  if (!content) return [];
154
172
 
155
173
  const utilities = [];
156
-
174
+
157
175
  // Match export function declarations
158
176
  const functionPattern = /export\s+(?:async\s+)?function\s+(\w+)/g;
159
177
  let match;
@@ -174,9 +192,12 @@ function extractExports(filePath) {
174
192
  while ((match = constPattern.exec(content))) {
175
193
  const name = match[1];
176
194
  // Check if it's likely a function (has => or function keyword after =)
177
- const afterMatch = content.slice(match.index + match[0].length, match.index + match[0].length + 50);
195
+ const afterMatch = content.slice(
196
+ match.index + match[0].length,
197
+ match.index + match[0].length + 50
198
+ );
178
199
  const isFunction = afterMatch.includes("=>") || afterMatch.includes("function");
179
-
200
+
180
201
  utilities.push({
181
202
  name,
182
203
  type: isFunction ? "function" : "constant",
@@ -207,28 +228,24 @@ function extractExports(filePath) {
207
228
  */
208
229
  function scanDirectory(dir, category) {
209
230
  const utilities = [];
210
-
231
+
211
232
  if (!fs.existsSync(dir)) return utilities;
212
-
233
+
213
234
  const files = fs.readdirSync(dir);
214
-
235
+
215
236
  for (const file of files) {
216
237
  const filePath = path.join(dir, file);
217
238
  const stat = fs.statSync(filePath);
218
-
239
+
219
240
  if (stat.isDirectory() && file !== "__tests__" && file !== "tests") {
220
241
  // Recursively scan subdirectories
221
242
  utilities.push(...scanDirectory(filePath, `${category}/${file}`));
222
243
  } else if ((file.endsWith(".ts") || file.endsWith(".tsx")) && !file.endsWith(".d.ts")) {
223
244
  // Skip test files, stories, and type definition files
224
- if (
225
- file.includes(".test.") ||
226
- file.includes(".spec.") ||
227
- file.includes(".stories.")
228
- ) {
245
+ if (file.includes(".test.") || file.includes(".spec.") || file.includes(".stories.")) {
229
246
  continue;
230
247
  }
231
-
248
+
232
249
  const funcs = extractExports(filePath);
233
250
  for (const func of funcs) {
234
251
  utilities.push({
@@ -239,43 +256,45 @@ function scanDirectory(dir, category) {
239
256
  }
240
257
  }
241
258
  }
242
-
259
+
243
260
  return utilities;
244
261
  }
245
262
 
246
263
  function run() {
247
264
  try {
248
265
  console.log("Generating utilities manifest...");
249
-
266
+
250
267
  const manifest = {
251
268
  version: process.env.npm_package_version || "unknown",
252
269
  generatedAt: new Date().toISOString(),
253
270
  categories: {},
254
271
  };
255
-
272
+
256
273
  // Scan hooks directory
257
274
  const hooksDir = path.join(SRC_DIR, "hooks");
258
275
  const hooks = scanDirectory(hooksDir, "hooks");
259
276
  if (hooks.length > 0) {
260
277
  manifest.categories.hooks = {
261
- description: "React hooks for common functionality like debouncing, local storage, and time controls",
278
+ description:
279
+ "React hooks for common functionality like debouncing, local storage, and time controls",
262
280
  utilities: hooks.sort((a, b) => a.name.localeCompare(b.name)),
263
281
  };
264
282
  }
265
-
283
+
266
284
  // Scan utils directory
267
285
  const utilsDir = path.join(SRC_DIR, "utils");
268
-
286
+
269
287
  // Formatting utilities
270
288
  const formattingDir = path.join(utilsDir, "formatting");
271
289
  const formatting = scanDirectory(formattingDir, "formatting");
272
290
  if (formatting.length > 0) {
273
291
  manifest.categories.formatting = {
274
- description: "Comprehensive formatting utilities for text, numbers, dates, currency, energy, temperature, distance, and more",
292
+ description:
293
+ "Comprehensive formatting utilities for text, numbers, dates, currency, energy, temperature, distance, and more",
275
294
  utilities: formatting.sort((a, b) => a.name.localeCompare(b.name)),
276
295
  };
277
296
  }
278
-
297
+
279
298
  // Chart utilities
280
299
  const chartsDir = path.join(utilsDir, "charts");
281
300
  const charts = scanDirectory(chartsDir, "charts");
@@ -283,52 +302,56 @@ function run() {
283
302
  const chartUtils = extractExports(path.join(utilsDir, "charts.ts"));
284
303
  const allChartUtils = [
285
304
  ...charts,
286
- ...chartExportUtils.map(f => ({ ...f, category: "charts", file: "utils/chartExport.ts" })),
287
- ...chartUtils.map(f => ({ ...f, category: "charts", file: "utils/charts.ts" }))
305
+ ...chartExportUtils.map((f) => ({ ...f, category: "charts", file: "utils/chartExport.ts" })),
306
+ ...chartUtils.map((f) => ({ ...f, category: "charts", file: "utils/charts.ts" })),
288
307
  ];
289
-
308
+
290
309
  if (allChartUtils.length > 0) {
291
310
  manifest.categories.charts = {
292
311
  description: "Chart utilities for data visualization, scaling, and export functionality",
293
312
  utilities: allChartUtils.sort((a, b) => a.name.localeCompare(b.name)),
294
313
  };
295
314
  }
296
-
315
+
297
316
  // Color utilities
298
317
  const colorUtils = extractExports(path.join(utilsDir, "colors.ts"));
299
318
  if (colorUtils.length > 0) {
300
319
  manifest.categories.colors = {
301
- description: "Color management utilities for theme-aware color resolution, contrast calculation, and palette generation",
302
- utilities: colorUtils.map(f => ({ ...f, category: "colors", file: "utils/colors.ts" }))
320
+ description:
321
+ "Color management utilities for theme-aware color resolution, contrast calculation, and palette generation",
322
+ utilities: colorUtils
323
+ .map((f) => ({ ...f, category: "colors", file: "utils/colors.ts" }))
303
324
  .sort((a, b) => a.name.localeCompare(b.name)),
304
325
  };
305
326
  }
306
-
327
+
307
328
  // General utilities from utils/index.ts
308
329
  const generalUtils = extractExports(path.join(utilsDir, "index.ts"));
309
330
  if (generalUtils.length > 0) {
310
331
  manifest.categories.general = {
311
- description: "General utility functions for focus management, Tailwind class composition, and theme utilities",
312
- utilities: generalUtils.map(f => ({ ...f, category: "general", file: "utils/index.ts" }))
332
+ description:
333
+ "General utility functions for focus management, Tailwind class composition, and theme utilities",
334
+ utilities: generalUtils
335
+ .map((f) => ({ ...f, category: "general", file: "utils/index.ts" }))
313
336
  .sort((a, b) => a.name.localeCompare(b.name)),
314
337
  };
315
338
  }
316
-
339
+
317
340
  // Add summary
318
341
  const totalUtilities = Object.values(manifest.categories).reduce(
319
342
  (sum, cat) => sum + cat.utilities.length,
320
343
  0
321
344
  );
322
-
345
+
323
346
  manifest.summary = {
324
347
  totalUtilities,
325
348
  totalCategories: Object.keys(manifest.categories).length,
326
- categories: Object.keys(manifest.categories).map(cat => ({
349
+ categories: Object.keys(manifest.categories).map((cat) => ({
327
350
  name: cat,
328
351
  count: manifest.categories[cat].utilities.length,
329
352
  })),
330
353
  };
331
-
354
+
332
355
  // Add import information
333
356
  manifest.importInfo = {
334
357
  package: "@texturehq/edges",
@@ -348,15 +371,15 @@ function run() {
348
371
  {
349
372
  description: "Import color utilities",
350
373
  code: 'import { getResolvedColor, isLightColor } from "@texturehq/edges"',
351
- }
374
+ },
352
375
  ],
353
376
  };
354
-
377
+
355
378
  // Write the manifest
356
379
  ensureDir(DIST_DIR);
357
380
  const outputPath = path.join(DIST_DIR, "utilities.manifest.json");
358
381
  fs.writeFileSync(outputPath, JSON.stringify(manifest, null, 2));
359
-
382
+
360
383
  console.log(
361
384
  `Generated ${path.join("dist", "utilities.manifest.json")} with ${totalUtilities} utilities in ${Object.keys(manifest.categories).length} categories.`
362
385
  );
@@ -92,4 +92,3 @@ try {
92
92
  console.error("❌ Error generating viz-runtime.css:", error);
93
93
  process.exit(1);
94
94
  }
95
-