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