rafters 0.0.60 → 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 +150 -36
  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";
@@ -12688,8 +12759,8 @@ var RegistryClient = class {
12688
12759
  return item;
12689
12760
  }
12690
12761
  /**
12691
- * Fetch a registry item (component or primitive) by name
12692
- * Tries component first, then primitive
12762
+ * Fetch a registry item by name
12763
+ * Tries component, then primitive, then composite
12693
12764
  */
12694
12765
  async fetchItem(name) {
12695
12766
  try {
@@ -12699,7 +12770,11 @@ var RegistryClient = class {
12699
12770
  try {
12700
12771
  return await this.fetchPrimitive(name);
12701
12772
  } catch {
12702
- throw err;
12773
+ try {
12774
+ return await this.fetchComposite(name);
12775
+ } catch {
12776
+ throw err;
12777
+ }
12703
12778
  }
12704
12779
  }
12705
12780
  throw err;
@@ -13635,26 +13710,6 @@ function selectFilesForFramework(files, target) {
13635
13710
  return { files, fallback: false };
13636
13711
  }
13637
13712
  var FOLDER_NAMES = /* @__PURE__ */ new Set(["composites"]);
13638
- var COMPOSITES_RUNTIME_CONTENT = `export { Composite, createComposites, toJsx, toMdx } from '@rafters/composites/client';
13639
- export type { CompositeProps, ToJsxOptions } from '@rafters/composites/client';
13640
- `;
13641
- function buildCompositesRuntimeItem() {
13642
- return {
13643
- name: "composites",
13644
- type: "composite",
13645
- primitives: [],
13646
- rules: [],
13647
- composites: [],
13648
- files: [
13649
- {
13650
- path: "composites/index.ts",
13651
- content: COMPOSITES_RUNTIME_CONTENT,
13652
- dependencies: ["@rafters/composites"],
13653
- devDependencies: []
13654
- }
13655
- ]
13656
- };
13657
- }
13658
13713
  function isAlreadyInstalled(config2, item) {
13659
13714
  if (!config2?.installed) return false;
13660
13715
  if (item.type === "ui") {
@@ -13848,7 +13903,7 @@ async function add(componentArgs, options) {
13848
13903
  components = installedNames;
13849
13904
  }
13850
13905
  if (folder === "composites" && components.length === 0) {
13851
- components = ["__composites_runtime__"];
13906
+ components = ["composites"];
13852
13907
  }
13853
13908
  if (components.length === 0) {
13854
13909
  error46("No components specified. Usage: rafters add <component...>");
@@ -13867,9 +13922,15 @@ async function add(componentArgs, options) {
13867
13922
  try {
13868
13923
  if (folder === "composites") {
13869
13924
  if (!seen.has(itemName)) {
13870
- const item = itemName === "__composites_runtime__" ? buildCompositesRuntimeItem() : await client.fetchComposite(itemName);
13925
+ const composite = await client.fetchComposite(itemName);
13871
13926
  seen.add(itemName);
13872
- allItems.push(item);
13927
+ allItems.push(composite);
13928
+ for (const dep of composite.primitives) {
13929
+ if (!seen.has(dep)) {
13930
+ const depItems = await client.resolveDependencies(dep, seen);
13931
+ allItems.push(...depItems);
13932
+ }
13933
+ }
13873
13934
  }
13874
13935
  } else {
13875
13936
  const items = await client.resolveDependencies(itemName, seen);
@@ -24622,14 +24683,25 @@ function colorRefToString(ref) {
24622
24683
  }
24623
24684
  function getSemanticMappingsFromTokens(semanticTokens) {
24624
24685
  const mappings = {};
24686
+ const tokensByName = /* @__PURE__ */ new Map();
24687
+ for (const t of semanticTokens) tokensByName.set(t.name, t);
24625
24688
  for (const token of semanticTokens) {
24626
24689
  const { name, value, dependsOn } = token;
24690
+ if (name.endsWith("--dark")) continue;
24627
24691
  if (typeof value !== "object" || value === null || !("family" in value)) {
24628
24692
  continue;
24629
24693
  }
24630
24694
  const colorRef = value;
24631
24695
  const lightRef = `${colorRef.family}-${colorRef.position}`;
24632
- 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
+ }
24633
24705
  mappings[name] = { light: lightRef, dark: darkRef };
24634
24706
  }
24635
24707
  for (const [name, mapping] of Object.entries(DEFAULT_SEMANTIC_COLOR_MAPPINGS)) {
@@ -27294,14 +27366,33 @@ function derivationToBinding(derivation) {
27294
27366
  };
27295
27367
  }
27296
27368
  }
27297
- function derivationParent(derivation) {
27369
+ function derivationParent(derivation, suffix = "") {
27298
27370
  switch (derivation.kind) {
27299
27371
  case "scale":
27300
27372
  return derivation.family;
27301
27373
  case "state":
27302
- 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
+ };
27303
27391
  case "contrast":
27304
- return derivation.against;
27392
+ return {
27393
+ plugin: "contrast",
27394
+ input: { against: `${derivation.against}--dark`, level: derivation.level }
27395
+ };
27305
27396
  }
27306
27397
  }
27307
27398
  function generateSemanticTokens(_config) {
@@ -27314,11 +27405,10 @@ function generateSemanticTokens(_config) {
27314
27405
  const derivation = deriveDerivation(name, lightRef, knownTokens);
27315
27406
  const binding = derivationToBinding(derivation);
27316
27407
  const parent = derivationParent(derivation);
27317
- const darkTokenName = `${darkRef.family}-${darkRef.position}`;
27318
- const dependsOn = [parent];
27319
- if (darkTokenName !== parent) {
27320
- dependsOn.push(darkTokenName);
27321
- }
27408
+ const darkName = `${name}--dark`;
27409
+ const darkBinding = deriveDarkBinding(derivation);
27410
+ const darkParent = derivationParent(derivation, "--dark");
27411
+ const dependsOn = [parent, darkName];
27322
27412
  tokens.push({
27323
27413
  name,
27324
27414
  value: lightRef,
@@ -27330,7 +27420,7 @@ function generateSemanticTokens(_config) {
27330
27420
  trustLevel: mapping.trustLevel,
27331
27421
  consequence: mapping.consequence,
27332
27422
  dependsOn,
27333
- description: `${mapping.meaning}. Light: ${lightRef.family}-${lightRef.position}, Dark: ${darkRef.family}-${darkRef.position}.`,
27423
+ description: `${mapping.meaning}. Light: ${lightRef.family}-${lightRef.position}.`,
27334
27424
  generatedAt: timestamp,
27335
27425
  containerQueryAware: true,
27336
27426
  userOverride: null,
@@ -27340,6 +27430,18 @@ function generateSemanticTokens(_config) {
27340
27430
  },
27341
27431
  requiresConfirmation: mapping.consequence === "destructive" || mapping.consequence === "permanent"
27342
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
+ });
27343
27445
  }
27344
27446
  return {
27345
27447
  namespace: "semantic",
@@ -29984,6 +30086,9 @@ function search(query) {
29984
30086
  }).filter((entry) => entry.score > 0).sort((a2, b2) => b2.score - a2.score).map((entry) => entry.c);
29985
30087
  }
29986
30088
 
30089
+ // ../composites/src/to-mdx.ts
30090
+ var import_escape_html = __toESM(require_escape_html(), 1);
30091
+
29987
30092
  // src/utils/workspaces.ts
29988
30093
  import { existsSync as existsSync5, readdirSync as readdirSync2, readFileSync as readFileSync2, statSync as statSync2 } from "fs";
29989
30094
  import { basename, dirname as dirname3, join as join9, resolve as resolve3 } from "path";
@@ -31354,6 +31459,15 @@ program.command("studio").description("Open Studio UI for visual token editing")
31354
31459
  program.parse();
31355
31460
  /*! Bundled license information:
31356
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
+
31357
31471
  colorparsley/src/colorparsley.js:
31358
31472
  (** @preserve
31359
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.60",
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",