tailwind-styled-v4 5.1.20 → 5.1.22

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/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 path32 = __require("path");
1001
- var fs17 = __require("fs");
1000
+ var path33 = __require("path");
1001
+ var fs18 = __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 = path32.resolve(baseDir, baseName);
1934
- if (fs17.existsSync(localBin)) return localBin;
1935
- if (sourceExt.includes(path32.extname(baseName))) return void 0;
1933
+ const localBin = path33.resolve(baseDir, baseName);
1934
+ if (fs18.existsSync(localBin)) return localBin;
1935
+ if (sourceExt.includes(path33.extname(baseName))) return void 0;
1936
1936
  const foundExt = sourceExt.find(
1937
- (ext) => fs17.existsSync(`${localBin}${ext}`)
1937
+ (ext) => fs18.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 = fs17.realpathSync(this._scriptPath);
1949
+ resolvedScriptPath = fs18.realpathSync(this._scriptPath);
1950
1950
  } catch (err) {
1951
1951
  resolvedScriptPath = this._scriptPath;
1952
1952
  }
1953
- executableDir = path32.resolve(
1954
- path32.dirname(resolvedScriptPath),
1953
+ executableDir = path33.resolve(
1954
+ path33.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 = path32.basename(
1961
+ const legacyName = path33.basename(
1962
1962
  this._scriptPath,
1963
- path32.extname(this._scriptPath)
1963
+ path33.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(path32.extname(executableFile));
1974
+ launchWithNode = sourceExt.includes(path33.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 = path32.basename(filename, path32.extname(filename));
2814
+ this._name = path33.basename(filename, path33.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(path33) {
2829
- if (path33 === void 0) return this._executableDir;
2830
- this._executableDir = path33;
2828
+ executableDir(path34) {
2829
+ if (path34 === void 0) return this._executableDir;
2830
+ this._executableDir = path34;
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(path32) {
3349
- if (!path32 || path32.length === 0) return "(root)";
3350
- return path32.map(
3348
+ function formatIssuePath(path33) {
3349
+ if (!path33 || path33.length === 0) return "(root)";
3350
+ return path33.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 path32 = formatIssuePath(first?.path);
3467
- const message = first ? `${path32}: ${first.message}` : "Schema validation failed";
3466
+ const path33 = formatIssuePath(first?.path);
3467
+ const message = first ? `${path33}: ${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 = (path32) => path32.length > 0 ? path32.map(
4023
+ formatIssuePath2 = (path33) => path33.length > 0 ? path33.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 path32 = formatIssuePath2(issue.path);
4028
- return `${path32}: ${issue.message}`;
4027
+ const path33 = formatIssuePath2(issue.path);
4028
+ return `${path33}: ${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 = (path32) => path32.length > 0 ? path32.map(
4633
+ formatIssuePath3 = (path33) => path33.length > 0 ? path33.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 path32 = formatIssuePath3(issue.path);
4643
- return `${path32}: ${issue.message}`;
4642
+ const path33 = formatIssuePath3(issue.path);
4643
+ return `${path33}: ${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 = (path32) => __require(path32);
6264
+ _loadNative = (path33) => __require(path33);
6265
6265
  log3 = (...args) => {
6266
6266
  if (process.env.DEBUG?.includes("compiler:native")) {
6267
6267
  console.log("[compiler:native]", ...args);
@@ -6404,8 +6404,8 @@ var init_watch = __esm({
6404
6404
  });
6405
6405
 
6406
6406
  // packages/domain/compiler/src/routeGraph.ts
6407
- import fs12 from "fs";
6408
- import path25 from "path";
6407
+ import fs13 from "fs";
6408
+ import path26 from "path";
6409
6409
  var init_routeGraph = __esm({
6410
6410
  "packages/domain/compiler/src/routeGraph.ts"() {
6411
6411
  "use strict";
@@ -6414,8 +6414,8 @@ var init_routeGraph = __esm({
6414
6414
  });
6415
6415
 
6416
6416
  // packages/domain/compiler/src/index.ts
6417
- import fs13 from "fs";
6418
- import path26 from "path";
6417
+ import fs14 from "fs";
6418
+ import path27 from "path";
6419
6419
  import { createRequire as createRequire4 } from "module";
6420
6420
  var _require3, compileCssFromClasses;
6421
6421
  var init_src4 = __esm({
@@ -8736,12 +8736,284 @@ function printDoctorOutput(result, output) {
8736
8736
  );
8737
8737
  }
8738
8738
 
8739
+ // packages/infrastructure/cli/src/commands/figma.ts
8740
+ init_esm_shims();
8741
+ init_errors();
8742
+ import fs12 from "fs";
8743
+ import path24 from "path";
8744
+
8745
+ // packages/infrastructure/cli/src/utils/figmaApi.ts
8746
+ init_esm_shims();
8747
+ async function figmaRequest(endpoint, options) {
8748
+ const { token, fileKey } = options;
8749
+ if (!token) {
8750
+ throw new Error("FIGMA_TOKEN environment variable not set");
8751
+ }
8752
+ if (!fileKey) {
8753
+ throw new Error("FIGMA_FILE_KEY environment variable not set");
8754
+ }
8755
+ const url = `https://api.figma.com/v1${endpoint.replace(":fileKey", fileKey)}`;
8756
+ const res = await fetch(url, {
8757
+ headers: { "X-Figma-Token": token }
8758
+ });
8759
+ if (!res.ok) {
8760
+ const body = await res.text();
8761
+ throw new Error(`Figma API ${res.status}: ${body.slice(0, 200)}`);
8762
+ }
8763
+ return res.json();
8764
+ }
8765
+ function figmaColorToHex(color) {
8766
+ const { r, g, b, a = 1 } = color;
8767
+ const toHex = (v) => Math.round(v * 255).toString(16).padStart(2, "0");
8768
+ const hex = `#${toHex(r)}${toHex(g)}${toHex(b)}`;
8769
+ return a < 1 ? `${hex}${toHex(a)}` : hex;
8770
+ }
8771
+ function figmaVariablesToTokens(variablesData) {
8772
+ const tokens = {};
8773
+ const { variables = {}, variableCollections = {} } = variablesData;
8774
+ for (const [id, variable] of Object.entries(variables)) {
8775
+ const collection = variableCollections[variable.variableCollectionId];
8776
+ if (!collection) continue;
8777
+ const modeId = Object.keys(variable.valuesByMode)[0];
8778
+ const rawValue = variable.valuesByMode[modeId];
8779
+ if (rawValue === void 0) continue;
8780
+ const parts = variable.name.split("/").map(
8781
+ (p) => p.toLowerCase().replace(/[^a-z0-9]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "")
8782
+ );
8783
+ let cursor = tokens;
8784
+ for (let i = 0; i < parts.length - 1; i++) {
8785
+ cursor[parts[i]] ??= {};
8786
+ cursor = cursor[parts[i]];
8787
+ }
8788
+ const leafKey = parts[parts.length - 1];
8789
+ if (variable.resolvedType === "COLOR") {
8790
+ cursor[leafKey] = {
8791
+ $value: typeof rawValue === "object" && "r" in rawValue ? figmaColorToHex(rawValue) : String(rawValue),
8792
+ $type: "color",
8793
+ $description: variable.description || void 0,
8794
+ _figmaId: id
8795
+ };
8796
+ } else if (variable.resolvedType === "FLOAT") {
8797
+ cursor[leafKey] = {
8798
+ $value: typeof rawValue === "number" ? `${rawValue}px` : String(rawValue),
8799
+ $type: "dimension",
8800
+ _figmaId: id
8801
+ };
8802
+ } else if (variable.resolvedType === "STRING") {
8803
+ cursor[leafKey] = {
8804
+ $value: String(rawValue),
8805
+ $type: "other",
8806
+ _figmaId: id
8807
+ };
8808
+ }
8809
+ }
8810
+ return tokens;
8811
+ }
8812
+
8813
+ // packages/infrastructure/cli/src/utils/tokenUtils.ts
8814
+ init_esm_shims();
8815
+ function tokensToFigmaUpdates(tokens, existingVariables = {}) {
8816
+ const updates = [];
8817
+ function walk(obj, path33 = []) {
8818
+ for (const [key, val] of Object.entries(obj)) {
8819
+ if (val.$value !== void 0) {
8820
+ const name = path33.concat(key).map(
8821
+ (p) => p.split("-").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join("")
8822
+ ).join("/");
8823
+ const existing = Object.values(existingVariables).find(
8824
+ (v) => v.name === name
8825
+ );
8826
+ if (existing) {
8827
+ updates.push({
8828
+ id: existing.id,
8829
+ name,
8830
+ value: val.$value,
8831
+ type: val.$type
8832
+ });
8833
+ }
8834
+ } else if (typeof val === "object" && !val.$type) {
8835
+ walk(val, path33.concat(key));
8836
+ }
8837
+ }
8838
+ }
8839
+ walk(tokens);
8840
+ return updates;
8841
+ }
8842
+ function flattenTokens(obj, prefix = "", target = {}) {
8843
+ for (const [k, v] of Object.entries(obj)) {
8844
+ const key = [prefix, k].filter(Boolean).join(".");
8845
+ if (v.$value !== void 0) {
8846
+ target[key] = v.$value;
8847
+ } else if (typeof v === "object" && !v.$type) {
8848
+ flattenTokens(v, key, target);
8849
+ }
8850
+ }
8851
+ return target;
8852
+ }
8853
+ function diffTokens(local, figma) {
8854
+ const allKeys = /* @__PURE__ */ new Set([...Object.keys(local), ...Object.keys(figma)]);
8855
+ const diffs = [];
8856
+ for (const key of allKeys) {
8857
+ if (local[key] !== figma[key]) {
8858
+ diffs.push({
8859
+ key,
8860
+ local: local[key],
8861
+ figma: figma[key]
8862
+ });
8863
+ }
8864
+ }
8865
+ return diffs;
8866
+ }
8867
+
8868
+ // packages/infrastructure/cli/src/commands/figma.ts
8869
+ var figmaCommand = {
8870
+ name: "figma",
8871
+ async run(args, context) {
8872
+ const cmd = args[0];
8873
+ const isDryRun = args.includes("--dry-run");
8874
+ const FIGMA_TOKEN = process.env.FIGMA_TOKEN;
8875
+ const FIGMA_FILE_KEY = process.env.FIGMA_FILE_KEY;
8876
+ const TOKEN_FILE = path24.join(context.cwd, "tokens.sync.json");
8877
+ if (!cmd || cmd === "help") {
8878
+ context.output.log(`Usage: tw figma <pull|push|diff> [--dry-run]
8879
+
8880
+ Environment variables:
8881
+ FIGMA_TOKEN \u2014 Figma personal access token (figd_...)
8882
+ FIGMA_FILE_KEY \u2014 Figma file key (from URL: figma.com/file/<KEY>/...)
8883
+
8884
+ Commands:
8885
+ pull Import Figma variables \u2192 tokens.sync.json
8886
+ push Export tokens.sync.json \u2192 Figma variables
8887
+ diff Show differences between local and Figma
8888
+
8889
+ Options:
8890
+ --dry-run Show what would change without writing`);
8891
+ return;
8892
+ }
8893
+ if (cmd === "pull") {
8894
+ if (!FIGMA_TOKEN || !FIGMA_FILE_KEY) {
8895
+ throw new CliUsageError(
8896
+ "Missing FIGMA_TOKEN or FIGMA_FILE_KEY\nSet environment variables and retry\n\nExample:\n export FIGMA_TOKEN=figd_your_token_here\n export FIGMA_FILE_KEY=abc123XYZ"
8897
+ );
8898
+ }
8899
+ try {
8900
+ context.output.status("[figma] Fetching Figma variables...");
8901
+ const data = await figmaRequest("/files/:fileKey/variables/local", {
8902
+ token: FIGMA_TOKEN,
8903
+ fileKey: FIGMA_FILE_KEY
8904
+ });
8905
+ const tokens = figmaVariablesToTokens(data);
8906
+ const variableCount = Object.values(data.variables ?? {}).length;
8907
+ if (isDryRun) {
8908
+ context.output.log("[figma] DRY RUN \u2014 would write:");
8909
+ context.output.log(JSON.stringify({ version: 1, tokens }, null, 2));
8910
+ } else {
8911
+ let existing = { version: 1, tokens: {} };
8912
+ if (fs12.existsSync(TOKEN_FILE)) {
8913
+ try {
8914
+ existing = JSON.parse(fs12.readFileSync(TOKEN_FILE, "utf8"));
8915
+ } catch {
8916
+ }
8917
+ }
8918
+ const merged = {
8919
+ ...existing,
8920
+ tokens: { ...existing.tokens, ...tokens },
8921
+ figmaFileKey: FIGMA_FILE_KEY,
8922
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
8923
+ source: "figma"
8924
+ };
8925
+ fs12.writeFileSync(TOKEN_FILE, JSON.stringify(merged, null, 2) + "\n");
8926
+ context.output.success(
8927
+ `Pulled ${variableCount} variables from Figma \u2192 ${TOKEN_FILE}`
8928
+ );
8929
+ }
8930
+ } catch (e) {
8931
+ throw new CliUsageError(
8932
+ `Pull failed: ${e instanceof Error ? e.message : String(e)}`
8933
+ );
8934
+ }
8935
+ } else if (cmd === "push") {
8936
+ if (!FIGMA_TOKEN || !FIGMA_FILE_KEY) {
8937
+ throw new CliUsageError("Missing FIGMA_TOKEN or FIGMA_FILE_KEY");
8938
+ }
8939
+ if (!fs12.existsSync(TOKEN_FILE)) {
8940
+ throw new CliUsageError(
8941
+ `${TOKEN_FILE} not found. Run 'tw sync init' first.`
8942
+ );
8943
+ }
8944
+ try {
8945
+ const local = JSON.parse(fs12.readFileSync(TOKEN_FILE, "utf8"));
8946
+ const data = await figmaRequest("/files/:fileKey/variables/local", {
8947
+ token: FIGMA_TOKEN,
8948
+ fileKey: FIGMA_FILE_KEY
8949
+ });
8950
+ const updates = tokensToFigmaUpdates(local.tokens ?? {}, data.variables ?? {});
8951
+ if (isDryRun) {
8952
+ context.output.log(
8953
+ `[figma] DRY RUN \u2014 would update ${updates.length} variables in Figma:`
8954
+ );
8955
+ updates.forEach((u) => context.output.log(` ${u.name}: ${u.value}`));
8956
+ } else {
8957
+ if (updates.length === 0) {
8958
+ context.output.log("[figma] No matching variables to update");
8959
+ } else {
8960
+ context.output.success(`Updated ${updates.length} variables in Figma`);
8961
+ }
8962
+ }
8963
+ } catch (e) {
8964
+ throw new CliUsageError(
8965
+ `Push failed: ${e instanceof Error ? e.message : String(e)}`
8966
+ );
8967
+ }
8968
+ } else if (cmd === "diff") {
8969
+ if (!FIGMA_TOKEN || !FIGMA_FILE_KEY) {
8970
+ throw new CliUsageError("Missing FIGMA_TOKEN or FIGMA_FILE_KEY");
8971
+ }
8972
+ if (!fs12.existsSync(TOKEN_FILE)) {
8973
+ throw new CliUsageError("tokens.sync.json not found");
8974
+ }
8975
+ try {
8976
+ const [local, figmaData] = await Promise.all([
8977
+ JSON.parse(fs12.readFileSync(TOKEN_FILE, "utf8")),
8978
+ figmaRequest("/files/:fileKey/variables/local", {
8979
+ token: FIGMA_TOKEN,
8980
+ fileKey: FIGMA_FILE_KEY
8981
+ })
8982
+ ]);
8983
+ const figmaTokens = figmaVariablesToTokens(figmaData);
8984
+ const figmaFlat = {};
8985
+ const localFlat = {};
8986
+ flattenTokens(local.tokens ?? {}, "", localFlat);
8987
+ flattenTokens(figmaTokens, "", figmaFlat);
8988
+ const diffs = diffTokens(localFlat, figmaFlat);
8989
+ if (diffs.length === 0) {
8990
+ context.output.success("No differences \u2014 local and Figma are in sync");
8991
+ } else {
8992
+ context.output.log(`${diffs.length} differences found:
8993
+ `);
8994
+ diffs.forEach((d) => {
8995
+ context.output.log(` ${d.key}`);
8996
+ context.output.log(` local: ${d.local ?? "(missing)"}`);
8997
+ context.output.log(` figma: ${d.figma ?? "(missing)"}`);
8998
+ });
8999
+ }
9000
+ } catch (e) {
9001
+ throw new CliUsageError(
9002
+ `Diff failed: ${e instanceof Error ? e.message : String(e)}`
9003
+ );
9004
+ }
9005
+ } else {
9006
+ throw new CliUsageError(`Unknown command: ${cmd}`);
9007
+ }
9008
+ }
9009
+ };
9010
+
8739
9011
  // packages/infrastructure/cli/src/commands/misc.ts
8740
9012
  init_esm_shims();
8741
9013
  init_errors();
8742
9014
  init_fs();
8743
9015
  init_json();
8744
- import path24 from "path";
9016
+ import path25 from "path";
8745
9017
  import { parseArgs as parseNodeArgs9 } from "util";
8746
9018
  var testCommand = {
8747
9019
  name: "test",
@@ -8771,7 +9043,7 @@ var shareCommand = {
8771
9043
  name: "share",
8772
9044
  async run(args, context) {
8773
9045
  const name = args.find((arg) => !arg.startsWith("-")) ?? "component-name";
8774
- const manifestPath = path24.join(process.cwd(), ".tw-cache", "deploy-manifest.json");
9046
+ const manifestPath = path25.join(process.cwd(), ".tw-cache", "deploy-manifest.json");
8775
9047
  const defaultManifest = {
8776
9048
  name,
8777
9049
  version: "0.1.0"
@@ -8857,14 +9129,14 @@ var isVersionOutdated = (currentVersion, latestVersion) => {
8857
9129
  };
8858
9130
  var resolveCurrentCliVersion = async (context) => {
8859
9131
  const candidates = [
8860
- path24.resolve(context.runtimeDir, "..", "package.json"),
8861
- path24.resolve(process.cwd(), "packages", "cli", "package.json"),
8862
- path24.resolve(process.cwd(), "package.json")
9132
+ path25.resolve(context.runtimeDir, "..", "package.json"),
9133
+ path25.resolve(process.cwd(), "packages", "cli", "package.json"),
9134
+ path25.resolve(process.cwd(), "package.json")
8863
9135
  ];
8864
9136
  for (const candidate of candidates) {
8865
9137
  if (!await pathExists2(candidate)) continue;
8866
9138
  const pkg = await readJsonSafe(candidate);
8867
- const isCliPackage = pkg?.version && (pkg.name === CLI_PACKAGE_NAME || candidate.includes(`${path24.sep}packages${path24.sep}cli${path24.sep}`));
9139
+ const isCliPackage = pkg?.version && (pkg.name === CLI_PACKAGE_NAME || candidate.includes(`${path25.sep}packages${path25.sep}cli${path25.sep}`));
8868
9140
  if (isCliPackage) return pkg.version ?? "0.0.0";
8869
9141
  }
8870
9142
  return "0.0.0";
@@ -9112,7 +9384,7 @@ init_errors();
9112
9384
  init_fs();
9113
9385
  init_json();
9114
9386
  init_src4();
9115
- import path27 from "path";
9387
+ import path28 from "path";
9116
9388
  import { pathToFileURL as pathToFileURL2 } from "url";
9117
9389
  var DEFAULT_TAILWIND_CSS2 = '@import "tailwindcss";\n';
9118
9390
  var DEFAULT_TW_CONFIG = `${JSON.stringify(
@@ -9139,8 +9411,8 @@ async function validateThemeConfig(cwd2) {
9139
9411
  const twConfigFiles = ["tailwind.config.ts", "tailwind.config.js", "tailwind.config.mjs"];
9140
9412
  let configPath = null;
9141
9413
  for (const file of twConfigFiles) {
9142
- if (await pathExists2(path27.join(cwd2, file))) {
9143
- configPath = path27.join(cwd2, file);
9414
+ if (await pathExists2(path28.join(cwd2, file))) {
9415
+ configPath = path28.join(cwd2, file);
9144
9416
  break;
9145
9417
  }
9146
9418
  }
@@ -9231,7 +9503,7 @@ function resolveCliEntry(scriptPath) {
9231
9503
  async function hasTailwindCssImport(cwd2) {
9232
9504
  const cssFiles = ["src/app/globals.css", "src/index.css", "src/style.css", "app/globals.css"];
9233
9505
  for (const file of cssFiles) {
9234
- const raw = await readFileSafe(path27.join(cwd2, file));
9506
+ const raw = await readFileSafe(path28.join(cwd2, file));
9235
9507
  if (raw?.includes("tailwindcss")) return true;
9236
9508
  }
9237
9509
  return false;
@@ -9247,7 +9519,7 @@ async function hasSafelistSource(cwd2) {
9247
9519
  "app/globals.css"
9248
9520
  ];
9249
9521
  for (const file of cssFiles) {
9250
- const raw = await readFileSafe(path27.join(cwd2, file));
9522
+ const raw = await readFileSafe(path28.join(cwd2, file));
9251
9523
  if (raw === null) continue;
9252
9524
  if (raw.includes("tw-classes")) return { found: true, cssFile: file };
9253
9525
  if (raw.includes("tailwindcss")) return { found: false, cssFile: file };
@@ -9255,8 +9527,8 @@ async function hasSafelistSource(cwd2) {
9255
9527
  return { found: false, cssFile: null };
9256
9528
  }
9257
9529
  async function applyTailwindInit(cwd2) {
9258
- await ensureFileSafe(path27.join(cwd2, "src", "tailwind.css"), DEFAULT_TAILWIND_CSS2);
9259
- await ensureFileSafe(path27.join(cwd2, "tailwind-styled.config.json"), DEFAULT_TW_CONFIG);
9530
+ await ensureFileSafe(path28.join(cwd2, "src", "tailwind.css"), DEFAULT_TAILWIND_CSS2);
9531
+ await ensureFileSafe(path28.join(cwd2, "tailwind-styled.config.json"), DEFAULT_TW_CONFIG);
9260
9532
  }
9261
9533
  function check(results, id, label, pass, message, fix) {
9262
9534
  results.push({ id, label, pass, message, fix });
@@ -9278,7 +9550,7 @@ async function runPreflightCli(rawArgs) {
9278
9550
  node.major >= 20 ? `Node ${node.full} OK` : `Node ${node.full} - requires >=20. Download: https://nodejs.org`,
9279
9551
  node.major < 20 ? "Install Node.js 20 LTS or newer from https://nodejs.org" : void 0
9280
9552
  );
9281
- const pkg = await readJsonSafe(path27.join(cwd2, "package.json"));
9553
+ const pkg = await readJsonSafe(path28.join(cwd2, "package.json"));
9282
9554
  check(
9283
9555
  results,
9284
9556
  "package-json",
@@ -9312,7 +9584,7 @@ async function runPreflightCli(rawArgs) {
9312
9584
  }
9313
9585
  const twConfigFiles = ["tailwind.config.ts", "tailwind.config.js", "tailwind.config.mjs"];
9314
9586
  const twConfigChecks = await Promise.all(
9315
- twConfigFiles.map(async (file) => ({ file, exists: await pathExists2(path27.join(cwd2, file)) }))
9587
+ twConfigFiles.map(async (file) => ({ file, exists: await pathExists2(path28.join(cwd2, file)) }))
9316
9588
  );
9317
9589
  const foundTwConfig = twConfigChecks.find((item) => item.exists)?.file ?? null;
9318
9590
  const hasCssConfig = await hasTailwindCssImport(cwd2);
@@ -9324,7 +9596,7 @@ async function runPreflightCli(rawArgs) {
9324
9596
  foundTwConfig ? `${foundTwConfig} found OK` : hasCssConfig ? "@import tailwindcss found in CSS OK" : "No Tailwind config found - run: tw init",
9325
9597
  "tw init"
9326
9598
  );
9327
- const oldConfig = await readJsonSafe(path27.join(cwd2, "tailwind.config.js")) ?? await readJsonSafe(path27.join(cwd2, "tailwind.config.ts"));
9599
+ const oldConfig = await readJsonSafe(path28.join(cwd2, "tailwind.config.js")) ?? await readJsonSafe(path28.join(cwd2, "tailwind.config.ts"));
9328
9600
  if (oldConfig) {
9329
9601
  const hasOldJit = oldConfig.mode === "jit";
9330
9602
  const hasOldPurge = "purge" in oldConfig;
@@ -9348,7 +9620,7 @@ async function runPreflightCli(rawArgs) {
9348
9620
  validation.message
9349
9621
  );
9350
9622
  }
9351
- const hasTsConfig = await pathExists2(path27.join(cwd2, "tsconfig.json"));
9623
+ const hasTsConfig = await pathExists2(path28.join(cwd2, "tsconfig.json"));
9352
9624
  check(
9353
9625
  results,
9354
9626
  "typescript",
@@ -9710,7 +9982,7 @@ init_esm_shims();
9710
9982
  init_errors();
9711
9983
  init_fs();
9712
9984
  init_json();
9713
- import path28 from "path";
9985
+ import path29 from "path";
9714
9986
  import { parseArgs as parseNodeArgs11 } from "util";
9715
9987
  var storybookCommand = {
9716
9988
  name: "storybook",
@@ -9749,7 +10021,7 @@ var storybookCommand = {
9749
10021
  context.output.writeText(
9750
10022
  `[tw storybook] Tip: use --variants='{"size":["sm","lg"]}' to enumerate variant combinations`
9751
10023
  );
9752
- const localBin = path28.join(
10024
+ const localBin = path29.join(
9753
10025
  process.cwd(),
9754
10026
  "node_modules",
9755
10027
  ".bin",
@@ -10936,10 +11208,10 @@ async function traceClass(className, options) {
10936
11208
  init_esm_shims();
10937
11209
  init_internal();
10938
11210
  init_src2();
10939
- import fs14 from "fs";
10940
- import path29 from "path";
11211
+ import fs15 from "fs";
11212
+ import path30 from "path";
10941
11213
  function toRelativePath(root, value) {
10942
- const relative = path29.relative(root, value);
11214
+ const relative = path30.relative(root, value);
10943
11215
  return relative.length > 0 ? relative : ".";
10944
11216
  }
10945
11217
  function uniqueSorted(values) {
@@ -11008,7 +11280,7 @@ function tryCompileClasses(classes) {
11008
11280
  }
11009
11281
  }
11010
11282
  function traceSingleFile(filePath, root) {
11011
- const source = fs14.readFileSync(filePath, "utf8");
11283
+ const source = fs15.readFileSync(filePath, "utf8");
11012
11284
  const classes = uniqueSorted(scanSource(source));
11013
11285
  const imports = extractImports(source);
11014
11286
  const compiled = tryCompileClasses(classes);
@@ -11039,7 +11311,7 @@ function traceDirectory(targetDir, root) {
11039
11311
  const imports = [];
11040
11312
  const importKeys = /* @__PURE__ */ new Set();
11041
11313
  const files = scanResult.files.filter((entry) => isScannableFile2(entry.file, DEFAULT_EXTENSIONS)).map((entry) => {
11042
- const source = fs14.readFileSync(entry.file, "utf8");
11314
+ const source = fs15.readFileSync(entry.file, "utf8");
11043
11315
  const fileImports = extractImports(source);
11044
11316
  for (const fileImport of fileImports) {
11045
11317
  const key = `${fileImport.kind}:${fileImport.source}`;
@@ -11070,12 +11342,12 @@ function traceDirectory(targetDir, root) {
11070
11342
  };
11071
11343
  }
11072
11344
  async function traceTarget(target, options = {}) {
11073
- const root = path29.resolve(options.root ?? process.cwd());
11074
- const resolvedTarget = path29.resolve(root, target);
11075
- if (!fs14.existsSync(resolvedTarget)) {
11345
+ const root = path30.resolve(options.root ?? process.cwd());
11346
+ const resolvedTarget = path30.resolve(root, target);
11347
+ if (!fs15.existsSync(resolvedTarget)) {
11076
11348
  throw new Error(`Trace target not found: ${resolvedTarget}`);
11077
11349
  }
11078
- const stat = fs14.statSync(resolvedTarget);
11350
+ const stat = fs15.statSync(resolvedTarget);
11079
11351
  if (stat.isDirectory()) {
11080
11352
  return traceDirectory(resolvedTarget, root);
11081
11353
  }
@@ -11240,14 +11512,14 @@ function printClassTraceOutput(result, output) {
11240
11512
  init_esm_shims();
11241
11513
  var import_picocolors6 = __toESM(require_picocolors(), 1);
11242
11514
  init_output();
11243
- import fs15 from "fs";
11244
- import path30 from "path";
11515
+ import fs16 from "fs";
11516
+ import path31 from "path";
11245
11517
  async function runGenerateTypesCli(rawArgs) {
11246
11518
  const output = createCliOutput({ json: rawArgs.includes("--json") });
11247
11519
  const logger = createCliLogger({ output });
11248
11520
  const cwd2 = process.cwd();
11249
11521
  const outFile = rawArgs.find((a) => a.startsWith("--out="))?.slice(6) ?? "src/types/tailwind-styled.d.ts";
11250
- const outPath = path30.resolve(cwd2, outFile);
11522
+ const outPath = path31.resolve(cwd2, outFile);
11251
11523
  output.writeText("");
11252
11524
  output.writeText(import_picocolors6.default.bold(import_picocolors6.default.cyan(" \u25C6 tw generate-types")));
11253
11525
  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"));
@@ -11283,12 +11555,12 @@ async function runGenerateTypesCli(rawArgs) {
11283
11555
  }
11284
11556
  output.writeText("");
11285
11557
  output.writeText(import_picocolors6.default.bold(" [2/2]") + import_picocolors6.default.cyan(" generate .d.ts"));
11286
- const outDir = path30.dirname(outPath);
11287
- if (!fs15.existsSync(outDir)) {
11288
- fs15.mkdirSync(outDir, { recursive: true });
11558
+ const outDir = path31.dirname(outPath);
11559
+ if (!fs16.existsSync(outDir)) {
11560
+ fs16.mkdirSync(outDir, { recursive: true });
11289
11561
  }
11290
- fs15.writeFileSync(outPath, result.dtsContent, "utf-8");
11291
- logger.ok(path30.relative(cwd2, outPath));
11562
+ fs16.writeFileSync(outPath, result.dtsContent, "utf-8");
11563
+ logger.ok(path31.relative(cwd2, outPath));
11292
11564
  output.writeText("");
11293
11565
  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"));
11294
11566
  output.writeText(import_picocolors6.default.bold(import_picocolors6.default.green(" \u2713 types generated")));
@@ -11299,11 +11571,11 @@ async function runGenerateTypesCli(rawArgs) {
11299
11571
  }
11300
11572
  async function loadNativeBinding2(cwd2) {
11301
11573
  const candidates = [
11302
- path30.join(cwd2, "native", "tailwind-styled-native.node"),
11303
- path30.join(cwd2, "node_modules", "tailwind-styled-v4", "native", "tailwind-styled-native.node")
11574
+ path31.join(cwd2, "native", "tailwind-styled-native.node"),
11575
+ path31.join(cwd2, "node_modules", "tailwind-styled-v4", "native", "tailwind-styled-native.node")
11304
11576
  ];
11305
11577
  for (const candidate of candidates) {
11306
- if (fs15.existsSync(candidate)) {
11578
+ if (fs16.existsSync(candidate)) {
11307
11579
  try {
11308
11580
  return __require(candidate);
11309
11581
  } catch {
@@ -11321,8 +11593,8 @@ import { parseArgs as parseNodeArgs14 } from "util";
11321
11593
  // packages/infrastructure/cli/src/utils/whyService.ts
11322
11594
  init_esm_shims();
11323
11595
  init_internal();
11324
- import fs16 from "fs";
11325
- import path31 from "path";
11596
+ import fs17 from "fs";
11597
+ import path32 from "path";
11326
11598
  init_src2();
11327
11599
  function extractVariantChain(usage) {
11328
11600
  const segments = normalizeScannedClass(usage).split(":").filter(Boolean);
@@ -11370,7 +11642,7 @@ async function whyClass(className, options) {
11370
11642
  for (const file of scanResult.files) {
11371
11643
  const source = (() => {
11372
11644
  try {
11373
- return fs16.readFileSync(file.file, "utf8");
11645
+ return fs17.readFileSync(file.file, "utf8");
11374
11646
  } catch {
11375
11647
  return "";
11376
11648
  }
@@ -11384,7 +11656,7 @@ async function whyClass(className, options) {
11384
11656
  className
11385
11657
  ]);
11386
11658
  usedIn.push({
11387
- file: path31.relative(root, file.file) || path31.basename(file.file),
11659
+ file: path32.relative(root, file.file) || path32.basename(file.file),
11388
11660
  line: location.line,
11389
11661
  column: location.column,
11390
11662
  usage: normalizeScannedClass(fileClass)
@@ -11691,6 +11963,12 @@ function buildMainProgram(context) {
11691
11963
  );
11692
11964
  });
11693
11965
  });
11966
+ const figmaTopLevel = program2.command("figma").description("Figma design token sync");
11967
+ ["pull", "push", "diff"].forEach((subcommand) => {
11968
+ figmaTopLevel.command(`${subcommand} [args...]`).description(`Figma ${subcommand}`).allowUnknownOption(true).action(async (args) => {
11969
+ await figmaCommand.run(contextArgs([subcommand, ...toVariadic(args)], context), context);
11970
+ });
11971
+ });
11694
11972
  program2.command("test").description("Test shortcut wrapper").option("--watch", "Watch mode").action(async (...actionArgs) => {
11695
11973
  const options = actionCommand(actionArgs).opts();
11696
11974
  const args = [];
@@ -11853,6 +12131,7 @@ if (process.argv[1] === __currentFile) {
11853
12131
  main2();
11854
12132
  }
11855
12133
  export {
12134
+ buildMainProgram,
11856
12135
  createCliOutput,
11857
12136
  ensureFlag,
11858
12137
  parseCliInput as parseCliArgs,