rafters 0.0.61 → 0.0.62

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.
Files changed (2) hide show
  1. package/dist/index.js +134 -10
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,9 +1,80 @@
1
1
  #!/usr/bin/env node
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __commonJS = (cb, mod) => function __require() {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ };
3
11
  var __export = (target, all) => {
4
12
  for (var name in all)
5
13
  __defProp(target, name, { get: all[name], enumerable: true });
6
14
  };
15
+ var __copyProps = (to2, from, except, desc) => {
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (let key of __getOwnPropNames(from))
18
+ if (!__hasOwnProp.call(to2, key) && key !== except)
19
+ __defProp(to2, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
+ }
21
+ return to2;
22
+ };
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
+ // If the importer is in node compatibility mode or this is not an ESM
25
+ // file that has been converted to a CommonJS file using a Babel-
26
+ // compatible transform (i.e. "__esModule" has not been set), then set
27
+ // "default" to the CommonJS "module.exports" for node compatibility.
28
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
+ mod
30
+ ));
31
+
32
+ // ../../node_modules/.pnpm/escape-html@1.0.3/node_modules/escape-html/index.js
33
+ var require_escape_html = __commonJS({
34
+ "../../node_modules/.pnpm/escape-html@1.0.3/node_modules/escape-html/index.js"(exports, module) {
35
+ "use strict";
36
+ var matchHtmlRegExp = /["'&<>]/;
37
+ module.exports = escapeHtml2;
38
+ function escapeHtml2(string4) {
39
+ var str = "" + string4;
40
+ var match = matchHtmlRegExp.exec(str);
41
+ if (!match) {
42
+ return str;
43
+ }
44
+ var escape;
45
+ var html = "";
46
+ var index = 0;
47
+ var lastIndex = 0;
48
+ for (index = match.index; index < str.length; index++) {
49
+ switch (str.charCodeAt(index)) {
50
+ case 34:
51
+ escape = "&quot;";
52
+ break;
53
+ case 38:
54
+ escape = "&amp;";
55
+ break;
56
+ case 39:
57
+ escape = "&#39;";
58
+ break;
59
+ case 60:
60
+ escape = "&lt;";
61
+ break;
62
+ case 62:
63
+ escape = "&gt;";
64
+ break;
65
+ default:
66
+ continue;
67
+ }
68
+ if (lastIndex !== index) {
69
+ html += str.substring(lastIndex, index);
70
+ }
71
+ lastIndex = index + 1;
72
+ html += escape;
73
+ }
74
+ return lastIndex !== index ? html + str.substring(lastIndex, index) : html;
75
+ }
76
+ }
77
+ });
7
78
 
8
79
  // src/index.ts
9
80
  import { Command } from "commander";
@@ -24612,14 +24683,25 @@ function colorRefToString(ref) {
24612
24683
  }
24613
24684
  function getSemanticMappingsFromTokens(semanticTokens) {
24614
24685
  const mappings = {};
24686
+ const tokensByName = /* @__PURE__ */ new Map();
24687
+ for (const t of semanticTokens) tokensByName.set(t.name, t);
24615
24688
  for (const token of semanticTokens) {
24616
24689
  const { name, value, dependsOn } = token;
24690
+ if (name.endsWith("--dark")) continue;
24617
24691
  if (typeof value !== "object" || value === null || !("family" in value)) {
24618
24692
  continue;
24619
24693
  }
24620
24694
  const colorRef = value;
24621
24695
  const lightRef = `${colorRef.family}-${colorRef.position}`;
24622
- const darkRef = dependsOn?.[1] ?? lightRef;
24696
+ let darkRef = lightRef;
24697
+ const darkTokenName = dependsOn?.[1];
24698
+ if (darkTokenName) {
24699
+ const darkToken = tokensByName.get(darkTokenName);
24700
+ if (darkToken?.value && typeof darkToken.value === "object" && "family" in darkToken.value) {
24701
+ const darkColorRef = darkToken.value;
24702
+ darkRef = `${darkColorRef.family}-${darkColorRef.position}`;
24703
+ }
24704
+ }
24623
24705
  mappings[name] = { light: lightRef, dark: darkRef };
24624
24706
  }
24625
24707
  for (const [name, mapping] of Object.entries(DEFAULT_SEMANTIC_COLOR_MAPPINGS)) {
@@ -27284,14 +27366,33 @@ function derivationToBinding(derivation) {
27284
27366
  };
27285
27367
  }
27286
27368
  }
27287
- function derivationParent(derivation) {
27369
+ function derivationParent(derivation, suffix = "") {
27288
27370
  switch (derivation.kind) {
27289
27371
  case "scale":
27290
27372
  return derivation.family;
27291
27373
  case "state":
27292
- return derivation.from;
27374
+ return `${derivation.from}${suffix}`;
27375
+ case "contrast":
27376
+ return `${derivation.against}${suffix}`;
27377
+ }
27378
+ }
27379
+ function deriveDarkBinding(derivation) {
27380
+ switch (derivation.kind) {
27381
+ case "scale":
27382
+ return {
27383
+ plugin: "invert",
27384
+ input: { familyName: derivation.family, basePosition: derivation.scalePosition }
27385
+ };
27386
+ case "state":
27387
+ return {
27388
+ plugin: "state",
27389
+ input: { from: `${derivation.from}--dark`, stateType: derivation.stateType }
27390
+ };
27293
27391
  case "contrast":
27294
- return derivation.against;
27392
+ return {
27393
+ plugin: "contrast",
27394
+ input: { against: `${derivation.against}--dark`, level: derivation.level }
27395
+ };
27295
27396
  }
27296
27397
  }
27297
27398
  function generateSemanticTokens(_config) {
@@ -27304,11 +27405,10 @@ function generateSemanticTokens(_config) {
27304
27405
  const derivation = deriveDerivation(name, lightRef, knownTokens);
27305
27406
  const binding = derivationToBinding(derivation);
27306
27407
  const parent = derivationParent(derivation);
27307
- const darkTokenName = `${darkRef.family}-${darkRef.position}`;
27308
- const dependsOn = [parent];
27309
- if (darkTokenName !== parent) {
27310
- dependsOn.push(darkTokenName);
27311
- }
27408
+ const darkName = `${name}--dark`;
27409
+ const darkBinding = deriveDarkBinding(derivation);
27410
+ const darkParent = derivationParent(derivation, "--dark");
27411
+ const dependsOn = [parent, darkName];
27312
27412
  tokens.push({
27313
27413
  name,
27314
27414
  value: lightRef,
@@ -27320,7 +27420,7 @@ function generateSemanticTokens(_config) {
27320
27420
  trustLevel: mapping.trustLevel,
27321
27421
  consequence: mapping.consequence,
27322
27422
  dependsOn,
27323
- description: `${mapping.meaning}. Light: ${lightRef.family}-${lightRef.position}, Dark: ${darkRef.family}-${darkRef.position}.`,
27423
+ description: `${mapping.meaning}. Light: ${lightRef.family}-${lightRef.position}.`,
27324
27424
  generatedAt: timestamp,
27325
27425
  containerQueryAware: true,
27326
27426
  userOverride: null,
@@ -27330,6 +27430,18 @@ function generateSemanticTokens(_config) {
27330
27430
  },
27331
27431
  requiresConfirmation: mapping.consequence === "destructive" || mapping.consequence === "permanent"
27332
27432
  });
27433
+ tokens.push({
27434
+ name: darkName,
27435
+ value: darkRef,
27436
+ category: "color",
27437
+ namespace: "semantic",
27438
+ binding: darkBinding,
27439
+ dependsOn: [darkParent],
27440
+ description: `Dark mode counterpart of ${name}.`,
27441
+ generatedAt: timestamp,
27442
+ containerQueryAware: true,
27443
+ userOverride: null
27444
+ });
27333
27445
  }
27334
27446
  return {
27335
27447
  namespace: "semantic",
@@ -29974,6 +30086,9 @@ function search(query) {
29974
30086
  }).filter((entry) => entry.score > 0).sort((a2, b2) => b2.score - a2.score).map((entry) => entry.c);
29975
30087
  }
29976
30088
 
30089
+ // ../composites/src/to-mdx.ts
30090
+ var import_escape_html = __toESM(require_escape_html(), 1);
30091
+
29977
30092
  // src/utils/workspaces.ts
29978
30093
  import { existsSync as existsSync5, readdirSync as readdirSync2, readFileSync as readFileSync2, statSync as statSync2 } from "fs";
29979
30094
  import { basename, dirname as dirname3, join as join9, resolve as resolve3 } from "path";
@@ -31344,6 +31459,15 @@ program.command("studio").description("Open Studio UI for visual token editing")
31344
31459
  program.parse();
31345
31460
  /*! Bundled license information:
31346
31461
 
31462
+ escape-html/index.js:
31463
+ (*!
31464
+ * escape-html
31465
+ * Copyright(c) 2012-2013 TJ Holowaychuk
31466
+ * Copyright(c) 2015 Andreas Lubbe
31467
+ * Copyright(c) 2015 Tiancheng "Timothy" Gu
31468
+ * MIT Licensed
31469
+ *)
31470
+
31347
31471
  colorparsley/src/colorparsley.js:
31348
31472
  (** @preserve
31349
31473
  ///// CoLoR PaRsLeY a simple set of color parsing thingies!
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rafters",
3
- "version": "0.0.61",
3
+ "version": "0.0.62",
4
4
  "description": "Design Intelligence CLI. Scaffold tokens, import existing shadcn/Tailwind v4 sources, add components, and serve an MCP server so AI agents read decisions instead of guessing.",
5
5
  "homepage": "https://rafters.studio",
6
6
  "license": "MIT",