onsystem 0.10.1 → 0.10.3

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.
@@ -1,6 +1,5 @@
1
- import { h as DesignSystemModel, i as ResolvedConfig } from "./config-BbTW1jKU.js";
1
+ import { h as DesignSystemModel, i as ResolvedConfig } from "./config-JaNAiR9Z.js";
2
2
  import { MessagePort } from "node:worker_threads";
3
- //#region src/eslint/worker.d.ts
4
3
  export interface LoadRequest {
5
4
  /** ESLint's working directory: where `check` would run from. */
6
5
  cwd: string;
@@ -32,5 +31,4 @@ export interface Call {
32
31
  signal: Int32Array;
33
32
  port: MessagePort;
34
33
  }
35
- export declare function load(request: LoadRequest): Promise<LoadResponse>;
36
- //#endregion
34
+ export declare function load(request: LoadRequest): Promise<LoadResponse>;
@@ -1,9 +1,9 @@
1
- import { at as excludedBy, i as componentFiles, kt as relativePath, r as buildModel } from "./design-system-CPH4C7-1.js";
2
- import { r as loadTarget } from "./workspace-BINqxi7p.js";
1
+ import { At as relativePath, i as componentFiles, ot as excludedBy, r as buildModel } from "./design-system-7wZoJsMm.js";
2
+ import { r as loadTarget } from "./workspace-C5pMS6Xv.js";
3
3
  import fs from "node:fs";
4
4
  import path from "node:path";
5
5
  import { parentPort } from "node:worker_threads";
6
- //#region src/eslint/worker.ts
6
+ // src/eslint/worker.ts
7
7
  /**
8
8
  * The ESLint plugin's loader, in a worker thread. ESLint rules run synchronously, and finding a
9
9
  * project's design system does not (config files written in code, globs, the extraction
@@ -89,5 +89,4 @@ parentPort?.on("message", ({ request, signal, port }) => {
89
89
  reply({ error: error.message });
90
90
  });
91
91
  });
92
- //#endregion
93
92
  export { load };
package/dist/eslint.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { Linter, Rule } from "eslint";
2
- //#region src/eslint/index.d.ts
3
2
  /** `settings.onsystem`: where the project and its config are, when finding them from ESLint's cwd is not right. */
4
3
  export interface Settings {
5
4
  /** The project root, relative to ESLint's working directory (`check --root`). */
@@ -19,5 +18,4 @@ declare const plugin: {
19
18
  recommended: Linter.Config;
20
19
  };
21
20
  };
22
- //#endregion
23
21
  export { plugin as default };
package/dist/eslint.js CHANGED
@@ -1,7 +1,7 @@
1
- import { N as RULES, Q as DEFAULT_TEST_FOLDERS, X as DEFAULT_SEVERITY, Z as DEFAULT_TEST_EXCLUDE, kt as relativePath, t as DesignSystem, v as NAME, y as VERSION } from "./design-system-CPH4C7-1.js";
1
+ import { At as relativePath, N as RULES, Q as DEFAULT_TEST_FOLDERS, X as DEFAULT_SEVERITY, Z as DEFAULT_TEST_EXCLUDE, t as DesignSystem, v as NAME, y as VERSION } from "./design-system-7wZoJsMm.js";
2
2
  import path from "node:path";
3
3
  import { MessageChannel, Worker, receiveMessageOnPort } from "node:worker_threads";
4
- //#region src/eslint/bridge.ts
4
+ // src/eslint/bridge.ts
5
5
  /**
6
6
  * Calls the loader worker (`worker.ts`) synchronously: posts the request, blocks on a shared
7
7
  * flag until the worker has answered, and takes the answer off the port. The worker is
@@ -39,8 +39,7 @@ function loadSync(request) {
39
39
  port1.close();
40
40
  }
41
41
  }
42
- //#endregion
43
- //#region src/eslint/index.ts
42
+ // src/eslint/index.ts
44
43
  /**
45
44
  * onsystem's rules as an ESLint plugin (ESLint 9 and 10, flat config):
46
45
  *
@@ -229,5 +228,4 @@ plugin.configs.recommended = {
229
228
  plugins: { onsystem: plugin },
230
229
  rules: Object.fromEntries(RULES.map((rule) => [`onsystem/${rule.id}`, DEFAULT_SEVERITY[rule.id]]))
231
230
  };
232
- //#endregion
233
231
  export { plugin as default };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,7 @@
1
- import { C as TOKEN_CATEGORIES, D as VariantInfo, E as TokenCategory, O as ImportMapping, S as SourceLocation, T as Token, _ as DocSection, a as ResolvedRule, b as PropInfo, c as configJsonSchema, d as CheckResult, f as ComponentDocs, g as Diagnostic, h as DesignSystemModel, i as ResolvedConfig, l as defineConfig, m as CompoundVariantInfo, n as LoadConfigOptions, o as RuleId, p as ComponentInfo, r as RULE_IDS, s as RuleOptions, t as Config, u as loadConfig, v as ExampleInfo, w as TextEdit, x as Severity, y as InheritedProps } from "./config-BbTW1jKU.js";
1
+ import { C as TOKEN_CATEGORIES, D as VariantInfo, E as TokenCategory, O as ImportMapping, S as SourceLocation, T as Token, _ as DocSection, a as ResolvedRule, b as PropInfo, c as configJsonSchema, d as CheckResult, f as ComponentDocs, g as Diagnostic, h as DesignSystemModel, i as ResolvedConfig, l as defineConfig, m as CompoundVariantInfo, n as LoadConfigOptions, o as RuleId, p as ComponentInfo, r as RULE_IDS, s as RuleOptions, t as Config, u as loadConfig, v as ExampleInfo, w as TextEdit, x as Severity, y as InheritedProps } from "./config-JaNAiR9Z.js";
2
2
  import ts from "typescript";
3
3
  import { Oklch } from "culori";
4
4
  import { McpServer, Transport } from "@modelcontextprotocol/server";
5
- //#region src/lint/analyze.d.ts
6
5
  interface ImportBinding {
7
6
  source: string;
8
7
  /** Imported name, `default`, or `*` for namespace imports. */
@@ -37,8 +36,6 @@ interface Analysis {
37
36
  classStrings: ClassString[];
38
37
  styles: StyleObject[];
39
38
  }
40
- //#endregion
41
- //#region src/modules.d.ts
42
39
  /** Where an import points: a file relative to the root, or `{}` for a declared module not on disk. */
43
40
  interface ModuleLocation {
44
41
  file?: string;
@@ -83,8 +80,6 @@ declare class ModuleResolver {
83
80
  exportsOf(file: string): ModuleExports | undefined;
84
81
  private createResolver;
85
82
  }
86
- //#endregion
87
- //#region src/tokens/roles.d.ts
88
83
  /**
89
84
  * What a color utility paints, which decides the tokens that fit it: `text-*`
90
85
  * wants a foreground, `bg-*` a surface, `border-*` a border color.
@@ -100,8 +95,6 @@ type ColorRole = 'text' | 'surface' | 'line';
100
95
  * palette (`color-red-500`).
101
96
  */
102
97
  type ScopedFamily = string;
103
- //#endregion
104
- //#region src/tokens/css.d.ts
105
98
  /**
106
99
  * Reads design tokens from CSS custom properties, the way shadcn/ui and
107
100
  * Tailwind v4 projects define them:
@@ -114,14 +107,10 @@ export declare function parseCssTokens(css: string, file: string): {
114
107
  tokens: Token[];
115
108
  warnings: string[];
116
109
  };
117
- //#endregion
118
- //#region src/tokens/design-md.d.ts
119
110
  export declare function parseDesignMd(text: string, file: string): {
120
111
  tokens: Token[];
121
112
  warnings: string[];
122
113
  };
123
- //#endregion
124
- //#region src/tokens/dtcg.d.ts
125
114
  interface DtcgOptions {
126
115
  /** Prefix for generated custom property names: `ds` → `--ds-color-primary`. */
127
116
  prefix?: string;
@@ -130,8 +119,6 @@ export declare function parseDtcgTokens(text: string, file: string, options?: Dt
130
119
  tokens: Token[];
131
120
  warnings: string[];
132
121
  };
133
- //#endregion
134
- //#region src/tokens/export.d.ts
135
122
  /**
136
123
  * Writes the tokens onsystem found as a DTCG 2025.10 file or a DESIGN.md. Both are grouped by
137
124
  * category; reading the DTCG file back gives the same tokens, with the same names.
@@ -158,8 +145,6 @@ export declare function toDtcg(tokens: readonly Token[]): Exported;
158
145
  export declare function toDesignMd(tokens: readonly Token[], options: {
159
146
  name: string;
160
147
  }): Exported;
161
- //#endregion
162
- //#region src/tokens/index.d.ts
163
148
  interface TokenSource {
164
149
  file: string;
165
150
  /** DTCG only: prefix for generated custom property names. */
@@ -281,12 +266,10 @@ export declare class TokenIndex {
281
266
  /** px value of a token-like length string, resolving `var()` against the token set. */
282
267
  toPx(value: string): number | undefined;
283
268
  }
284
- //#endregion
285
- //#region src/lint/target.d.ts
286
269
  /** What the lint rules need to know about the design system. */
287
270
  declare class LintTarget {
288
271
  readonly model: DesignSystemModel;
289
- readonly config: Pick<ResolvedConfig, 'elements' | 'importPath'> & Partial<Pick<ResolvedConfig, 'designSystems'>>;
272
+ readonly config: Pick<ResolvedConfig, 'elements' | 'importPath'> & Partial<Pick<ResolvedConfig, 'designSystems' | 'imports'>>;
290
273
  private readonly resolver?;
291
274
  readonly components: Map<string, ComponentInfo>;
292
275
  /** Every component under each name and alias, when two design systems share one (`Button`). */
@@ -308,13 +291,15 @@ declare class LintTarget {
308
291
  private readonly sources?;
309
292
  /** Published libraries the model read from type declarations: `@mui/material`. */
310
293
  readonly libraries: Set<string>;
294
+ /** The name in each package.json read, by its path: undefined where there is none. */
295
+ private readonly manifests;
311
296
  /**
312
297
  * `resolver` finds the module an import points at and what it exports
313
298
  * (`@calcom/ui/components/icon` → `components/icon/index.ts`), so a name from
314
299
  * a module the model left out is not taken for an invented one. Without it,
315
300
  * every missing name is invented.
316
301
  */
317
- constructor(model: DesignSystemModel, config: Pick<ResolvedConfig, 'elements' | 'importPath'> & Partial<Pick<ResolvedConfig, 'designSystems'>>, resolver?: Pick<ModuleResolver, "locate" | "exportsOf"> | undefined);
302
+ constructor(model: DesignSystemModel, config: Pick<ResolvedConfig, 'elements' | 'importPath'> & Partial<Pick<ResolvedConfig, 'designSystems' | 'imports'>>, resolver?: Pick<ModuleResolver, "locate" | "exportsOf"> | undefined);
318
303
  /**
319
304
  * Whether an import specifier points at the design system. Relative
320
305
  * specifiers are resolved against `fromFile` (relative to the root) and
@@ -335,10 +320,27 @@ declare class LintTarget {
335
320
  * model left out rather than an invented one: its module exists outside the
336
321
  * folders extraction read and exports `name`, or re-exports from such a
337
322
  * module (an excluded `icons/` folder, a barrel's `export * from "./icons"`).
338
- * A module declared in a package's `exports` but not on disk counts too,
339
- * except the design system's own import path.
323
+ * A module declared in a package's `exports` but not on disk counts too (built to `dist/`,
324
+ * not built yet), except the design system's own import path, and one whose export, as the
325
+ * package.json writes it, leads to a source file only: `@acme/ui/components/tooltip` is
326
+ * `src/components/tooltip.tsx` through `"./components/*": "./src/components/*.tsx"`, and with
327
+ * no such file it does not exist.
340
328
  */
341
329
  outsideModel(specifier: string, name: string, fromFile?: string): boolean;
330
+ /**
331
+ * The module a design-system package's `exports` lead `specifier` to, relative to the root, as
332
+ * its package.json writes them: the first of the entry's targets that is on disk, else, when
333
+ * each of them is a source file, the first (which does not exist). Undefined when a target
334
+ * leads to a build folder (`"./*": "./dist/components/*.js"`, maybe not built yet, whose
335
+ * sources may be anywhere), the entry blocks the subpath (`null`), or no entry maps it.
336
+ */
337
+ private exportedSource;
338
+ /**
339
+ * The folder of package `name` that `file` is in: the nearest package.json above it with a
340
+ * name, when that name is `name`. One without a name (`{"type": "module"}` in a subfolder) is
341
+ * no package's. Each package.json is read once.
342
+ */
343
+ private packageDir;
342
344
  /**
343
345
  * The component a JSX tag means when `name` is imported from `specifier`, among the
344
346
  * model's components of that name: the one declared where the import leads, through
@@ -378,8 +380,6 @@ declare class LintTarget {
378
380
  /** Component names for "did you mean" suggestions. */
379
381
  names(): string[];
380
382
  }
381
- //#endregion
382
- //#region src/lint/context.d.ts
383
383
  interface Report {
384
384
  start: number;
385
385
  end: number;
@@ -440,12 +440,8 @@ type Resolution =
440
440
  {
441
441
  kind: 'external';
442
442
  };
443
- //#endregion
444
- //#region src/lint/rules/index.d.ts
445
443
  /** Every rule, in the order they run. */
446
444
  export declare const RULES: readonly Rule[];
447
- //#endregion
448
- //#region src/lint/format.d.ts
449
445
  type OutputFormat = 'pretty' | 'json' | 'github' | 'sarif';
450
446
  /**
451
447
  * Renders check results:
@@ -468,8 +464,6 @@ export declare function formatDiagnostics(results: CheckResult[], format: Output
468
464
  */
469
465
  uri?: ((file: string) => string) | undefined;
470
466
  }): string;
471
- //#endregion
472
- //#region src/lint/index.d.ts
473
467
  interface CheckOptions {
474
468
  /** File name used in results and to pick TSX vs JSX parsing. Default `snippet.tsx`. */
475
469
  filename?: string | undefined;
@@ -483,8 +477,6 @@ interface CheckOptions {
483
477
  export declare function checkSource(code: string, target: LintTarget, options: CheckOptions): CheckResult;
484
478
  /** Applies non-overlapping fixes from the end of the file backwards. */
485
479
  export declare function applyFixes(code: string, diagnostics: Diagnostic[]): string;
486
- //#endregion
487
- //#region src/search/bm25.d.ts
488
480
  /**
489
481
  * Okapi BM25 over weighted fields (BM25F-style: field weights scale term
490
482
  * frequency and document length). Small, dependency-free and deterministic,
@@ -512,8 +504,6 @@ declare class Bm25Index<T> {
512
504
  get size(): number;
513
505
  search(query: Map<string, number>, limit?: number): Bm25Hit<T>[];
514
506
  }
515
- //#endregion
516
- //#region src/search/index.d.ts
517
507
  interface SearchHit {
518
508
  component: ComponentInfo;
519
509
  score: number;
@@ -530,8 +520,6 @@ interface SearchHit {
530
520
  * which is not an answer to give as the best match.
531
521
  */
532
522
  export declare function searchComponents(index: Bm25Index<ComponentInfo>, query: string, limit?: number): SearchHit[];
533
- //#endregion
534
- //#region src/util/log.d.ts
535
523
  /**
536
524
  * Diagnostics go to stderr: in stdio mode stdout carries JSON-RPC and must
537
525
  * never receive anything else.
@@ -541,8 +529,6 @@ interface Logger {
541
529
  warn(message: string): void;
542
530
  error(message: string): void;
543
531
  }
544
- //#endregion
545
- //#region src/design-system.d.ts
546
532
  /** A loaded design system: the model plus the indexes the tools query. */
547
533
  export declare class DesignSystem {
548
534
  readonly model: DesignSystemModel;
@@ -659,6 +645,11 @@ export declare class DesignSystemHost {
659
645
  constructor(config: ResolvedConfig, options?: HostOptions);
660
646
  get(): Promise<DesignSystem>;
661
647
  reload(): Promise<DesignSystem>;
648
+ /**
649
+ * `build`, dropped if it fails with no earlier model to serve instead (a first build that
650
+ * fails), so the next `get()` builds again.
651
+ */
652
+ private kept;
662
653
  onChange(listener: (ds: DesignSystem) => void): () => void;
663
654
  /** Watches the component, token and docs locations, the config and the tsconfig chain. */
664
655
  watch(): void;
@@ -677,8 +668,6 @@ export declare class DesignSystemHost {
677
668
  private reloadConfig;
678
669
  private build;
679
670
  }
680
- //#endregion
681
- //#region src/extract/components.d.ts
682
671
  interface ExtractComponentsOptions {
683
672
  root: string;
684
673
  /** Absolute paths of the component source files. */
@@ -708,8 +697,6 @@ interface ExtractComponentsResult {
708
697
  * `Tabs.List` via static members or `Object.assign`).
709
698
  */
710
699
  export declare function extractComponents(options: ExtractComponentsOptions): ExtractComponentsResult;
711
- //#endregion
712
- //#region src/extract/cva.d.ts
713
700
  /** A `cva()` (class-variance-authority) or `tv()` (tailwind-variants) definition. */
714
701
  interface VariantDefinition {
715
702
  /** The variable it is assigned to, e.g. `buttonVariants`. */
@@ -721,8 +708,6 @@ interface VariantDefinition {
721
708
  }
722
709
  /** Finds every `const x = cva(base, { variants, defaultVariants })` in a file. */
723
710
  export declare function findVariantDefinitions(sourceFile: ts.SourceFile): Map<string, VariantDefinition>;
724
- //#endregion
725
- //#region src/extract/docs.d.ts
726
711
  interface ParsedDoc {
727
712
  file: string;
728
713
  title?: string;
@@ -739,8 +724,6 @@ interface ParsedDoc {
739
724
  export declare function parseDoc(text: string, file: string): ParsedDoc;
740
725
  /** Attaches docs and their examples to components. Returns warnings for unmatched pages. */
741
726
  export declare function attachDocs(components: ComponentInfo[], docs: ParsedDoc[]): string[];
742
- //#endregion
743
- //#region src/catalog.d.ts
744
727
  /** One project's design system at a workspace root. */
745
728
  interface ServedProject {
746
729
  ds: DesignSystem;
@@ -809,8 +792,6 @@ declare class Catalog {
809
792
  query?: string | undefined;
810
793
  }): CatalogToken[];
811
794
  }
812
- //#endregion
813
- //#region src/server/index.d.ts
814
795
  export declare const INSTRUCTIONS = "This server describes the project's design system: its React components (props, variants, parts), design tokens and usage docs, and lints UI code against it.\nWhen writing or changing UI in this project:\n1. Find components with search_components (by intent) or list_components.\n2. Read get_component before using a component: use only the props and variant values it lists.\n3. Style with tokens from get_tokens, never with hex/rgb colors, arbitrary px values or Tailwind's default palette. chart-* and sidebar-* tokens are for charts and the sidebar only: for a status color the theme has no token for (success, warning, info), add a token or keep the Tailwind color as check_ui says, and never use a chart-* or sidebar-* token for it.\n4. Run check_ui on every snippet or file you write and fix all errors before you finish.\nIn a monorepo served from its root, pass `path` (the file you are editing) to list_components, get_component, search_components and get_tokens, and `path` or `filename` to check_ui, so each answer comes from that file's own project.";
815
796
  interface CreateServerOptions {
816
797
  /**
@@ -827,8 +808,6 @@ interface CreateServerOptions {
827
808
  }
828
809
  /** Builds the MCP server: five tools, two resources and one prompt. Transport-agnostic. */
829
810
  export declare function createServer(options: CreateServerOptions): McpServer;
830
- //#endregion
831
- //#region src/server/stdio.d.ts
832
811
  interface ServeOptions extends LoadConfigOptions {
833
812
  cwd: string;
834
813
  cache: boolean;
@@ -860,12 +839,18 @@ interface ServerHandle {
860
839
  * project marker, or the monorepo root above that, served as if the server had been
861
840
  * started there, except that a config there is read only when it is JSON: a prompt can
862
841
  * choose the path, so a JavaScript or TypeScript config is not run. Each root found is
863
- * loaded once and kept; a request without an absolute path is answered from the one root
864
- * found so far.
842
+ * loaded once and kept, by its real path; a request without an absolute path is answered from
843
+ * the one root found so far. The same holds for a `--root` (or a client's root) that is no
844
+ * project but holds projects in its folders, such as a folder of repositories, except that only
845
+ * an absolute path in that folder is answered, from the project in it that holds the file (never
846
+ * from a folder outside or above it), and a file in none of them from that folder, as before.
847
+ * Links are resolved: a path, or the project it leads to, that is really outside the folder is
848
+ * refused, a workspace in it serves only its packages that are really in it, and a project in it
849
+ * that a link replaces while the server runs is not built again from where the link leads.
850
+ *
851
+ * A load that fails, such as on an invalid config, is not kept: the next request loads
852
+ * again, so fixing the config is enough, also when it was invalid at startup.
865
853
  */
866
854
  export declare function serveStdio(options: ServeOptions): Promise<ServerHandle>;
867
- //#endregion
868
- //#region src/version.d.ts
869
855
  export declare const VERSION: string;
870
- //#endregion
871
856
  export { type CheckResult, type ComponentDocs, type ComponentInfo, type CompoundVariantInfo, type Config, type DesignSystemModel, type Diagnostic, type DocSection, type ExampleInfo, type HostOptions, type InheritedProps, type LoadConfigOptions, type LoadOptions, type OutputFormat, type PropInfo, RULE_IDS, type ResolvedConfig, type RuleId, type Severity, type SourceLocation, type TOKEN_CATEGORIES, type TextEdit, type Token, type TokenCategory, type VariantInfo, configJsonSchema, defineConfig, loadConfig };
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import { F as loadTokens, G as parseDoc, H as parseDesignMd, I as mergeTokens, K as extractComponents, L as toDesignMd, N as RULES, P as TokenIndex, R as toDtcg, U as parseCssTokens, V as parseDtcgTokens, W as attachDocs, _ as formatDiagnostics, a as fingerprint, dt as findVariantDefinitions, f as searchComponents, it as defineConfig, m as checkSource, n as DesignSystemHost, nt as RULE_IDS, o as loadDesignSystem, p as applyFixes, r as buildModel, rt as configJsonSchema, st as loadConfig, t as DesignSystem, y as VERSION } from "./design-system-CPH4C7-1.js";
2
- import { n as INSTRUCTIONS, r as createServer, t as serveStdio } from "./stdio-BK2kMN1x.js";
1
+ import { F as loadTokens, G as parseDoc, H as parseDesignMd, I as mergeTokens, K as extractComponents, L as toDesignMd, N as RULES, P as TokenIndex, R as toDtcg, U as parseCssTokens, V as parseDtcgTokens, W as attachDocs, _ as formatDiagnostics, a as fingerprint, at as defineConfig, ct as loadConfig, f as searchComponents, ft as findVariantDefinitions, it as configJsonSchema, m as checkSource, n as DesignSystemHost, o as loadDesignSystem, p as applyFixes, r as buildModel, rt as RULE_IDS, t as DesignSystem, y as VERSION } from "./design-system-7wZoJsMm.js";
2
+ import { n as INSTRUCTIONS, r as createServer, t as serveStdio } from "./stdio-B31hp2UZ.js";
3
3
  export { DesignSystem, DesignSystemHost, INSTRUCTIONS, RULES, RULE_IDS, TokenIndex, VERSION, applyFixes, attachDocs, buildModel, checkSource, configJsonSchema, createServer, defineConfig, extractComponents, findVariantDefinitions, fingerprint, formatDiagnostics, loadConfig, loadDesignSystem, loadTokens, mergeTokens, parseCssTokens, parseDesignMd, parseDoc, parseDtcgTokens, searchComponents, serveStdio, toDesignMd, toDtcg };