tailwind-styled-v4 5.1.22 → 5.1.24
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/README.md +216 -0
- package/dist/atomic.js +34 -4
- package/dist/atomic.js.map +1 -1
- package/dist/atomic.mjs +31 -2
- package/dist/atomic.mjs.map +1 -1
- package/dist/cli.js +132 -97
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +129 -95
- package/dist/cli.mjs.map +1 -1
- package/dist/compiler.d.mts +195 -1
- package/dist/compiler.d.ts +195 -1
- package/dist/compiler.js +356 -12
- package/dist/compiler.js.map +1 -1
- package/dist/compiler.mjs +340 -10
- package/dist/compiler.mjs.map +1 -1
- package/dist/engine.js +194 -164
- package/dist/engine.js.map +1 -1
- package/dist/engine.mjs +184 -155
- package/dist/engine.mjs.map +1 -1
- package/dist/index.browser.mjs +136 -14
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.d.mts +45 -4
- package/dist/index.d.ts +45 -4
- package/dist/index.js +166 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +177 -21
- package/dist/index.mjs.map +1 -1
- package/dist/next.js +489 -158
- package/dist/next.js.map +1 -1
- package/dist/next.mjs +483 -153
- package/dist/next.mjs.map +1 -1
- package/dist/runtime-css.js +1 -1
- package/dist/runtime-css.js.map +1 -1
- package/dist/runtime-css.mjs +1 -1
- package/dist/runtime-css.mjs.map +1 -1
- package/dist/runtime.js +17 -0
- package/dist/runtime.js.map +1 -1
- package/dist/runtime.mjs +23 -0
- package/dist/runtime.mjs.map +1 -1
- package/dist/shared.js +91 -61
- package/dist/shared.js.map +1 -1
- package/dist/shared.mjs +85 -56
- package/dist/shared.mjs.map +1 -1
- package/dist/turbopackLoader.js +79 -49
- package/dist/turbopackLoader.js.map +1 -1
- package/dist/turbopackLoader.mjs +76 -47
- package/dist/turbopackLoader.mjs.map +1 -1
- package/dist/tw.js +132 -97
- package/dist/tw.js.map +1 -1
- package/dist/tw.mjs +129 -95
- package/dist/tw.mjs.map +1 -1
- package/dist/vite.js +157 -127
- package/dist/vite.js.map +1 -1
- package/dist/vite.mjs +150 -121
- package/dist/vite.mjs.map +1 -1
- package/dist/webpackLoader.js +39 -9
- package/dist/webpackLoader.js.map +1 -1
- package/dist/webpackLoader.mjs +36 -7
- package/dist/webpackLoader.mjs.map +1 -1
- package/package.json +1 -1
- package/CHANGELOG.md +0 -182
package/dist/tw.mjs
CHANGED
|
@@ -998,8 +998,8 @@ var require_command = __commonJS({
|
|
|
998
998
|
init_esm_shims();
|
|
999
999
|
var EventEmitter = __require("events").EventEmitter;
|
|
1000
1000
|
var childProcess = __require("child_process");
|
|
1001
|
-
var
|
|
1002
|
-
var
|
|
1001
|
+
var path34 = __require("path");
|
|
1002
|
+
var fs19 = __require("fs");
|
|
1003
1003
|
var process2 = __require("process");
|
|
1004
1004
|
var { Argument: Argument2, humanReadableArgName } = require_argument();
|
|
1005
1005
|
var { CommanderError: CommanderError2 } = require_error();
|
|
@@ -1931,11 +1931,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1931
1931
|
let launchWithNode = false;
|
|
1932
1932
|
const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
|
|
1933
1933
|
function findFile(baseDir, baseName) {
|
|
1934
|
-
const localBin =
|
|
1935
|
-
if (
|
|
1936
|
-
if (sourceExt.includes(
|
|
1934
|
+
const localBin = path34.resolve(baseDir, baseName);
|
|
1935
|
+
if (fs19.existsSync(localBin)) return localBin;
|
|
1936
|
+
if (sourceExt.includes(path34.extname(baseName))) return void 0;
|
|
1937
1937
|
const foundExt = sourceExt.find(
|
|
1938
|
-
(ext) =>
|
|
1938
|
+
(ext) => fs19.existsSync(`${localBin}${ext}`)
|
|
1939
1939
|
);
|
|
1940
1940
|
if (foundExt) return `${localBin}${foundExt}`;
|
|
1941
1941
|
return void 0;
|
|
@@ -1947,21 +1947,21 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1947
1947
|
if (this._scriptPath) {
|
|
1948
1948
|
let resolvedScriptPath;
|
|
1949
1949
|
try {
|
|
1950
|
-
resolvedScriptPath =
|
|
1950
|
+
resolvedScriptPath = fs19.realpathSync(this._scriptPath);
|
|
1951
1951
|
} catch (err) {
|
|
1952
1952
|
resolvedScriptPath = this._scriptPath;
|
|
1953
1953
|
}
|
|
1954
|
-
executableDir =
|
|
1955
|
-
|
|
1954
|
+
executableDir = path34.resolve(
|
|
1955
|
+
path34.dirname(resolvedScriptPath),
|
|
1956
1956
|
executableDir
|
|
1957
1957
|
);
|
|
1958
1958
|
}
|
|
1959
1959
|
if (executableDir) {
|
|
1960
1960
|
let localFile = findFile(executableDir, executableFile);
|
|
1961
1961
|
if (!localFile && !subcommand._executableFile && this._scriptPath) {
|
|
1962
|
-
const legacyName =
|
|
1962
|
+
const legacyName = path34.basename(
|
|
1963
1963
|
this._scriptPath,
|
|
1964
|
-
|
|
1964
|
+
path34.extname(this._scriptPath)
|
|
1965
1965
|
);
|
|
1966
1966
|
if (legacyName !== this._name) {
|
|
1967
1967
|
localFile = findFile(
|
|
@@ -1972,7 +1972,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1972
1972
|
}
|
|
1973
1973
|
executableFile = localFile || executableFile;
|
|
1974
1974
|
}
|
|
1975
|
-
launchWithNode = sourceExt.includes(
|
|
1975
|
+
launchWithNode = sourceExt.includes(path34.extname(executableFile));
|
|
1976
1976
|
let proc;
|
|
1977
1977
|
if (process2.platform !== "win32") {
|
|
1978
1978
|
if (launchWithNode) {
|
|
@@ -2812,7 +2812,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2812
2812
|
* @return {Command}
|
|
2813
2813
|
*/
|
|
2814
2814
|
nameFromFilename(filename) {
|
|
2815
|
-
this._name =
|
|
2815
|
+
this._name = path34.basename(filename, path34.extname(filename));
|
|
2816
2816
|
return this;
|
|
2817
2817
|
}
|
|
2818
2818
|
/**
|
|
@@ -2826,9 +2826,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2826
2826
|
* @param {string} [path]
|
|
2827
2827
|
* @return {(string|null|Command)}
|
|
2828
2828
|
*/
|
|
2829
|
-
executableDir(
|
|
2830
|
-
if (
|
|
2831
|
-
this._executableDir =
|
|
2829
|
+
executableDir(path35) {
|
|
2830
|
+
if (path35 === void 0) return this._executableDir;
|
|
2831
|
+
this._executableDir = path35;
|
|
2832
2832
|
return this;
|
|
2833
2833
|
}
|
|
2834
2834
|
/**
|
|
@@ -3346,9 +3346,9 @@ function createDebugLogger(namespace, label) {
|
|
|
3346
3346
|
}
|
|
3347
3347
|
};
|
|
3348
3348
|
}
|
|
3349
|
-
function formatIssuePath(
|
|
3350
|
-
if (!
|
|
3351
|
-
return
|
|
3349
|
+
function formatIssuePath(path34) {
|
|
3350
|
+
if (!path34 || path34.length === 0) return "(root)";
|
|
3351
|
+
return path34.map(
|
|
3352
3352
|
(segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
|
|
3353
3353
|
).join(".");
|
|
3354
3354
|
}
|
|
@@ -3464,8 +3464,8 @@ var init_src = __esm({
|
|
|
3464
3464
|
/** Buat TwError dari ZodError — dukung shape Zod v3 (`errors`) dan v4 (`issues`). */
|
|
3465
3465
|
static fromZod(err) {
|
|
3466
3466
|
const first = err.issues?.[0] ?? err.errors?.[0];
|
|
3467
|
-
const
|
|
3468
|
-
const message = first ? `${
|
|
3467
|
+
const path34 = formatIssuePath(first?.path);
|
|
3468
|
+
const message = first ? `${path34}: ${first.message}` : "Schema validation failed";
|
|
3469
3469
|
return new _TwError("validation", "SCHEMA_VALIDATION_FAILED", message, err);
|
|
3470
3470
|
}
|
|
3471
3471
|
static wrap(source, code, err) {
|
|
@@ -4021,12 +4021,12 @@ var init_schemas = __esm({
|
|
|
4021
4021
|
"use strict";
|
|
4022
4022
|
init_esm_shims();
|
|
4023
4023
|
init_src();
|
|
4024
|
-
formatIssuePath2 = (
|
|
4024
|
+
formatIssuePath2 = (path34) => path34.length > 0 ? path34.map(
|
|
4025
4025
|
(segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
|
|
4026
4026
|
).join(".") : "<root>";
|
|
4027
4027
|
formatIssues = (error) => error.issues.map((issue) => {
|
|
4028
|
-
const
|
|
4029
|
-
return `${
|
|
4028
|
+
const path34 = formatIssuePath2(issue.path);
|
|
4029
|
+
return `${path34}: ${issue.message}`;
|
|
4030
4030
|
}).join("; ");
|
|
4031
4031
|
parseWithSchema = (schema, data, label) => {
|
|
4032
4032
|
const parsed = schema.safeParse(data);
|
|
@@ -4631,7 +4631,7 @@ var init_schemas2 = __esm({
|
|
|
4631
4631
|
"use strict";
|
|
4632
4632
|
init_esm_shims();
|
|
4633
4633
|
init_src();
|
|
4634
|
-
formatIssuePath3 = (
|
|
4634
|
+
formatIssuePath3 = (path34) => path34.length > 0 ? path34.map(
|
|
4635
4635
|
(segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
|
|
4636
4636
|
).join(".") : "<root>";
|
|
4637
4637
|
isPlainObject = (value) => {
|
|
@@ -4640,8 +4640,8 @@ var init_schemas2 = __esm({
|
|
|
4640
4640
|
return proto === Object.prototype || proto === null;
|
|
4641
4641
|
};
|
|
4642
4642
|
formatIssues2 = (error) => error.issues.map((issue) => {
|
|
4643
|
-
const
|
|
4644
|
-
return `${
|
|
4643
|
+
const path34 = formatIssuePath3(issue.path);
|
|
4644
|
+
return `${path34}: ${issue.message}`;
|
|
4645
4645
|
}).join("; ");
|
|
4646
4646
|
parseWithSchema2 = (schema, data, label) => {
|
|
4647
4647
|
const parsed = schema.safeParse(data);
|
|
@@ -6262,7 +6262,7 @@ var init_nativeBridge = __esm({
|
|
|
6262
6262
|
"use strict";
|
|
6263
6263
|
init_esm_shims();
|
|
6264
6264
|
init_src();
|
|
6265
|
-
_loadNative = (
|
|
6265
|
+
_loadNative = (path34) => __require(path34);
|
|
6266
6266
|
log3 = (...args) => {
|
|
6267
6267
|
if (process.env.DEBUG?.includes("compiler:native")) {
|
|
6268
6268
|
console.log("[compiler:native]", ...args);
|
|
@@ -6414,9 +6414,35 @@ var init_routeGraph = __esm({
|
|
|
6414
6414
|
}
|
|
6415
6415
|
});
|
|
6416
6416
|
|
|
6417
|
-
// packages/domain/compiler/src/
|
|
6417
|
+
// packages/domain/compiler/src/semanticComponentAnalyzer.ts
|
|
6418
|
+
var init_semanticComponentAnalyzer = __esm({
|
|
6419
|
+
"packages/domain/compiler/src/semanticComponentAnalyzer.ts"() {
|
|
6420
|
+
"use strict";
|
|
6421
|
+
init_esm_shims();
|
|
6422
|
+
}
|
|
6423
|
+
});
|
|
6424
|
+
|
|
6425
|
+
// packages/domain/compiler/src/typeGeneratorFromMetadata.ts
|
|
6426
|
+
var init_typeGeneratorFromMetadata = __esm({
|
|
6427
|
+
"packages/domain/compiler/src/typeGeneratorFromMetadata.ts"() {
|
|
6428
|
+
"use strict";
|
|
6429
|
+
init_esm_shims();
|
|
6430
|
+
}
|
|
6431
|
+
});
|
|
6432
|
+
|
|
6433
|
+
// packages/domain/compiler/src/typeGenerationPlugin.ts
|
|
6418
6434
|
import fs14 from "fs";
|
|
6419
6435
|
import path27 from "path";
|
|
6436
|
+
var init_typeGenerationPlugin = __esm({
|
|
6437
|
+
"packages/domain/compiler/src/typeGenerationPlugin.ts"() {
|
|
6438
|
+
"use strict";
|
|
6439
|
+
init_esm_shims();
|
|
6440
|
+
}
|
|
6441
|
+
});
|
|
6442
|
+
|
|
6443
|
+
// packages/domain/compiler/src/index.ts
|
|
6444
|
+
import fs15 from "fs";
|
|
6445
|
+
import path28 from "path";
|
|
6420
6446
|
import { createRequire as createRequire4 } from "module";
|
|
6421
6447
|
var _require3, compileCssFromClasses;
|
|
6422
6448
|
var init_src4 = __esm({
|
|
@@ -6431,6 +6457,9 @@ var init_src4 = __esm({
|
|
|
6431
6457
|
init_redis();
|
|
6432
6458
|
init_watch();
|
|
6433
6459
|
init_routeGraph();
|
|
6460
|
+
init_semanticComponentAnalyzer();
|
|
6461
|
+
init_typeGeneratorFromMetadata();
|
|
6462
|
+
init_typeGenerationPlugin();
|
|
6434
6463
|
_require3 = createRequire4(
|
|
6435
6464
|
typeof __require !== "undefined" ? typeof __filename !== "undefined" ? `file://${__filename}` : "file://unknown" : import.meta.url
|
|
6436
6465
|
);
|
|
@@ -8773,7 +8802,7 @@ function figmaVariablesToTokens(variablesData) {
|
|
|
8773
8802
|
const tokens = {};
|
|
8774
8803
|
const { variables = {}, variableCollections = {} } = variablesData;
|
|
8775
8804
|
for (const [id, variable] of Object.entries(variables)) {
|
|
8776
|
-
const collection = variableCollections[variable.variableCollectionId];
|
|
8805
|
+
const collection = variableCollections?.[variable.variableCollectionId];
|
|
8777
8806
|
if (!collection) continue;
|
|
8778
8807
|
const modeId = Object.keys(variable.valuesByMode)[0];
|
|
8779
8808
|
const rawValue = variable.valuesByMode[modeId];
|
|
@@ -8788,12 +8817,13 @@ function figmaVariablesToTokens(variablesData) {
|
|
|
8788
8817
|
}
|
|
8789
8818
|
const leafKey = parts[parts.length - 1];
|
|
8790
8819
|
if (variable.resolvedType === "COLOR") {
|
|
8791
|
-
|
|
8792
|
-
$value: typeof rawValue === "object" && "r" in rawValue ? figmaColorToHex(rawValue) : String(rawValue),
|
|
8793
|
-
$type: "color"
|
|
8794
|
-
$description: variable.description || void 0,
|
|
8795
|
-
_figmaId: id
|
|
8820
|
+
const token = {
|
|
8821
|
+
$value: typeof rawValue === "object" && rawValue !== null && "r" in rawValue ? figmaColorToHex(rawValue) : String(rawValue),
|
|
8822
|
+
$type: "color"
|
|
8796
8823
|
};
|
|
8824
|
+
if (variable.description) token.$description = variable.description;
|
|
8825
|
+
token._figmaId = id;
|
|
8826
|
+
cursor[leafKey] = token;
|
|
8797
8827
|
} else if (variable.resolvedType === "FLOAT") {
|
|
8798
8828
|
cursor[leafKey] = {
|
|
8799
8829
|
$value: typeof rawValue === "number" ? `${rawValue}px` : String(rawValue),
|
|
@@ -8815,10 +8845,11 @@ function figmaVariablesToTokens(variablesData) {
|
|
|
8815
8845
|
init_esm_shims();
|
|
8816
8846
|
function tokensToFigmaUpdates(tokens, existingVariables = {}) {
|
|
8817
8847
|
const updates = [];
|
|
8818
|
-
function walk(obj,
|
|
8848
|
+
function walk(obj, path34 = []) {
|
|
8819
8849
|
for (const [key, val] of Object.entries(obj)) {
|
|
8820
|
-
if (val
|
|
8821
|
-
const
|
|
8850
|
+
if (typeof val === "object" && val !== null && "$value" in val) {
|
|
8851
|
+
const tokenVal = val;
|
|
8852
|
+
const name = path34.concat(key).map(
|
|
8822
8853
|
(p) => p.split("-").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join("")
|
|
8823
8854
|
).join("/");
|
|
8824
8855
|
const existing = Object.values(existingVariables).find(
|
|
@@ -8828,12 +8859,12 @@ function tokensToFigmaUpdates(tokens, existingVariables = {}) {
|
|
|
8828
8859
|
updates.push({
|
|
8829
8860
|
id: existing.id,
|
|
8830
8861
|
name,
|
|
8831
|
-
value:
|
|
8832
|
-
type:
|
|
8862
|
+
value: tokenVal.$value,
|
|
8863
|
+
type: tokenVal.$type
|
|
8833
8864
|
});
|
|
8834
8865
|
}
|
|
8835
|
-
} else if (typeof val === "object" && !val
|
|
8836
|
-
walk(val,
|
|
8866
|
+
} else if (typeof val === "object" && val !== null && !("$type" in val)) {
|
|
8867
|
+
walk(val, path34.concat(key));
|
|
8837
8868
|
}
|
|
8838
8869
|
}
|
|
8839
8870
|
}
|
|
@@ -8843,9 +8874,10 @@ function tokensToFigmaUpdates(tokens, existingVariables = {}) {
|
|
|
8843
8874
|
function flattenTokens(obj, prefix = "", target = {}) {
|
|
8844
8875
|
for (const [k, v] of Object.entries(obj)) {
|
|
8845
8876
|
const key = [prefix, k].filter(Boolean).join(".");
|
|
8846
|
-
if (v
|
|
8847
|
-
|
|
8848
|
-
|
|
8877
|
+
if (typeof v === "object" && v !== null && "$value" in v) {
|
|
8878
|
+
const tokenVal = v;
|
|
8879
|
+
target[key] = tokenVal.$value;
|
|
8880
|
+
} else if (typeof v === "object" && v !== null && !("$type" in v)) {
|
|
8849
8881
|
flattenTokens(v, key, target);
|
|
8850
8882
|
}
|
|
8851
8883
|
}
|
|
@@ -8876,7 +8908,7 @@ var figmaCommand = {
|
|
|
8876
8908
|
const FIGMA_FILE_KEY = process.env.FIGMA_FILE_KEY;
|
|
8877
8909
|
const TOKEN_FILE = path24.join(context.cwd, "tokens.sync.json");
|
|
8878
8910
|
if (!cmd || cmd === "help") {
|
|
8879
|
-
context.output.
|
|
8911
|
+
context.output.writeText(`Usage: tw figma <pull|push|diff> [--dry-run]
|
|
8880
8912
|
|
|
8881
8913
|
Environment variables:
|
|
8882
8914
|
FIGMA_TOKEN \u2014 Figma personal access token (figd_...)
|
|
@@ -8898,16 +8930,18 @@ Options:
|
|
|
8898
8930
|
);
|
|
8899
8931
|
}
|
|
8900
8932
|
try {
|
|
8901
|
-
context.output.
|
|
8933
|
+
const spinner = context.output.spinner();
|
|
8934
|
+
spinner.start("Fetching Figma variables...");
|
|
8902
8935
|
const data = await figmaRequest("/files/:fileKey/variables/local", {
|
|
8903
8936
|
token: FIGMA_TOKEN,
|
|
8904
8937
|
fileKey: FIGMA_FILE_KEY
|
|
8905
8938
|
});
|
|
8939
|
+
spinner.stop();
|
|
8906
8940
|
const tokens = figmaVariablesToTokens(data);
|
|
8907
8941
|
const variableCount = Object.values(data.variables ?? {}).length;
|
|
8908
8942
|
if (isDryRun) {
|
|
8909
|
-
context.output.
|
|
8910
|
-
context.output.
|
|
8943
|
+
context.output.info("DRY RUN \u2014 would write:");
|
|
8944
|
+
context.output.writeText(JSON.stringify({ version: 1, tokens }, null, 2));
|
|
8911
8945
|
} else {
|
|
8912
8946
|
let existing = { version: 1, tokens: {} };
|
|
8913
8947
|
if (fs12.existsSync(TOKEN_FILE)) {
|
|
@@ -8948,15 +8982,15 @@ Options:
|
|
|
8948
8982
|
token: FIGMA_TOKEN,
|
|
8949
8983
|
fileKey: FIGMA_FILE_KEY
|
|
8950
8984
|
});
|
|
8951
|
-
const updates = tokensToFigmaUpdates(local.tokens ?? {}, data.variables ?? {});
|
|
8985
|
+
const updates = tokensToFigmaUpdates(local.tokens ?? {}, data.variables?.length ? Object.entries(data.variables ?? {}).reduce((acc, [id, v]) => ({ ...acc, [id]: { ...v, id } }), {}) : {});
|
|
8952
8986
|
if (isDryRun) {
|
|
8953
|
-
context.output.
|
|
8954
|
-
`
|
|
8987
|
+
context.output.info(
|
|
8988
|
+
`DRY RUN \u2014 would update ${updates.length} variables in Figma:`
|
|
8955
8989
|
);
|
|
8956
|
-
updates.forEach((u) => context.output.
|
|
8990
|
+
updates.forEach((u) => context.output.writeText(` ${u.name}: ${u.value}`));
|
|
8957
8991
|
} else {
|
|
8958
8992
|
if (updates.length === 0) {
|
|
8959
|
-
context.output.
|
|
8993
|
+
context.output.info("No matching variables to update");
|
|
8960
8994
|
} else {
|
|
8961
8995
|
context.output.success(`Updated ${updates.length} variables in Figma`);
|
|
8962
8996
|
}
|
|
@@ -8990,12 +9024,12 @@ Options:
|
|
|
8990
9024
|
if (diffs.length === 0) {
|
|
8991
9025
|
context.output.success("No differences \u2014 local and Figma are in sync");
|
|
8992
9026
|
} else {
|
|
8993
|
-
context.output.
|
|
9027
|
+
context.output.info(`${diffs.length} differences found:
|
|
8994
9028
|
`);
|
|
8995
9029
|
diffs.forEach((d) => {
|
|
8996
|
-
context.output.
|
|
8997
|
-
context.output.
|
|
8998
|
-
context.output.
|
|
9030
|
+
context.output.writeText(` ${d.key}`);
|
|
9031
|
+
context.output.writeText(` local: ${d.local ?? "(missing)"}`);
|
|
9032
|
+
context.output.writeText(` figma: ${d.figma ?? "(missing)"}`);
|
|
8999
9033
|
});
|
|
9000
9034
|
}
|
|
9001
9035
|
} catch (e) {
|
|
@@ -9385,7 +9419,7 @@ init_errors();
|
|
|
9385
9419
|
init_fs();
|
|
9386
9420
|
init_json();
|
|
9387
9421
|
init_src4();
|
|
9388
|
-
import
|
|
9422
|
+
import path29 from "path";
|
|
9389
9423
|
import { pathToFileURL as pathToFileURL2 } from "url";
|
|
9390
9424
|
var DEFAULT_TAILWIND_CSS2 = '@import "tailwindcss";\n';
|
|
9391
9425
|
var DEFAULT_TW_CONFIG = `${JSON.stringify(
|
|
@@ -9412,8 +9446,8 @@ async function validateThemeConfig(cwd2) {
|
|
|
9412
9446
|
const twConfigFiles = ["tailwind.config.ts", "tailwind.config.js", "tailwind.config.mjs"];
|
|
9413
9447
|
let configPath = null;
|
|
9414
9448
|
for (const file of twConfigFiles) {
|
|
9415
|
-
if (await pathExists2(
|
|
9416
|
-
configPath =
|
|
9449
|
+
if (await pathExists2(path29.join(cwd2, file))) {
|
|
9450
|
+
configPath = path29.join(cwd2, file);
|
|
9417
9451
|
break;
|
|
9418
9452
|
}
|
|
9419
9453
|
}
|
|
@@ -9504,7 +9538,7 @@ function resolveCliEntry(scriptPath) {
|
|
|
9504
9538
|
async function hasTailwindCssImport(cwd2) {
|
|
9505
9539
|
const cssFiles = ["src/app/globals.css", "src/index.css", "src/style.css", "app/globals.css"];
|
|
9506
9540
|
for (const file of cssFiles) {
|
|
9507
|
-
const raw = await readFileSafe(
|
|
9541
|
+
const raw = await readFileSafe(path29.join(cwd2, file));
|
|
9508
9542
|
if (raw?.includes("tailwindcss")) return true;
|
|
9509
9543
|
}
|
|
9510
9544
|
return false;
|
|
@@ -9520,7 +9554,7 @@ async function hasSafelistSource(cwd2) {
|
|
|
9520
9554
|
"app/globals.css"
|
|
9521
9555
|
];
|
|
9522
9556
|
for (const file of cssFiles) {
|
|
9523
|
-
const raw = await readFileSafe(
|
|
9557
|
+
const raw = await readFileSafe(path29.join(cwd2, file));
|
|
9524
9558
|
if (raw === null) continue;
|
|
9525
9559
|
if (raw.includes("tw-classes")) return { found: true, cssFile: file };
|
|
9526
9560
|
if (raw.includes("tailwindcss")) return { found: false, cssFile: file };
|
|
@@ -9528,8 +9562,8 @@ async function hasSafelistSource(cwd2) {
|
|
|
9528
9562
|
return { found: false, cssFile: null };
|
|
9529
9563
|
}
|
|
9530
9564
|
async function applyTailwindInit(cwd2) {
|
|
9531
|
-
await ensureFileSafe(
|
|
9532
|
-
await ensureFileSafe(
|
|
9565
|
+
await ensureFileSafe(path29.join(cwd2, "src", "tailwind.css"), DEFAULT_TAILWIND_CSS2);
|
|
9566
|
+
await ensureFileSafe(path29.join(cwd2, "tailwind-styled.config.json"), DEFAULT_TW_CONFIG);
|
|
9533
9567
|
}
|
|
9534
9568
|
function check(results, id, label, pass, message, fix) {
|
|
9535
9569
|
results.push({ id, label, pass, message, fix });
|
|
@@ -9551,7 +9585,7 @@ async function runPreflightCli(rawArgs) {
|
|
|
9551
9585
|
node.major >= 20 ? `Node ${node.full} OK` : `Node ${node.full} - requires >=20. Download: https://nodejs.org`,
|
|
9552
9586
|
node.major < 20 ? "Install Node.js 20 LTS or newer from https://nodejs.org" : void 0
|
|
9553
9587
|
);
|
|
9554
|
-
const pkg = await readJsonSafe(
|
|
9588
|
+
const pkg = await readJsonSafe(path29.join(cwd2, "package.json"));
|
|
9555
9589
|
check(
|
|
9556
9590
|
results,
|
|
9557
9591
|
"package-json",
|
|
@@ -9585,7 +9619,7 @@ async function runPreflightCli(rawArgs) {
|
|
|
9585
9619
|
}
|
|
9586
9620
|
const twConfigFiles = ["tailwind.config.ts", "tailwind.config.js", "tailwind.config.mjs"];
|
|
9587
9621
|
const twConfigChecks = await Promise.all(
|
|
9588
|
-
twConfigFiles.map(async (file) => ({ file, exists: await pathExists2(
|
|
9622
|
+
twConfigFiles.map(async (file) => ({ file, exists: await pathExists2(path29.join(cwd2, file)) }))
|
|
9589
9623
|
);
|
|
9590
9624
|
const foundTwConfig = twConfigChecks.find((item) => item.exists)?.file ?? null;
|
|
9591
9625
|
const hasCssConfig = await hasTailwindCssImport(cwd2);
|
|
@@ -9597,7 +9631,7 @@ async function runPreflightCli(rawArgs) {
|
|
|
9597
9631
|
foundTwConfig ? `${foundTwConfig} found OK` : hasCssConfig ? "@import tailwindcss found in CSS OK" : "No Tailwind config found - run: tw init",
|
|
9598
9632
|
"tw init"
|
|
9599
9633
|
);
|
|
9600
|
-
const oldConfig = await readJsonSafe(
|
|
9634
|
+
const oldConfig = await readJsonSafe(path29.join(cwd2, "tailwind.config.js")) ?? await readJsonSafe(path29.join(cwd2, "tailwind.config.ts"));
|
|
9601
9635
|
if (oldConfig) {
|
|
9602
9636
|
const hasOldJit = oldConfig.mode === "jit";
|
|
9603
9637
|
const hasOldPurge = "purge" in oldConfig;
|
|
@@ -9621,7 +9655,7 @@ async function runPreflightCli(rawArgs) {
|
|
|
9621
9655
|
validation.message
|
|
9622
9656
|
);
|
|
9623
9657
|
}
|
|
9624
|
-
const hasTsConfig = await pathExists2(
|
|
9658
|
+
const hasTsConfig = await pathExists2(path29.join(cwd2, "tsconfig.json"));
|
|
9625
9659
|
check(
|
|
9626
9660
|
results,
|
|
9627
9661
|
"typescript",
|
|
@@ -9983,7 +10017,7 @@ init_esm_shims();
|
|
|
9983
10017
|
init_errors();
|
|
9984
10018
|
init_fs();
|
|
9985
10019
|
init_json();
|
|
9986
|
-
import
|
|
10020
|
+
import path30 from "path";
|
|
9987
10021
|
import { parseArgs as parseNodeArgs11 } from "util";
|
|
9988
10022
|
var storybookCommand = {
|
|
9989
10023
|
name: "storybook",
|
|
@@ -10022,7 +10056,7 @@ var storybookCommand = {
|
|
|
10022
10056
|
context.output.writeText(
|
|
10023
10057
|
`[tw storybook] Tip: use --variants='{"size":["sm","lg"]}' to enumerate variant combinations`
|
|
10024
10058
|
);
|
|
10025
|
-
const localBin =
|
|
10059
|
+
const localBin = path30.join(
|
|
10026
10060
|
process.cwd(),
|
|
10027
10061
|
"node_modules",
|
|
10028
10062
|
".bin",
|
|
@@ -11209,10 +11243,10 @@ async function traceClass(className, options) {
|
|
|
11209
11243
|
init_esm_shims();
|
|
11210
11244
|
init_internal();
|
|
11211
11245
|
init_src2();
|
|
11212
|
-
import
|
|
11213
|
-
import
|
|
11246
|
+
import fs16 from "fs";
|
|
11247
|
+
import path31 from "path";
|
|
11214
11248
|
function toRelativePath(root, value) {
|
|
11215
|
-
const relative =
|
|
11249
|
+
const relative = path31.relative(root, value);
|
|
11216
11250
|
return relative.length > 0 ? relative : ".";
|
|
11217
11251
|
}
|
|
11218
11252
|
function uniqueSorted(values) {
|
|
@@ -11281,7 +11315,7 @@ function tryCompileClasses(classes) {
|
|
|
11281
11315
|
}
|
|
11282
11316
|
}
|
|
11283
11317
|
function traceSingleFile(filePath, root) {
|
|
11284
|
-
const source =
|
|
11318
|
+
const source = fs16.readFileSync(filePath, "utf8");
|
|
11285
11319
|
const classes = uniqueSorted(scanSource(source));
|
|
11286
11320
|
const imports = extractImports(source);
|
|
11287
11321
|
const compiled = tryCompileClasses(classes);
|
|
@@ -11312,7 +11346,7 @@ function traceDirectory(targetDir, root) {
|
|
|
11312
11346
|
const imports = [];
|
|
11313
11347
|
const importKeys = /* @__PURE__ */ new Set();
|
|
11314
11348
|
const files = scanResult.files.filter((entry) => isScannableFile2(entry.file, DEFAULT_EXTENSIONS)).map((entry) => {
|
|
11315
|
-
const source =
|
|
11349
|
+
const source = fs16.readFileSync(entry.file, "utf8");
|
|
11316
11350
|
const fileImports = extractImports(source);
|
|
11317
11351
|
for (const fileImport of fileImports) {
|
|
11318
11352
|
const key = `${fileImport.kind}:${fileImport.source}`;
|
|
@@ -11343,12 +11377,12 @@ function traceDirectory(targetDir, root) {
|
|
|
11343
11377
|
};
|
|
11344
11378
|
}
|
|
11345
11379
|
async function traceTarget(target, options = {}) {
|
|
11346
|
-
const root =
|
|
11347
|
-
const resolvedTarget =
|
|
11348
|
-
if (!
|
|
11380
|
+
const root = path31.resolve(options.root ?? process.cwd());
|
|
11381
|
+
const resolvedTarget = path31.resolve(root, target);
|
|
11382
|
+
if (!fs16.existsSync(resolvedTarget)) {
|
|
11349
11383
|
throw new Error(`Trace target not found: ${resolvedTarget}`);
|
|
11350
11384
|
}
|
|
11351
|
-
const stat =
|
|
11385
|
+
const stat = fs16.statSync(resolvedTarget);
|
|
11352
11386
|
if (stat.isDirectory()) {
|
|
11353
11387
|
return traceDirectory(resolvedTarget, root);
|
|
11354
11388
|
}
|
|
@@ -11513,14 +11547,14 @@ function printClassTraceOutput(result, output) {
|
|
|
11513
11547
|
init_esm_shims();
|
|
11514
11548
|
var import_picocolors6 = __toESM(require_picocolors(), 1);
|
|
11515
11549
|
init_output();
|
|
11516
|
-
import
|
|
11517
|
-
import
|
|
11550
|
+
import fs17 from "fs";
|
|
11551
|
+
import path32 from "path";
|
|
11518
11552
|
async function runGenerateTypesCli(rawArgs) {
|
|
11519
11553
|
const output = createCliOutput({ json: rawArgs.includes("--json") });
|
|
11520
11554
|
const logger = createCliLogger({ output });
|
|
11521
11555
|
const cwd2 = process.cwd();
|
|
11522
11556
|
const outFile = rawArgs.find((a) => a.startsWith("--out="))?.slice(6) ?? "src/types/tailwind-styled.d.ts";
|
|
11523
|
-
const outPath =
|
|
11557
|
+
const outPath = path32.resolve(cwd2, outFile);
|
|
11524
11558
|
output.writeText("");
|
|
11525
11559
|
output.writeText(import_picocolors6.default.bold(import_picocolors6.default.cyan(" \u25C6 tw generate-types")));
|
|
11526
11560
|
output.writeText(import_picocolors6.default.dim(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
|
|
@@ -11556,12 +11590,12 @@ async function runGenerateTypesCli(rawArgs) {
|
|
|
11556
11590
|
}
|
|
11557
11591
|
output.writeText("");
|
|
11558
11592
|
output.writeText(import_picocolors6.default.bold(" [2/2]") + import_picocolors6.default.cyan(" generate .d.ts"));
|
|
11559
|
-
const outDir =
|
|
11560
|
-
if (!
|
|
11561
|
-
|
|
11593
|
+
const outDir = path32.dirname(outPath);
|
|
11594
|
+
if (!fs17.existsSync(outDir)) {
|
|
11595
|
+
fs17.mkdirSync(outDir, { recursive: true });
|
|
11562
11596
|
}
|
|
11563
|
-
|
|
11564
|
-
logger.ok(
|
|
11597
|
+
fs17.writeFileSync(outPath, result.dtsContent, "utf-8");
|
|
11598
|
+
logger.ok(path32.relative(cwd2, outPath));
|
|
11565
11599
|
output.writeText("");
|
|
11566
11600
|
output.writeText(import_picocolors6.default.dim(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
|
|
11567
11601
|
output.writeText(import_picocolors6.default.bold(import_picocolors6.default.green(" \u2713 types generated")));
|
|
@@ -11572,11 +11606,11 @@ async function runGenerateTypesCli(rawArgs) {
|
|
|
11572
11606
|
}
|
|
11573
11607
|
async function loadNativeBinding2(cwd2) {
|
|
11574
11608
|
const candidates = [
|
|
11575
|
-
|
|
11576
|
-
|
|
11609
|
+
path32.join(cwd2, "native", "tailwind-styled-native.node"),
|
|
11610
|
+
path32.join(cwd2, "node_modules", "tailwind-styled-v4", "native", "tailwind-styled-native.node")
|
|
11577
11611
|
];
|
|
11578
11612
|
for (const candidate of candidates) {
|
|
11579
|
-
if (
|
|
11613
|
+
if (fs17.existsSync(candidate)) {
|
|
11580
11614
|
try {
|
|
11581
11615
|
return __require(candidate);
|
|
11582
11616
|
} catch {
|
|
@@ -11594,8 +11628,8 @@ import { parseArgs as parseNodeArgs14 } from "util";
|
|
|
11594
11628
|
// packages/infrastructure/cli/src/utils/whyService.ts
|
|
11595
11629
|
init_esm_shims();
|
|
11596
11630
|
init_internal();
|
|
11597
|
-
import
|
|
11598
|
-
import
|
|
11631
|
+
import fs18 from "fs";
|
|
11632
|
+
import path33 from "path";
|
|
11599
11633
|
init_src2();
|
|
11600
11634
|
function extractVariantChain(usage) {
|
|
11601
11635
|
const segments = normalizeScannedClass(usage).split(":").filter(Boolean);
|
|
@@ -11643,7 +11677,7 @@ async function whyClass(className, options) {
|
|
|
11643
11677
|
for (const file of scanResult.files) {
|
|
11644
11678
|
const source = (() => {
|
|
11645
11679
|
try {
|
|
11646
|
-
return
|
|
11680
|
+
return fs18.readFileSync(file.file, "utf8");
|
|
11647
11681
|
} catch {
|
|
11648
11682
|
return "";
|
|
11649
11683
|
}
|
|
@@ -11657,7 +11691,7 @@ async function whyClass(className, options) {
|
|
|
11657
11691
|
className
|
|
11658
11692
|
]);
|
|
11659
11693
|
usedIn.push({
|
|
11660
|
-
file:
|
|
11694
|
+
file: path33.relative(root, file.file) || path33.basename(file.file),
|
|
11661
11695
|
line: location.line,
|
|
11662
11696
|
column: location.column,
|
|
11663
11697
|
usage: normalizeScannedClass(fileClass)
|