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/cli.js CHANGED
@@ -988,8 +988,8 @@ var require_command = __commonJS({
988
988
  init_cjs_shims();
989
989
  var EventEmitter = require("events").EventEmitter;
990
990
  var childProcess = require("child_process");
991
- var path31 = require("path");
992
- var fs17 = require("fs");
991
+ var path32 = require("path");
992
+ var fs18 = require("fs");
993
993
  var process2 = require("process");
994
994
  var { Argument: Argument2, humanReadableArgName } = require_argument();
995
995
  var { CommanderError: CommanderError2 } = require_error();
@@ -1921,11 +1921,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
1921
1921
  let launchWithNode = false;
1922
1922
  const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
1923
1923
  function findFile(baseDir, baseName) {
1924
- const localBin = path31.resolve(baseDir, baseName);
1925
- if (fs17.existsSync(localBin)) return localBin;
1926
- if (sourceExt.includes(path31.extname(baseName))) return void 0;
1924
+ const localBin = path32.resolve(baseDir, baseName);
1925
+ if (fs18.existsSync(localBin)) return localBin;
1926
+ if (sourceExt.includes(path32.extname(baseName))) return void 0;
1927
1927
  const foundExt = sourceExt.find(
1928
- (ext) => fs17.existsSync(`${localBin}${ext}`)
1928
+ (ext) => fs18.existsSync(`${localBin}${ext}`)
1929
1929
  );
1930
1930
  if (foundExt) return `${localBin}${foundExt}`;
1931
1931
  return void 0;
@@ -1937,21 +1937,21 @@ Expecting one of '${allowedValues.join("', '")}'`);
1937
1937
  if (this._scriptPath) {
1938
1938
  let resolvedScriptPath;
1939
1939
  try {
1940
- resolvedScriptPath = fs17.realpathSync(this._scriptPath);
1940
+ resolvedScriptPath = fs18.realpathSync(this._scriptPath);
1941
1941
  } catch (err) {
1942
1942
  resolvedScriptPath = this._scriptPath;
1943
1943
  }
1944
- executableDir = path31.resolve(
1945
- path31.dirname(resolvedScriptPath),
1944
+ executableDir = path32.resolve(
1945
+ path32.dirname(resolvedScriptPath),
1946
1946
  executableDir
1947
1947
  );
1948
1948
  }
1949
1949
  if (executableDir) {
1950
1950
  let localFile = findFile(executableDir, executableFile);
1951
1951
  if (!localFile && !subcommand._executableFile && this._scriptPath) {
1952
- const legacyName = path31.basename(
1952
+ const legacyName = path32.basename(
1953
1953
  this._scriptPath,
1954
- path31.extname(this._scriptPath)
1954
+ path32.extname(this._scriptPath)
1955
1955
  );
1956
1956
  if (legacyName !== this._name) {
1957
1957
  localFile = findFile(
@@ -1962,7 +1962,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1962
1962
  }
1963
1963
  executableFile = localFile || executableFile;
1964
1964
  }
1965
- launchWithNode = sourceExt.includes(path31.extname(executableFile));
1965
+ launchWithNode = sourceExt.includes(path32.extname(executableFile));
1966
1966
  let proc;
1967
1967
  if (process2.platform !== "win32") {
1968
1968
  if (launchWithNode) {
@@ -2802,7 +2802,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2802
2802
  * @return {Command}
2803
2803
  */
2804
2804
  nameFromFilename(filename) {
2805
- this._name = path31.basename(filename, path31.extname(filename));
2805
+ this._name = path32.basename(filename, path32.extname(filename));
2806
2806
  return this;
2807
2807
  }
2808
2808
  /**
@@ -2816,9 +2816,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
2816
2816
  * @param {string} [path]
2817
2817
  * @return {(string|null|Command)}
2818
2818
  */
2819
- executableDir(path32) {
2820
- if (path32 === void 0) return this._executableDir;
2821
- this._executableDir = path32;
2819
+ executableDir(path33) {
2820
+ if (path33 === void 0) return this._executableDir;
2821
+ this._executableDir = path33;
2822
2822
  return this;
2823
2823
  }
2824
2824
  /**
@@ -3332,9 +3332,9 @@ function createDebugLogger(namespace, label) {
3332
3332
  }
3333
3333
  };
3334
3334
  }
3335
- function formatIssuePath(path31) {
3336
- if (!path31 || path31.length === 0) return "(root)";
3337
- return path31.map(
3335
+ function formatIssuePath(path32) {
3336
+ if (!path32 || path32.length === 0) return "(root)";
3337
+ return path32.map(
3338
3338
  (segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
3339
3339
  ).join(".");
3340
3340
  }
@@ -3455,8 +3455,8 @@ var init_src = __esm({
3455
3455
  /** Buat TwError dari ZodError — dukung shape Zod v3 (`errors`) dan v4 (`issues`). */
3456
3456
  static fromZod(err) {
3457
3457
  const first = err.issues?.[0] ?? err.errors?.[0];
3458
- const path31 = formatIssuePath(first?.path);
3459
- const message = first ? `${path31}: ${first.message}` : "Schema validation failed";
3458
+ const path32 = formatIssuePath(first?.path);
3459
+ const message = first ? `${path32}: ${first.message}` : "Schema validation failed";
3460
3460
  return new _TwError("validation", "SCHEMA_VALIDATION_FAILED", message, err);
3461
3461
  }
3462
3462
  static wrap(source, code, err) {
@@ -4013,12 +4013,12 @@ var init_schemas = __esm({
4013
4013
  init_cjs_shims();
4014
4014
  import_zod = require("zod");
4015
4015
  init_src();
4016
- formatIssuePath2 = (path31) => path31.length > 0 ? path31.map(
4016
+ formatIssuePath2 = (path32) => path32.length > 0 ? path32.map(
4017
4017
  (segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
4018
4018
  ).join(".") : "<root>";
4019
4019
  formatIssues = (error) => error.issues.map((issue) => {
4020
- const path31 = formatIssuePath2(issue.path);
4021
- return `${path31}: ${issue.message}`;
4020
+ const path32 = formatIssuePath2(issue.path);
4021
+ return `${path32}: ${issue.message}`;
4022
4022
  }).join("; ");
4023
4023
  parseWithSchema = (schema, data, label) => {
4024
4024
  const parsed = schema.safeParse(data);
@@ -4624,7 +4624,7 @@ var init_schemas2 = __esm({
4624
4624
  init_cjs_shims();
4625
4625
  init_src();
4626
4626
  import_zod2 = require("zod");
4627
- formatIssuePath3 = (path31) => path31.length > 0 ? path31.map(
4627
+ formatIssuePath3 = (path32) => path32.length > 0 ? path32.map(
4628
4628
  (segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
4629
4629
  ).join(".") : "<root>";
4630
4630
  isPlainObject = (value) => {
@@ -4633,8 +4633,8 @@ var init_schemas2 = __esm({
4633
4633
  return proto === Object.prototype || proto === null;
4634
4634
  };
4635
4635
  formatIssues2 = (error) => error.issues.map((issue) => {
4636
- const path31 = formatIssuePath3(issue.path);
4637
- return `${path31}: ${issue.message}`;
4636
+ const path32 = formatIssuePath3(issue.path);
4637
+ return `${path32}: ${issue.message}`;
4638
4638
  }).join("; ");
4639
4639
  parseWithSchema2 = (schema, data, label) => {
4640
4640
  const parsed = schema.safeParse(data);
@@ -6254,7 +6254,7 @@ var init_nativeBridge = __esm({
6254
6254
  "use strict";
6255
6255
  init_cjs_shims();
6256
6256
  init_src();
6257
- _loadNative = (path31) => require(path31);
6257
+ _loadNative = (path32) => require(path32);
6258
6258
  log3 = (...args) => {
6259
6259
  if (process.env.DEBUG?.includes("compiler:native")) {
6260
6260
  console.log("[compiler:native]", ...args);
@@ -6397,24 +6397,24 @@ var init_watch = __esm({
6397
6397
  });
6398
6398
 
6399
6399
  // packages/domain/compiler/src/routeGraph.ts
6400
- var import_node_fs9, import_node_path24;
6400
+ var import_node_fs10, import_node_path25;
6401
6401
  var init_routeGraph = __esm({
6402
6402
  "packages/domain/compiler/src/routeGraph.ts"() {
6403
6403
  "use strict";
6404
6404
  init_cjs_shims();
6405
- import_node_fs9 = __toESM(require("fs"), 1);
6406
- import_node_path24 = __toESM(require("path"), 1);
6405
+ import_node_fs10 = __toESM(require("fs"), 1);
6406
+ import_node_path25 = __toESM(require("path"), 1);
6407
6407
  }
6408
6408
  });
6409
6409
 
6410
6410
  // packages/domain/compiler/src/index.ts
6411
- var import_node_fs10, import_node_path25, import_node_module4, _require3, compileCssFromClasses;
6411
+ var import_node_fs11, import_node_path26, import_node_module4, _require3, compileCssFromClasses;
6412
6412
  var init_src4 = __esm({
6413
6413
  "packages/domain/compiler/src/index.ts"() {
6414
6414
  "use strict";
6415
6415
  init_cjs_shims();
6416
- import_node_fs10 = __toESM(require("fs"), 1);
6417
- import_node_path25 = __toESM(require("path"), 1);
6416
+ import_node_fs11 = __toESM(require("fs"), 1);
6417
+ import_node_path26 = __toESM(require("path"), 1);
6418
6418
  import_node_module4 = require("module");
6419
6419
  init_nativeBridge();
6420
6420
  init_compiler();
@@ -6459,6 +6459,7 @@ var init_internal = __esm({
6459
6459
  // src/umbrella/cli.ts
6460
6460
  var cli_exports = {};
6461
6461
  __export(cli_exports, {
6462
+ buildMainProgram: () => buildMainProgram,
6462
6463
  createCliOutput: () => createCliOutput,
6463
6464
  ensureFlag: () => ensureFlag,
6464
6465
  parseCliArgs: () => parseCliInput,
@@ -8738,9 +8739,281 @@ function printDoctorOutput(result, output) {
8738
8739
  );
8739
8740
  }
8740
8741
 
8741
- // packages/infrastructure/cli/src/commands/misc.ts
8742
+ // packages/infrastructure/cli/src/commands/figma.ts
8742
8743
  init_cjs_shims();
8744
+ var import_node_fs9 = __toESM(require("fs"), 1);
8743
8745
  var import_node_path23 = __toESM(require("path"), 1);
8746
+ init_errors();
8747
+
8748
+ // packages/infrastructure/cli/src/utils/figmaApi.ts
8749
+ init_cjs_shims();
8750
+ async function figmaRequest(endpoint, options) {
8751
+ const { token, fileKey } = options;
8752
+ if (!token) {
8753
+ throw new Error("FIGMA_TOKEN environment variable not set");
8754
+ }
8755
+ if (!fileKey) {
8756
+ throw new Error("FIGMA_FILE_KEY environment variable not set");
8757
+ }
8758
+ const url = `https://api.figma.com/v1${endpoint.replace(":fileKey", fileKey)}`;
8759
+ const res = await fetch(url, {
8760
+ headers: { "X-Figma-Token": token }
8761
+ });
8762
+ if (!res.ok) {
8763
+ const body = await res.text();
8764
+ throw new Error(`Figma API ${res.status}: ${body.slice(0, 200)}`);
8765
+ }
8766
+ return res.json();
8767
+ }
8768
+ function figmaColorToHex(color) {
8769
+ const { r, g, b, a = 1 } = color;
8770
+ const toHex = (v) => Math.round(v * 255).toString(16).padStart(2, "0");
8771
+ const hex = `#${toHex(r)}${toHex(g)}${toHex(b)}`;
8772
+ return a < 1 ? `${hex}${toHex(a)}` : hex;
8773
+ }
8774
+ function figmaVariablesToTokens(variablesData) {
8775
+ const tokens = {};
8776
+ const { variables = {}, variableCollections = {} } = variablesData;
8777
+ for (const [id, variable] of Object.entries(variables)) {
8778
+ const collection = variableCollections[variable.variableCollectionId];
8779
+ if (!collection) continue;
8780
+ const modeId = Object.keys(variable.valuesByMode)[0];
8781
+ const rawValue = variable.valuesByMode[modeId];
8782
+ if (rawValue === void 0) continue;
8783
+ const parts = variable.name.split("/").map(
8784
+ (p) => p.toLowerCase().replace(/[^a-z0-9]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "")
8785
+ );
8786
+ let cursor = tokens;
8787
+ for (let i = 0; i < parts.length - 1; i++) {
8788
+ cursor[parts[i]] ??= {};
8789
+ cursor = cursor[parts[i]];
8790
+ }
8791
+ const leafKey = parts[parts.length - 1];
8792
+ if (variable.resolvedType === "COLOR") {
8793
+ cursor[leafKey] = {
8794
+ $value: typeof rawValue === "object" && "r" in rawValue ? figmaColorToHex(rawValue) : String(rawValue),
8795
+ $type: "color",
8796
+ $description: variable.description || void 0,
8797
+ _figmaId: id
8798
+ };
8799
+ } else if (variable.resolvedType === "FLOAT") {
8800
+ cursor[leafKey] = {
8801
+ $value: typeof rawValue === "number" ? `${rawValue}px` : String(rawValue),
8802
+ $type: "dimension",
8803
+ _figmaId: id
8804
+ };
8805
+ } else if (variable.resolvedType === "STRING") {
8806
+ cursor[leafKey] = {
8807
+ $value: String(rawValue),
8808
+ $type: "other",
8809
+ _figmaId: id
8810
+ };
8811
+ }
8812
+ }
8813
+ return tokens;
8814
+ }
8815
+
8816
+ // packages/infrastructure/cli/src/utils/tokenUtils.ts
8817
+ init_cjs_shims();
8818
+ function tokensToFigmaUpdates(tokens, existingVariables = {}) {
8819
+ const updates = [];
8820
+ function walk(obj, path32 = []) {
8821
+ for (const [key, val] of Object.entries(obj)) {
8822
+ if (val.$value !== void 0) {
8823
+ const name = path32.concat(key).map(
8824
+ (p) => p.split("-").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join("")
8825
+ ).join("/");
8826
+ const existing = Object.values(existingVariables).find(
8827
+ (v) => v.name === name
8828
+ );
8829
+ if (existing) {
8830
+ updates.push({
8831
+ id: existing.id,
8832
+ name,
8833
+ value: val.$value,
8834
+ type: val.$type
8835
+ });
8836
+ }
8837
+ } else if (typeof val === "object" && !val.$type) {
8838
+ walk(val, path32.concat(key));
8839
+ }
8840
+ }
8841
+ }
8842
+ walk(tokens);
8843
+ return updates;
8844
+ }
8845
+ function flattenTokens(obj, prefix = "", target = {}) {
8846
+ for (const [k, v] of Object.entries(obj)) {
8847
+ const key = [prefix, k].filter(Boolean).join(".");
8848
+ if (v.$value !== void 0) {
8849
+ target[key] = v.$value;
8850
+ } else if (typeof v === "object" && !v.$type) {
8851
+ flattenTokens(v, key, target);
8852
+ }
8853
+ }
8854
+ return target;
8855
+ }
8856
+ function diffTokens(local, figma) {
8857
+ const allKeys = /* @__PURE__ */ new Set([...Object.keys(local), ...Object.keys(figma)]);
8858
+ const diffs = [];
8859
+ for (const key of allKeys) {
8860
+ if (local[key] !== figma[key]) {
8861
+ diffs.push({
8862
+ key,
8863
+ local: local[key],
8864
+ figma: figma[key]
8865
+ });
8866
+ }
8867
+ }
8868
+ return diffs;
8869
+ }
8870
+
8871
+ // packages/infrastructure/cli/src/commands/figma.ts
8872
+ var figmaCommand = {
8873
+ name: "figma",
8874
+ async run(args, context) {
8875
+ const cmd = args[0];
8876
+ const isDryRun = args.includes("--dry-run");
8877
+ const FIGMA_TOKEN = process.env.FIGMA_TOKEN;
8878
+ const FIGMA_FILE_KEY = process.env.FIGMA_FILE_KEY;
8879
+ const TOKEN_FILE = import_node_path23.default.join(context.cwd, "tokens.sync.json");
8880
+ if (!cmd || cmd === "help") {
8881
+ context.output.log(`Usage: tw figma <pull|push|diff> [--dry-run]
8882
+
8883
+ Environment variables:
8884
+ FIGMA_TOKEN \u2014 Figma personal access token (figd_...)
8885
+ FIGMA_FILE_KEY \u2014 Figma file key (from URL: figma.com/file/<KEY>/...)
8886
+
8887
+ Commands:
8888
+ pull Import Figma variables \u2192 tokens.sync.json
8889
+ push Export tokens.sync.json \u2192 Figma variables
8890
+ diff Show differences between local and Figma
8891
+
8892
+ Options:
8893
+ --dry-run Show what would change without writing`);
8894
+ return;
8895
+ }
8896
+ if (cmd === "pull") {
8897
+ if (!FIGMA_TOKEN || !FIGMA_FILE_KEY) {
8898
+ throw new CliUsageError(
8899
+ "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"
8900
+ );
8901
+ }
8902
+ try {
8903
+ context.output.status("[figma] Fetching Figma variables...");
8904
+ const data = await figmaRequest("/files/:fileKey/variables/local", {
8905
+ token: FIGMA_TOKEN,
8906
+ fileKey: FIGMA_FILE_KEY
8907
+ });
8908
+ const tokens = figmaVariablesToTokens(data);
8909
+ const variableCount = Object.values(data.variables ?? {}).length;
8910
+ if (isDryRun) {
8911
+ context.output.log("[figma] DRY RUN \u2014 would write:");
8912
+ context.output.log(JSON.stringify({ version: 1, tokens }, null, 2));
8913
+ } else {
8914
+ let existing = { version: 1, tokens: {} };
8915
+ if (import_node_fs9.default.existsSync(TOKEN_FILE)) {
8916
+ try {
8917
+ existing = JSON.parse(import_node_fs9.default.readFileSync(TOKEN_FILE, "utf8"));
8918
+ } catch {
8919
+ }
8920
+ }
8921
+ const merged = {
8922
+ ...existing,
8923
+ tokens: { ...existing.tokens, ...tokens },
8924
+ figmaFileKey: FIGMA_FILE_KEY,
8925
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
8926
+ source: "figma"
8927
+ };
8928
+ import_node_fs9.default.writeFileSync(TOKEN_FILE, JSON.stringify(merged, null, 2) + "\n");
8929
+ context.output.success(
8930
+ `Pulled ${variableCount} variables from Figma \u2192 ${TOKEN_FILE}`
8931
+ );
8932
+ }
8933
+ } catch (e) {
8934
+ throw new CliUsageError(
8935
+ `Pull failed: ${e instanceof Error ? e.message : String(e)}`
8936
+ );
8937
+ }
8938
+ } else if (cmd === "push") {
8939
+ if (!FIGMA_TOKEN || !FIGMA_FILE_KEY) {
8940
+ throw new CliUsageError("Missing FIGMA_TOKEN or FIGMA_FILE_KEY");
8941
+ }
8942
+ if (!import_node_fs9.default.existsSync(TOKEN_FILE)) {
8943
+ throw new CliUsageError(
8944
+ `${TOKEN_FILE} not found. Run 'tw sync init' first.`
8945
+ );
8946
+ }
8947
+ try {
8948
+ const local = JSON.parse(import_node_fs9.default.readFileSync(TOKEN_FILE, "utf8"));
8949
+ const data = await figmaRequest("/files/:fileKey/variables/local", {
8950
+ token: FIGMA_TOKEN,
8951
+ fileKey: FIGMA_FILE_KEY
8952
+ });
8953
+ const updates = tokensToFigmaUpdates(local.tokens ?? {}, data.variables ?? {});
8954
+ if (isDryRun) {
8955
+ context.output.log(
8956
+ `[figma] DRY RUN \u2014 would update ${updates.length} variables in Figma:`
8957
+ );
8958
+ updates.forEach((u) => context.output.log(` ${u.name}: ${u.value}`));
8959
+ } else {
8960
+ if (updates.length === 0) {
8961
+ context.output.log("[figma] No matching variables to update");
8962
+ } else {
8963
+ context.output.success(`Updated ${updates.length} variables in Figma`);
8964
+ }
8965
+ }
8966
+ } catch (e) {
8967
+ throw new CliUsageError(
8968
+ `Push failed: ${e instanceof Error ? e.message : String(e)}`
8969
+ );
8970
+ }
8971
+ } else if (cmd === "diff") {
8972
+ if (!FIGMA_TOKEN || !FIGMA_FILE_KEY) {
8973
+ throw new CliUsageError("Missing FIGMA_TOKEN or FIGMA_FILE_KEY");
8974
+ }
8975
+ if (!import_node_fs9.default.existsSync(TOKEN_FILE)) {
8976
+ throw new CliUsageError("tokens.sync.json not found");
8977
+ }
8978
+ try {
8979
+ const [local, figmaData] = await Promise.all([
8980
+ JSON.parse(import_node_fs9.default.readFileSync(TOKEN_FILE, "utf8")),
8981
+ figmaRequest("/files/:fileKey/variables/local", {
8982
+ token: FIGMA_TOKEN,
8983
+ fileKey: FIGMA_FILE_KEY
8984
+ })
8985
+ ]);
8986
+ const figmaTokens = figmaVariablesToTokens(figmaData);
8987
+ const figmaFlat = {};
8988
+ const localFlat = {};
8989
+ flattenTokens(local.tokens ?? {}, "", localFlat);
8990
+ flattenTokens(figmaTokens, "", figmaFlat);
8991
+ const diffs = diffTokens(localFlat, figmaFlat);
8992
+ if (diffs.length === 0) {
8993
+ context.output.success("No differences \u2014 local and Figma are in sync");
8994
+ } else {
8995
+ context.output.log(`${diffs.length} differences found:
8996
+ `);
8997
+ diffs.forEach((d) => {
8998
+ context.output.log(` ${d.key}`);
8999
+ context.output.log(` local: ${d.local ?? "(missing)"}`);
9000
+ context.output.log(` figma: ${d.figma ?? "(missing)"}`);
9001
+ });
9002
+ }
9003
+ } catch (e) {
9004
+ throw new CliUsageError(
9005
+ `Diff failed: ${e instanceof Error ? e.message : String(e)}`
9006
+ );
9007
+ }
9008
+ } else {
9009
+ throw new CliUsageError(`Unknown command: ${cmd}`);
9010
+ }
9011
+ }
9012
+ };
9013
+
9014
+ // packages/infrastructure/cli/src/commands/misc.ts
9015
+ init_cjs_shims();
9016
+ var import_node_path24 = __toESM(require("path"), 1);
8744
9017
  var import_node_util9 = require("util");
8745
9018
  init_errors();
8746
9019
  init_fs();
@@ -8773,7 +9046,7 @@ var shareCommand = {
8773
9046
  name: "share",
8774
9047
  async run(args, context) {
8775
9048
  const name = args.find((arg) => !arg.startsWith("-")) ?? "component-name";
8776
- const manifestPath = import_node_path23.default.join(process.cwd(), ".tw-cache", "deploy-manifest.json");
9049
+ const manifestPath = import_node_path24.default.join(process.cwd(), ".tw-cache", "deploy-manifest.json");
8777
9050
  const defaultManifest = {
8778
9051
  name,
8779
9052
  version: "0.1.0"
@@ -8859,14 +9132,14 @@ var isVersionOutdated = (currentVersion, latestVersion) => {
8859
9132
  };
8860
9133
  var resolveCurrentCliVersion = async (context) => {
8861
9134
  const candidates = [
8862
- import_node_path23.default.resolve(context.runtimeDir, "..", "package.json"),
8863
- import_node_path23.default.resolve(process.cwd(), "packages", "cli", "package.json"),
8864
- import_node_path23.default.resolve(process.cwd(), "package.json")
9135
+ import_node_path24.default.resolve(context.runtimeDir, "..", "package.json"),
9136
+ import_node_path24.default.resolve(process.cwd(), "packages", "cli", "package.json"),
9137
+ import_node_path24.default.resolve(process.cwd(), "package.json")
8865
9138
  ];
8866
9139
  for (const candidate of candidates) {
8867
9140
  if (!await pathExists2(candidate)) continue;
8868
9141
  const pkg = await readJsonSafe(candidate);
8869
- 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}`));
9142
+ 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}`));
8870
9143
  if (isCliPackage) return pkg.version ?? "0.0.0";
8871
9144
  }
8872
9145
  return "0.0.0";
@@ -9109,7 +9382,7 @@ init_cjs_shims();
9109
9382
 
9110
9383
  // packages/infrastructure/cli/src/preflight.ts
9111
9384
  init_cjs_shims();
9112
- var import_node_path26 = __toESM(require("path"), 1);
9385
+ var import_node_path27 = __toESM(require("path"), 1);
9113
9386
  var import_node_url7 = require("url");
9114
9387
  init_args();
9115
9388
  init_errors();
@@ -9142,8 +9415,8 @@ async function validateThemeConfig(cwd2) {
9142
9415
  const twConfigFiles = ["tailwind.config.ts", "tailwind.config.js", "tailwind.config.mjs"];
9143
9416
  let configPath = null;
9144
9417
  for (const file of twConfigFiles) {
9145
- if (await pathExists2(import_node_path26.default.join(cwd2, file))) {
9146
- configPath = import_node_path26.default.join(cwd2, file);
9418
+ if (await pathExists2(import_node_path27.default.join(cwd2, file))) {
9419
+ configPath = import_node_path27.default.join(cwd2, file);
9147
9420
  break;
9148
9421
  }
9149
9422
  }
@@ -9234,7 +9507,7 @@ function resolveCliEntry(scriptPath) {
9234
9507
  async function hasTailwindCssImport(cwd2) {
9235
9508
  const cssFiles = ["src/app/globals.css", "src/index.css", "src/style.css", "app/globals.css"];
9236
9509
  for (const file of cssFiles) {
9237
- const raw = await readFileSafe(import_node_path26.default.join(cwd2, file));
9510
+ const raw = await readFileSafe(import_node_path27.default.join(cwd2, file));
9238
9511
  if (raw?.includes("tailwindcss")) return true;
9239
9512
  }
9240
9513
  return false;
@@ -9250,7 +9523,7 @@ async function hasSafelistSource(cwd2) {
9250
9523
  "app/globals.css"
9251
9524
  ];
9252
9525
  for (const file of cssFiles) {
9253
- const raw = await readFileSafe(import_node_path26.default.join(cwd2, file));
9526
+ const raw = await readFileSafe(import_node_path27.default.join(cwd2, file));
9254
9527
  if (raw === null) continue;
9255
9528
  if (raw.includes("tw-classes")) return { found: true, cssFile: file };
9256
9529
  if (raw.includes("tailwindcss")) return { found: false, cssFile: file };
@@ -9258,8 +9531,8 @@ async function hasSafelistSource(cwd2) {
9258
9531
  return { found: false, cssFile: null };
9259
9532
  }
9260
9533
  async function applyTailwindInit(cwd2) {
9261
- await ensureFileSafe(import_node_path26.default.join(cwd2, "src", "tailwind.css"), DEFAULT_TAILWIND_CSS2);
9262
- await ensureFileSafe(import_node_path26.default.join(cwd2, "tailwind-styled.config.json"), DEFAULT_TW_CONFIG);
9534
+ await ensureFileSafe(import_node_path27.default.join(cwd2, "src", "tailwind.css"), DEFAULT_TAILWIND_CSS2);
9535
+ await ensureFileSafe(import_node_path27.default.join(cwd2, "tailwind-styled.config.json"), DEFAULT_TW_CONFIG);
9263
9536
  }
9264
9537
  function check(results, id, label, pass, message, fix) {
9265
9538
  results.push({ id, label, pass, message, fix });
@@ -9281,7 +9554,7 @@ async function runPreflightCli(rawArgs) {
9281
9554
  node.major >= 20 ? `Node ${node.full} OK` : `Node ${node.full} - requires >=20. Download: https://nodejs.org`,
9282
9555
  node.major < 20 ? "Install Node.js 20 LTS or newer from https://nodejs.org" : void 0
9283
9556
  );
9284
- const pkg = await readJsonSafe(import_node_path26.default.join(cwd2, "package.json"));
9557
+ const pkg = await readJsonSafe(import_node_path27.default.join(cwd2, "package.json"));
9285
9558
  check(
9286
9559
  results,
9287
9560
  "package-json",
@@ -9315,7 +9588,7 @@ async function runPreflightCli(rawArgs) {
9315
9588
  }
9316
9589
  const twConfigFiles = ["tailwind.config.ts", "tailwind.config.js", "tailwind.config.mjs"];
9317
9590
  const twConfigChecks = await Promise.all(
9318
- twConfigFiles.map(async (file) => ({ file, exists: await pathExists2(import_node_path26.default.join(cwd2, file)) }))
9591
+ twConfigFiles.map(async (file) => ({ file, exists: await pathExists2(import_node_path27.default.join(cwd2, file)) }))
9319
9592
  );
9320
9593
  const foundTwConfig = twConfigChecks.find((item) => item.exists)?.file ?? null;
9321
9594
  const hasCssConfig = await hasTailwindCssImport(cwd2);
@@ -9327,7 +9600,7 @@ async function runPreflightCli(rawArgs) {
9327
9600
  foundTwConfig ? `${foundTwConfig} found OK` : hasCssConfig ? "@import tailwindcss found in CSS OK" : "No Tailwind config found - run: tw init",
9328
9601
  "tw init"
9329
9602
  );
9330
- const oldConfig = await readJsonSafe(import_node_path26.default.join(cwd2, "tailwind.config.js")) ?? await readJsonSafe(import_node_path26.default.join(cwd2, "tailwind.config.ts"));
9603
+ const oldConfig = await readJsonSafe(import_node_path27.default.join(cwd2, "tailwind.config.js")) ?? await readJsonSafe(import_node_path27.default.join(cwd2, "tailwind.config.ts"));
9331
9604
  if (oldConfig) {
9332
9605
  const hasOldJit = oldConfig.mode === "jit";
9333
9606
  const hasOldPurge = "purge" in oldConfig;
@@ -9351,7 +9624,7 @@ async function runPreflightCli(rawArgs) {
9351
9624
  validation.message
9352
9625
  );
9353
9626
  }
9354
- const hasTsConfig = await pathExists2(import_node_path26.default.join(cwd2, "tsconfig.json"));
9627
+ const hasTsConfig = await pathExists2(import_node_path27.default.join(cwd2, "tsconfig.json"));
9355
9628
  check(
9356
9629
  results,
9357
9630
  "typescript",
@@ -9710,7 +9983,7 @@ var scriptCommands = [
9710
9983
 
9711
9984
  // packages/infrastructure/cli/src/commands/storybook.ts
9712
9985
  init_cjs_shims();
9713
- var import_node_path27 = __toESM(require("path"), 1);
9986
+ var import_node_path28 = __toESM(require("path"), 1);
9714
9987
  var import_node_util11 = require("util");
9715
9988
  init_errors();
9716
9989
  init_fs();
@@ -9752,7 +10025,7 @@ var storybookCommand = {
9752
10025
  context.output.writeText(
9753
10026
  `[tw storybook] Tip: use --variants='{"size":["sm","lg"]}' to enumerate variant combinations`
9754
10027
  );
9755
- const localBin = import_node_path27.default.join(
10028
+ const localBin = import_node_path28.default.join(
9756
10029
  process.cwd(),
9757
10030
  "node_modules",
9758
10031
  ".bin",
@@ -10938,12 +11211,12 @@ async function traceClass(className, options) {
10938
11211
 
10939
11212
  // packages/infrastructure/cli/src/utils/traceTargetService.ts
10940
11213
  init_cjs_shims();
10941
- var import_node_fs11 = __toESM(require("fs"), 1);
10942
- var import_node_path28 = __toESM(require("path"), 1);
11214
+ var import_node_fs12 = __toESM(require("fs"), 1);
11215
+ var import_node_path29 = __toESM(require("path"), 1);
10943
11216
  init_internal();
10944
11217
  init_src2();
10945
11218
  function toRelativePath(root, value) {
10946
- const relative = import_node_path28.default.relative(root, value);
11219
+ const relative = import_node_path29.default.relative(root, value);
10947
11220
  return relative.length > 0 ? relative : ".";
10948
11221
  }
10949
11222
  function uniqueSorted(values) {
@@ -11012,7 +11285,7 @@ function tryCompileClasses(classes) {
11012
11285
  }
11013
11286
  }
11014
11287
  function traceSingleFile(filePath, root) {
11015
- const source = import_node_fs11.default.readFileSync(filePath, "utf8");
11288
+ const source = import_node_fs12.default.readFileSync(filePath, "utf8");
11016
11289
  const classes = uniqueSorted(scanSource(source));
11017
11290
  const imports = extractImports(source);
11018
11291
  const compiled = tryCompileClasses(classes);
@@ -11043,7 +11316,7 @@ function traceDirectory(targetDir, root) {
11043
11316
  const imports = [];
11044
11317
  const importKeys = /* @__PURE__ */ new Set();
11045
11318
  const files = scanResult.files.filter((entry) => isScannableFile2(entry.file, DEFAULT_EXTENSIONS)).map((entry) => {
11046
- const source = import_node_fs11.default.readFileSync(entry.file, "utf8");
11319
+ const source = import_node_fs12.default.readFileSync(entry.file, "utf8");
11047
11320
  const fileImports = extractImports(source);
11048
11321
  for (const fileImport of fileImports) {
11049
11322
  const key = `${fileImport.kind}:${fileImport.source}`;
@@ -11074,12 +11347,12 @@ function traceDirectory(targetDir, root) {
11074
11347
  };
11075
11348
  }
11076
11349
  async function traceTarget(target, options = {}) {
11077
- const root = import_node_path28.default.resolve(options.root ?? process.cwd());
11078
- const resolvedTarget = import_node_path28.default.resolve(root, target);
11079
- if (!import_node_fs11.default.existsSync(resolvedTarget)) {
11350
+ const root = import_node_path29.default.resolve(options.root ?? process.cwd());
11351
+ const resolvedTarget = import_node_path29.default.resolve(root, target);
11352
+ if (!import_node_fs12.default.existsSync(resolvedTarget)) {
11080
11353
  throw new Error(`Trace target not found: ${resolvedTarget}`);
11081
11354
  }
11082
- const stat = import_node_fs11.default.statSync(resolvedTarget);
11355
+ const stat = import_node_fs12.default.statSync(resolvedTarget);
11083
11356
  if (stat.isDirectory()) {
11084
11357
  return traceDirectory(resolvedTarget, root);
11085
11358
  }
@@ -11242,8 +11515,8 @@ function printClassTraceOutput(result, output) {
11242
11515
 
11243
11516
  // packages/infrastructure/cli/src/generateTypes.ts
11244
11517
  init_cjs_shims();
11245
- var import_node_fs12 = __toESM(require("fs"), 1);
11246
- var import_node_path29 = __toESM(require("path"), 1);
11518
+ var import_node_fs13 = __toESM(require("fs"), 1);
11519
+ var import_node_path30 = __toESM(require("path"), 1);
11247
11520
  var import_picocolors6 = __toESM(require_picocolors(), 1);
11248
11521
  init_output();
11249
11522
  async function runGenerateTypesCli(rawArgs) {
@@ -11251,7 +11524,7 @@ async function runGenerateTypesCli(rawArgs) {
11251
11524
  const logger = createCliLogger({ output });
11252
11525
  const cwd2 = process.cwd();
11253
11526
  const outFile = rawArgs.find((a) => a.startsWith("--out="))?.slice(6) ?? "src/types/tailwind-styled.d.ts";
11254
- const outPath = import_node_path29.default.resolve(cwd2, outFile);
11527
+ const outPath = import_node_path30.default.resolve(cwd2, outFile);
11255
11528
  output.writeText("");
11256
11529
  output.writeText(import_picocolors6.default.bold(import_picocolors6.default.cyan(" \u25C6 tw generate-types")));
11257
11530
  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"));
@@ -11287,12 +11560,12 @@ async function runGenerateTypesCli(rawArgs) {
11287
11560
  }
11288
11561
  output.writeText("");
11289
11562
  output.writeText(import_picocolors6.default.bold(" [2/2]") + import_picocolors6.default.cyan(" generate .d.ts"));
11290
- const outDir = import_node_path29.default.dirname(outPath);
11291
- if (!import_node_fs12.default.existsSync(outDir)) {
11292
- import_node_fs12.default.mkdirSync(outDir, { recursive: true });
11563
+ const outDir = import_node_path30.default.dirname(outPath);
11564
+ if (!import_node_fs13.default.existsSync(outDir)) {
11565
+ import_node_fs13.default.mkdirSync(outDir, { recursive: true });
11293
11566
  }
11294
- import_node_fs12.default.writeFileSync(outPath, result.dtsContent, "utf-8");
11295
- logger.ok(import_node_path29.default.relative(cwd2, outPath));
11567
+ import_node_fs13.default.writeFileSync(outPath, result.dtsContent, "utf-8");
11568
+ logger.ok(import_node_path30.default.relative(cwd2, outPath));
11296
11569
  output.writeText("");
11297
11570
  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"));
11298
11571
  output.writeText(import_picocolors6.default.bold(import_picocolors6.default.green(" \u2713 types generated")));
@@ -11303,11 +11576,11 @@ async function runGenerateTypesCli(rawArgs) {
11303
11576
  }
11304
11577
  async function loadNativeBinding2(cwd2) {
11305
11578
  const candidates = [
11306
- import_node_path29.default.join(cwd2, "native", "tailwind-styled-native.node"),
11307
- import_node_path29.default.join(cwd2, "node_modules", "tailwind-styled-v4", "native", "tailwind-styled-native.node")
11579
+ import_node_path30.default.join(cwd2, "native", "tailwind-styled-native.node"),
11580
+ import_node_path30.default.join(cwd2, "node_modules", "tailwind-styled-v4", "native", "tailwind-styled-native.node")
11308
11581
  ];
11309
11582
  for (const candidate of candidates) {
11310
- if (import_node_fs12.default.existsSync(candidate)) {
11583
+ if (import_node_fs13.default.existsSync(candidate)) {
11311
11584
  try {
11312
11585
  return require(candidate);
11313
11586
  } catch {
@@ -11324,8 +11597,8 @@ init_errors();
11324
11597
 
11325
11598
  // packages/infrastructure/cli/src/utils/whyService.ts
11326
11599
  init_cjs_shims();
11327
- var import_node_fs13 = __toESM(require("fs"), 1);
11328
- var import_node_path30 = __toESM(require("path"), 1);
11600
+ var import_node_fs14 = __toESM(require("fs"), 1);
11601
+ var import_node_path31 = __toESM(require("path"), 1);
11329
11602
  init_internal();
11330
11603
  init_src2();
11331
11604
  function extractVariantChain(usage) {
@@ -11374,7 +11647,7 @@ async function whyClass(className, options) {
11374
11647
  for (const file of scanResult.files) {
11375
11648
  const source = (() => {
11376
11649
  try {
11377
- return import_node_fs13.default.readFileSync(file.file, "utf8");
11650
+ return import_node_fs14.default.readFileSync(file.file, "utf8");
11378
11651
  } catch {
11379
11652
  return "";
11380
11653
  }
@@ -11388,7 +11661,7 @@ async function whyClass(className, options) {
11388
11661
  className
11389
11662
  ]);
11390
11663
  usedIn.push({
11391
- file: import_node_path30.default.relative(root, file.file) || import_node_path30.default.basename(file.file),
11664
+ file: import_node_path31.default.relative(root, file.file) || import_node_path31.default.basename(file.file),
11392
11665
  line: location.line,
11393
11666
  column: location.column,
11394
11667
  usage: normalizeScannedClass(fileClass)
@@ -11695,6 +11968,12 @@ function buildMainProgram(context) {
11695
11968
  );
11696
11969
  });
11697
11970
  });
11971
+ const figmaTopLevel = program2.command("figma").description("Figma design token sync");
11972
+ ["pull", "push", "diff"].forEach((subcommand) => {
11973
+ figmaTopLevel.command(`${subcommand} [args...]`).description(`Figma ${subcommand}`).allowUnknownOption(true).action(async (args) => {
11974
+ await figmaCommand.run(contextArgs([subcommand, ...toVariadic(args)], context), context);
11975
+ });
11976
+ });
11698
11977
  program2.command("test").description("Test shortcut wrapper").option("--watch", "Watch mode").action(async (...actionArgs) => {
11699
11978
  const options = actionCommand(actionArgs).opts();
11700
11979
  const args = [];
@@ -11858,6 +12137,7 @@ if (process.argv[1] === __currentFile) {
11858
12137
  }
11859
12138
  // Annotate the CommonJS export names for ESM import in node:
11860
12139
  0 && (module.exports = {
12140
+ buildMainProgram,
11861
12141
  createCliOutput,
11862
12142
  ensureFlag,
11863
12143
  parseCliArgs,