@getcoherent/core 0.6.49 → 0.6.51
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/index.d.ts +28 -1
- package/dist/index.js +80 -0
- package/package.json +8 -8
- package/LICENSE +0 -21
package/dist/index.d.ts
CHANGED
|
@@ -4365,6 +4365,33 @@ declare function atomicWriteFile(filePath: string, content: string): Promise<voi
|
|
|
4365
4365
|
|
|
4366
4366
|
declare function colorToHex(value: string): string | null;
|
|
4367
4367
|
|
|
4368
|
+
/**
|
|
4369
|
+
* Single source of truth for allowed color classes.
|
|
4370
|
+
* Generates whitelist from CSS variable output of buildCssVariables().
|
|
4371
|
+
*/
|
|
4372
|
+
/** Raw Tailwind palette color names (those that take a numeric shade, e.g. blue-500) */
|
|
4373
|
+
declare const RAW_TAILWIND_COLORS: string[];
|
|
4374
|
+
/** All Tailwind prefixes that accept color values */
|
|
4375
|
+
declare const COLOR_PREFIXES: string[];
|
|
4376
|
+
interface AllowedColorClasses {
|
|
4377
|
+
/** Set of all allowed color class names (e.g., "bg-primary", "text-foreground") */
|
|
4378
|
+
classes: Set<string>;
|
|
4379
|
+
/** Compact string for AI constraint injection */
|
|
4380
|
+
constraintSnippet: string;
|
|
4381
|
+
/** Regex matching raw Tailwind color classes (NOT in the whitelist) */
|
|
4382
|
+
disallowedPattern: RegExp;
|
|
4383
|
+
}
|
|
4384
|
+
/**
|
|
4385
|
+
* Extract CSS variable names from the output of buildCssVariables().
|
|
4386
|
+
* Filters out non-color variables like --radius.
|
|
4387
|
+
*/
|
|
4388
|
+
declare function extractCssVariableNames(cssString: string): string[];
|
|
4389
|
+
/**
|
|
4390
|
+
* Generate the complete set of allowed color classes from CSS variable output.
|
|
4391
|
+
* @param cssString - Output of buildCssVariables()
|
|
4392
|
+
*/
|
|
4393
|
+
declare function getAllowedColorClasses(cssString: string): AllowedColorClasses;
|
|
4394
|
+
|
|
4368
4395
|
/**
|
|
4369
4396
|
* Story 2.11 Part C: Consistency audit for shared components.
|
|
4370
4397
|
* - Verify usedIn vs actual imports
|
|
@@ -4395,4 +4422,4 @@ interface AuditResult {
|
|
|
4395
4422
|
*/
|
|
4396
4423
|
declare function runAudit(projectRoot: string): Promise<AuditResult>;
|
|
4397
4424
|
|
|
4398
|
-
export { type AuditEntryResult, type AuditResult, type BlogContent, CLI_VERSION, type ChangelogContent, type ColorToken, ColorTokenSchema, type ComponentAPI, type ComponentCriteria, type ComponentDefinition, ComponentDefinitionSchema, type ComponentDependency, ComponentGenerator, ComponentManager, type ComponentMeta, type ComponentProvider, type ComponentSize, ComponentSizeSchema, type ComponentSpec, type ComponentVariant, ComponentVariantSchema, type ContactContent, type CreateSharedComponentInput, type DashboardContent, type DesignSystemConfig, DesignSystemConfigSchema, DesignSystemGenerator, DesignSystemManager, type DesignTokens, DesignTokensSchema, type DiscoveryResult, EXAMPLE_MULTIPAGE_CONFIG, EXAMPLE_SPA_CONFIG, FIGMA_BASE_IDS, FRAMEWORK_VERSIONS, type FaqContent, type Features, FeaturesSchema, type FigmaBaseId, FigmaClient, type FigmaClientOptions, type FigmaColorStyle, type FigmaComponentData, type FigmaComponentMap, type FigmaComponentMeta, type FigmaDocumentNode, type FigmaEffectStyle, type FigmaFileResponse, type FigmaIntermediateData, type FigmaLayout, type FigmaNode, type FigmaNormalizationResult, type FigmaNormalizedEntry, type FigmaPageData, type FigmaProperty, type FigmaRgba, type FigmaStyleMeta, type FigmaTextStyle, type FigmaTokenExtractionResult, type FigmaVariant, type GalleryContent, type GenerateSharedComponentInput, type GenerateSharedComponentResult, type GeneratedPage, type LandingContent, type LayoutBlockDefinition, LayoutBlockDefinitionSchema, type ListingContent, type LoginContent, MANIFEST_FILENAME, type ModificationRequest, type ModificationResult, type Navigation, type NavigationItem, NavigationItemSchema, NavigationSchema, type OnboardingContent, type PageAnalysis, PageAnalysisSchema, type PageContent, type PageDefinition, PageDefinitionSchema, PageGenerator, type PageLayout, PageLayoutSchema, PageManager, type PageSection, PageSectionSchema, type PricingContent, type ProfileContent, ProjectScaffolder, type RadiusToken, RadiusTokenSchema, type RegisterContent, type SettingsContent, type SharedComponentEntry, SharedComponentEntrySchema, type SharedComponentType, SharedComponentTypeSchema, type SharedComponentsManifest, SharedComponentsManifestSchema, type SpacingToken, SpacingTokenSchema, TailwindConfigGenerator, type TemplateOptions, type TypographyToken, TypographyTokenSchema, allocateNextCid, atomicWriteFile, buildCssVariables, colorToHex, componentExists, createEntry, extractConfigObject, extractTokensFromFigma, figmaComponentNameToBaseId, figmaRgbaToHex, findSharedComponent, findSharedComponentByIdOrName, formatCid, generatePageFromFrame, generatePagesFromFigma, generateSharedComponent, generateSharedComponentTsx, getComponent, getManifestPath, getPage, getPageFilePath, getSupportedPageTypes, getTemplateForPageType, integrateSharedLayoutIntoRootLayout, loadManifest, mergeExtractedColorsWithDefaults, normalizeFigmaComponents, pageRouteExists, parseCid, parseFigmaFileResponse, removeEntry, resolveUniqueName, runAudit, saveManifest, setSharedMapping, toSharedFileName, updateEntry, updateUsedIn, validateConfig, validatePartialConfig };
|
|
4425
|
+
export { type AllowedColorClasses, type AuditEntryResult, type AuditResult, type BlogContent, CLI_VERSION, COLOR_PREFIXES, type ChangelogContent, type ColorToken, ColorTokenSchema, type ComponentAPI, type ComponentCriteria, type ComponentDefinition, ComponentDefinitionSchema, type ComponentDependency, ComponentGenerator, ComponentManager, type ComponentMeta, type ComponentProvider, type ComponentSize, ComponentSizeSchema, type ComponentSpec, type ComponentVariant, ComponentVariantSchema, type ContactContent, type CreateSharedComponentInput, type DashboardContent, type DesignSystemConfig, DesignSystemConfigSchema, DesignSystemGenerator, DesignSystemManager, type DesignTokens, DesignTokensSchema, type DiscoveryResult, EXAMPLE_MULTIPAGE_CONFIG, EXAMPLE_SPA_CONFIG, FIGMA_BASE_IDS, FRAMEWORK_VERSIONS, type FaqContent, type Features, FeaturesSchema, type FigmaBaseId, FigmaClient, type FigmaClientOptions, type FigmaColorStyle, type FigmaComponentData, type FigmaComponentMap, type FigmaComponentMeta, type FigmaDocumentNode, type FigmaEffectStyle, type FigmaFileResponse, type FigmaIntermediateData, type FigmaLayout, type FigmaNode, type FigmaNormalizationResult, type FigmaNormalizedEntry, type FigmaPageData, type FigmaProperty, type FigmaRgba, type FigmaStyleMeta, type FigmaTextStyle, type FigmaTokenExtractionResult, type FigmaVariant, type GalleryContent, type GenerateSharedComponentInput, type GenerateSharedComponentResult, type GeneratedPage, type LandingContent, type LayoutBlockDefinition, LayoutBlockDefinitionSchema, type ListingContent, type LoginContent, MANIFEST_FILENAME, type ModificationRequest, type ModificationResult, type Navigation, type NavigationItem, NavigationItemSchema, NavigationSchema, type OnboardingContent, type PageAnalysis, PageAnalysisSchema, type PageContent, type PageDefinition, PageDefinitionSchema, PageGenerator, type PageLayout, PageLayoutSchema, PageManager, type PageSection, PageSectionSchema, type PricingContent, type ProfileContent, ProjectScaffolder, RAW_TAILWIND_COLORS, type RadiusToken, RadiusTokenSchema, type RegisterContent, type SettingsContent, type SharedComponentEntry, SharedComponentEntrySchema, type SharedComponentType, SharedComponentTypeSchema, type SharedComponentsManifest, SharedComponentsManifestSchema, type SpacingToken, SpacingTokenSchema, TailwindConfigGenerator, type TemplateOptions, type TypographyToken, TypographyTokenSchema, allocateNextCid, atomicWriteFile, buildCssVariables, colorToHex, componentExists, createEntry, extractConfigObject, extractCssVariableNames, extractTokensFromFigma, figmaComponentNameToBaseId, figmaRgbaToHex, findSharedComponent, findSharedComponentByIdOrName, formatCid, generatePageFromFrame, generatePagesFromFigma, generateSharedComponent, generateSharedComponentTsx, getAllowedColorClasses, getComponent, getManifestPath, getPage, getPageFilePath, getSupportedPageTypes, getTemplateForPageType, integrateSharedLayoutIntoRootLayout, loadManifest, mergeExtractedColorsWithDefaults, normalizeFigmaComponents, pageRouteExists, parseCid, parseFigmaFileResponse, removeEntry, resolveUniqueName, runAudit, saveManifest, setSharedMapping, toSharedFileName, updateEntry, updateUsedIn, validateConfig, validatePartialConfig };
|
package/dist/index.js
CHANGED
|
@@ -10266,6 +10266,82 @@ function colorToHex(value) {
|
|
|
10266
10266
|
return null;
|
|
10267
10267
|
}
|
|
10268
10268
|
|
|
10269
|
+
// src/utils/allowedColorClasses.ts
|
|
10270
|
+
var NON_COLOR_VARS = /* @__PURE__ */ new Set(["radius"]);
|
|
10271
|
+
var RAW_TAILWIND_COLORS = [
|
|
10272
|
+
"gray",
|
|
10273
|
+
"blue",
|
|
10274
|
+
"red",
|
|
10275
|
+
"green",
|
|
10276
|
+
"yellow",
|
|
10277
|
+
"purple",
|
|
10278
|
+
"pink",
|
|
10279
|
+
"indigo",
|
|
10280
|
+
"orange",
|
|
10281
|
+
"slate",
|
|
10282
|
+
"zinc",
|
|
10283
|
+
"stone",
|
|
10284
|
+
"neutral",
|
|
10285
|
+
"emerald",
|
|
10286
|
+
"teal",
|
|
10287
|
+
"cyan",
|
|
10288
|
+
"sky",
|
|
10289
|
+
"violet",
|
|
10290
|
+
"fuchsia",
|
|
10291
|
+
"rose",
|
|
10292
|
+
"amber",
|
|
10293
|
+
"lime"
|
|
10294
|
+
];
|
|
10295
|
+
var COLOR_PREFIXES = [
|
|
10296
|
+
"bg",
|
|
10297
|
+
"text",
|
|
10298
|
+
"border",
|
|
10299
|
+
"ring",
|
|
10300
|
+
"outline",
|
|
10301
|
+
"shadow",
|
|
10302
|
+
"from",
|
|
10303
|
+
"to",
|
|
10304
|
+
"via",
|
|
10305
|
+
"divide",
|
|
10306
|
+
"placeholder",
|
|
10307
|
+
"decoration",
|
|
10308
|
+
"caret",
|
|
10309
|
+
"fill",
|
|
10310
|
+
"stroke",
|
|
10311
|
+
"accent"
|
|
10312
|
+
];
|
|
10313
|
+
function extractCssVariableNames(cssString) {
|
|
10314
|
+
const matches = cssString.matchAll(/--([a-z][a-z0-9-]*)/g);
|
|
10315
|
+
const unique = /* @__PURE__ */ new Set();
|
|
10316
|
+
for (const m of matches) {
|
|
10317
|
+
if (!NON_COLOR_VARS.has(m[1])) {
|
|
10318
|
+
unique.add(m[1]);
|
|
10319
|
+
}
|
|
10320
|
+
}
|
|
10321
|
+
return [...unique];
|
|
10322
|
+
}
|
|
10323
|
+
function getAllowedColorClasses(cssString) {
|
|
10324
|
+
const varNames = extractCssVariableNames(cssString);
|
|
10325
|
+
const classes = /* @__PURE__ */ new Set();
|
|
10326
|
+
for (const varName of varNames) {
|
|
10327
|
+
for (const prefix of COLOR_PREFIXES) {
|
|
10328
|
+
classes.add(`${prefix}-${varName}`);
|
|
10329
|
+
}
|
|
10330
|
+
}
|
|
10331
|
+
classes.add("border");
|
|
10332
|
+
const tokens = varNames.join("|");
|
|
10333
|
+
const bgClasses = varNames.map((v) => `bg-${v}`);
|
|
10334
|
+
const textClasses = varNames.map((v) => `text-${v}`);
|
|
10335
|
+
const constraintSnippet = `bg: ${bgClasses.join(", ")}. text: ${textClasses.join(", ")}. border/ring/shadow/fill/stroke: same tokens (${tokens}). Opacity ok (e.g., bg-primary/50).`;
|
|
10336
|
+
const modifierGroup = `(?:(?:[a-z][a-z0-9-]*:)*)?`;
|
|
10337
|
+
const prefixGroup = `(?:${COLOR_PREFIXES.join("|")})`;
|
|
10338
|
+
const colorGroup = `(?:${RAW_TAILWIND_COLORS.join("|")})`;
|
|
10339
|
+
const disallowedPattern = new RegExp(
|
|
10340
|
+
`\\b${modifierGroup}${prefixGroup}-${colorGroup}-\\d+(?:\\/\\d+)?\\b`
|
|
10341
|
+
);
|
|
10342
|
+
return { classes, constraintSnippet, disallowedPattern };
|
|
10343
|
+
}
|
|
10344
|
+
|
|
10269
10345
|
// src/audit/ComponentAuditor.ts
|
|
10270
10346
|
import { readFile as readFile4, readdir } from "fs/promises";
|
|
10271
10347
|
import { join as join5 } from "path";
|
|
@@ -10441,6 +10517,7 @@ async function runAudit(projectRoot) {
|
|
|
10441
10517
|
}
|
|
10442
10518
|
export {
|
|
10443
10519
|
CLI_VERSION,
|
|
10520
|
+
COLOR_PREFIXES,
|
|
10444
10521
|
ColorTokenSchema,
|
|
10445
10522
|
ComponentDefinitionSchema,
|
|
10446
10523
|
ComponentGenerator,
|
|
@@ -10468,6 +10545,7 @@ export {
|
|
|
10468
10545
|
PageManager,
|
|
10469
10546
|
PageSectionSchema,
|
|
10470
10547
|
ProjectScaffolder,
|
|
10548
|
+
RAW_TAILWIND_COLORS,
|
|
10471
10549
|
RadiusTokenSchema,
|
|
10472
10550
|
SharedComponentEntrySchema,
|
|
10473
10551
|
SharedComponentTypeSchema,
|
|
@@ -10482,6 +10560,7 @@ export {
|
|
|
10482
10560
|
componentExists,
|
|
10483
10561
|
createEntry,
|
|
10484
10562
|
extractConfigObject,
|
|
10563
|
+
extractCssVariableNames,
|
|
10485
10564
|
extractTokensFromFigma,
|
|
10486
10565
|
figmaComponentNameToBaseId,
|
|
10487
10566
|
figmaRgbaToHex,
|
|
@@ -10492,6 +10571,7 @@ export {
|
|
|
10492
10571
|
generatePagesFromFigma,
|
|
10493
10572
|
generateSharedComponent,
|
|
10494
10573
|
generateSharedComponentTsx,
|
|
10574
|
+
getAllowedColorClasses,
|
|
10495
10575
|
getComponent,
|
|
10496
10576
|
getManifestPath,
|
|
10497
10577
|
getPage,
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.6.
|
|
6
|
+
"version": "0.6.51",
|
|
7
7
|
"description": "Core design system engine for Coherent",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"main": "./dist/index.js",
|
|
@@ -32,6 +32,12 @@
|
|
|
32
32
|
],
|
|
33
33
|
"author": "Coherent Design Method",
|
|
34
34
|
"license": "MIT",
|
|
35
|
+
"scripts": {
|
|
36
|
+
"dev": "tsup --watch",
|
|
37
|
+
"build": "tsup",
|
|
38
|
+
"typecheck": "tsc --noEmit",
|
|
39
|
+
"test": "vitest"
|
|
40
|
+
},
|
|
35
41
|
"dependencies": {
|
|
36
42
|
"handlebars": "^4.7.8",
|
|
37
43
|
"zod": "^3.22.4"
|
|
@@ -41,11 +47,5 @@
|
|
|
41
47
|
"tsup": "^8.0.1",
|
|
42
48
|
"typescript": "^5.3.3",
|
|
43
49
|
"vitest": "^1.2.1"
|
|
44
|
-
},
|
|
45
|
-
"scripts": {
|
|
46
|
-
"dev": "tsup --watch",
|
|
47
|
-
"build": "tsup",
|
|
48
|
-
"typecheck": "tsc --noEmit",
|
|
49
|
-
"test": "vitest"
|
|
50
50
|
}
|
|
51
|
-
}
|
|
51
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 Sergei Kovtun
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|