tailwind-styled-v4 5.1.21 → 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/tw.js CHANGED
@@ -989,8 +989,8 @@ var require_command = __commonJS({
989
989
  init_cjs_shims();
990
990
  var EventEmitter = require("events").EventEmitter;
991
991
  var childProcess = require("child_process");
992
- var path31 = require("path");
993
- var fs17 = require("fs");
992
+ var path32 = require("path");
993
+ var fs18 = require("fs");
994
994
  var process2 = require("process");
995
995
  var { Argument: Argument2, humanReadableArgName } = require_argument();
996
996
  var { CommanderError: CommanderError2 } = require_error();
@@ -1922,11 +1922,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
1922
1922
  let launchWithNode = false;
1923
1923
  const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
1924
1924
  function findFile(baseDir, baseName) {
1925
- const localBin = path31.resolve(baseDir, baseName);
1926
- if (fs17.existsSync(localBin)) return localBin;
1927
- if (sourceExt.includes(path31.extname(baseName))) return void 0;
1925
+ const localBin = path32.resolve(baseDir, baseName);
1926
+ if (fs18.existsSync(localBin)) return localBin;
1927
+ if (sourceExt.includes(path32.extname(baseName))) return void 0;
1928
1928
  const foundExt = sourceExt.find(
1929
- (ext) => fs17.existsSync(`${localBin}${ext}`)
1929
+ (ext) => fs18.existsSync(`${localBin}${ext}`)
1930
1930
  );
1931
1931
  if (foundExt) return `${localBin}${foundExt}`;
1932
1932
  return void 0;
@@ -1938,21 +1938,21 @@ Expecting one of '${allowedValues.join("', '")}'`);
1938
1938
  if (this._scriptPath) {
1939
1939
  let resolvedScriptPath;
1940
1940
  try {
1941
- resolvedScriptPath = fs17.realpathSync(this._scriptPath);
1941
+ resolvedScriptPath = fs18.realpathSync(this._scriptPath);
1942
1942
  } catch (err) {
1943
1943
  resolvedScriptPath = this._scriptPath;
1944
1944
  }
1945
- executableDir = path31.resolve(
1946
- path31.dirname(resolvedScriptPath),
1945
+ executableDir = path32.resolve(
1946
+ path32.dirname(resolvedScriptPath),
1947
1947
  executableDir
1948
1948
  );
1949
1949
  }
1950
1950
  if (executableDir) {
1951
1951
  let localFile = findFile(executableDir, executableFile);
1952
1952
  if (!localFile && !subcommand._executableFile && this._scriptPath) {
1953
- const legacyName = path31.basename(
1953
+ const legacyName = path32.basename(
1954
1954
  this._scriptPath,
1955
- path31.extname(this._scriptPath)
1955
+ path32.extname(this._scriptPath)
1956
1956
  );
1957
1957
  if (legacyName !== this._name) {
1958
1958
  localFile = findFile(
@@ -1963,7 +1963,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1963
1963
  }
1964
1964
  executableFile = localFile || executableFile;
1965
1965
  }
1966
- launchWithNode = sourceExt.includes(path31.extname(executableFile));
1966
+ launchWithNode = sourceExt.includes(path32.extname(executableFile));
1967
1967
  let proc;
1968
1968
  if (process2.platform !== "win32") {
1969
1969
  if (launchWithNode) {
@@ -2803,7 +2803,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2803
2803
  * @return {Command}
2804
2804
  */
2805
2805
  nameFromFilename(filename) {
2806
- this._name = path31.basename(filename, path31.extname(filename));
2806
+ this._name = path32.basename(filename, path32.extname(filename));
2807
2807
  return this;
2808
2808
  }
2809
2809
  /**
@@ -2817,9 +2817,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
2817
2817
  * @param {string} [path]
2818
2818
  * @return {(string|null|Command)}
2819
2819
  */
2820
- executableDir(path32) {
2821
- if (path32 === void 0) return this._executableDir;
2822
- this._executableDir = path32;
2820
+ executableDir(path33) {
2821
+ if (path33 === void 0) return this._executableDir;
2822
+ this._executableDir = path33;
2823
2823
  return this;
2824
2824
  }
2825
2825
  /**
@@ -3333,9 +3333,9 @@ function createDebugLogger(namespace, label) {
3333
3333
  }
3334
3334
  };
3335
3335
  }
3336
- function formatIssuePath(path31) {
3337
- if (!path31 || path31.length === 0) return "(root)";
3338
- return path31.map(
3336
+ function formatIssuePath(path32) {
3337
+ if (!path32 || path32.length === 0) return "(root)";
3338
+ return path32.map(
3339
3339
  (segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
3340
3340
  ).join(".");
3341
3341
  }
@@ -3456,8 +3456,8 @@ var init_src = __esm({
3456
3456
  /** Buat TwError dari ZodError — dukung shape Zod v3 (`errors`) dan v4 (`issues`). */
3457
3457
  static fromZod(err) {
3458
3458
  const first = err.issues?.[0] ?? err.errors?.[0];
3459
- const path31 = formatIssuePath(first?.path);
3460
- const message = first ? `${path31}: ${first.message}` : "Schema validation failed";
3459
+ const path32 = formatIssuePath(first?.path);
3460
+ const message = first ? `${path32}: ${first.message}` : "Schema validation failed";
3461
3461
  return new _TwError("validation", "SCHEMA_VALIDATION_FAILED", message, err);
3462
3462
  }
3463
3463
  static wrap(source, code, err) {
@@ -4014,12 +4014,12 @@ var init_schemas = __esm({
4014
4014
  init_cjs_shims();
4015
4015
  import_zod = require("zod");
4016
4016
  init_src();
4017
- formatIssuePath2 = (path31) => path31.length > 0 ? path31.map(
4017
+ formatIssuePath2 = (path32) => path32.length > 0 ? path32.map(
4018
4018
  (segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
4019
4019
  ).join(".") : "<root>";
4020
4020
  formatIssues = (error) => error.issues.map((issue) => {
4021
- const path31 = formatIssuePath2(issue.path);
4022
- return `${path31}: ${issue.message}`;
4021
+ const path32 = formatIssuePath2(issue.path);
4022
+ return `${path32}: ${issue.message}`;
4023
4023
  }).join("; ");
4024
4024
  parseWithSchema = (schema, data, label) => {
4025
4025
  const parsed = schema.safeParse(data);
@@ -4625,7 +4625,7 @@ var init_schemas2 = __esm({
4625
4625
  init_cjs_shims();
4626
4626
  init_src();
4627
4627
  import_zod2 = require("zod");
4628
- formatIssuePath3 = (path31) => path31.length > 0 ? path31.map(
4628
+ formatIssuePath3 = (path32) => path32.length > 0 ? path32.map(
4629
4629
  (segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
4630
4630
  ).join(".") : "<root>";
4631
4631
  isPlainObject = (value) => {
@@ -4634,8 +4634,8 @@ var init_schemas2 = __esm({
4634
4634
  return proto === Object.prototype || proto === null;
4635
4635
  };
4636
4636
  formatIssues2 = (error) => error.issues.map((issue) => {
4637
- const path31 = formatIssuePath3(issue.path);
4638
- return `${path31}: ${issue.message}`;
4637
+ const path32 = formatIssuePath3(issue.path);
4638
+ return `${path32}: ${issue.message}`;
4639
4639
  }).join("; ");
4640
4640
  parseWithSchema2 = (schema, data, label) => {
4641
4641
  const parsed = schema.safeParse(data);
@@ -6255,7 +6255,7 @@ var init_nativeBridge = __esm({
6255
6255
  "use strict";
6256
6256
  init_cjs_shims();
6257
6257
  init_src();
6258
- _loadNative = (path31) => require(path31);
6258
+ _loadNative = (path32) => require(path32);
6259
6259
  log3 = (...args) => {
6260
6260
  if (process.env.DEBUG?.includes("compiler:native")) {
6261
6261
  console.log("[compiler:native]", ...args);
@@ -6398,24 +6398,24 @@ var init_watch = __esm({
6398
6398
  });
6399
6399
 
6400
6400
  // packages/domain/compiler/src/routeGraph.ts
6401
- var import_node_fs9, import_node_path24;
6401
+ var import_node_fs10, import_node_path25;
6402
6402
  var init_routeGraph = __esm({
6403
6403
  "packages/domain/compiler/src/routeGraph.ts"() {
6404
6404
  "use strict";
6405
6405
  init_cjs_shims();
6406
- import_node_fs9 = __toESM(require("fs"), 1);
6407
- import_node_path24 = __toESM(require("path"), 1);
6406
+ import_node_fs10 = __toESM(require("fs"), 1);
6407
+ import_node_path25 = __toESM(require("path"), 1);
6408
6408
  }
6409
6409
  });
6410
6410
 
6411
6411
  // packages/domain/compiler/src/index.ts
6412
- var import_node_fs10, import_node_path25, import_node_module4, _require3, compileCssFromClasses;
6412
+ var import_node_fs11, import_node_path26, import_node_module4, _require3, compileCssFromClasses;
6413
6413
  var init_src4 = __esm({
6414
6414
  "packages/domain/compiler/src/index.ts"() {
6415
6415
  "use strict";
6416
6416
  init_cjs_shims();
6417
- import_node_fs10 = __toESM(require("fs"), 1);
6418
- import_node_path25 = __toESM(require("path"), 1);
6417
+ import_node_fs11 = __toESM(require("fs"), 1);
6418
+ import_node_path26 = __toESM(require("path"), 1);
6419
6419
  import_node_module4 = require("module");
6420
6420
  init_nativeBridge();
6421
6421
  init_compiler();
@@ -8731,9 +8731,281 @@ function printDoctorOutput(result, output) {
8731
8731
  );
8732
8732
  }
8733
8733
 
8734
- // packages/infrastructure/cli/src/commands/misc.ts
8734
+ // packages/infrastructure/cli/src/commands/figma.ts
8735
8735
  init_cjs_shims();
8736
+ var import_node_fs9 = __toESM(require("fs"), 1);
8736
8737
  var import_node_path23 = __toESM(require("path"), 1);
8738
+ init_errors();
8739
+
8740
+ // packages/infrastructure/cli/src/utils/figmaApi.ts
8741
+ init_cjs_shims();
8742
+ async function figmaRequest(endpoint, options) {
8743
+ const { token, fileKey } = options;
8744
+ if (!token) {
8745
+ throw new Error("FIGMA_TOKEN environment variable not set");
8746
+ }
8747
+ if (!fileKey) {
8748
+ throw new Error("FIGMA_FILE_KEY environment variable not set");
8749
+ }
8750
+ const url = `https://api.figma.com/v1${endpoint.replace(":fileKey", fileKey)}`;
8751
+ const res = await fetch(url, {
8752
+ headers: { "X-Figma-Token": token }
8753
+ });
8754
+ if (!res.ok) {
8755
+ const body = await res.text();
8756
+ throw new Error(`Figma API ${res.status}: ${body.slice(0, 200)}`);
8757
+ }
8758
+ return res.json();
8759
+ }
8760
+ function figmaColorToHex(color) {
8761
+ const { r, g, b, a = 1 } = color;
8762
+ const toHex = (v) => Math.round(v * 255).toString(16).padStart(2, "0");
8763
+ const hex = `#${toHex(r)}${toHex(g)}${toHex(b)}`;
8764
+ return a < 1 ? `${hex}${toHex(a)}` : hex;
8765
+ }
8766
+ function figmaVariablesToTokens(variablesData) {
8767
+ const tokens = {};
8768
+ const { variables = {}, variableCollections = {} } = variablesData;
8769
+ for (const [id, variable] of Object.entries(variables)) {
8770
+ const collection = variableCollections[variable.variableCollectionId];
8771
+ if (!collection) continue;
8772
+ const modeId = Object.keys(variable.valuesByMode)[0];
8773
+ const rawValue = variable.valuesByMode[modeId];
8774
+ if (rawValue === void 0) continue;
8775
+ const parts = variable.name.split("/").map(
8776
+ (p) => p.toLowerCase().replace(/[^a-z0-9]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "")
8777
+ );
8778
+ let cursor = tokens;
8779
+ for (let i = 0; i < parts.length - 1; i++) {
8780
+ cursor[parts[i]] ??= {};
8781
+ cursor = cursor[parts[i]];
8782
+ }
8783
+ const leafKey = parts[parts.length - 1];
8784
+ if (variable.resolvedType === "COLOR") {
8785
+ cursor[leafKey] = {
8786
+ $value: typeof rawValue === "object" && "r" in rawValue ? figmaColorToHex(rawValue) : String(rawValue),
8787
+ $type: "color",
8788
+ $description: variable.description || void 0,
8789
+ _figmaId: id
8790
+ };
8791
+ } else if (variable.resolvedType === "FLOAT") {
8792
+ cursor[leafKey] = {
8793
+ $value: typeof rawValue === "number" ? `${rawValue}px` : String(rawValue),
8794
+ $type: "dimension",
8795
+ _figmaId: id
8796
+ };
8797
+ } else if (variable.resolvedType === "STRING") {
8798
+ cursor[leafKey] = {
8799
+ $value: String(rawValue),
8800
+ $type: "other",
8801
+ _figmaId: id
8802
+ };
8803
+ }
8804
+ }
8805
+ return tokens;
8806
+ }
8807
+
8808
+ // packages/infrastructure/cli/src/utils/tokenUtils.ts
8809
+ init_cjs_shims();
8810
+ function tokensToFigmaUpdates(tokens, existingVariables = {}) {
8811
+ const updates = [];
8812
+ function walk(obj, path32 = []) {
8813
+ for (const [key, val] of Object.entries(obj)) {
8814
+ if (val.$value !== void 0) {
8815
+ const name = path32.concat(key).map(
8816
+ (p) => p.split("-").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join("")
8817
+ ).join("/");
8818
+ const existing = Object.values(existingVariables).find(
8819
+ (v) => v.name === name
8820
+ );
8821
+ if (existing) {
8822
+ updates.push({
8823
+ id: existing.id,
8824
+ name,
8825
+ value: val.$value,
8826
+ type: val.$type
8827
+ });
8828
+ }
8829
+ } else if (typeof val === "object" && !val.$type) {
8830
+ walk(val, path32.concat(key));
8831
+ }
8832
+ }
8833
+ }
8834
+ walk(tokens);
8835
+ return updates;
8836
+ }
8837
+ function flattenTokens(obj, prefix = "", target = {}) {
8838
+ for (const [k, v] of Object.entries(obj)) {
8839
+ const key = [prefix, k].filter(Boolean).join(".");
8840
+ if (v.$value !== void 0) {
8841
+ target[key] = v.$value;
8842
+ } else if (typeof v === "object" && !v.$type) {
8843
+ flattenTokens(v, key, target);
8844
+ }
8845
+ }
8846
+ return target;
8847
+ }
8848
+ function diffTokens(local, figma) {
8849
+ const allKeys = /* @__PURE__ */ new Set([...Object.keys(local), ...Object.keys(figma)]);
8850
+ const diffs = [];
8851
+ for (const key of allKeys) {
8852
+ if (local[key] !== figma[key]) {
8853
+ diffs.push({
8854
+ key,
8855
+ local: local[key],
8856
+ figma: figma[key]
8857
+ });
8858
+ }
8859
+ }
8860
+ return diffs;
8861
+ }
8862
+
8863
+ // packages/infrastructure/cli/src/commands/figma.ts
8864
+ var figmaCommand = {
8865
+ name: "figma",
8866
+ async run(args, context) {
8867
+ const cmd = args[0];
8868
+ const isDryRun = args.includes("--dry-run");
8869
+ const FIGMA_TOKEN = process.env.FIGMA_TOKEN;
8870
+ const FIGMA_FILE_KEY = process.env.FIGMA_FILE_KEY;
8871
+ const TOKEN_FILE = import_node_path23.default.join(context.cwd, "tokens.sync.json");
8872
+ if (!cmd || cmd === "help") {
8873
+ context.output.log(`Usage: tw figma <pull|push|diff> [--dry-run]
8874
+
8875
+ Environment variables:
8876
+ FIGMA_TOKEN \u2014 Figma personal access token (figd_...)
8877
+ FIGMA_FILE_KEY \u2014 Figma file key (from URL: figma.com/file/<KEY>/...)
8878
+
8879
+ Commands:
8880
+ pull Import Figma variables \u2192 tokens.sync.json
8881
+ push Export tokens.sync.json \u2192 Figma variables
8882
+ diff Show differences between local and Figma
8883
+
8884
+ Options:
8885
+ --dry-run Show what would change without writing`);
8886
+ return;
8887
+ }
8888
+ if (cmd === "pull") {
8889
+ if (!FIGMA_TOKEN || !FIGMA_FILE_KEY) {
8890
+ throw new CliUsageError(
8891
+ "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"
8892
+ );
8893
+ }
8894
+ try {
8895
+ context.output.status("[figma] Fetching Figma variables...");
8896
+ const data = await figmaRequest("/files/:fileKey/variables/local", {
8897
+ token: FIGMA_TOKEN,
8898
+ fileKey: FIGMA_FILE_KEY
8899
+ });
8900
+ const tokens = figmaVariablesToTokens(data);
8901
+ const variableCount = Object.values(data.variables ?? {}).length;
8902
+ if (isDryRun) {
8903
+ context.output.log("[figma] DRY RUN \u2014 would write:");
8904
+ context.output.log(JSON.stringify({ version: 1, tokens }, null, 2));
8905
+ } else {
8906
+ let existing = { version: 1, tokens: {} };
8907
+ if (import_node_fs9.default.existsSync(TOKEN_FILE)) {
8908
+ try {
8909
+ existing = JSON.parse(import_node_fs9.default.readFileSync(TOKEN_FILE, "utf8"));
8910
+ } catch {
8911
+ }
8912
+ }
8913
+ const merged = {
8914
+ ...existing,
8915
+ tokens: { ...existing.tokens, ...tokens },
8916
+ figmaFileKey: FIGMA_FILE_KEY,
8917
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
8918
+ source: "figma"
8919
+ };
8920
+ import_node_fs9.default.writeFileSync(TOKEN_FILE, JSON.stringify(merged, null, 2) + "\n");
8921
+ context.output.success(
8922
+ `Pulled ${variableCount} variables from Figma \u2192 ${TOKEN_FILE}`
8923
+ );
8924
+ }
8925
+ } catch (e) {
8926
+ throw new CliUsageError(
8927
+ `Pull failed: ${e instanceof Error ? e.message : String(e)}`
8928
+ );
8929
+ }
8930
+ } else if (cmd === "push") {
8931
+ if (!FIGMA_TOKEN || !FIGMA_FILE_KEY) {
8932
+ throw new CliUsageError("Missing FIGMA_TOKEN or FIGMA_FILE_KEY");
8933
+ }
8934
+ if (!import_node_fs9.default.existsSync(TOKEN_FILE)) {
8935
+ throw new CliUsageError(
8936
+ `${TOKEN_FILE} not found. Run 'tw sync init' first.`
8937
+ );
8938
+ }
8939
+ try {
8940
+ const local = JSON.parse(import_node_fs9.default.readFileSync(TOKEN_FILE, "utf8"));
8941
+ const data = await figmaRequest("/files/:fileKey/variables/local", {
8942
+ token: FIGMA_TOKEN,
8943
+ fileKey: FIGMA_FILE_KEY
8944
+ });
8945
+ const updates = tokensToFigmaUpdates(local.tokens ?? {}, data.variables ?? {});
8946
+ if (isDryRun) {
8947
+ context.output.log(
8948
+ `[figma] DRY RUN \u2014 would update ${updates.length} variables in Figma:`
8949
+ );
8950
+ updates.forEach((u) => context.output.log(` ${u.name}: ${u.value}`));
8951
+ } else {
8952
+ if (updates.length === 0) {
8953
+ context.output.log("[figma] No matching variables to update");
8954
+ } else {
8955
+ context.output.success(`Updated ${updates.length} variables in Figma`);
8956
+ }
8957
+ }
8958
+ } catch (e) {
8959
+ throw new CliUsageError(
8960
+ `Push failed: ${e instanceof Error ? e.message : String(e)}`
8961
+ );
8962
+ }
8963
+ } else if (cmd === "diff") {
8964
+ if (!FIGMA_TOKEN || !FIGMA_FILE_KEY) {
8965
+ throw new CliUsageError("Missing FIGMA_TOKEN or FIGMA_FILE_KEY");
8966
+ }
8967
+ if (!import_node_fs9.default.existsSync(TOKEN_FILE)) {
8968
+ throw new CliUsageError("tokens.sync.json not found");
8969
+ }
8970
+ try {
8971
+ const [local, figmaData] = await Promise.all([
8972
+ JSON.parse(import_node_fs9.default.readFileSync(TOKEN_FILE, "utf8")),
8973
+ figmaRequest("/files/:fileKey/variables/local", {
8974
+ token: FIGMA_TOKEN,
8975
+ fileKey: FIGMA_FILE_KEY
8976
+ })
8977
+ ]);
8978
+ const figmaTokens = figmaVariablesToTokens(figmaData);
8979
+ const figmaFlat = {};
8980
+ const localFlat = {};
8981
+ flattenTokens(local.tokens ?? {}, "", localFlat);
8982
+ flattenTokens(figmaTokens, "", figmaFlat);
8983
+ const diffs = diffTokens(localFlat, figmaFlat);
8984
+ if (diffs.length === 0) {
8985
+ context.output.success("No differences \u2014 local and Figma are in sync");
8986
+ } else {
8987
+ context.output.log(`${diffs.length} differences found:
8988
+ `);
8989
+ diffs.forEach((d) => {
8990
+ context.output.log(` ${d.key}`);
8991
+ context.output.log(` local: ${d.local ?? "(missing)"}`);
8992
+ context.output.log(` figma: ${d.figma ?? "(missing)"}`);
8993
+ });
8994
+ }
8995
+ } catch (e) {
8996
+ throw new CliUsageError(
8997
+ `Diff failed: ${e instanceof Error ? e.message : String(e)}`
8998
+ );
8999
+ }
9000
+ } else {
9001
+ throw new CliUsageError(`Unknown command: ${cmd}`);
9002
+ }
9003
+ }
9004
+ };
9005
+
9006
+ // packages/infrastructure/cli/src/commands/misc.ts
9007
+ init_cjs_shims();
9008
+ var import_node_path24 = __toESM(require("path"), 1);
8737
9009
  var import_node_util9 = require("util");
8738
9010
  init_errors();
8739
9011
  init_fs();
@@ -8766,7 +9038,7 @@ var shareCommand = {
8766
9038
  name: "share",
8767
9039
  async run(args, context) {
8768
9040
  const name = args.find((arg) => !arg.startsWith("-")) ?? "component-name";
8769
- const manifestPath = import_node_path23.default.join(process.cwd(), ".tw-cache", "deploy-manifest.json");
9041
+ const manifestPath = import_node_path24.default.join(process.cwd(), ".tw-cache", "deploy-manifest.json");
8770
9042
  const defaultManifest = {
8771
9043
  name,
8772
9044
  version: "0.1.0"
@@ -8852,14 +9124,14 @@ var isVersionOutdated = (currentVersion, latestVersion) => {
8852
9124
  };
8853
9125
  var resolveCurrentCliVersion = async (context) => {
8854
9126
  const candidates = [
8855
- import_node_path23.default.resolve(context.runtimeDir, "..", "package.json"),
8856
- import_node_path23.default.resolve(process.cwd(), "packages", "cli", "package.json"),
8857
- import_node_path23.default.resolve(process.cwd(), "package.json")
9127
+ import_node_path24.default.resolve(context.runtimeDir, "..", "package.json"),
9128
+ import_node_path24.default.resolve(process.cwd(), "packages", "cli", "package.json"),
9129
+ import_node_path24.default.resolve(process.cwd(), "package.json")
8858
9130
  ];
8859
9131
  for (const candidate of candidates) {
8860
9132
  if (!await pathExists2(candidate)) continue;
8861
9133
  const pkg = await readJsonSafe(candidate);
8862
- const isCliPackage = pkg?.version && (pkg.name === CLI_PACKAGE_NAME || candidate.includes(`${import_node_path23.default.sep}packages${import_node_path23.default.sep}cli${import_node_path23.default.sep}`));
9134
+ const isCliPackage = pkg?.version && (pkg.name === CLI_PACKAGE_NAME || candidate.includes(`${import_node_path24.default.sep}packages${import_node_path24.default.sep}cli${import_node_path24.default.sep}`));
8863
9135
  if (isCliPackage) return pkg.version ?? "0.0.0";
8864
9136
  }
8865
9137
  return "0.0.0";
@@ -9102,7 +9374,7 @@ init_cjs_shims();
9102
9374
 
9103
9375
  // packages/infrastructure/cli/src/preflight.ts
9104
9376
  init_cjs_shims();
9105
- var import_node_path26 = __toESM(require("path"), 1);
9377
+ var import_node_path27 = __toESM(require("path"), 1);
9106
9378
  var import_node_url7 = require("url");
9107
9379
  init_args();
9108
9380
  init_errors();
@@ -9135,8 +9407,8 @@ async function validateThemeConfig(cwd2) {
9135
9407
  const twConfigFiles = ["tailwind.config.ts", "tailwind.config.js", "tailwind.config.mjs"];
9136
9408
  let configPath = null;
9137
9409
  for (const file of twConfigFiles) {
9138
- if (await pathExists2(import_node_path26.default.join(cwd2, file))) {
9139
- configPath = import_node_path26.default.join(cwd2, file);
9410
+ if (await pathExists2(import_node_path27.default.join(cwd2, file))) {
9411
+ configPath = import_node_path27.default.join(cwd2, file);
9140
9412
  break;
9141
9413
  }
9142
9414
  }
@@ -9227,7 +9499,7 @@ function resolveCliEntry(scriptPath) {
9227
9499
  async function hasTailwindCssImport(cwd2) {
9228
9500
  const cssFiles = ["src/app/globals.css", "src/index.css", "src/style.css", "app/globals.css"];
9229
9501
  for (const file of cssFiles) {
9230
- const raw = await readFileSafe(import_node_path26.default.join(cwd2, file));
9502
+ const raw = await readFileSafe(import_node_path27.default.join(cwd2, file));
9231
9503
  if (raw?.includes("tailwindcss")) return true;
9232
9504
  }
9233
9505
  return false;
@@ -9243,7 +9515,7 @@ async function hasSafelistSource(cwd2) {
9243
9515
  "app/globals.css"
9244
9516
  ];
9245
9517
  for (const file of cssFiles) {
9246
- const raw = await readFileSafe(import_node_path26.default.join(cwd2, file));
9518
+ const raw = await readFileSafe(import_node_path27.default.join(cwd2, file));
9247
9519
  if (raw === null) continue;
9248
9520
  if (raw.includes("tw-classes")) return { found: true, cssFile: file };
9249
9521
  if (raw.includes("tailwindcss")) return { found: false, cssFile: file };
@@ -9251,8 +9523,8 @@ async function hasSafelistSource(cwd2) {
9251
9523
  return { found: false, cssFile: null };
9252
9524
  }
9253
9525
  async function applyTailwindInit(cwd2) {
9254
- await ensureFileSafe(import_node_path26.default.join(cwd2, "src", "tailwind.css"), DEFAULT_TAILWIND_CSS2);
9255
- await ensureFileSafe(import_node_path26.default.join(cwd2, "tailwind-styled.config.json"), DEFAULT_TW_CONFIG);
9526
+ await ensureFileSafe(import_node_path27.default.join(cwd2, "src", "tailwind.css"), DEFAULT_TAILWIND_CSS2);
9527
+ await ensureFileSafe(import_node_path27.default.join(cwd2, "tailwind-styled.config.json"), DEFAULT_TW_CONFIG);
9256
9528
  }
9257
9529
  function check(results, id, label, pass, message, fix) {
9258
9530
  results.push({ id, label, pass, message, fix });
@@ -9274,7 +9546,7 @@ async function runPreflightCli(rawArgs) {
9274
9546
  node.major >= 20 ? `Node ${node.full} OK` : `Node ${node.full} - requires >=20. Download: https://nodejs.org`,
9275
9547
  node.major < 20 ? "Install Node.js 20 LTS or newer from https://nodejs.org" : void 0
9276
9548
  );
9277
- const pkg = await readJsonSafe(import_node_path26.default.join(cwd2, "package.json"));
9549
+ const pkg = await readJsonSafe(import_node_path27.default.join(cwd2, "package.json"));
9278
9550
  check(
9279
9551
  results,
9280
9552
  "package-json",
@@ -9308,7 +9580,7 @@ async function runPreflightCli(rawArgs) {
9308
9580
  }
9309
9581
  const twConfigFiles = ["tailwind.config.ts", "tailwind.config.js", "tailwind.config.mjs"];
9310
9582
  const twConfigChecks = await Promise.all(
9311
- twConfigFiles.map(async (file) => ({ file, exists: await pathExists2(import_node_path26.default.join(cwd2, file)) }))
9583
+ twConfigFiles.map(async (file) => ({ file, exists: await pathExists2(import_node_path27.default.join(cwd2, file)) }))
9312
9584
  );
9313
9585
  const foundTwConfig = twConfigChecks.find((item) => item.exists)?.file ?? null;
9314
9586
  const hasCssConfig = await hasTailwindCssImport(cwd2);
@@ -9320,7 +9592,7 @@ async function runPreflightCli(rawArgs) {
9320
9592
  foundTwConfig ? `${foundTwConfig} found OK` : hasCssConfig ? "@import tailwindcss found in CSS OK" : "No Tailwind config found - run: tw init",
9321
9593
  "tw init"
9322
9594
  );
9323
- const oldConfig = await readJsonSafe(import_node_path26.default.join(cwd2, "tailwind.config.js")) ?? await readJsonSafe(import_node_path26.default.join(cwd2, "tailwind.config.ts"));
9595
+ const oldConfig = await readJsonSafe(import_node_path27.default.join(cwd2, "tailwind.config.js")) ?? await readJsonSafe(import_node_path27.default.join(cwd2, "tailwind.config.ts"));
9324
9596
  if (oldConfig) {
9325
9597
  const hasOldJit = oldConfig.mode === "jit";
9326
9598
  const hasOldPurge = "purge" in oldConfig;
@@ -9344,7 +9616,7 @@ async function runPreflightCli(rawArgs) {
9344
9616
  validation.message
9345
9617
  );
9346
9618
  }
9347
- const hasTsConfig = await pathExists2(import_node_path26.default.join(cwd2, "tsconfig.json"));
9619
+ const hasTsConfig = await pathExists2(import_node_path27.default.join(cwd2, "tsconfig.json"));
9348
9620
  check(
9349
9621
  results,
9350
9622
  "typescript",
@@ -9703,7 +9975,7 @@ var scriptCommands = [
9703
9975
 
9704
9976
  // packages/infrastructure/cli/src/commands/storybook.ts
9705
9977
  init_cjs_shims();
9706
- var import_node_path27 = __toESM(require("path"), 1);
9978
+ var import_node_path28 = __toESM(require("path"), 1);
9707
9979
  var import_node_util11 = require("util");
9708
9980
  init_errors();
9709
9981
  init_fs();
@@ -9745,7 +10017,7 @@ var storybookCommand = {
9745
10017
  context.output.writeText(
9746
10018
  `[tw storybook] Tip: use --variants='{"size":["sm","lg"]}' to enumerate variant combinations`
9747
10019
  );
9748
- const localBin = import_node_path27.default.join(
10020
+ const localBin = import_node_path28.default.join(
9749
10021
  process.cwd(),
9750
10022
  "node_modules",
9751
10023
  ".bin",
@@ -10931,12 +11203,12 @@ async function traceClass(className, options) {
10931
11203
 
10932
11204
  // packages/infrastructure/cli/src/utils/traceTargetService.ts
10933
11205
  init_cjs_shims();
10934
- var import_node_fs11 = __toESM(require("fs"), 1);
10935
- var import_node_path28 = __toESM(require("path"), 1);
11206
+ var import_node_fs12 = __toESM(require("fs"), 1);
11207
+ var import_node_path29 = __toESM(require("path"), 1);
10936
11208
  init_internal();
10937
11209
  init_src2();
10938
11210
  function toRelativePath(root, value) {
10939
- const relative = import_node_path28.default.relative(root, value);
11211
+ const relative = import_node_path29.default.relative(root, value);
10940
11212
  return relative.length > 0 ? relative : ".";
10941
11213
  }
10942
11214
  function uniqueSorted(values) {
@@ -11005,7 +11277,7 @@ function tryCompileClasses(classes) {
11005
11277
  }
11006
11278
  }
11007
11279
  function traceSingleFile(filePath, root) {
11008
- const source = import_node_fs11.default.readFileSync(filePath, "utf8");
11280
+ const source = import_node_fs12.default.readFileSync(filePath, "utf8");
11009
11281
  const classes = uniqueSorted(scanSource(source));
11010
11282
  const imports = extractImports(source);
11011
11283
  const compiled = tryCompileClasses(classes);
@@ -11036,7 +11308,7 @@ function traceDirectory(targetDir, root) {
11036
11308
  const imports = [];
11037
11309
  const importKeys = /* @__PURE__ */ new Set();
11038
11310
  const files = scanResult.files.filter((entry) => isScannableFile2(entry.file, DEFAULT_EXTENSIONS)).map((entry) => {
11039
- const source = import_node_fs11.default.readFileSync(entry.file, "utf8");
11311
+ const source = import_node_fs12.default.readFileSync(entry.file, "utf8");
11040
11312
  const fileImports = extractImports(source);
11041
11313
  for (const fileImport of fileImports) {
11042
11314
  const key = `${fileImport.kind}:${fileImport.source}`;
@@ -11067,12 +11339,12 @@ function traceDirectory(targetDir, root) {
11067
11339
  };
11068
11340
  }
11069
11341
  async function traceTarget(target, options = {}) {
11070
- const root = import_node_path28.default.resolve(options.root ?? process.cwd());
11071
- const resolvedTarget = import_node_path28.default.resolve(root, target);
11072
- if (!import_node_fs11.default.existsSync(resolvedTarget)) {
11342
+ const root = import_node_path29.default.resolve(options.root ?? process.cwd());
11343
+ const resolvedTarget = import_node_path29.default.resolve(root, target);
11344
+ if (!import_node_fs12.default.existsSync(resolvedTarget)) {
11073
11345
  throw new Error(`Trace target not found: ${resolvedTarget}`);
11074
11346
  }
11075
- const stat = import_node_fs11.default.statSync(resolvedTarget);
11347
+ const stat = import_node_fs12.default.statSync(resolvedTarget);
11076
11348
  if (stat.isDirectory()) {
11077
11349
  return traceDirectory(resolvedTarget, root);
11078
11350
  }
@@ -11235,8 +11507,8 @@ function printClassTraceOutput(result, output) {
11235
11507
 
11236
11508
  // packages/infrastructure/cli/src/generateTypes.ts
11237
11509
  init_cjs_shims();
11238
- var import_node_fs12 = __toESM(require("fs"), 1);
11239
- var import_node_path29 = __toESM(require("path"), 1);
11510
+ var import_node_fs13 = __toESM(require("fs"), 1);
11511
+ var import_node_path30 = __toESM(require("path"), 1);
11240
11512
  var import_picocolors6 = __toESM(require_picocolors(), 1);
11241
11513
  init_output();
11242
11514
  async function runGenerateTypesCli(rawArgs) {
@@ -11244,7 +11516,7 @@ async function runGenerateTypesCli(rawArgs) {
11244
11516
  const logger = createCliLogger({ output });
11245
11517
  const cwd2 = process.cwd();
11246
11518
  const outFile = rawArgs.find((a) => a.startsWith("--out="))?.slice(6) ?? "src/types/tailwind-styled.d.ts";
11247
- const outPath = import_node_path29.default.resolve(cwd2, outFile);
11519
+ const outPath = import_node_path30.default.resolve(cwd2, outFile);
11248
11520
  output.writeText("");
11249
11521
  output.writeText(import_picocolors6.default.bold(import_picocolors6.default.cyan(" \u25C6 tw generate-types")));
11250
11522
  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"));
@@ -11280,12 +11552,12 @@ async function runGenerateTypesCli(rawArgs) {
11280
11552
  }
11281
11553
  output.writeText("");
11282
11554
  output.writeText(import_picocolors6.default.bold(" [2/2]") + import_picocolors6.default.cyan(" generate .d.ts"));
11283
- const outDir = import_node_path29.default.dirname(outPath);
11284
- if (!import_node_fs12.default.existsSync(outDir)) {
11285
- import_node_fs12.default.mkdirSync(outDir, { recursive: true });
11555
+ const outDir = import_node_path30.default.dirname(outPath);
11556
+ if (!import_node_fs13.default.existsSync(outDir)) {
11557
+ import_node_fs13.default.mkdirSync(outDir, { recursive: true });
11286
11558
  }
11287
- import_node_fs12.default.writeFileSync(outPath, result.dtsContent, "utf-8");
11288
- logger.ok(import_node_path29.default.relative(cwd2, outPath));
11559
+ import_node_fs13.default.writeFileSync(outPath, result.dtsContent, "utf-8");
11560
+ logger.ok(import_node_path30.default.relative(cwd2, outPath));
11289
11561
  output.writeText("");
11290
11562
  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"));
11291
11563
  output.writeText(import_picocolors6.default.bold(import_picocolors6.default.green(" \u2713 types generated")));
@@ -11296,11 +11568,11 @@ async function runGenerateTypesCli(rawArgs) {
11296
11568
  }
11297
11569
  async function loadNativeBinding2(cwd2) {
11298
11570
  const candidates = [
11299
- import_node_path29.default.join(cwd2, "native", "tailwind-styled-native.node"),
11300
- import_node_path29.default.join(cwd2, "node_modules", "tailwind-styled-v4", "native", "tailwind-styled-native.node")
11571
+ import_node_path30.default.join(cwd2, "native", "tailwind-styled-native.node"),
11572
+ import_node_path30.default.join(cwd2, "node_modules", "tailwind-styled-v4", "native", "tailwind-styled-native.node")
11301
11573
  ];
11302
11574
  for (const candidate of candidates) {
11303
- if (import_node_fs12.default.existsSync(candidate)) {
11575
+ if (import_node_fs13.default.existsSync(candidate)) {
11304
11576
  try {
11305
11577
  return require(candidate);
11306
11578
  } catch {
@@ -11317,8 +11589,8 @@ init_errors();
11317
11589
 
11318
11590
  // packages/infrastructure/cli/src/utils/whyService.ts
11319
11591
  init_cjs_shims();
11320
- var import_node_fs13 = __toESM(require("fs"), 1);
11321
- var import_node_path30 = __toESM(require("path"), 1);
11592
+ var import_node_fs14 = __toESM(require("fs"), 1);
11593
+ var import_node_path31 = __toESM(require("path"), 1);
11322
11594
  init_internal();
11323
11595
  init_src2();
11324
11596
  function extractVariantChain(usage) {
@@ -11367,7 +11639,7 @@ async function whyClass(className, options) {
11367
11639
  for (const file of scanResult.files) {
11368
11640
  const source = (() => {
11369
11641
  try {
11370
- return import_node_fs13.default.readFileSync(file.file, "utf8");
11642
+ return import_node_fs14.default.readFileSync(file.file, "utf8");
11371
11643
  } catch {
11372
11644
  return "";
11373
11645
  }
@@ -11381,7 +11653,7 @@ async function whyClass(className, options) {
11381
11653
  className
11382
11654
  ]);
11383
11655
  usedIn.push({
11384
- file: import_node_path30.default.relative(root, file.file) || import_node_path30.default.basename(file.file),
11656
+ file: import_node_path31.default.relative(root, file.file) || import_node_path31.default.basename(file.file),
11385
11657
  line: location.line,
11386
11658
  column: location.column,
11387
11659
  usage: normalizeScannedClass(fileClass)
@@ -11688,6 +11960,12 @@ function buildMainProgram(context) {
11688
11960
  );
11689
11961
  });
11690
11962
  });
11963
+ const figmaTopLevel = program2.command("figma").description("Figma design token sync");
11964
+ ["pull", "push", "diff"].forEach((subcommand) => {
11965
+ figmaTopLevel.command(`${subcommand} [args...]`).description(`Figma ${subcommand}`).allowUnknownOption(true).action(async (args) => {
11966
+ await figmaCommand.run(contextArgs([subcommand, ...toVariadic(args)], context), context);
11967
+ });
11968
+ });
11691
11969
  program2.command("test").description("Test shortcut wrapper").option("--watch", "Watch mode").action(async (...actionArgs) => {
11692
11970
  const options = actionCommand(actionArgs).opts();
11693
11971
  const args = [];