@typestyles/cli 0.3.4 → 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,487 +0,0 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
- import ts from 'typescript';
4
- import fg from 'fast-glob';
5
-
6
- // src/snapshot-classnames.ts
7
- function sanitizeClassSegment(label) {
8
- const normalized = label.trim().toLowerCase().replace(/[^a-z0-9-]/g, "-");
9
- return normalized.replace(/-+/g, "-").replace(/^-|-$/g, "") || "style";
10
- }
11
- var RESERVED_COMPONENT_KEYS = /* @__PURE__ */ new Set([
12
- "base",
13
- "variants",
14
- "compoundVariants",
15
- "defaultVariants",
16
- "slots"
17
- ]);
18
- var PUBLIC_CLASSNAMES_SNAPSHOT = ".typestyles-public-classnames.json";
19
- var DEFAULT_INCLUDE = ["**/*.{ts,tsx}"];
20
- var DEFAULT_EXCLUDE = [
21
- "**/node_modules/**",
22
- "**/dist/**",
23
- "**/*.d.ts",
24
- "**/*.test.{ts,tsx}",
25
- "**/*.spec.{ts,tsx}"
26
- ];
27
- function semanticScopePrefix(scopeId) {
28
- if (!scopeId.trim()) return "";
29
- return `${sanitizeClassSegment(scopeId)}-`;
30
- }
31
- function semanticClassName(config, namespace, suffix) {
32
- if (config.mode === "hashed" || config.mode === "compact" || config.mode === "atomic" || config.mode === "template") {
33
- return null;
34
- }
35
- const prefix = semanticScopePrefix(config.scopeId);
36
- if (suffix === void 0 || suffix === "base") return `${prefix}${namespace}`;
37
- if (config.mode === "attribute") return `${prefix}${namespace}`;
38
- if (config.mode === "bem") return `${prefix}${namespace}--${suffix}`;
39
- return `${prefix}${namespace}--${suffix}`;
40
- }
41
- function getStaticObjectKey(name) {
42
- if (ts.isIdentifier(name)) return name.text;
43
- if (ts.isStringLiteral(name)) return name.text;
44
- return null;
45
- }
46
- function firstStringArg(args) {
47
- const first = args[0];
48
- if (!first || !ts.isStringLiteral(first)) return null;
49
- return first.text;
50
- }
51
- function unwrapExpression(expr) {
52
- let current = expr;
53
- while (ts.isParenthesizedExpression(current) || ts.isAsExpression(current) || ts.isSatisfiesExpression(current) || ts.isTypeAssertionExpression(current) || ts.isNonNullExpression(current)) {
54
- current = current.expression;
55
- }
56
- return current;
57
- }
58
- function objectExpressionFromConfigArg(arg) {
59
- if (!arg) return null;
60
- const expr = unwrapExpression(arg);
61
- if (ts.isObjectLiteralExpression(expr)) return expr;
62
- if (ts.isArrowFunction(expr)) {
63
- if (ts.isBlock(expr.body)) {
64
- for (const stmt of expr.body.statements) {
65
- if (ts.isReturnStatement(stmt) && stmt.expression && ts.isObjectLiteralExpression(unwrapExpression(stmt.expression))) {
66
- return unwrapExpression(stmt.expression);
67
- }
68
- }
69
- } else {
70
- const body = unwrapExpression(expr.body);
71
- if (ts.isObjectLiteralExpression(body)) return body;
72
- }
73
- }
74
- return null;
75
- }
76
- function literalFromProperty(obj, key) {
77
- for (const prop of obj.properties) {
78
- if (!ts.isPropertyAssignment(prop)) continue;
79
- const propKey = getStaticObjectKey(prop.name);
80
- if (propKey !== key) continue;
81
- const init = unwrapExpression(prop.initializer);
82
- if (ts.isStringLiteral(init)) return init.text;
83
- if (ts.isNoSubstitutionTemplateLiteral(init)) return init.text;
84
- }
85
- return null;
86
- }
87
- function hasObjectKey(obj, key) {
88
- return obj.properties.some((prop) => {
89
- if (!ts.isPropertyAssignment(prop)) return false;
90
- return getStaticObjectKey(prop.name) === key;
91
- });
92
- }
93
- function slotsArrayFromObject(obj) {
94
- const slotsProp = obj.properties.find((prop) => {
95
- if (!ts.isPropertyAssignment(prop)) return false;
96
- return getStaticObjectKey(prop.name) === "slots";
97
- });
98
- if (!slotsProp || !ts.isPropertyAssignment(slotsProp)) return null;
99
- const init = unwrapExpression(slotsProp.initializer);
100
- return ts.isArrayLiteralExpression(init) ? init : null;
101
- }
102
- function isSchemaRecipeCall(node) {
103
- if (node.arguments.length < 3) return false;
104
- const callback = node.arguments[2];
105
- if (!callback) return false;
106
- const unwrapped = unwrapExpression(callback);
107
- return ts.isArrowFunction(unwrapped) || ts.isFunctionExpression(unwrapped);
108
- }
109
- function propertyInit(obj, key) {
110
- for (const prop of obj.properties) {
111
- if (!ts.isPropertyAssignment(prop)) continue;
112
- if (getStaticObjectKey(prop.name) === key) return prop.initializer;
113
- }
114
- return void 0;
115
- }
116
- function recipeInputFromCall(node) {
117
- const first = node.arguments[0];
118
- if (!first) return null;
119
- const unwrapped = unwrapExpression(first);
120
- if (ts.isObjectLiteralExpression(unwrapped)) {
121
- const namespace = literalFromProperty(unwrapped, "name");
122
- if (!namespace) return null;
123
- return {
124
- namespace,
125
- styles: objectExpressionFromConfigArg(propertyInit(unwrapped, "styles")),
126
- slots: slotsArrayFromObject(unwrapped)
127
- };
128
- }
129
- return null;
130
- }
131
- function definitionSlots(arg) {
132
- if (!arg) return null;
133
- const def = unwrapExpression(arg);
134
- if (!ts.isObjectLiteralExpression(def)) return null;
135
- return slotsArrayFromObject(def);
136
- }
137
- function collectClassNamePartsFromConfig(obj, slotsOverride) {
138
- const parts = [];
139
- const hasVariants = hasObjectKey(obj, "variants");
140
- const hasCompound = hasObjectKey(obj, "compoundVariants");
141
- const hasDefaults = hasObjectKey(obj, "defaultVariants");
142
- const slotsNode = slotsOverride ?? slotsArrayFromObject(obj);
143
- const hasSlots = slotsNode !== null;
144
- if (hasSlots && (hasVariants || hasCompound || hasDefaults)) {
145
- const baseObj = obj.properties.find((prop) => {
146
- if (!ts.isPropertyAssignment(prop)) return false;
147
- return getStaticObjectKey(prop.name) === "base";
148
- });
149
- if (baseObj && ts.isPropertyAssignment(baseObj) && ts.isObjectLiteralExpression(baseObj.initializer)) {
150
- for (const slotProp of baseObj.initializer.properties) {
151
- if (!ts.isPropertyAssignment(slotProp)) continue;
152
- const slot = getStaticObjectKey(slotProp.name);
153
- if (slot) parts.push({ element: slot === "root" ? void 0 : slot });
154
- }
155
- }
156
- const variantsProp = obj.properties.find((prop) => {
157
- if (!ts.isPropertyAssignment(prop)) return false;
158
- return getStaticObjectKey(prop.name) === "variants";
159
- });
160
- if (variantsProp && ts.isPropertyAssignment(variantsProp) && ts.isObjectLiteralExpression(variantsProp.initializer)) {
161
- for (const dimProp of variantsProp.initializer.properties) {
162
- if (!ts.isPropertyAssignment(dimProp) || !ts.isObjectLiteralExpression(dimProp.initializer)) {
163
- continue;
164
- }
165
- const dimension = getStaticObjectKey(dimProp.name);
166
- if (!dimension) continue;
167
- for (const optProp of dimProp.initializer.properties) {
168
- if (!ts.isPropertyAssignment(optProp) || !ts.isObjectLiteralExpression(optProp.initializer)) {
169
- continue;
170
- }
171
- const option = getStaticObjectKey(optProp.name);
172
- if (!option) continue;
173
- for (const slotProp of optProp.initializer.properties) {
174
- if (!ts.isPropertyAssignment(slotProp)) continue;
175
- const slot = getStaticObjectKey(slotProp.name);
176
- if (slot) {
177
- parts.push({
178
- element: slot === "root" ? void 0 : slot,
179
- dimension,
180
- modifier: option
181
- });
182
- }
183
- }
184
- }
185
- }
186
- }
187
- return parts;
188
- }
189
- if (hasSlots && !hasVariants && !hasCompound && !hasDefaults) {
190
- if (slotsNode) {
191
- for (const element of slotsNode.elements) {
192
- if (element && ts.isStringLiteral(element)) {
193
- parts.push({ element: element.text === "root" ? void 0 : element.text });
194
- }
195
- }
196
- }
197
- return parts;
198
- }
199
- if (hasVariants || hasCompound || hasDefaults) {
200
- parts.push({});
201
- const variantsProp = obj.properties.find((prop) => {
202
- if (!ts.isPropertyAssignment(prop)) return false;
203
- return getStaticObjectKey(prop.name) === "variants";
204
- });
205
- if (variantsProp && ts.isPropertyAssignment(variantsProp) && ts.isObjectLiteralExpression(variantsProp.initializer)) {
206
- for (const dimProp of variantsProp.initializer.properties) {
207
- if (!ts.isPropertyAssignment(dimProp) || !ts.isObjectLiteralExpression(dimProp.initializer)) {
208
- continue;
209
- }
210
- const dimension = getStaticObjectKey(dimProp.name);
211
- if (!dimension) continue;
212
- for (const optProp of dimProp.initializer.properties) {
213
- if (!ts.isPropertyAssignment(optProp)) continue;
214
- const option = getStaticObjectKey(optProp.name);
215
- if (option) parts.push({ dimension, modifier: option });
216
- }
217
- }
218
- }
219
- return parts;
220
- }
221
- for (const prop of obj.properties) {
222
- if (!ts.isPropertyAssignment(prop)) continue;
223
- const key = getStaticObjectKey(prop.name);
224
- if (!key) continue;
225
- if (key === "base") {
226
- parts.push({});
227
- continue;
228
- }
229
- if (RESERVED_COMPONENT_KEYS.has(key)) continue;
230
- parts.push({ modifier: key });
231
- }
232
- return parts;
233
- }
234
- function componentClassName(config, namespace, part) {
235
- if (config.mode === "hashed" || config.mode === "compact" || config.mode === "atomic" || config.mode === "template") {
236
- return null;
237
- }
238
- const prefix = semanticScopePrefix(config.scopeId);
239
- const block = `${prefix}${namespace}${part.element ? `__${part.element}` : ""}`;
240
- if (!part.modifier) return block;
241
- if (config.mode === "attribute" && part.dimension) return block;
242
- if (config.mode === "bem") return `${block}--${part.modifier}`;
243
- return `${block}--${part.dimension ? `${part.dimension}-` : ""}${part.modifier}`;
244
- }
245
- function parseCreateStylesConfig(init) {
246
- const config = { mode: "semantic", scopeId: "" };
247
- let expr = unwrapExpression(init);
248
- if (ts.isCallExpression(expr)) {
249
- const firstArg = expr.arguments[0];
250
- if (!firstArg) return config;
251
- expr = unwrapExpression(firstArg);
252
- }
253
- if (!ts.isObjectLiteralExpression(expr)) return config;
254
- const mode = literalFromProperty(expr, "mode");
255
- if (mode === "semantic" || mode === "hashed" || mode === "compact" || mode === "atomic" || mode === "attribute" || mode === "bem" || mode === "template") {
256
- config.mode = mode;
257
- }
258
- const scopeId = literalFromProperty(expr, "scopeId");
259
- if (scopeId != null) config.scopeId = scopeId;
260
- return config;
261
- }
262
- function isCreateStylesCall(expr) {
263
- const unwrapped = unwrapExpression(expr);
264
- if (!ts.isCallExpression(unwrapped)) return false;
265
- const callee = unwrapped.expression;
266
- if (ts.isIdentifier(callee) && (callee.text === "createStyles" || callee.text === "createTypeStyles")) {
267
- return true;
268
- }
269
- if (ts.isPropertyAccessExpression(callee) && ts.isIdentifier(callee.expression) && callee.expression.text === "typestyles" && (callee.name.text === "createStyles" || callee.name.text === "createTypeStyles")) {
270
- return true;
271
- }
272
- return false;
273
- }
274
- function registerBindingFromCreateCall(bindings, name, init) {
275
- bindings.set(name, parseCreateStylesConfig(init));
276
- }
277
- function collectBindings(sourceFile) {
278
- const bindings = /* @__PURE__ */ new Map();
279
- const visit = (node) => {
280
- if (ts.isVariableDeclaration(node) && node.initializer && isCreateStylesCall(node.initializer)) {
281
- if (ts.isIdentifier(node.name)) {
282
- registerBindingFromCreateCall(bindings, node.name.text, node.initializer);
283
- } else if (ts.isObjectBindingPattern(node.name)) {
284
- const config = parseCreateStylesConfig(node.initializer);
285
- for (const element of node.name.elements) {
286
- if (ts.isBindingElement(element) && ts.isIdentifier(element.name)) {
287
- bindings.set(element.name.text, config);
288
- }
289
- }
290
- }
291
- }
292
- ts.forEachChild(node, visit);
293
- };
294
- visit(sourceFile);
295
- return bindings;
296
- }
297
- function normalizeCalleeMethod(name) {
298
- if (name === "style" || name === "class") return "class";
299
- if (name === "recipe" || name === "component") return "component";
300
- return null;
301
- }
302
- function calleeMethodName(expr) {
303
- if (ts.isIdentifier(expr)) {
304
- return normalizeCalleeMethod(expr.text);
305
- }
306
- if (!ts.isPropertyAccessExpression(expr)) return null;
307
- if (ts.isIdentifier(expr.name)) return normalizeCalleeMethod(expr.name.text);
308
- return null;
309
- }
310
- function lineOf(sourceFile, node) {
311
- const { line } = sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile));
312
- return line + 1;
313
- }
314
- function stylesBindingFromCallee(expr, bindings, defaultConfig) {
315
- if (ts.isPropertyAccessExpression(expr) && ts.isIdentifier(expr.expression)) {
316
- const binding = bindings.get(expr.expression.text);
317
- if (binding) return binding;
318
- if (expr.expression.text === "styles" && defaultConfig) return defaultConfig;
319
- }
320
- if (ts.isIdentifier(expr)) {
321
- return bindings.get(expr.text) ?? defaultConfig ?? { mode: "semantic", scopeId: "" };
322
- }
323
- return defaultConfig ?? { mode: "semantic", scopeId: "" };
324
- }
325
- function mergeProjectBindings(sourceFiles) {
326
- const bindings = /* @__PURE__ */ new Map();
327
- const configs = [];
328
- for (const sourceFile of sourceFiles) {
329
- const fileBindings = collectBindings(sourceFile);
330
- for (const [key, value] of fileBindings) {
331
- bindings.set(key, value);
332
- configs.push(value);
333
- }
334
- }
335
- const unique = /* @__PURE__ */ new Map();
336
- for (const config of configs) {
337
- unique.set(`${config.mode}:${config.scopeId}`, config);
338
- }
339
- const defaultConfig = unique.size === 1 ? [...unique.values()][0] : void 0;
340
- return { bindings, defaultConfig };
341
- }
342
- function collectCallsFromSourceFile(sourceFile, relativePath, bindings, defaultConfig) {
343
- const entries = [];
344
- const visit = (node) => {
345
- if (ts.isCallExpression(node)) {
346
- const method = calleeMethodName(node.expression);
347
- if (method === "class" || method === "component") {
348
- const recipeInput = method === "component" ? recipeInputFromCall(node) : null;
349
- const namespace = recipeInput?.namespace ?? firstStringArg(node.arguments);
350
- if (!namespace) {
351
- ts.forEachChild(node, visit);
352
- return;
353
- }
354
- const config = stylesBindingFromCallee(node.expression, bindings, defaultConfig);
355
- const line = lineOf(sourceFile, node.arguments[0] ?? node);
356
- if (method === "class") {
357
- const className = semanticClassName(config, namespace);
358
- if (className) {
359
- entries.push({
360
- className,
361
- kind: "class",
362
- namespace,
363
- file: relativePath,
364
- line
365
- });
366
- }
367
- } else {
368
- const schemaCall = recipeInput ? false : isSchemaRecipeCall(node);
369
- const configObj = recipeInput?.styles ?? objectExpressionFromConfigArg(schemaCall ? node.arguments[2] : node.arguments[1]);
370
- const slotsOverride = recipeInput ? recipeInput.slots : schemaCall ? definitionSlots(node.arguments[1]) : void 0;
371
- const parts = configObj ? collectClassNamePartsFromConfig(configObj, slotsOverride) : [{}];
372
- for (const part of parts) {
373
- const className = componentClassName(config, namespace, part);
374
- if (className) {
375
- entries.push({
376
- className,
377
- kind: "component",
378
- namespace,
379
- suffix: part.modifier ? `${part.element ? `${part.element}-` : ""}${part.dimension ? `${part.dimension}-` : ""}${part.modifier}` : part.element ?? "base",
380
- file: relativePath,
381
- line
382
- });
383
- }
384
- }
385
- }
386
- }
387
- }
388
- ts.forEachChild(node, visit);
389
- };
390
- visit(sourceFile);
391
- return entries;
392
- }
393
- function collectPublicClassNamesFromFiles(filePaths, rootDir) {
394
- const parsed = filePaths.map((filePath) => {
395
- const sourceText = fs.readFileSync(filePath, "utf8");
396
- const sourceFile = ts.createSourceFile(
397
- filePath,
398
- sourceText,
399
- ts.ScriptTarget.Latest,
400
- true,
401
- filePath.endsWith(".tsx") ? ts.ScriptKind.TSX : ts.ScriptKind.TS
402
- );
403
- return { filePath, sourceFile, relativePath: path.relative(rootDir, filePath) };
404
- });
405
- const { bindings, defaultConfig } = mergeProjectBindings(parsed.map((item) => item.sourceFile));
406
- const entries = [];
407
- for (const { sourceFile, relativePath } of parsed) {
408
- entries.push(...collectCallsFromSourceFile(sourceFile, relativePath, bindings, defaultConfig));
409
- }
410
- return dedupeEntries(entries);
411
- }
412
- function dedupeEntries(entries) {
413
- const byClass = /* @__PURE__ */ new Map();
414
- for (const entry of entries) {
415
- if (!byClass.has(entry.className)) {
416
- byClass.set(entry.className, entry);
417
- }
418
- }
419
- return [...byClass.values()].sort((a, b) => a.className.localeCompare(b.className));
420
- }
421
- async function collectPublicClassNames(options = {}) {
422
- const rootDir = path.resolve(options.rootDir ?? process.cwd());
423
- const include = options.include ?? DEFAULT_INCLUDE;
424
- const exclude = options.exclude ?? DEFAULT_EXCLUDE;
425
- const files = await fg(include, {
426
- cwd: rootDir,
427
- absolute: true,
428
- ignore: exclude
429
- });
430
- return collectPublicClassNamesFromFiles(files, rootDir);
431
- }
432
- function collectPublicClassNamesSync(options = {}) {
433
- const rootDir = path.resolve(options.rootDir ?? process.cwd());
434
- const include = options.include ?? DEFAULT_INCLUDE;
435
- const exclude = options.exclude ?? DEFAULT_EXCLUDE;
436
- const files = fg.sync(include, {
437
- cwd: rootDir,
438
- absolute: true,
439
- ignore: exclude
440
- });
441
- return collectPublicClassNamesFromFiles(files, rootDir);
442
- }
443
- function resolveProjectStylesBindings(filePaths, _rootDir) {
444
- const parsed = filePaths.map((filePath) => {
445
- const sourceText = fs.readFileSync(filePath, "utf8");
446
- return ts.createSourceFile(
447
- filePath,
448
- sourceText,
449
- ts.ScriptTarget.Latest,
450
- true,
451
- filePath.endsWith(".tsx") ? ts.ScriptKind.TSX : ts.ScriptKind.TS
452
- );
453
- });
454
- return mergeProjectBindings(parsed).bindings;
455
- }
456
- function buildSnapshot(entries) {
457
- const sorted = dedupeEntries(entries);
458
- return {
459
- version: 1,
460
- classNames: sorted.map((entry) => entry.className),
461
- entries: sorted
462
- };
463
- }
464
- function loadPublicClassNamesSnapshot(snapshotPath) {
465
- if (!fs.existsSync(snapshotPath)) return null;
466
- const raw = JSON.parse(fs.readFileSync(snapshotPath, "utf8"));
467
- if (!raw || raw.version !== 1 || !Array.isArray(raw.classNames)) {
468
- throw new Error(
469
- `[typestyles] Invalid public class name snapshot at ${snapshotPath}. Regenerate with \`typestyles snapshot --write\`.`
470
- );
471
- }
472
- return raw;
473
- }
474
- function writePublicClassNamesSnapshot(snapshotPath, entries) {
475
- const snapshot = buildSnapshot(entries);
476
- fs.writeFileSync(snapshotPath, `${JSON.stringify(snapshot, null, 2)}
477
- `, "utf8");
478
- return snapshot;
479
- }
480
- function diffRemovedPublicClassNames(snapshot, current) {
481
- const currentSet = new Set(current.map((entry) => entry.className));
482
- return snapshot.entries.filter((entry) => !currentSet.has(entry.className));
483
- }
484
-
485
- export { PUBLIC_CLASSNAMES_SNAPSHOT, buildSnapshot, collectPublicClassNames, collectPublicClassNamesFromFiles, collectPublicClassNamesSync, diffRemovedPublicClassNames, loadPublicClassNamesSnapshot, resolveProjectStylesBindings, semanticClassName, writePublicClassNamesSnapshot };
486
- //# sourceMappingURL=chunk-DO2YWMF2.js.map
487
- //# sourceMappingURL=chunk-DO2YWMF2.js.map
@@ -1 +0,0 @@
1
- {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s';\nimport path from 'node:path';\nimport ts from 'typescript';\nimport fg from 'fast-glob';\n\n/** Mirrors `sanitizeClassSegment` in `typestyles` class naming. */\nfunction sanitizeClassSegment(label: string): string {\n const normalized = label\n .trim()\n .toLowerCase()\n .replace(/[^a-z0-9-]/g, '-');\n return normalized.replace(/-+/g, '-').replace(/^-|-$/g, '') || 'style';\n}\n\nconst RESERVED_COMPONENT_KEYS = new Set([\n 'base',\n 'variants',\n 'compoundVariants',\n 'defaultVariants',\n 'slots',\n]);\n\nexport const PUBLIC_CLASSNAMES_SNAPSHOT = '.typestyles-public-classnames.json';\n\nexport type PublicClassNameEntry = {\n className: string;\n kind: 'class' | 'component';\n namespace: string;\n suffix?: string;\n file: string;\n line: number;\n};\n\nexport type PublicClassNamesSnapshot = {\n version: 1;\n classNames: string[];\n entries: PublicClassNameEntry[];\n};\n\nexport type StylesBindingConfig = {\n mode: 'semantic' | 'hashed' | 'compact' | 'atomic' | 'attribute' | 'bem' | 'template';\n scopeId: string;\n};\n\nexport type CollectPublicClassNamesOptions = {\n /** Project root for resolving snapshot paths and globs */\n rootDir?: string;\n /** Glob patterns relative to rootDir */\n include?: string[];\n /** Glob patterns to exclude */\n exclude?: string[];\n};\n\nconst DEFAULT_INCLUDE = ['**/*.{ts,tsx}'];\nconst DEFAULT_EXCLUDE = [\n '**/node_modules/**',\n '**/dist/**',\n '**/*.d.ts',\n '**/*.test.{ts,tsx}',\n '**/*.spec.{ts,tsx}',\n];\n\nfunction semanticScopePrefix(scopeId: string): string {\n if (!scopeId.trim()) return '';\n return `${sanitizeClassSegment(scopeId)}-`;\n}\n\nexport function semanticClassName(\n config: StylesBindingConfig,\n namespace: string,\n suffix?: string,\n): string | null {\n if (\n config.mode === 'hashed' ||\n config.mode === 'compact' ||\n config.mode === 'atomic' ||\n config.mode === 'template'\n ) {\n return null;\n }\n const prefix = semanticScopePrefix(config.scopeId);\n if (suffix === undefined || suffix === 'base') return `${prefix}${namespace}`;\n // Dimensioned attribute variants are data-* only; the helper cannot tell flat\n // modifiers from option names — prefer `componentClassName` / collect for that.\n if (config.mode === 'attribute') return `${prefix}${namespace}`;\n if (config.mode === 'bem') return `${prefix}${namespace}--${suffix}`;\n return `${prefix}${namespace}--${suffix}`;\n}\n\nfunction getStaticObjectKey(name: ts.PropertyName): string | null {\n if (ts.isIdentifier(name)) return name.text;\n if (ts.isStringLiteral(name)) return name.text;\n return null;\n}\n\nfunction firstStringArg(args: ts.NodeArray<ts.Expression>): string | null {\n const first = args[0];\n if (!first || !ts.isStringLiteral(first)) return null;\n return first.text;\n}\n\nfunction unwrapExpression(expr: ts.Expression): ts.Expression {\n let current = expr;\n while (\n ts.isParenthesizedExpression(current) ||\n ts.isAsExpression(current) ||\n ts.isSatisfiesExpression(current) ||\n ts.isTypeAssertionExpression(current) ||\n ts.isNonNullExpression(current)\n ) {\n current = current.expression;\n }\n return current;\n}\n\nfunction objectExpressionFromConfigArg(\n arg: ts.Expression | undefined,\n): ts.ObjectLiteralExpression | null {\n if (!arg) return null;\n const expr = unwrapExpression(arg);\n if (ts.isObjectLiteralExpression(expr)) return expr;\n if (ts.isArrowFunction(expr)) {\n if (ts.isBlock(expr.body)) {\n for (const stmt of expr.body.statements) {\n if (\n ts.isReturnStatement(stmt) &&\n stmt.expression &&\n ts.isObjectLiteralExpression(unwrapExpression(stmt.expression))\n ) {\n return unwrapExpression(stmt.expression) as ts.ObjectLiteralExpression;\n }\n }\n } else {\n // `() => ({ ... })` wraps the object in parentheses.\n const body = unwrapExpression(expr.body);\n if (ts.isObjectLiteralExpression(body)) return body;\n }\n }\n return null;\n}\n\nfunction literalFromProperty(obj: ts.ObjectLiteralExpression, key: string): string | null {\n for (const prop of obj.properties) {\n if (!ts.isPropertyAssignment(prop)) continue;\n const propKey = getStaticObjectKey(prop.name);\n if (propKey !== key) continue;\n const init = unwrapExpression(prop.initializer);\n if (ts.isStringLiteral(init)) return init.text;\n if (ts.isNoSubstitutionTemplateLiteral(init)) return init.text;\n }\n return null;\n}\n\nfunction hasObjectKey(obj: ts.ObjectLiteralExpression, key: string): boolean {\n return obj.properties.some((prop) => {\n if (!ts.isPropertyAssignment(prop)) return false;\n return getStaticObjectKey(prop.name) === key;\n });\n}\n\n/** Read the `slots` array literal from an object, if present. */\nfunction slotsArrayFromObject(obj: ts.ObjectLiteralExpression): ts.ArrayLiteralExpression | null {\n const slotsProp = obj.properties.find((prop) => {\n if (!ts.isPropertyAssignment(prop)) return false;\n return getStaticObjectKey(prop.name) === 'slots';\n });\n if (!slotsProp || !ts.isPropertyAssignment(slotsProp)) return null;\n const init = unwrapExpression(slotsProp.initializer);\n return ts.isArrayLiteralExpression(init) ? init : null;\n}\n\n/**\n * A schema-first recipe call: `recipe(namespace, definition, callback, options?)`.\n *\n * The style config is the third argument (the callback); the second is a definition\n * `{ slots?, variants }` whose axes are branded `variant.enum(...)` / `variant.boolean(...)`\n * values rather than style objects. In the legacy shapes the third argument is an options\n * object (`{ layer }`), never a function, so a function there is an unambiguous tell.\n */\nfunction isSchemaRecipeCall(node: ts.CallExpression): boolean {\n if (node.arguments.length < 3) return false;\n const callback = node.arguments[2];\n if (!callback) return false;\n const unwrapped = unwrapExpression(callback);\n return ts.isArrowFunction(unwrapped) || ts.isFunctionExpression(unwrapped);\n}\n\nfunction propertyInit(obj: ts.ObjectLiteralExpression, key: string): ts.Expression | undefined {\n for (const prop of obj.properties) {\n if (!ts.isPropertyAssignment(prop)) continue;\n if (getStaticObjectKey(prop.name) === key) return prop.initializer;\n }\n return undefined;\n}\n\n/**\n * `recipe({ name, slots?, styles })` or the removed positional\n * `recipe(name, config | definition, callback?)`.\n */\nfunction recipeInputFromCall(node: ts.CallExpression): {\n namespace: string;\n styles: ts.ObjectLiteralExpression | null;\n slots: ts.ArrayLiteralExpression | null;\n} | null {\n const first = node.arguments[0];\n if (!first) return null;\n const unwrapped = unwrapExpression(first);\n if (ts.isObjectLiteralExpression(unwrapped)) {\n const namespace = literalFromProperty(unwrapped, 'name');\n if (!namespace) return null;\n return {\n namespace,\n styles: objectExpressionFromConfigArg(propertyInit(unwrapped, 'styles')),\n slots: slotsArrayFromObject(unwrapped),\n };\n }\n return null;\n}\n\n/** Slots declared on a schema recipe's definition argument, if any. */\nfunction definitionSlots(arg: ts.Expression | undefined): ts.ArrayLiteralExpression | null {\n if (!arg) return null;\n const def = unwrapExpression(arg);\n if (!ts.isObjectLiteralExpression(def)) return null;\n return slotsArrayFromObject(def);\n}\n\ntype ComponentClassNamePart = {\n suffix?: string;\n element?: string;\n dimension?: string;\n modifier?: string;\n};\n\nfunction collectClassNamePartsFromConfig(\n obj: ts.ObjectLiteralExpression,\n slotsOverride?: ts.ArrayLiteralExpression | null,\n): ComponentClassNamePart[] {\n const parts: ComponentClassNamePart[] = [];\n\n const hasVariants = hasObjectKey(obj, 'variants');\n const hasCompound = hasObjectKey(obj, 'compoundVariants');\n const hasDefaults = hasObjectKey(obj, 'defaultVariants');\n // Schema-first recipes carry `slots` on the definition (second call argument), not on\n // the callback's returned config, so the caller passes it in.\n const slotsNode = slotsOverride ?? slotsArrayFromObject(obj);\n const hasSlots = slotsNode !== null;\n\n if (hasSlots && (hasVariants || hasCompound || hasDefaults)) {\n const baseObj = obj.properties.find((prop) => {\n if (!ts.isPropertyAssignment(prop)) return false;\n return getStaticObjectKey(prop.name) === 'base';\n });\n if (\n baseObj &&\n ts.isPropertyAssignment(baseObj) &&\n ts.isObjectLiteralExpression(baseObj.initializer)\n ) {\n for (const slotProp of baseObj.initializer.properties) {\n if (!ts.isPropertyAssignment(slotProp)) continue;\n const slot = getStaticObjectKey(slotProp.name);\n if (slot) parts.push({ element: slot === 'root' ? undefined : slot });\n }\n }\n\n const variantsProp = obj.properties.find((prop) => {\n if (!ts.isPropertyAssignment(prop)) return false;\n return getStaticObjectKey(prop.name) === 'variants';\n });\n if (\n variantsProp &&\n ts.isPropertyAssignment(variantsProp) &&\n ts.isObjectLiteralExpression(variantsProp.initializer)\n ) {\n for (const dimProp of variantsProp.initializer.properties) {\n if (\n !ts.isPropertyAssignment(dimProp) ||\n !ts.isObjectLiteralExpression(dimProp.initializer)\n ) {\n continue;\n }\n const dimension = getStaticObjectKey(dimProp.name);\n if (!dimension) continue;\n for (const optProp of dimProp.initializer.properties) {\n if (\n !ts.isPropertyAssignment(optProp) ||\n !ts.isObjectLiteralExpression(optProp.initializer)\n ) {\n continue;\n }\n const option = getStaticObjectKey(optProp.name);\n if (!option) continue;\n for (const slotProp of optProp.initializer.properties) {\n if (!ts.isPropertyAssignment(slotProp)) continue;\n const slot = getStaticObjectKey(slotProp.name);\n if (slot) {\n parts.push({\n element: slot === 'root' ? undefined : slot,\n dimension,\n modifier: option,\n });\n }\n }\n }\n }\n }\n\n return parts;\n }\n\n if (hasSlots && !hasVariants && !hasCompound && !hasDefaults) {\n // Slot class names come from the declared `slots` list. `styles.base` is the\n // slot style map, not a slot named \"base\".\n if (slotsNode) {\n for (const element of slotsNode.elements) {\n if (element && ts.isStringLiteral(element)) {\n parts.push({ element: element.text === 'root' ? undefined : element.text });\n }\n }\n }\n return parts;\n }\n\n if (hasVariants || hasCompound || hasDefaults) {\n parts.push({});\n\n const variantsProp = obj.properties.find((prop) => {\n if (!ts.isPropertyAssignment(prop)) return false;\n return getStaticObjectKey(prop.name) === 'variants';\n });\n if (\n variantsProp &&\n ts.isPropertyAssignment(variantsProp) &&\n ts.isObjectLiteralExpression(variantsProp.initializer)\n ) {\n for (const dimProp of variantsProp.initializer.properties) {\n if (\n !ts.isPropertyAssignment(dimProp) ||\n !ts.isObjectLiteralExpression(dimProp.initializer)\n ) {\n continue;\n }\n const dimension = getStaticObjectKey(dimProp.name);\n if (!dimension) continue;\n for (const optProp of dimProp.initializer.properties) {\n if (!ts.isPropertyAssignment(optProp)) continue;\n const option = getStaticObjectKey(optProp.name);\n if (option) parts.push({ dimension, modifier: option });\n }\n }\n }\n\n return parts;\n }\n\n for (const prop of obj.properties) {\n if (!ts.isPropertyAssignment(prop)) continue;\n const key = getStaticObjectKey(prop.name);\n if (!key) continue;\n if (key === 'base') {\n parts.push({});\n continue;\n }\n if (RESERVED_COMPONENT_KEYS.has(key)) continue;\n parts.push({ modifier: key });\n }\n\n return parts;\n}\n\nfunction componentClassName(\n config: StylesBindingConfig,\n namespace: string,\n part: ComponentClassNamePart,\n): string | null {\n if (\n config.mode === 'hashed' ||\n config.mode === 'compact' ||\n config.mode === 'atomic' ||\n config.mode === 'template'\n ) {\n return null;\n }\n\n const prefix = semanticScopePrefix(config.scopeId);\n const block = `${prefix}${namespace}${part.element ? `__${part.element}` : ''}`;\n if (!part.modifier) return block;\n // Dimensioned attribute variants compile to data-* attrs (no public class).\n // Flat attribute modifiers still emit `block--modifier` classes.\n if (config.mode === 'attribute' && part.dimension) return block;\n if (config.mode === 'bem') return `${block}--${part.modifier}`;\n return `${block}--${part.dimension ? `${part.dimension}-` : ''}${part.modifier}`;\n}\n\nfunction parseCreateStylesConfig(init: ts.Expression): StylesBindingConfig {\n const config: StylesBindingConfig = { mode: 'semantic', scopeId: '' };\n let expr = unwrapExpression(init);\n if (ts.isCallExpression(expr)) {\n const firstArg = expr.arguments[0];\n if (!firstArg) return config;\n expr = unwrapExpression(firstArg);\n }\n if (!ts.isObjectLiteralExpression(expr)) return config;\n\n const mode = literalFromProperty(expr, 'mode');\n if (\n mode === 'semantic' ||\n mode === 'hashed' ||\n mode === 'compact' ||\n mode === 'atomic' ||\n mode === 'attribute' ||\n mode === 'bem' ||\n mode === 'template'\n ) {\n config.mode = mode;\n }\n const scopeId = literalFromProperty(expr, 'scopeId');\n if (scopeId != null) config.scopeId = scopeId;\n return config;\n}\n\nfunction isCreateStylesCall(expr: ts.Expression): boolean {\n const unwrapped = unwrapExpression(expr);\n if (!ts.isCallExpression(unwrapped)) return false;\n const callee = unwrapped.expression;\n if (\n ts.isIdentifier(callee) &&\n (callee.text === 'createStyles' || callee.text === 'createTypeStyles')\n ) {\n return true;\n }\n if (\n ts.isPropertyAccessExpression(callee) &&\n ts.isIdentifier(callee.expression) &&\n callee.expression.text === 'typestyles' &&\n (callee.name.text === 'createStyles' || callee.name.text === 'createTypeStyles')\n ) {\n return true;\n }\n return false;\n}\n\nfunction registerBindingFromCreateCall(\n bindings: Map<string, StylesBindingConfig>,\n name: string,\n init: ts.Expression,\n): void {\n bindings.set(name, parseCreateStylesConfig(init));\n}\n\nfunction collectBindings(sourceFile: ts.SourceFile): Map<string, StylesBindingConfig> {\n const bindings = new Map<string, StylesBindingConfig>();\n\n const visit = (node: ts.Node): void => {\n if (\n ts.isVariableDeclaration(node) &&\n node.initializer &&\n isCreateStylesCall(node.initializer)\n ) {\n if (ts.isIdentifier(node.name)) {\n registerBindingFromCreateCall(bindings, node.name.text, node.initializer);\n } else if (ts.isObjectBindingPattern(node.name)) {\n const config = parseCreateStylesConfig(node.initializer);\n for (const element of node.name.elements) {\n if (ts.isBindingElement(element) && ts.isIdentifier(element.name)) {\n bindings.set(element.name.text, config);\n }\n }\n }\n }\n ts.forEachChild(node, visit);\n };\n\n visit(sourceFile);\n return bindings;\n}\n\nfunction normalizeCalleeMethod(name: string): 'class' | 'component' | null {\n if (name === 'style' || name === 'class') return 'class';\n if (name === 'recipe' || name === 'component') return 'component';\n return null;\n}\n\nfunction calleeMethodName(expr: ts.Expression): 'class' | 'component' | null {\n // Flat API: `style(...)` / `recipe(...)` and `typestyles.style` / `typestyles.recipe`\n // Legacy: `styles.class` / `styles.component`\n if (ts.isIdentifier(expr)) {\n return normalizeCalleeMethod(expr.text);\n }\n if (!ts.isPropertyAccessExpression(expr)) return null;\n if (ts.isIdentifier(expr.name)) return normalizeCalleeMethod(expr.name.text);\n return null;\n}\n\nfunction lineOf(sourceFile: ts.SourceFile, node: ts.Node): number {\n const { line } = sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile));\n return line + 1;\n}\n\nfunction stylesBindingFromCallee(\n expr: ts.Expression,\n bindings: Map<string, StylesBindingConfig>,\n defaultConfig?: StylesBindingConfig,\n): StylesBindingConfig {\n if (ts.isPropertyAccessExpression(expr) && ts.isIdentifier(expr.expression)) {\n const binding = bindings.get(expr.expression.text);\n if (binding) return binding;\n if (expr.expression.text === 'styles' && defaultConfig) return defaultConfig;\n }\n if (ts.isIdentifier(expr)) {\n return bindings.get(expr.text) ?? defaultConfig ?? { mode: 'semantic', scopeId: '' };\n }\n return defaultConfig ?? { mode: 'semantic', scopeId: '' };\n}\n\nfunction mergeProjectBindings(sourceFiles: ts.SourceFile[]): {\n bindings: Map<string, StylesBindingConfig>;\n defaultConfig?: StylesBindingConfig;\n} {\n const bindings = new Map<string, StylesBindingConfig>();\n const configs: StylesBindingConfig[] = [];\n\n for (const sourceFile of sourceFiles) {\n const fileBindings = collectBindings(sourceFile);\n for (const [key, value] of fileBindings) {\n bindings.set(key, value);\n configs.push(value);\n }\n }\n\n const unique = new Map<string, StylesBindingConfig>();\n for (const config of configs) {\n unique.set(`${config.mode}:${config.scopeId}`, config);\n }\n\n const defaultConfig = unique.size === 1 ? [...unique.values()][0] : undefined;\n return { bindings, defaultConfig };\n}\n\nfunction collectCallsFromSourceFile(\n sourceFile: ts.SourceFile,\n relativePath: string,\n bindings: Map<string, StylesBindingConfig>,\n defaultConfig?: StylesBindingConfig,\n): PublicClassNameEntry[] {\n const entries: PublicClassNameEntry[] = [];\n\n const visit = (node: ts.Node): void => {\n if (ts.isCallExpression(node)) {\n const method = calleeMethodName(node.expression);\n if (method === 'class' || method === 'component') {\n const recipeInput = method === 'component' ? recipeInputFromCall(node) : null;\n const namespace = recipeInput?.namespace ?? firstStringArg(node.arguments);\n if (!namespace) {\n ts.forEachChild(node, visit);\n return;\n }\n\n const config = stylesBindingFromCallee(node.expression, bindings, defaultConfig);\n const line = lineOf(sourceFile, node.arguments[0] ?? node);\n\n if (method === 'class') {\n const className = semanticClassName(config, namespace);\n if (className) {\n entries.push({\n className,\n kind: 'class',\n namespace,\n file: relativePath,\n line,\n });\n }\n } else {\n const schemaCall = recipeInput ? false : isSchemaRecipeCall(node);\n const configObj =\n recipeInput?.styles ??\n objectExpressionFromConfigArg(schemaCall ? node.arguments[2] : node.arguments[1]);\n const slotsOverride = recipeInput\n ? recipeInput.slots\n : schemaCall\n ? definitionSlots(node.arguments[1])\n : undefined;\n const parts = configObj\n ? collectClassNamePartsFromConfig(configObj, slotsOverride)\n : [{}];\n for (const part of parts) {\n const className = componentClassName(config, namespace, part);\n if (className) {\n entries.push({\n className,\n kind: 'component',\n namespace,\n suffix: part.modifier\n ? `${part.element ? `${part.element}-` : ''}${part.dimension ? `${part.dimension}-` : ''}${part.modifier}`\n : (part.element ?? 'base'),\n file: relativePath,\n line,\n });\n }\n }\n }\n }\n }\n ts.forEachChild(node, visit);\n };\n\n visit(sourceFile);\n return entries;\n}\n\nexport function collectPublicClassNamesFromFiles(\n filePaths: string[],\n rootDir: string,\n): PublicClassNameEntry[] {\n const parsed = filePaths.map((filePath) => {\n const sourceText = fs.readFileSync(filePath, 'utf8');\n const sourceFile = ts.createSourceFile(\n filePath,\n sourceText,\n ts.ScriptTarget.Latest,\n true,\n filePath.endsWith('.tsx') ? ts.ScriptKind.TSX : ts.ScriptKind.TS,\n );\n return { filePath, sourceFile, relativePath: path.relative(rootDir, filePath) };\n });\n\n const { bindings, defaultConfig } = mergeProjectBindings(parsed.map((item) => item.sourceFile));\n const entries: PublicClassNameEntry[] = [];\n\n for (const { sourceFile, relativePath } of parsed) {\n entries.push(...collectCallsFromSourceFile(sourceFile, relativePath, bindings, defaultConfig));\n }\n\n return dedupeEntries(entries);\n}\n\nfunction dedupeEntries(entries: PublicClassNameEntry[]): PublicClassNameEntry[] {\n const byClass = new Map<string, PublicClassNameEntry>();\n for (const entry of entries) {\n if (!byClass.has(entry.className)) {\n byClass.set(entry.className, entry);\n }\n }\n return [...byClass.values()].sort((a, b) => a.className.localeCompare(b.className));\n}\n\nexport async function collectPublicClassNames(\n options: CollectPublicClassNamesOptions = {},\n): Promise<PublicClassNameEntry[]> {\n const rootDir = path.resolve(options.rootDir ?? process.cwd());\n const include = options.include ?? DEFAULT_INCLUDE;\n const exclude = options.exclude ?? DEFAULT_EXCLUDE;\n\n const files = await fg(include, {\n cwd: rootDir,\n absolute: true,\n ignore: exclude,\n });\n\n return collectPublicClassNamesFromFiles(files, rootDir);\n}\n\nexport function collectPublicClassNamesSync(\n options: CollectPublicClassNamesOptions = {},\n): PublicClassNameEntry[] {\n const rootDir = path.resolve(options.rootDir ?? process.cwd());\n const include = options.include ?? DEFAULT_INCLUDE;\n const exclude = options.exclude ?? DEFAULT_EXCLUDE;\n\n const files = fg.sync(include, {\n cwd: rootDir,\n absolute: true,\n ignore: exclude,\n });\n\n return collectPublicClassNamesFromFiles(files, rootDir);\n}\n\n/** @internal Resolve merged `createStyles` / `createTypeStyles` bindings for tests. */\nexport function resolveProjectStylesBindings(\n filePaths: string[],\n _rootDir: string,\n): Map<string, StylesBindingConfig> {\n const parsed = filePaths.map((filePath) => {\n const sourceText = fs.readFileSync(filePath, 'utf8');\n return ts.createSourceFile(\n filePath,\n sourceText,\n ts.ScriptTarget.Latest,\n true,\n filePath.endsWith('.tsx') ? ts.ScriptKind.TSX : ts.ScriptKind.TS,\n );\n });\n return mergeProjectBindings(parsed).bindings;\n}\n\nexport function buildSnapshot(entries: PublicClassNameEntry[]): PublicClassNamesSnapshot {\n const sorted = dedupeEntries(entries);\n return {\n version: 1,\n classNames: sorted.map((entry) => entry.className),\n entries: sorted,\n };\n}\n\nexport function loadPublicClassNamesSnapshot(\n snapshotPath: string,\n): PublicClassNamesSnapshot | null {\n if (!fs.existsSync(snapshotPath)) return null;\n const raw = JSON.parse(fs.readFileSync(snapshotPath, 'utf8')) as PublicClassNamesSnapshot;\n if (!raw || raw.version !== 1 || !Array.isArray(raw.classNames)) {\n throw new Error(\n `[typestyles] Invalid public class name snapshot at ${snapshotPath}. Regenerate with \\`typestyles snapshot --write\\`.`,\n );\n }\n return raw;\n}\n\nexport function writePublicClassNamesSnapshot(\n snapshotPath: string,\n entries: PublicClassNameEntry[],\n): PublicClassNamesSnapshot {\n const snapshot = buildSnapshot(entries);\n fs.writeFileSync(snapshotPath, `${JSON.stringify(snapshot, null, 2)}\\n`, 'utf8');\n return snapshot;\n}\n\nexport function diffRemovedPublicClassNames(\n snapshot: PublicClassNamesSnapshot,\n current: PublicClassNameEntry[],\n): PublicClassNameEntry[] {\n const currentSet = new Set(current.map((entry) => entry.className));\n return snapshot.entries.filter((entry) => !currentSet.has(entry.className));\n}\n"]}