styled-components-to-stylex-codemod 0.0.28 → 0.0.30
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.
- package/dist/{logger-Bt4qdjjb.mjs → adapter-BP7bn_pZ.mjs} +1 -236
- package/dist/{bridge-consumer-patcher-yD2M8NhV.mjs → bridge-consumer-patcher-BbjyGr2R.mjs} +4 -6
- package/dist/{forwarded-as-consumer-patcher-DobBjqdG.mjs → forwarded-as-consumer-patcher-Rd7QcRNR.mjs} +3 -5
- package/dist/index.d.mts +6 -1
- package/dist/index.mjs +10 -10
- package/dist/{logger-DKOqU7as.d.mts → logger-BQnWs1On.d.mts} +30 -2
- package/dist/logger-C2O81VeU.mjs +239 -0
- package/dist/{path-utils-CTsuWb5f.mjs → path-utils-BlOXGcCF.mjs} +1 -3
- package/dist/{resolve-imports-CN7ulI4X.mjs → resolve-imports-DKohVjNI.mjs} +1 -3
- package/dist/{run-prepass-BInfVTeK.mjs → run-prepass-4gxoyZ8y.mjs} +6 -11
- package/dist/{selector-context-heuristic-CQgP_0dH.mjs → selector-context-heuristic-Dualf7ac.mjs} +1 -2
- package/dist/{string-utils-J3iaDsXd.mjs → string-utils-5EMAWj3q.mjs} +10 -2
- package/dist/{styled-css-BJH7gntu.mjs → styled-css-C3QKH6Od.mjs} +1 -3
- package/dist/transform.d.mts +1 -2
- package/dist/transform.mjs +11709 -11555
- package/dist/{transient-prop-consumer-patcher-DAX9HWDH.mjs → transient-prop-consumer-patcher-CeMJEJG9.mjs} +3 -5
- package/package.json +19 -19
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { readFileSync } from "node:fs";
|
|
2
|
-
|
|
3
1
|
//#region src/internal/public-api-validation.ts
|
|
4
2
|
function describeValue(value) {
|
|
5
3
|
if (value === null) return "null";
|
|
@@ -175,7 +173,6 @@ function assertFunctionNameAndImportSource(args) {
|
|
|
175
173
|
if (typeof value !== "string" || !value.trim()) throw new Error([`${where}: ${configPath}.importSource.value must be a non-empty string.`, `Received: value=${describeValue(value)}`].join("\n"));
|
|
176
174
|
}
|
|
177
175
|
const ADAPTER_DOCS_URL = `https://github.com/skovhus/styled-components-to-stylex-codemod#adapter`;
|
|
178
|
-
|
|
179
176
|
//#endregion
|
|
180
177
|
//#region src/adapter.ts
|
|
181
178
|
/**
|
|
@@ -268,237 +265,5 @@ function defineAdapter(adapter) {
|
|
|
268
265
|
assertValidAdapterInput(adapter, "defineAdapter(adapter)");
|
|
269
266
|
return adapter;
|
|
270
267
|
}
|
|
271
|
-
|
|
272
268
|
//#endregion
|
|
273
|
-
|
|
274
|
-
/**
|
|
275
|
-
* Logger and warning types for transform diagnostics.
|
|
276
|
-
* Core concepts: severity classification and source context reporting.
|
|
277
|
-
*/
|
|
278
|
-
/**
|
|
279
|
-
* When fileCount <= this threshold, warnings are printed per-file inline and
|
|
280
|
-
* the summary is skipped. Above the threshold only the summary is printed.
|
|
281
|
-
*/
|
|
282
|
-
const FILE_COUNT_INLINE_THRESHOLD = 10;
|
|
283
|
-
var Logger = class Logger {
|
|
284
|
-
/**
|
|
285
|
-
* Set the total number of files being transformed.
|
|
286
|
-
* Controls whether warnings are printed per-file or only in the summary.
|
|
287
|
-
*/
|
|
288
|
-
static setFileCount(count) {
|
|
289
|
-
Logger.fileCount = count;
|
|
290
|
-
}
|
|
291
|
-
/**
|
|
292
|
-
* Set the maximum number of examples shown per warning category in the summary.
|
|
293
|
-
*/
|
|
294
|
-
static setMaxExamples(count) {
|
|
295
|
-
Logger.maxExamples = count;
|
|
296
|
-
}
|
|
297
|
-
/**
|
|
298
|
-
* Log a warning message to stdout.
|
|
299
|
-
* All codemod warnings go through this so tests can mock it.
|
|
300
|
-
*/
|
|
301
|
-
static warn(message, context) {
|
|
302
|
-
Logger.writeWithSpacing(message, context);
|
|
303
|
-
}
|
|
304
|
-
/**
|
|
305
|
-
* Mark an Error instance as already logged so downstream catch blocks can skip it.
|
|
306
|
-
*/
|
|
307
|
-
static markErrorAsLogged(e) {
|
|
308
|
-
if (e instanceof Error) Logger.loggedErrors.add(e);
|
|
309
|
-
}
|
|
310
|
-
/**
|
|
311
|
-
* Check whether an error was already logged via `markErrorAsLogged`.
|
|
312
|
-
*/
|
|
313
|
-
static isErrorLogged(e) {
|
|
314
|
-
return e instanceof Error && Logger.loggedErrors.has(e);
|
|
315
|
-
}
|
|
316
|
-
/**
|
|
317
|
-
* Log an error message to stdout with file path and optional location.
|
|
318
|
-
* Formats like warnings: "Error filepath:line:column\nmessage"
|
|
319
|
-
* Always prints regardless of file count.
|
|
320
|
-
*/
|
|
321
|
-
static logError(message, filePath, loc, context) {
|
|
322
|
-
const location = loc ? `${filePath}:${loc.line}:${loc.column}` : filePath;
|
|
323
|
-
const label = Logger.colorizeErrorLabel("Error");
|
|
324
|
-
Logger.writeWithSpacing(`${label} ${location}\n${message}`, context);
|
|
325
|
-
}
|
|
326
|
-
/**
|
|
327
|
-
* Collect transform warnings and optionally print them per-file.
|
|
328
|
-
* Per-file output is shown when fileCount is unknown or <= threshold.
|
|
329
|
-
* When fileCount > threshold, warnings are only collected for the summary.
|
|
330
|
-
*/
|
|
331
|
-
static logWarnings(warnings, filePath) {
|
|
332
|
-
const printInline = Logger.fileCount === null || Logger.fileCount <= FILE_COUNT_INLINE_THRESHOLD;
|
|
333
|
-
for (const warning of warnings) {
|
|
334
|
-
Logger.collected.push({
|
|
335
|
-
...warning,
|
|
336
|
-
filePath
|
|
337
|
-
});
|
|
338
|
-
if (printInline) {
|
|
339
|
-
const location = warning.loc ? `${filePath}:${warning.loc.line}:${warning.loc.column}` : `${filePath}`;
|
|
340
|
-
const label = Logger.colorizeSeverityLabel(warning.severity);
|
|
341
|
-
Logger.writeWithSpacing(`${label} ${location}\n${warning.type}`, warning.context);
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
/**
|
|
346
|
-
* Create a report from all collected warnings.
|
|
347
|
-
*/
|
|
348
|
-
static createReport() {
|
|
349
|
-
return new LoggerReport([...Logger.collected], Logger.fileCount, Logger.maxExamples);
|
|
350
|
-
}
|
|
351
|
-
/** @internal - for testing only */
|
|
352
|
-
static _clearCollected() {
|
|
353
|
-
Logger.collected = [];
|
|
354
|
-
Logger.fileCount = null;
|
|
355
|
-
Logger.loggedErrors = /* @__PURE__ */ new WeakSet();
|
|
356
|
-
}
|
|
357
|
-
static collected = [];
|
|
358
|
-
static fileCount = null;
|
|
359
|
-
static maxExamples = 3;
|
|
360
|
-
static loggedErrors = /* @__PURE__ */ new WeakSet();
|
|
361
|
-
static writeWithSpacing(message, context) {
|
|
362
|
-
const trimmed = message.replace(/\s+$/u, "");
|
|
363
|
-
const serialized = Logger.formatContext(context);
|
|
364
|
-
process.stdout.write(`${trimmed}${serialized ? `\n${serialized}` : ""}\n\n`);
|
|
365
|
-
}
|
|
366
|
-
static colorizeSeverityLabel(severity) {
|
|
367
|
-
if (severity === "error") return Logger.colorizeErrorLabel("Error");
|
|
368
|
-
if (severity === "info") return Logger.colorizeInfoLabel("Info");
|
|
369
|
-
return Logger.colorizeWarnLabel("Warning");
|
|
370
|
-
}
|
|
371
|
-
static colorizeWarnLabel(label) {
|
|
372
|
-
if (!process.stdout.isTTY) return label;
|
|
373
|
-
return `${WARN_BG_COLOR}${WARN_TEXT_COLOR}${label}${RESET_COLOR}`;
|
|
374
|
-
}
|
|
375
|
-
static colorizeErrorLabel(label) {
|
|
376
|
-
if (!process.stdout.isTTY) return label;
|
|
377
|
-
return `${ERROR_BG_COLOR}${ERROR_TEXT_COLOR}${label}${RESET_COLOR}`;
|
|
378
|
-
}
|
|
379
|
-
static colorizeInfoLabel(label) {
|
|
380
|
-
if (!process.stdout.isTTY) return label;
|
|
381
|
-
return `${INFO_BG_COLOR}${INFO_TEXT_COLOR}${label}${RESET_COLOR}`;
|
|
382
|
-
}
|
|
383
|
-
static formatContext(context) {
|
|
384
|
-
if (typeof context === "undefined") return null;
|
|
385
|
-
return JSON.stringify(context, null, 2);
|
|
386
|
-
}
|
|
387
|
-
};
|
|
388
|
-
var LoggerReport = class {
|
|
389
|
-
warnings;
|
|
390
|
-
fileCount;
|
|
391
|
-
maxExamples;
|
|
392
|
-
fileCache = /* @__PURE__ */ new Map();
|
|
393
|
-
constructor(warnings, fileCount, maxExamples = 3) {
|
|
394
|
-
this.warnings = warnings;
|
|
395
|
-
this.fileCount = fileCount;
|
|
396
|
-
this.maxExamples = maxExamples;
|
|
397
|
-
}
|
|
398
|
-
getWarnings() {
|
|
399
|
-
return this.warnings;
|
|
400
|
-
}
|
|
401
|
-
/**
|
|
402
|
-
* Get the formatted report as a string.
|
|
403
|
-
*/
|
|
404
|
-
toString() {
|
|
405
|
-
if (this.warnings.length === 0) return "";
|
|
406
|
-
const lines = [];
|
|
407
|
-
const groups = this.groupWarnings();
|
|
408
|
-
lines.push("");
|
|
409
|
-
lines.push("─".repeat(60));
|
|
410
|
-
lines.push(`Warning Summary: ${this.warnings.length} warning(s) in ${groups.length} category(s)`);
|
|
411
|
-
lines.push("─".repeat(60));
|
|
412
|
-
const MAX_EXAMPLES = this.maxExamples;
|
|
413
|
-
for (const group of groups) {
|
|
414
|
-
lines.push("");
|
|
415
|
-
lines.push(`▸ ${group.message} (${group.warnings.length})`);
|
|
416
|
-
lines.push("");
|
|
417
|
-
const seenFiles = /* @__PURE__ */ new Set();
|
|
418
|
-
const uniqueLocations = [];
|
|
419
|
-
for (const loc of group.warnings) if (!seenFiles.has(loc.filePath)) {
|
|
420
|
-
seenFiles.add(loc.filePath);
|
|
421
|
-
uniqueLocations.push(loc);
|
|
422
|
-
}
|
|
423
|
-
const displayed = uniqueLocations.slice(0, MAX_EXAMPLES);
|
|
424
|
-
for (const loc of displayed) {
|
|
425
|
-
const location = loc.loc ? `${loc.filePath}:${loc.loc.line}:${loc.loc.column}` : loc.filePath;
|
|
426
|
-
lines.push(` ${location}`);
|
|
427
|
-
if (loc.snippet) lines.push(loc.snippet);
|
|
428
|
-
lines.push("");
|
|
429
|
-
}
|
|
430
|
-
const remaining = uniqueLocations.length - MAX_EXAMPLES;
|
|
431
|
-
if (remaining > 0) {
|
|
432
|
-
lines.push(` ... and ${remaining} more file(s)`);
|
|
433
|
-
lines.push("");
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
return lines.join("\n");
|
|
437
|
-
}
|
|
438
|
-
/**
|
|
439
|
-
* Print the formatted warning report to stdout.
|
|
440
|
-
* Skips the summary when fileCount <= threshold (warnings already shown inline).
|
|
441
|
-
*/
|
|
442
|
-
print() {
|
|
443
|
-
if (this.fileCount !== null && this.fileCount <= FILE_COUNT_INLINE_THRESHOLD) return;
|
|
444
|
-
const output = this.toString();
|
|
445
|
-
if (output) {
|
|
446
|
-
const colored = output.replace(/▸ (.+?) \((\d+)\)/g, `${SECTION_COLOR}▸ $1 ($2)${RESET_COLOR}`);
|
|
447
|
-
process.stdout.write(colored + "\n");
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
groupWarnings() {
|
|
451
|
-
const groupMap = /* @__PURE__ */ new Map();
|
|
452
|
-
for (const warning of this.warnings) {
|
|
453
|
-
const enrichedWarning = {
|
|
454
|
-
...warning,
|
|
455
|
-
snippet: warning.loc ? this.getSnippet(warning.filePath, warning.loc) : void 0
|
|
456
|
-
};
|
|
457
|
-
const existing = groupMap.get(warning.type);
|
|
458
|
-
if (existing) existing.warnings.push(enrichedWarning);
|
|
459
|
-
else groupMap.set(warning.type, {
|
|
460
|
-
message: warning.type,
|
|
461
|
-
warnings: [enrichedWarning]
|
|
462
|
-
});
|
|
463
|
-
}
|
|
464
|
-
return Array.from(groupMap.values()).sort((a, b) => b.warnings.length - a.warnings.length);
|
|
465
|
-
}
|
|
466
|
-
getSnippet(filePath, loc) {
|
|
467
|
-
if (!loc) return;
|
|
468
|
-
const lines = this.getFileLines(filePath);
|
|
469
|
-
if (!lines) return;
|
|
470
|
-
const lineIndex = loc.line - 1;
|
|
471
|
-
if (lineIndex < 0 || lineIndex >= lines.length) return;
|
|
472
|
-
const snippetLines = [];
|
|
473
|
-
const startLine = Math.max(0, lineIndex - 2);
|
|
474
|
-
const endLine = Math.min(lines.length - 1, lineIndex + 4);
|
|
475
|
-
for (let i = startLine; i <= endLine; i++) {
|
|
476
|
-
const lineNum = String(i + 1).padStart(4, " ");
|
|
477
|
-
const marker = i === lineIndex ? ">" : " ";
|
|
478
|
-
snippetLines.push(` ${marker} ${lineNum} | ${lines[i]}`);
|
|
479
|
-
}
|
|
480
|
-
return snippetLines.join("\n");
|
|
481
|
-
}
|
|
482
|
-
getFileLines(filePath) {
|
|
483
|
-
if (this.fileCache.has(filePath)) return this.fileCache.get(filePath) ?? null;
|
|
484
|
-
try {
|
|
485
|
-
const lines = readFileSync(filePath, "utf-8").split("\n");
|
|
486
|
-
this.fileCache.set(filePath, lines);
|
|
487
|
-
return lines;
|
|
488
|
-
} catch {
|
|
489
|
-
this.fileCache.set(filePath, null);
|
|
490
|
-
return null;
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
|
-
};
|
|
494
|
-
const WARN_BG_COLOR = "\x1B[43m";
|
|
495
|
-
const WARN_TEXT_COLOR = "\x1B[30m";
|
|
496
|
-
const ERROR_BG_COLOR = "\x1B[41m";
|
|
497
|
-
const ERROR_TEXT_COLOR = "\x1B[37m";
|
|
498
|
-
const INFO_BG_COLOR = "\x1B[44m";
|
|
499
|
-
const INFO_TEXT_COLOR = "\x1B[37m";
|
|
500
|
-
const SECTION_COLOR = "\x1B[36m";
|
|
501
|
-
const RESET_COLOR = "\x1B[0m";
|
|
502
|
-
|
|
503
|
-
//#endregion
|
|
504
|
-
export { assertValidAdapter as a, isDirectionalResult as i, DEFAULT_THEME_HOOK as n, assertValidAdapterInput as o, defineAdapter as r, describeValue as s, Logger as t };
|
|
269
|
+
export { assertValidAdapterInput as a, assertValidAdapter as i, defineAdapter as n, describeValue as o, isDirectionalResult as r, DEFAULT_THEME_HOOK as t };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { n as escapeRegex } from "./string-utils-
|
|
2
|
-
import { t as toRealPath } from "./path-utils-
|
|
3
|
-
import { t as isSelectorContext } from "./selector-context-heuristic-
|
|
1
|
+
import { n as escapeRegex } from "./string-utils-5EMAWj3q.mjs";
|
|
2
|
+
import { t as toRealPath } from "./path-utils-BlOXGcCF.mjs";
|
|
3
|
+
import { t as isSelectorContext } from "./selector-context-heuristic-Dualf7ac.mjs";
|
|
4
4
|
import { readFileSync } from "node:fs";
|
|
5
|
-
|
|
6
5
|
//#region src/internal/bridge-consumer-patcher.ts
|
|
7
6
|
/**
|
|
8
7
|
* Post-transform consumer patching for global selector bridges.
|
|
@@ -120,6 +119,5 @@ function isInStyledTemplateSelectorContext(source, offset, length) {
|
|
|
120
119
|
function hasExactImportName(importSpecifiers, name) {
|
|
121
120
|
return new RegExp(`(?:^|[^A-Za-z0-9_$])${escapeRegex(name)}(?:$|[^A-Za-z0-9_$])`).test(importSpecifiers);
|
|
122
121
|
}
|
|
123
|
-
|
|
124
122
|
//#endregion
|
|
125
|
-
export { buildConsumerReplacements, patchConsumerFile };
|
|
123
|
+
export { buildConsumerReplacements, patchConsumerFile };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { n as escapeRegex } from "./string-utils-
|
|
2
|
-
import { t as toRealPath } from "./path-utils-
|
|
1
|
+
import { n as escapeRegex } from "./string-utils-5EMAWj3q.mjs";
|
|
2
|
+
import { t as toRealPath } from "./path-utils-BlOXGcCF.mjs";
|
|
3
3
|
import { readFileSync } from "node:fs";
|
|
4
|
-
|
|
5
4
|
//#region src/internal/forwarded-as-consumer-patcher.ts
|
|
6
5
|
/**
|
|
7
6
|
* Post-transform consumer patching for `as` → `forwardedAs`.
|
|
@@ -77,6 +76,5 @@ function patchAttrsAsProp(source, componentName) {
|
|
|
77
76
|
return `${before}forwardedAs${after}`;
|
|
78
77
|
});
|
|
79
78
|
}
|
|
80
|
-
|
|
81
79
|
//#endregion
|
|
82
|
-
export { buildForwardedAsReplacements, patchConsumerForwardedAs };
|
|
80
|
+
export { buildForwardedAsReplacements, patchConsumerForwardedAs };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as defineAdapter, i as AdapterInput, t as CollectedWarning } from "./logger-
|
|
1
|
+
import { a as defineAdapter, i as AdapterInput, t as CollectedWarning } from "./logger-BQnWs1On.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/run.d.ts
|
|
4
4
|
interface RunTransformOptions {
|
|
@@ -59,6 +59,11 @@ interface RunTransformOptions {
|
|
|
59
59
|
* @default 3
|
|
60
60
|
*/
|
|
61
61
|
maxExamples?: number;
|
|
62
|
+
/**
|
|
63
|
+
* Suppress jscodeshift runner output.
|
|
64
|
+
* @default false
|
|
65
|
+
*/
|
|
66
|
+
silent?: boolean;
|
|
62
67
|
}
|
|
63
68
|
interface RunTransformResult {
|
|
64
69
|
/** Number of files that had errors */
|
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as assertValidAdapterInput, n as defineAdapter, o as describeValue } from "./adapter-BP7bn_pZ.mjs";
|
|
2
|
+
import { t as Logger } from "./logger-C2O81VeU.mjs";
|
|
2
3
|
import { run } from "jscodeshift/src/Runner.js";
|
|
3
4
|
import { fileURLToPath } from "node:url";
|
|
4
5
|
import { dirname, join, resolve } from "node:path";
|
|
5
6
|
import { existsSync, readFileSync, realpathSync } from "node:fs";
|
|
6
7
|
import { glob, writeFile } from "node:fs/promises";
|
|
7
8
|
import { spawn } from "node:child_process";
|
|
8
|
-
|
|
9
9
|
//#region src/run.ts
|
|
10
10
|
/**
|
|
11
11
|
* Runs the codemod over input files with an adapter.
|
|
@@ -141,9 +141,9 @@ async function runTransform(options) {
|
|
|
141
141
|
`Pattern(s): ${consumerPatterns.join(", ")}`,
|
|
142
142
|
"Check that the glob pattern is correct and files exist."
|
|
143
143
|
].join("\n"));
|
|
144
|
-
const { createModuleResolver } = await import("./resolve-imports-
|
|
144
|
+
const { createModuleResolver } = await import("./resolve-imports-DKohVjNI.mjs");
|
|
145
145
|
const sharedResolver = createModuleResolver();
|
|
146
|
-
const { runPrepass } = await import("./run-prepass-
|
|
146
|
+
const { runPrepass } = await import("./run-prepass-4gxoyZ8y.mjs");
|
|
147
147
|
const absoluteFiles = filePaths.map((f) => resolve(f));
|
|
148
148
|
const absoluteConsumers = consumerFilePaths.map((f) => resolve(f));
|
|
149
149
|
let prepassResult;
|
|
@@ -230,11 +230,12 @@ async function runTransform(options) {
|
|
|
230
230
|
bridgeResults,
|
|
231
231
|
transformedFiles,
|
|
232
232
|
transientPropRenames,
|
|
233
|
-
runInBand: true
|
|
233
|
+
runInBand: true,
|
|
234
|
+
silent: options.silent ?? false
|
|
234
235
|
});
|
|
235
236
|
if (sidecarFiles.size > 0 && !dryRun) for (const [sidecarPath, content] of sidecarFiles) await writeFile(sidecarPath, mergeSidecarContent(sidecarPath, content), "utf-8");
|
|
236
237
|
if (bridgeResults.size > 0 && !dryRun) {
|
|
237
|
-
const { buildConsumerReplacements, patchConsumerFile } = await import("./bridge-consumer-patcher-
|
|
238
|
+
const { buildConsumerReplacements, patchConsumerFile } = await import("./bridge-consumer-patcher-BbjyGr2R.mjs");
|
|
238
239
|
const consumerReplacements = buildConsumerReplacements(crossFilePrepassResult.selectorUsages, bridgeResults, transformedFiles);
|
|
239
240
|
const patchedFiles = [];
|
|
240
241
|
for (const [consumerPath, replacements] of consumerReplacements) {
|
|
@@ -247,7 +248,7 @@ async function runTransform(options) {
|
|
|
247
248
|
if (formatterCommands && patchedFiles.length > 0) await runFormatters(formatterCommands, patchedFiles);
|
|
248
249
|
}
|
|
249
250
|
if (prepassResult.forwardedAsConsumers.size > 0 && !dryRun) {
|
|
250
|
-
const { buildForwardedAsReplacements, patchConsumerForwardedAs } = await import("./forwarded-as-consumer-patcher-
|
|
251
|
+
const { buildForwardedAsReplacements, patchConsumerForwardedAs } = await import("./forwarded-as-consumer-patcher-Rd7QcRNR.mjs");
|
|
251
252
|
const forwardedAsReplacements = buildForwardedAsReplacements(prepassResult.forwardedAsConsumers, transformedFiles);
|
|
252
253
|
const patchedFiles = [];
|
|
253
254
|
for (const [consumerPath, entries] of forwardedAsReplacements) {
|
|
@@ -260,7 +261,7 @@ async function runTransform(options) {
|
|
|
260
261
|
if (formatterCommands && patchedFiles.length > 0) await runFormatters(formatterCommands, patchedFiles);
|
|
261
262
|
}
|
|
262
263
|
if (transientPropRenames.size > 0 && !dryRun) {
|
|
263
|
-
const { collectTransientPropPatches } = await import("./transient-prop-consumer-patcher-
|
|
264
|
+
const { collectTransientPropPatches } = await import("./transient-prop-consumer-patcher-CeMJEJG9.mjs");
|
|
264
265
|
const patches = collectTransientPropPatches({
|
|
265
266
|
transientPropRenames,
|
|
266
267
|
consumerFilePaths: consumerFilePaths.map((p) => resolve(p)),
|
|
@@ -349,6 +350,5 @@ async function runFormatters(commands, files) {
|
|
|
349
350
|
}
|
|
350
351
|
}
|
|
351
352
|
}
|
|
352
|
-
|
|
353
353
|
//#endregion
|
|
354
|
-
export { defineAdapter, runTransform };
|
|
354
|
+
export { defineAdapter, runTransform };
|
|
@@ -260,6 +260,19 @@ type CallResolveResultWithExpr = {
|
|
|
260
260
|
* - Theme access in the original call is rewritten to use the wrapper `useTheme()` value.
|
|
261
261
|
*/
|
|
262
262
|
preserveRuntimeCall?: boolean;
|
|
263
|
+
/**
|
|
264
|
+
* Additional className expressions to merge into the component's className attribute.
|
|
265
|
+
*
|
|
266
|
+
* Used for CSS modules or other class-based styles that StyleX cannot express
|
|
267
|
+
* (child selectors like `& > *`, ancestor selectors like `html:not(.class) &`, etc.).
|
|
268
|
+
*
|
|
269
|
+
* Each entry provides an expression string (e.g., `cssModuleStyles.myClass`)
|
|
270
|
+
* and its required imports.
|
|
271
|
+
*
|
|
272
|
+
* When present, the codemod merges these expressions into the rendered element's
|
|
273
|
+
* className alongside any existing static className from `.attrs()` or bridge classes.
|
|
274
|
+
*/
|
|
275
|
+
extraClassNames?: ExprWithImports[];
|
|
263
276
|
};
|
|
264
277
|
type CallResolveRuntimeOnlyResult = {
|
|
265
278
|
/**
|
|
@@ -275,7 +288,17 @@ type CallResolveRuntimeOnlyResult = {
|
|
|
275
288
|
*/
|
|
276
289
|
usage?: "create";
|
|
277
290
|
};
|
|
278
|
-
|
|
291
|
+
/**
|
|
292
|
+
* Resolved result containing only className expressions (no StyleX style object).
|
|
293
|
+
* Used for CSS modules or other class-based styles that StyleX cannot express.
|
|
294
|
+
*/
|
|
295
|
+
type CallResolveClassNamesResult = {
|
|
296
|
+
/**
|
|
297
|
+
* className expressions to merge into the component's className attribute.
|
|
298
|
+
*/
|
|
299
|
+
extraClassNames: ExprWithImports[];
|
|
300
|
+
};
|
|
301
|
+
type CallResolveResult = CallResolveResultWithExpr | CallResolveRuntimeOnlyResult | CallResolveClassNamesResult;
|
|
279
302
|
type ImportSource = {
|
|
280
303
|
kind: "absolutePath";
|
|
281
304
|
value: string;
|
|
@@ -290,6 +313,11 @@ type ImportSpec = {
|
|
|
290
313
|
local?: string;
|
|
291
314
|
}>;
|
|
292
315
|
};
|
|
316
|
+
/** An expression string with its required imports, used for className emission. */
|
|
317
|
+
type ExprWithImports = {
|
|
318
|
+
expr: string;
|
|
319
|
+
imports: ImportSpec[];
|
|
320
|
+
};
|
|
293
321
|
type ResolveBaseComponentStaticValue = string | number | boolean;
|
|
294
322
|
interface ResolveBaseComponentContext {
|
|
295
323
|
/**
|
|
@@ -690,7 +718,7 @@ declare function defineAdapter<T extends AdapterInput>(adapter: T): T;
|
|
|
690
718
|
//#endregion
|
|
691
719
|
//#region src/internal/logger.d.ts
|
|
692
720
|
type Severity = "info" | "warning" | "error";
|
|
693
|
-
type WarningType = "`css` helper function switch must return css templates in all branches" | "`css` helper usage as a function call (css(...)) is not supported" | "`css` helper used outside of a styled component template cannot be statically transformed" | "Adapter helper call in border interpolation did not resolve to a single CSS value" | "Adapter resolveCall returned an unparseable styles expression" | "Adapter resolveCall returned an unparseable value expression" | "Adapter resolveCall returned StyleX styles for helper call where a CSS value was expected" | "Adapter resolveCall returned undefined for helper call" | "Adapter resolveBaseComponent threw an error" | "Adapter resolved StyleX styles cannot be applied under nested selectors/at-rules" | "Adapter resolved StyleX styles inside pseudo selector but did not provide cssText for property expansion — add cssText to resolveCall result to enable pseudo-wrapping" | 'Adapter resolveCall cssText could not be parsed as CSS declarations — expected semicolon-separated property: value pairs (e.g. "white-space: nowrap; overflow: hidden;")' | "Adapter resolveValue returned an unparseable value expression" | "Adapter resolveValue returned undefined for imported value" | "Arrow function: body is not a recognized pattern (expected ternary, logical, call, or member expression)" | "Arrow function: conditional branches could not be resolved to static or theme values" | "Arrow function: helper call body is not supported" | "Arrow function: indexed theme lookup pattern not matched" | "Arrow function: logical expression pattern not supported" | "Arrow function: prop access cannot be converted to style function for this CSS property" | "Arrow function: theme access path could not be resolved" | "Component selectors like `${OtherComponent}:hover &` are not directly representable in StyleX. Manual refactor is required" | "Conditional `css` block: !important is not supported in StyleX" | "Conditional `css` block: @-rules (e.g., @media, @supports) are not supported" | "CSS block contains unsupported at-rule (only @media and @container are supported; @supports, etc. require manual handling)" | "Conditional `css` block: dynamic interpolation could not be resolved to a single component prop" | "Conditional `css` block: failed to parse expression" | "Conditional `css` block: missing CSS property name" | "Conditional `css` block: missing interpolation expression" | "Conditional `css` block: mixed static/dynamic values with non-theme expressions cannot be safely transformed" | "Conditional `css` block: multiple interpolation slots in a single property value" | "Conditional `css` block: ternary branch value could not be resolved (imported values require adapter support)" | "Conditional `css` block: ternary expressions inside pseudo selectors are not supported" | "Conditional `css` block: media query interpolation must be a simple imported reference (expressions like `value + 1` are not supported)" | "Conditional `css` block: unsupported selector" | "Directional border helper styles are not supported" | "Multi-slot border interpolation could not be resolved" | "Resolved border helper value could not be expanded to longhand properties" | "Resolved conditional border variant could not be expanded to longhand properties" | "createGlobalStyle is not supported in StyleX. Global styles should be handled separately (e.g., in a CSS file or using CSS reset libraries)" | "
|
|
721
|
+
type WarningType = "`css` helper function switch must return css templates in all branches" | "`css` helper usage as a function call (css(...)) is not supported" | "`css` helper used outside of a styled component template cannot be statically transformed" | "Adapter helper call in border interpolation did not resolve to a single CSS value" | "Adapter resolveCall returned an unparseable styles expression" | "Adapter resolveCall returned an unparseable value expression" | "Adapter resolveCall returned StyleX styles for helper call where a CSS value was expected" | "Adapter resolveCall returned undefined for helper call" | "Adapter resolveBaseComponent threw an error" | "Adapter resolved StyleX styles cannot be applied under nested selectors/at-rules" | "Adapter resolved StyleX styles inside pseudo selector but did not provide cssText for property expansion — add cssText to resolveCall result to enable pseudo-wrapping" | 'Adapter resolveCall cssText could not be parsed as CSS declarations — expected semicolon-separated property: value pairs (e.g. "white-space: nowrap; overflow: hidden;")' | "Adapter resolveValue returned an unparseable value expression" | "Adapter resolveValue returned undefined for imported value" | "Arrow function: body is not a recognized pattern (expected ternary, logical, call, or member expression)" | "Arrow function: conditional branches could not be resolved to static or theme values" | "Arrow function: helper call body is not supported" | "Arrow function: indexed theme lookup pattern not matched" | "Arrow function: logical expression pattern not supported" | "Arrow function: prop access cannot be converted to style function for this CSS property" | "Arrow function: theme access path could not be resolved" | "Component selectors like `${OtherComponent}:hover &` are not directly representable in StyleX. Manual refactor is required" | "Conditional `css` block: !important is not supported in StyleX" | "Conditional `css` block: @-rules (e.g., @media, @supports) are not supported" | "CSS block contains unsupported at-rule (only @media and @container are supported; @supports, etc. require manual handling)" | "Conditional `css` block: dynamic interpolation could not be resolved to a single component prop" | "Conditional `css` block: failed to parse expression" | "Conditional `css` block: missing CSS property name" | "Conditional `css` block: missing interpolation expression" | "Conditional `css` block: mixed static/dynamic values with non-theme expressions cannot be safely transformed" | "Conditional `css` block: multiple interpolation slots in a single property value" | "Conditional `css` block: ternary branch value could not be resolved (imported values require adapter support)" | "Conditional `css` block: ternary expressions inside pseudo selectors are not supported" | "Conditional `css` block: media query interpolation must be a simple imported reference (expressions like `value + 1` are not supported)" | "Conditional `css` block: unsupported selector" | "Directional border helper styles are not supported" | "Multi-slot border interpolation could not be resolved" | "Resolved border helper value could not be expanded to longhand properties" | "Resolved conditional border variant could not be expanded to longhand properties" | "createGlobalStyle is not supported in StyleX. Global styles should be handled separately (e.g., in a CSS file or using CSS reset libraries)" | "Failed to parse theme expressions" | "Heterogeneous background values (mix of gradients and colors) not currently supported" | "Higher-order styled factory wrappers (e.g. hoc(styled)) are not supported" | "Imported CSS helper mixins: cannot determine inherited properties for correct pseudo selector handling" | "Local helper function returns CSS that cannot be decomposed into individual properties" | "Local helper function computes CSS values that cannot be statically traced to the component prop" | "Styled-components specificity hacks like `&&` / `&&&` are not representable in StyleX" | "Theme-dependent block-level conditional could not be fully resolved (branches may contain dynamic interpolations)" | "Theme-dependant call expression could not be resolved (e.g. theme helper calls like theme.highlight() are not supported)" | "Theme value with fallback (props.theme.X ?? / || default) cannot be resolved statically — use adapter.resolveValue to map theme paths to StyleX tokens" | "Theme-dependent nested prop access requires a project-specific theme source (e.g. useTheme())" | "Theme-dependent template literals require a project-specific theme source (e.g. useTheme())" | "Theme prop overrides on styled components are not supported" | "Universal selectors (`*`) are currently unsupported" | "Unsupported call expression (expected imported helper(...) or imported helper(...)(...))" | "Unsupported conditional test in shouldForwardProp" | "Unsupported shouldForwardProp pattern (only !prop.startsWith(), ![].includes(prop), and prop !== are supported)" | "Unsupported interpolation: arrow function" | "Unsupported interpolation: call expression" | "Unsupported interpolation: identifier" | "Unsupported interpolation: member expression" | "Unsupported interpolation: property" | "Unsupported interpolation: unknown" | "Unsupported nested conditional interpolation" | "Unsupported prop-based inline style expression cannot be safely inlined" | "Unsupported prop-based inline style props.theme access is not supported" | "Unsupported selector interpolation: imported value in selector position" | "Unsupported: media query interpolation must be a simple imported reference (expressions like `value + 1` are not supported)" | "Unsupported selector: class selector" | "Unsupported selector: comma-separated selectors must all be simple pseudos or pseudo-elements" | "Unsupported selector: descendant pseudo selector (space before pseudo)" | "Unsupported selector: descendant/child/sibling selector" | "Unsupported selector: interpolated pseudo selector" | "Unsupported selector: sibling combinator" | "Unsupported selector: unresolved interpolation in sibling selector" | "Unsupported selector: ambiguous element selector" | "Unsupported selector: attribute selector on unsupported element" | "Unsupported selector: element selector on exported component" | "Unsupported selector: element selector with combined ancestor and child pseudos" | "Unsupported selector: element selector with dynamic children" | "Unsupported selector: element selector with plain intrinsic children" | "Unsupported selector: element selector pseudo collision" | "Unsupported selector: cross-file component selector target has no JSX usage in this file" | "Unsupported selector: unresolved interpolation in cross-file component selector" | "Unsupported selector: unresolved interpolation in descendant component selector" | "Unsupported selector: unresolved interpolation in element selector" | "Unsupported selector: unresolved interpolation in reverse component selector" | "Unsupported selector: unresolved interpolation in cross-component sibling selector" | "Unsupported selector: grouped reverse selector references different components" | "Unsupported selector: computed media query inside cross-component sibling selector" | "Unsupported selector: computed media query inside sibling selector" | "Unsupported selector: unknown component selector" | "Unsupported css`` mixin: after-base mixin style is not a plain object" | "Unsupported css`` mixin: nested contextual conditions in after-base mixin" | "Unsupported css`` mixin: cannot infer base default for after-base contextual override (base value is non-literal)" | "css`` helper function interpolation references closure variable that cannot be hoisted" | "Using styled-components components as mixins is not supported; use css`` mixins or strings instead" | "styled(ImportedComponent) wraps a component whose file contains internal styled-components — convert the base component's file first to avoid CSS cascade conflicts" | "Transient $-prefixed props renamed on exported component — update consumer call sites to use the new prop names" | "Shorthand property has an opaque value that StyleX will expand to longhands — use `directional` in resolveValue to return separate longhand tokens";
|
|
694
722
|
interface WarningLog {
|
|
695
723
|
severity: Severity;
|
|
696
724
|
type: WarningType;
|