@idealyst/tooling 1.2.30 → 1.2.31

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.
@@ -1,33 +1,58 @@
1
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
+ }) : x)(function(x) {
4
+ if (typeof require !== "undefined") return require.apply(this, arguments);
5
+ throw Error('Dynamic require of "' + x + '" is not supported');
6
+ });
7
+
1
8
  // src/vite-plugin.ts
9
+ import * as fs4 from "fs";
10
+ import * as path4 from "path";
11
+
12
+ // src/analyzer/component-analyzer.ts
13
+ import * as ts3 from "typescript";
2
14
  import * as fs3 from "fs";
3
15
  import * as path3 from "path";
4
16
 
5
- // src/analyzer/component-analyzer.ts
17
+ // src/analyzer/theme-analyzer.ts
6
18
  import * as ts2 from "typescript";
7
19
  import * as fs2 from "fs";
8
20
  import * as path2 from "path";
9
21
 
10
- // src/analyzer/theme-analyzer.ts
22
+ // src/analyzer/theme-source-analyzer.ts
11
23
  import * as ts from "typescript";
12
24
  import * as fs from "fs";
13
25
  import * as path from "path";
14
- function analyzeTheme(themePath, verbose = false) {
26
+ function analyzeThemeSource(themePath, options = {}) {
15
27
  const resolvedPath = path.resolve(themePath);
28
+ const verbose = options.verbose ?? false;
29
+ const aliases = options.aliases ?? {};
30
+ const log = (...args) => {
31
+ if (verbose) console.log("[theme-source-analyzer]", ...args);
32
+ };
16
33
  if (!fs.existsSync(resolvedPath)) {
17
34
  throw new Error(`Theme file not found: ${resolvedPath}`);
18
35
  }
19
- const log = (...args) => {
20
- if (verbose) console.log("[theme-analyzer]", ...args);
21
- };
22
36
  log("Analyzing theme file:", resolvedPath);
23
- const program = ts.createProgram([resolvedPath], {
37
+ const configPath = ts.findConfigFile(path.dirname(resolvedPath), ts.sys.fileExists, "tsconfig.json");
38
+ let compilerOptions = {
24
39
  target: ts.ScriptTarget.ES2020,
25
40
  module: ts.ModuleKind.ESNext,
41
+ moduleResolution: ts.ModuleResolutionKind.Node10,
26
42
  strict: true,
27
43
  esModuleInterop: true,
28
44
  skipLibCheck: true,
29
- allowSyntheticDefaultImports: true
30
- });
45
+ allowSyntheticDefaultImports: true,
46
+ resolveJsonModule: true
47
+ };
48
+ if (configPath) {
49
+ const configFile = ts.readConfigFile(configPath, ts.sys.readFile);
50
+ if (!configFile.error) {
51
+ const parsed = ts.parseJsonConfigFileContent(configFile.config, ts.sys, path.dirname(configPath));
52
+ compilerOptions = { ...compilerOptions, ...parsed.options };
53
+ }
54
+ }
55
+ const program = ts.createProgram([resolvedPath], compilerOptions);
31
56
  const sourceFile = program.getSourceFile(resolvedPath);
32
57
  if (!sourceFile) {
33
58
  throw new Error(`Failed to parse theme file: ${resolvedPath}`);
@@ -35,7 +60,9 @@ function analyzeTheme(themePath, verbose = false) {
35
60
  const ctx = {
36
61
  program,
37
62
  typeChecker: program.getTypeChecker(),
38
- verbose
63
+ verbose,
64
+ aliases,
65
+ analyzedFiles: /* @__PURE__ */ new Set([resolvedPath])
39
66
  };
40
67
  const values = {
41
68
  intents: [],
@@ -58,13 +85,368 @@ function analyzeTheme(themePath, verbose = false) {
58
85
  const localName = element.name.text;
59
86
  const importedName = element.propertyName?.text ?? localName;
60
87
  imports.set(localName, { source, imported: importedName });
88
+ log(` Import: ${localName} from '${source}'`);
61
89
  }
62
90
  }
63
91
  }
64
92
  });
93
+ function resolveImportPath(source, fromFile) {
94
+ for (const [aliasPrefix, aliasPath] of Object.entries(ctx.aliases)) {
95
+ if (source === aliasPrefix || source.startsWith(aliasPrefix + "/")) {
96
+ const remainder = source.slice(aliasPrefix.length);
97
+ let resolved = aliasPath + remainder;
98
+ if (!path.isAbsolute(resolved)) {
99
+ resolved = path.resolve(path.dirname(fromFile), resolved);
100
+ }
101
+ return resolved;
102
+ }
103
+ }
104
+ if (source.startsWith(".")) {
105
+ return path.resolve(path.dirname(fromFile), source);
106
+ }
107
+ try {
108
+ return __require.resolve(source, { paths: [path.dirname(fromFile)] });
109
+ } catch {
110
+ return null;
111
+ }
112
+ }
113
+ function findThemeFile(basePath, preferDark) {
114
+ const themeFileName = preferDark ? "darkTheme" : "lightTheme";
115
+ const candidates = [
116
+ basePath,
117
+ `${basePath}.ts`,
118
+ `${basePath}.tsx`,
119
+ path.join(basePath, "src", `${themeFileName}.ts`),
120
+ path.join(basePath, `${themeFileName}.ts`),
121
+ path.join(basePath, "src", "index.ts"),
122
+ path.join(basePath, "index.ts")
123
+ ];
124
+ for (const candidate of candidates) {
125
+ if (fs.existsSync(candidate) && fs.statSync(candidate).isFile()) {
126
+ return candidate;
127
+ }
128
+ }
129
+ return null;
130
+ }
131
+ function analyzeBaseTheme2(varName) {
132
+ const importInfo = imports.get(varName);
133
+ if (!importInfo) {
134
+ log(`Could not find import for base theme: ${varName}`);
135
+ return;
136
+ }
137
+ log(`Analyzing base theme '${varName}' from '${importInfo.source}'`);
138
+ const resolvedBase = resolveImportPath(importInfo.source, resolvedPath);
139
+ if (!resolvedBase) {
140
+ log(`Could not resolve import path: ${importInfo.source}`);
141
+ return;
142
+ }
143
+ const preferDark = varName.toLowerCase().includes("dark");
144
+ const themeFile = findThemeFile(resolvedBase, preferDark);
145
+ if (!themeFile) {
146
+ log(`Could not find theme file for: ${resolvedBase}`);
147
+ return;
148
+ }
149
+ if (ctx.analyzedFiles.has(themeFile)) {
150
+ log(`Already analyzed: ${themeFile}`);
151
+ return;
152
+ }
153
+ ctx.analyzedFiles.add(themeFile);
154
+ log(`Recursively analyzing: ${themeFile}`);
155
+ const baseValues = analyzeThemeSource(themeFile, { verbose, aliases });
156
+ mergeThemeValues(values, baseValues, false);
157
+ }
158
+ function traceBuilderCalls(node, calls = []) {
159
+ if (!ts.isPropertyAccessExpression(node.expression)) {
160
+ if (ts.isCallExpression(node) && ts.isIdentifier(node.expression)) {
161
+ const fnName = node.expression.text;
162
+ if (fnName === "fromTheme" && node.arguments.length > 0) {
163
+ const arg = node.arguments[0];
164
+ if (ts.isIdentifier(arg)) {
165
+ return { calls, baseThemeVar: arg.text };
166
+ }
167
+ }
168
+ }
169
+ return { calls, baseThemeVar: null };
170
+ }
171
+ const methodName = node.expression.name.text;
172
+ calls.unshift({ method: methodName, args: node.arguments });
173
+ const obj = node.expression.expression;
174
+ if (ts.isCallExpression(obj)) {
175
+ return traceBuilderCalls(obj, calls);
176
+ }
177
+ return { calls, baseThemeVar: null };
178
+ }
179
+ function getStringValue2(node) {
180
+ if (!node) return null;
181
+ if (ts.isStringLiteral(node)) return node.text;
182
+ if (ts.isIdentifier(node)) return node.text;
183
+ if (ts.isNoSubstitutionTemplateLiteral(node)) return node.text;
184
+ return null;
185
+ }
186
+ function getObjectKeys2(node) {
187
+ return node.properties.filter((prop) => ts.isPropertyAssignment(prop)).map((prop) => {
188
+ if (ts.isIdentifier(prop.name)) return prop.name.text;
189
+ if (ts.isStringLiteral(prop.name)) return prop.name.text;
190
+ return null;
191
+ }).filter((k) => k !== null);
192
+ }
193
+ function processCalls(calls) {
194
+ log(`Processing ${calls.length} builder method calls`);
195
+ for (const { method, args } of calls) {
196
+ switch (method) {
197
+ case "addIntent": {
198
+ const name = getStringValue2(args[0]);
199
+ if (name && !values.intents.includes(name)) {
200
+ values.intents.push(name);
201
+ log(` Found intent: ${name}`);
202
+ }
203
+ break;
204
+ }
205
+ case "addRadius": {
206
+ const name = getStringValue2(args[0]);
207
+ if (name && !values.radii.includes(name)) {
208
+ values.radii.push(name);
209
+ log(` Found radius: ${name}`);
210
+ }
211
+ break;
212
+ }
213
+ case "addShadow": {
214
+ const name = getStringValue2(args[0]);
215
+ if (name && !values.shadows.includes(name)) {
216
+ values.shadows.push(name);
217
+ log(` Found shadow: ${name}`);
218
+ }
219
+ break;
220
+ }
221
+ case "addBreakpoint": {
222
+ const name = getStringValue2(args[0]);
223
+ if (name && !values.breakpoints.includes(name)) {
224
+ values.breakpoints.push(name);
225
+ log(` Found breakpoint: ${name}`);
226
+ }
227
+ break;
228
+ }
229
+ case "setBreakpoints": {
230
+ if (args[0] && ts.isObjectLiteralExpression(args[0])) {
231
+ const keys = getObjectKeys2(args[0]);
232
+ for (const key of keys) {
233
+ if (!values.breakpoints.includes(key)) {
234
+ values.breakpoints.push(key);
235
+ }
236
+ }
237
+ log(` Found breakpoints: ${values.breakpoints.join(", ")}`);
238
+ }
239
+ break;
240
+ }
241
+ case "setSizes": {
242
+ if (args[0] && ts.isObjectLiteralExpression(args[0])) {
243
+ for (const prop of args[0].properties) {
244
+ if (ts.isPropertyAssignment(prop)) {
245
+ let componentName = null;
246
+ if (ts.isIdentifier(prop.name)) {
247
+ componentName = prop.name.text;
248
+ } else if (ts.isStringLiteral(prop.name)) {
249
+ componentName = prop.name.text;
250
+ }
251
+ if (componentName && ts.isObjectLiteralExpression(prop.initializer)) {
252
+ const sizeKeys = getObjectKeys2(prop.initializer);
253
+ values.sizes[componentName] = sizeKeys;
254
+ log(` Found sizes for ${componentName}: ${sizeKeys.join(", ")}`);
255
+ if (componentName === "typography") {
256
+ for (const key of sizeKeys) {
257
+ if (!values.typography.includes(key)) {
258
+ values.typography.push(key);
259
+ }
260
+ }
261
+ }
262
+ }
263
+ }
264
+ }
265
+ } else if (args[0] && ts.isPropertyAccessExpression(args[0])) {
266
+ const propAccess = args[0];
267
+ if (ts.isIdentifier(propAccess.expression) && propAccess.name.text === "sizes") {
268
+ const themeVarName = propAccess.expression.text;
269
+ log(` Found sizes reference: ${themeVarName}.sizes`);
270
+ const importInfo = imports.get(themeVarName);
271
+ if (importInfo) {
272
+ log(` Resolving sizes from imported theme: ${importInfo.source}`);
273
+ const resolvedBase = resolveImportPath(importInfo.source, resolvedPath);
274
+ if (resolvedBase) {
275
+ const preferDark = themeVarName.toLowerCase().includes("dark");
276
+ const themeFile = findThemeFile(resolvedBase, preferDark);
277
+ if (themeFile && !ctx.analyzedFiles.has(themeFile)) {
278
+ ctx.analyzedFiles.add(themeFile);
279
+ const baseValues = analyzeThemeSource(themeFile, { verbose, aliases });
280
+ for (const [comp, sizes] of Object.entries(baseValues.sizes)) {
281
+ if (!values.sizes[comp]) {
282
+ values.sizes[comp] = sizes;
283
+ log(` Inherited sizes for ${comp}: ${sizes.join(", ")}`);
284
+ }
285
+ }
286
+ for (const typo of baseValues.typography) {
287
+ if (!values.typography.includes(typo)) {
288
+ values.typography.push(typo);
289
+ }
290
+ }
291
+ }
292
+ }
293
+ }
294
+ }
295
+ }
296
+ break;
297
+ }
298
+ case "setColors": {
299
+ if (args[0] && ts.isObjectLiteralExpression(args[0])) {
300
+ for (const prop of args[0].properties) {
301
+ if (ts.isPropertyAssignment(prop)) {
302
+ let colorType = null;
303
+ if (ts.isIdentifier(prop.name)) {
304
+ colorType = prop.name.text;
305
+ } else if (ts.isStringLiteral(prop.name)) {
306
+ colorType = prop.name.text;
307
+ }
308
+ if (colorType && ts.isObjectLiteralExpression(prop.initializer)) {
309
+ const colorKeys = getObjectKeys2(prop.initializer);
310
+ switch (colorType) {
311
+ case "surface":
312
+ values.surfaceColors = colorKeys;
313
+ log(` Found surface colors: ${colorKeys.join(", ")}`);
314
+ break;
315
+ case "text":
316
+ values.textColors = colorKeys;
317
+ log(` Found text colors: ${colorKeys.join(", ")}`);
318
+ break;
319
+ case "border":
320
+ values.borderColors = colorKeys;
321
+ log(` Found border colors: ${colorKeys.join(", ")}`);
322
+ break;
323
+ }
324
+ }
325
+ }
326
+ }
327
+ }
328
+ break;
329
+ }
330
+ case "build":
331
+ break;
332
+ default:
333
+ log(` Skipping unknown method: ${method}`);
334
+ }
335
+ }
336
+ }
65
337
  function processBuilderChain(node) {
66
338
  if (!ts.isCallExpression(node)) return;
67
- if (ts.isPropertyAccessExpression(node.expression)) {
339
+ if (ts.isPropertyAccessExpression(node.expression) && node.expression.name.text === "build") {
340
+ log("Found .build() call, tracing chain...");
341
+ const { calls, baseThemeVar } = traceBuilderCalls(node);
342
+ if (baseThemeVar) {
343
+ log(`Found fromTheme(${baseThemeVar})`);
344
+ analyzeBaseTheme2(baseThemeVar);
345
+ }
346
+ processCalls(calls);
347
+ return;
348
+ }
349
+ ts.forEachChild(node, processBuilderChain);
350
+ }
351
+ ts.forEachChild(sourceFile, (node) => {
352
+ if (ts.isVariableStatement(node)) {
353
+ for (const decl of node.declarationList.declarations) {
354
+ if (decl.initializer) {
355
+ processBuilderChain(decl.initializer);
356
+ }
357
+ }
358
+ }
359
+ if (ts.isExportAssignment(node)) {
360
+ processBuilderChain(node.expression);
361
+ }
362
+ });
363
+ log("Analysis complete:");
364
+ log(` Intents: ${values.intents.join(", ")}`);
365
+ log(` Radii: ${values.radii.join(", ")}`);
366
+ log(` Shadows: ${values.shadows.join(", ")}`);
367
+ log(` Breakpoints: ${values.breakpoints.join(", ")}`);
368
+ log(` Typography: ${values.typography.join(", ")}`);
369
+ log(` Size components: ${Object.keys(values.sizes).join(", ")}`);
370
+ return values;
371
+ }
372
+ function mergeThemeValues(target, source, sourceOverrides) {
373
+ const mergeArrays = (targetArr, sourceArr) => {
374
+ for (const item of sourceArr) {
375
+ if (!targetArr.includes(item)) {
376
+ targetArr.push(item);
377
+ }
378
+ }
379
+ };
380
+ mergeArrays(target.intents, source.intents);
381
+ mergeArrays(target.radii, source.radii);
382
+ mergeArrays(target.shadows, source.shadows);
383
+ mergeArrays(target.breakpoints, source.breakpoints);
384
+ mergeArrays(target.typography, source.typography);
385
+ mergeArrays(target.surfaceColors, source.surfaceColors);
386
+ mergeArrays(target.textColors, source.textColors);
387
+ mergeArrays(target.borderColors, source.borderColors);
388
+ for (const [component, sizes] of Object.entries(source.sizes)) {
389
+ if (sourceOverrides || !target.sizes[component]) {
390
+ target.sizes[component] = sizes;
391
+ }
392
+ }
393
+ }
394
+
395
+ // src/analyzer/theme-analyzer.ts
396
+ function analyzeTheme(themePath, verbose = false) {
397
+ const resolvedPath = path2.resolve(themePath);
398
+ if (!fs2.existsSync(resolvedPath)) {
399
+ throw new Error(`Theme file not found: ${resolvedPath}`);
400
+ }
401
+ const log = (...args) => {
402
+ if (verbose) console.log("[theme-analyzer]", ...args);
403
+ };
404
+ log("Analyzing theme file:", resolvedPath);
405
+ const program = ts2.createProgram([resolvedPath], {
406
+ target: ts2.ScriptTarget.ES2020,
407
+ module: ts2.ModuleKind.ESNext,
408
+ strict: true,
409
+ esModuleInterop: true,
410
+ skipLibCheck: true,
411
+ allowSyntheticDefaultImports: true
412
+ });
413
+ const sourceFile = program.getSourceFile(resolvedPath);
414
+ if (!sourceFile) {
415
+ throw new Error(`Failed to parse theme file: ${resolvedPath}`);
416
+ }
417
+ const ctx = {
418
+ program,
419
+ typeChecker: program.getTypeChecker(),
420
+ verbose
421
+ };
422
+ const values = {
423
+ intents: [],
424
+ sizes: {},
425
+ radii: [],
426
+ shadows: [],
427
+ breakpoints: [],
428
+ typography: [],
429
+ surfaceColors: [],
430
+ textColors: [],
431
+ borderColors: []
432
+ };
433
+ const imports = /* @__PURE__ */ new Map();
434
+ ts2.forEachChild(sourceFile, (node) => {
435
+ if (ts2.isImportDeclaration(node)) {
436
+ const source = node.moduleSpecifier.text;
437
+ const clause = node.importClause;
438
+ if (clause?.namedBindings && ts2.isNamedImports(clause.namedBindings)) {
439
+ for (const element of clause.namedBindings.elements) {
440
+ const localName = element.name.text;
441
+ const importedName = element.propertyName?.text ?? localName;
442
+ imports.set(localName, { source, imported: importedName });
443
+ }
444
+ }
445
+ }
446
+ });
447
+ function processBuilderChain(node) {
448
+ if (!ts2.isCallExpression(node)) return;
449
+ if (ts2.isPropertyAccessExpression(node.expression)) {
68
450
  const methodName = node.expression.name.text;
69
451
  if (methodName === "build") {
70
452
  const calls = traceBuilderCalls(node);
@@ -72,15 +454,15 @@ function analyzeTheme(themePath, verbose = false) {
72
454
  return;
73
455
  }
74
456
  }
75
- ts.forEachChild(node, processBuilderChain);
457
+ ts2.forEachChild(node, processBuilderChain);
76
458
  }
77
459
  function traceBuilderCalls(node, calls = []) {
78
- if (!ts.isPropertyAccessExpression(node.expression)) {
79
- if (ts.isCallExpression(node) && ts.isIdentifier(node.expression)) {
460
+ if (!ts2.isPropertyAccessExpression(node.expression)) {
461
+ if (ts2.isCallExpression(node) && ts2.isIdentifier(node.expression)) {
80
462
  const fnName = node.expression.text;
81
463
  if (fnName === "fromTheme" && node.arguments.length > 0) {
82
464
  const arg = node.arguments[0];
83
- if (ts.isIdentifier(arg)) {
465
+ if (ts2.isIdentifier(arg)) {
84
466
  analyzeBaseTheme(arg.text, imports, values, ctx);
85
467
  }
86
468
  }
@@ -90,7 +472,7 @@ function analyzeTheme(themePath, verbose = false) {
90
472
  const methodName = node.expression.name.text;
91
473
  calls.unshift({ method: methodName, args: node.arguments });
92
474
  const obj = node.expression.expression;
93
- if (ts.isCallExpression(obj)) {
475
+ if (ts2.isCallExpression(obj)) {
94
476
  return traceBuilderCalls(obj, calls);
95
477
  }
96
478
  return calls;
@@ -124,11 +506,11 @@ function analyzeTheme(themePath, verbose = false) {
124
506
  break;
125
507
  }
126
508
  case "setSizes": {
127
- if (args[0] && ts.isObjectLiteralExpression(args[0])) {
509
+ if (args[0] && ts2.isObjectLiteralExpression(args[0])) {
128
510
  for (const prop of args[0].properties) {
129
- if (ts.isPropertyAssignment(prop)) {
511
+ if (ts2.isPropertyAssignment(prop)) {
130
512
  const componentName = getPropertyName(prop.name);
131
- if (componentName && ts.isObjectLiteralExpression(prop.initializer)) {
513
+ if (componentName && ts2.isObjectLiteralExpression(prop.initializer)) {
132
514
  values.sizes[componentName] = getObjectKeys(prop.initializer);
133
515
  log(" Found sizes for", componentName + ":", values.sizes[componentName]);
134
516
  }
@@ -138,18 +520,18 @@ function analyzeTheme(themePath, verbose = false) {
138
520
  break;
139
521
  }
140
522
  case "setBreakpoints": {
141
- if (args[0] && ts.isObjectLiteralExpression(args[0])) {
523
+ if (args[0] && ts2.isObjectLiteralExpression(args[0])) {
142
524
  values.breakpoints = getObjectKeys(args[0]);
143
525
  log(" Found breakpoints:", values.breakpoints);
144
526
  }
145
527
  break;
146
528
  }
147
529
  case "setColors": {
148
- if (args[0] && ts.isObjectLiteralExpression(args[0])) {
530
+ if (args[0] && ts2.isObjectLiteralExpression(args[0])) {
149
531
  for (const prop of args[0].properties) {
150
- if (ts.isPropertyAssignment(prop)) {
532
+ if (ts2.isPropertyAssignment(prop)) {
151
533
  const colorType = getPropertyName(prop.name);
152
- if (ts.isObjectLiteralExpression(prop.initializer)) {
534
+ if (ts2.isObjectLiteralExpression(prop.initializer)) {
153
535
  const keys = getObjectKeys(prop.initializer);
154
536
  switch (colorType) {
155
537
  case "surface":
@@ -178,15 +560,15 @@ function analyzeTheme(themePath, verbose = false) {
178
560
  }
179
561
  }
180
562
  }
181
- ts.forEachChild(sourceFile, (node) => {
182
- if (ts.isVariableStatement(node)) {
563
+ ts2.forEachChild(sourceFile, (node) => {
564
+ if (ts2.isVariableStatement(node)) {
183
565
  for (const decl of node.declarationList.declarations) {
184
566
  if (decl.initializer) {
185
567
  processBuilderChain(decl.initializer);
186
568
  }
187
569
  }
188
570
  }
189
- if (ts.isExportAssignment(node)) {
571
+ if (ts2.isExportAssignment(node)) {
190
572
  processBuilderChain(node.expression);
191
573
  }
192
574
  });
@@ -207,9 +589,30 @@ function analyzeBaseTheme(varName, imports, values, ctx) {
207
589
  }
208
590
  log("Base theme", varName, "imported from", importInfo.source);
209
591
  if (importInfo.source === "@idealyst/theme" || importInfo.source.includes("@idealyst/theme")) {
210
- const defaultValues = getDefaultThemeValues();
211
- mergeThemeValues(values, defaultValues);
592
+ const aliasPath = packageAliases["@idealyst/theme"];
593
+ if (aliasPath) {
594
+ const themeFileName = varName.toLowerCase().includes("dark") ? "darkTheme.ts" : "lightTheme.ts";
595
+ const themePath = path2.join(aliasPath, "src", themeFileName);
596
+ if (fs2.existsSync(themePath)) {
597
+ log(`Analyzing @idealyst/theme from source: ${themePath}`);
598
+ try {
599
+ const sourceValues = analyzeThemeSource(themePath, {
600
+ verbose: ctx.verbose,
601
+ aliases: packageAliases
602
+ });
603
+ mergeThemeValues2(values, sourceValues);
604
+ log("Successfully extracted values from source");
605
+ return;
606
+ } catch (err) {
607
+ log("Failed to analyze source, falling back to defaults:", err.message);
608
+ }
609
+ } else {
610
+ log(`Theme file not found at alias path: ${themePath}`);
611
+ }
612
+ }
212
613
  log("Using default @idealyst/theme values");
614
+ const defaultValues = getDefaultThemeValues();
615
+ mergeThemeValues2(values, defaultValues);
213
616
  return;
214
617
  }
215
618
  log("Skipping base theme analysis for:", importInfo.source);
@@ -219,6 +622,7 @@ function getDefaultThemeValues() {
219
622
  intents: ["primary", "success", "danger", "warning", "neutral", "info"],
220
623
  sizes: {
221
624
  button: ["xs", "sm", "md", "lg", "xl"],
625
+ iconButton: ["xs", "sm", "md", "lg", "xl"],
222
626
  chip: ["xs", "sm", "md", "lg", "xl"],
223
627
  badge: ["xs", "sm", "md", "lg", "xl"],
224
628
  icon: ["xs", "sm", "md", "lg", "xl"],
@@ -232,6 +636,7 @@ function getDefaultThemeValues() {
232
636
  progress: ["xs", "sm", "md", "lg", "xl"],
233
637
  accordion: ["xs", "sm", "md", "lg", "xl"],
234
638
  activityIndicator: ["xs", "sm", "md", "lg", "xl"],
639
+ alert: ["xs", "sm", "md", "lg", "xl"],
235
640
  breadcrumb: ["xs", "sm", "md", "lg", "xl"],
236
641
  list: ["xs", "sm", "md", "lg", "xl"],
237
642
  menu: ["xs", "sm", "md", "lg", "xl"],
@@ -252,7 +657,7 @@ function getDefaultThemeValues() {
252
657
  borderColors: ["primary", "secondary", "tertiary", "disabled"]
253
658
  };
254
659
  }
255
- function mergeThemeValues(target, source) {
660
+ function mergeThemeValues2(target, source) {
256
661
  target.intents.push(...source.intents.filter((k) => !target.intents.includes(k)));
257
662
  target.radii.push(...source.radii.filter((k) => !target.radii.includes(k)));
258
663
  target.shadows.push(...source.shadows.filter((k) => !target.shadows.includes(k)));
@@ -269,18 +674,19 @@ function mergeThemeValues(target, source) {
269
674
  }
270
675
  function getStringValue(node) {
271
676
  if (!node) return null;
272
- if (ts.isStringLiteral(node)) return node.text;
273
- if (ts.isIdentifier(node)) return node.text;
677
+ if (ts2.isStringLiteral(node)) return node.text;
678
+ if (ts2.isIdentifier(node)) return node.text;
274
679
  return null;
275
680
  }
276
681
  function getPropertyName(node) {
277
- if (ts.isIdentifier(node)) return node.text;
278
- if (ts.isStringLiteral(node)) return node.text;
682
+ if (ts2.isIdentifier(node)) return node.text;
683
+ if (ts2.isStringLiteral(node)) return node.text;
279
684
  return null;
280
685
  }
281
686
  function getObjectKeys(node) {
282
- return node.properties.filter(ts.isPropertyAssignment).map((prop) => getPropertyName(prop.name)).filter((k) => k !== null);
687
+ return node.properties.filter(ts2.isPropertyAssignment).map((prop) => getPropertyName(prop.name)).filter((k) => k !== null);
283
688
  }
689
+ var packageAliases = {};
284
690
 
285
691
  // src/analyzer/component-analyzer.ts
286
692
  function analyzeComponents(options) {
@@ -288,14 +694,14 @@ function analyzeComponents(options) {
288
694
  const registry = {};
289
695
  const themeValues = analyzeTheme(themePath, false);
290
696
  for (const componentPath of componentPaths) {
291
- const resolvedPath = path2.resolve(componentPath);
292
- if (!fs2.existsSync(resolvedPath)) {
697
+ const resolvedPath = path3.resolve(componentPath);
698
+ if (!fs3.existsSync(resolvedPath)) {
293
699
  console.warn(`[component-analyzer] Path not found: ${resolvedPath}`);
294
700
  continue;
295
701
  }
296
702
  const componentDirs = findComponentDirs(resolvedPath);
297
703
  for (const dir of componentDirs) {
298
- const componentName = path2.basename(dir);
704
+ const componentName = path3.basename(dir);
299
705
  if (include && !include.includes(componentName)) continue;
300
706
  if (exclude && exclude.includes(componentName)) continue;
301
707
  if (!includeInternal && componentName.startsWith("_")) continue;
@@ -309,12 +715,12 @@ function analyzeComponents(options) {
309
715
  }
310
716
  function findComponentDirs(basePath) {
311
717
  const dirs = [];
312
- const entries = fs2.readdirSync(basePath, { withFileTypes: true });
718
+ const entries = fs3.readdirSync(basePath, { withFileTypes: true });
313
719
  for (const entry of entries) {
314
720
  if (!entry.isDirectory()) continue;
315
- const dirPath = path2.join(basePath, entry.name);
316
- const hasIndex = fs2.existsSync(path2.join(dirPath, "index.ts"));
317
- const hasTypes = fs2.existsSync(path2.join(dirPath, "types.ts"));
721
+ const dirPath = path3.join(basePath, entry.name);
722
+ const hasIndex = fs3.existsSync(path3.join(dirPath, "index.ts"));
723
+ const hasTypes = fs3.existsSync(path3.join(dirPath, "types.ts"));
318
724
  if (hasIndex || hasTypes) {
319
725
  dirs.push(dirPath);
320
726
  }
@@ -322,14 +728,14 @@ function findComponentDirs(basePath) {
322
728
  return dirs;
323
729
  }
324
730
  function analyzeComponentDir(dir, componentName, themeValues) {
325
- const tsFiles = fs2.readdirSync(dir).filter((f) => f.endsWith(".ts") || f.endsWith(".tsx")).map((f) => path2.join(dir, f));
731
+ const tsFiles = fs3.readdirSync(dir).filter((f) => f.endsWith(".ts") || f.endsWith(".tsx")).map((f) => path3.join(dir, f));
326
732
  if (tsFiles.length === 0) {
327
733
  return null;
328
734
  }
329
- const program = ts2.createProgram(tsFiles, {
330
- target: ts2.ScriptTarget.ES2020,
331
- module: ts2.ModuleKind.ESNext,
332
- jsx: ts2.JsxEmit.React,
735
+ const program = ts3.createProgram(tsFiles, {
736
+ target: ts3.ScriptTarget.ES2020,
737
+ module: ts3.ModuleKind.ESNext,
738
+ jsx: ts3.JsxEmit.React,
333
739
  strict: true,
334
740
  esModuleInterop: true,
335
741
  skipLibCheck: true
@@ -342,12 +748,12 @@ function analyzeComponentDir(dir, componentName, themeValues) {
342
748
  for (const filePath of tsFiles) {
343
749
  const sourceFile = program.getSourceFile(filePath);
344
750
  if (!sourceFile) continue;
345
- ts2.forEachChild(sourceFile, (node) => {
346
- if (ts2.isInterfaceDeclaration(node) && node.name.text === propsInterfaceName) {
751
+ ts3.forEachChild(sourceFile, (node) => {
752
+ if (ts3.isInterfaceDeclaration(node) && node.name.text === propsInterfaceName) {
347
753
  propsInterface = node;
348
754
  interfaceDescription = getJSDocDescription(node);
349
755
  }
350
- if (ts2.isTypeAliasDeclaration(node) && node.name.text === propsInterfaceName) {
756
+ if (ts3.isTypeAliasDeclaration(node) && node.name.text === propsInterfaceName) {
351
757
  propsInterface = node;
352
758
  interfaceDescription = getJSDocDescription(node);
353
759
  }
@@ -359,8 +765,8 @@ function analyzeComponentDir(dir, componentName, themeValues) {
359
765
  for (const filePath of tsFiles) {
360
766
  const sourceFile = program.getSourceFile(filePath);
361
767
  if (!sourceFile) continue;
362
- ts2.forEachChild(sourceFile, (node) => {
363
- if ((ts2.isInterfaceDeclaration(node) || ts2.isTypeAliasDeclaration(node)) && node.name.text === altName) {
768
+ ts3.forEachChild(sourceFile, (node) => {
769
+ if ((ts3.isInterfaceDeclaration(node) || ts3.isTypeAliasDeclaration(node)) && node.name.text === altName) {
364
770
  propsInterface = node;
365
771
  interfaceDescription = getJSDocDescription(node);
366
772
  }
@@ -392,32 +798,32 @@ function analyzeComponentDir(dir, componentName, themeValues) {
392
798
  description,
393
799
  props,
394
800
  category,
395
- filePath: path2.relative(process.cwd(), dir),
801
+ filePath: path3.relative(process.cwd(), dir),
396
802
  sampleProps
397
803
  };
398
804
  }
399
805
  function extractSampleProps(dir) {
400
- const docsPath = path2.join(dir, "docs.ts");
401
- if (!fs2.existsSync(docsPath)) {
806
+ const docsPath = path3.join(dir, "docs.ts");
807
+ if (!fs3.existsSync(docsPath)) {
402
808
  return void 0;
403
809
  }
404
810
  try {
405
- const content = fs2.readFileSync(docsPath, "utf-8");
406
- const sourceFile = ts2.createSourceFile(
811
+ const content = fs3.readFileSync(docsPath, "utf-8");
812
+ const sourceFile = ts3.createSourceFile(
407
813
  "docs.ts",
408
814
  content,
409
- ts2.ScriptTarget.ES2020,
815
+ ts3.ScriptTarget.ES2020,
410
816
  true,
411
- ts2.ScriptKind.TS
817
+ ts3.ScriptKind.TS
412
818
  );
413
819
  let samplePropsNode = null;
414
- ts2.forEachChild(sourceFile, (node) => {
415
- if (ts2.isVariableStatement(node)) {
416
- const isExported = node.modifiers?.some((m) => m.kind === ts2.SyntaxKind.ExportKeyword);
820
+ ts3.forEachChild(sourceFile, (node) => {
821
+ if (ts3.isVariableStatement(node)) {
822
+ const isExported = node.modifiers?.some((m) => m.kind === ts3.SyntaxKind.ExportKeyword);
417
823
  if (isExported) {
418
824
  for (const decl of node.declarationList.declarations) {
419
- if (ts2.isIdentifier(decl.name) && decl.name.text === "sampleProps" && decl.initializer) {
420
- if (ts2.isObjectLiteralExpression(decl.initializer)) {
825
+ if (ts3.isIdentifier(decl.name) && decl.name.text === "sampleProps" && decl.initializer) {
826
+ if (ts3.isObjectLiteralExpression(decl.initializer)) {
421
827
  samplePropsNode = decl.initializer;
422
828
  }
423
829
  }
@@ -431,13 +837,13 @@ function extractSampleProps(dir) {
431
837
  const result = {};
432
838
  const propsNode = samplePropsNode;
433
839
  for (const prop of propsNode.properties) {
434
- if (ts2.isPropertyAssignment(prop) && ts2.isIdentifier(prop.name)) {
840
+ if (ts3.isPropertyAssignment(prop) && ts3.isIdentifier(prop.name)) {
435
841
  const propName = prop.name.text;
436
- if (propName === "props" && ts2.isObjectLiteralExpression(prop.initializer)) {
842
+ if (propName === "props" && ts3.isObjectLiteralExpression(prop.initializer)) {
437
843
  result.props = extractObjectLiteral(prop.initializer, content);
438
844
  } else if (propName === "children") {
439
845
  result.children = prop.initializer.getText(sourceFile);
440
- } else if (propName === "state" && ts2.isObjectLiteralExpression(prop.initializer)) {
846
+ } else if (propName === "state" && ts3.isObjectLiteralExpression(prop.initializer)) {
441
847
  result.state = extractObjectLiteral(prop.initializer, content);
442
848
  }
443
849
  }
@@ -451,20 +857,20 @@ function extractSampleProps(dir) {
451
857
  function extractObjectLiteral(node, sourceContent) {
452
858
  const result = {};
453
859
  for (const prop of node.properties) {
454
- if (ts2.isPropertyAssignment(prop) && ts2.isIdentifier(prop.name)) {
860
+ if (ts3.isPropertyAssignment(prop) && ts3.isIdentifier(prop.name)) {
455
861
  const key = prop.name.text;
456
862
  const init = prop.initializer;
457
- if (ts2.isStringLiteral(init)) {
863
+ if (ts3.isStringLiteral(init)) {
458
864
  result[key] = init.text;
459
- } else if (ts2.isNumericLiteral(init)) {
865
+ } else if (ts3.isNumericLiteral(init)) {
460
866
  result[key] = Number(init.text);
461
- } else if (init.kind === ts2.SyntaxKind.TrueKeyword) {
867
+ } else if (init.kind === ts3.SyntaxKind.TrueKeyword) {
462
868
  result[key] = true;
463
- } else if (init.kind === ts2.SyntaxKind.FalseKeyword) {
869
+ } else if (init.kind === ts3.SyntaxKind.FalseKeyword) {
464
870
  result[key] = false;
465
- } else if (ts2.isArrayLiteralExpression(init)) {
871
+ } else if (ts3.isArrayLiteralExpression(init)) {
466
872
  result[key] = extractArrayLiteral(init, sourceContent);
467
- } else if (ts2.isObjectLiteralExpression(init)) {
873
+ } else if (ts3.isObjectLiteralExpression(init)) {
468
874
  result[key] = extractObjectLiteral(init, sourceContent);
469
875
  } else {
470
876
  result[key] = init.getText();
@@ -476,17 +882,17 @@ function extractObjectLiteral(node, sourceContent) {
476
882
  function extractArrayLiteral(node, sourceContent) {
477
883
  const result = [];
478
884
  for (const element of node.elements) {
479
- if (ts2.isStringLiteral(element)) {
885
+ if (ts3.isStringLiteral(element)) {
480
886
  result.push(element.text);
481
- } else if (ts2.isNumericLiteral(element)) {
887
+ } else if (ts3.isNumericLiteral(element)) {
482
888
  result.push(Number(element.text));
483
- } else if (element.kind === ts2.SyntaxKind.TrueKeyword) {
889
+ } else if (element.kind === ts3.SyntaxKind.TrueKeyword) {
484
890
  result.push(true);
485
- } else if (element.kind === ts2.SyntaxKind.FalseKeyword) {
891
+ } else if (element.kind === ts3.SyntaxKind.FalseKeyword) {
486
892
  result.push(false);
487
- } else if (ts2.isObjectLiteralExpression(element)) {
893
+ } else if (ts3.isObjectLiteralExpression(element)) {
488
894
  result.push(extractObjectLiteral(element, sourceContent));
489
- } else if (ts2.isArrayLiteralExpression(element)) {
895
+ } else if (ts3.isArrayLiteralExpression(element)) {
490
896
  result.push(extractArrayLiteral(element, sourceContent));
491
897
  } else {
492
898
  result.push(element.getText());
@@ -501,8 +907,8 @@ function analyzeProperty(symbol, typeChecker, themeValues) {
501
907
  const declaration = declarations[0];
502
908
  const type = typeChecker.getTypeOfSymbolAtLocation(symbol, declaration);
503
909
  const typeString = typeChecker.typeToString(type);
504
- const description = ts2.displayPartsToString(symbol.getDocumentationComment(typeChecker)) || void 0;
505
- const required = !(symbol.flags & ts2.SymbolFlags.Optional);
910
+ const description = ts3.displayPartsToString(symbol.getDocumentationComment(typeChecker)) || void 0;
911
+ const required = !(symbol.flags & ts3.SymbolFlags.Optional);
506
912
  const values = extractPropValues(type, typeString, typeChecker, themeValues);
507
913
  const defaultValue = extractDefaultValue(symbol);
508
914
  return {
@@ -543,7 +949,7 @@ function extractDefaultValue(symbol) {
543
949
  const tags = symbol.getJsDocTags();
544
950
  for (const tag of tags) {
545
951
  if (tag.name === "default" && tag.text) {
546
- const value = ts2.displayPartsToString(tag.text);
952
+ const value = ts3.displayPartsToString(tag.text);
547
953
  try {
548
954
  return JSON.parse(value);
549
955
  } catch {
@@ -663,11 +1069,11 @@ function idealystDocsPlugin(options) {
663
1069
  log("Components found:", Object.keys(registry));
664
1070
  }
665
1071
  if (output === "file" && outputPath) {
666
- const outputDir = path3.dirname(outputPath);
667
- if (!fs3.existsSync(outputDir)) {
668
- fs3.mkdirSync(outputDir, { recursive: true });
1072
+ const outputDir = path4.dirname(outputPath);
1073
+ if (!fs4.existsSync(outputDir)) {
1074
+ fs4.mkdirSync(outputDir, { recursive: true });
669
1075
  }
670
- fs3.writeFileSync(
1076
+ fs4.writeFileSync(
671
1077
  outputPath,
672
1078
  `// Auto-generated by @idealyst/tooling - DO NOT EDIT
673
1079
  export const componentRegistry = ${JSON.stringify(registry, null, 2)} as const;
@@ -738,8 +1144,8 @@ export const componentRegistry = ${JSON.stringify(registry, null, 2)} as const;
738
1144
  },
739
1145
  // Regenerate on component file changes
740
1146
  handleHotUpdate({ file, server }) {
741
- const isComponentFile = options.componentPaths.some((p) => file.includes(path3.resolve(p))) && (file.endsWith(".ts") || file.endsWith(".tsx"));
742
- const isThemeFile = file.includes(path3.resolve(options.themePath));
1147
+ const isComponentFile = options.componentPaths.some((p) => file.includes(path4.resolve(p))) && (file.endsWith(".ts") || file.endsWith(".tsx"));
1148
+ const isThemeFile = file.includes(path4.resolve(options.themePath));
743
1149
  if (isComponentFile || isThemeFile) {
744
1150
  log(`File changed: ${file}, regenerating registry...`);
745
1151
  registry = null;