@nuasite/cms-marker 0.0.53 → 0.0.54

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 (39) hide show
  1. package/README.md +0 -4
  2. package/dist/types/astro-transform.d.ts +21 -0
  3. package/dist/types/astro-transform.d.ts.map +1 -0
  4. package/dist/types/build-processor.d.ts +10 -0
  5. package/dist/types/build-processor.d.ts.map +1 -0
  6. package/dist/types/component-registry.d.ts +63 -0
  7. package/dist/types/component-registry.d.ts.map +1 -0
  8. package/dist/types/dev-middleware.d.ts +7 -0
  9. package/dist/types/dev-middleware.d.ts.map +1 -0
  10. package/dist/types/html-processor.d.ts +51 -0
  11. package/dist/types/html-processor.d.ts.map +1 -0
  12. package/dist/types/index.d.ts +7 -0
  13. package/dist/types/index.d.ts.map +1 -0
  14. package/dist/types/manifest-writer.d.ts +75 -0
  15. package/dist/types/manifest-writer.d.ts.map +1 -0
  16. package/dist/types/source-finder.d.ts +97 -0
  17. package/dist/types/source-finder.d.ts.map +1 -0
  18. package/dist/types/tailwind-colors.d.ts +66 -0
  19. package/dist/types/tailwind-colors.d.ts.map +1 -0
  20. package/dist/types/tsconfig.tsbuildinfo +1 -0
  21. package/dist/types/types.d.ts +195 -0
  22. package/dist/types/types.d.ts.map +1 -0
  23. package/dist/types/utils.d.ts +38 -0
  24. package/dist/types/utils.d.ts.map +1 -0
  25. package/dist/types/vite-plugin.d.ts +14 -0
  26. package/dist/types/vite-plugin.d.ts.map +1 -0
  27. package/package.json +1 -1
  28. package/src/astro-transform.ts +4 -4
  29. package/src/build-processor.ts +1 -1
  30. package/src/component-registry.ts +2 -2
  31. package/src/dev-middleware.ts +5 -5
  32. package/src/html-processor.ts +180 -6
  33. package/src/index.ts +0 -1
  34. package/src/manifest-writer.ts +47 -1
  35. package/src/source-finder.ts +117 -6
  36. package/src/tailwind-colors.ts +338 -0
  37. package/src/tsconfig.json +1 -1
  38. package/src/types.ts +123 -1
  39. package/src/utils.ts +99 -0
package/README.md CHANGED
@@ -231,10 +231,6 @@ bun test
231
231
 
232
232
  See `src/tests/` for all test cases.
233
233
 
234
- ## License
235
-
236
- MIT
237
-
238
234
  ## Contributing
239
235
 
240
236
  Contributions are welcome! Please feel free to submit issues and pull requests.
@@ -0,0 +1,21 @@
1
+ import type { Plugin } from 'vite';
2
+ export interface AstroTransformOptions {
3
+ markComponents?: boolean;
4
+ enabled?: boolean;
5
+ }
6
+ /**
7
+ * Vite plugin that transforms .astro files to inject source location metadata.
8
+ *
9
+ * NOTE: This plugin is currently DISABLED because Astro's native compiler already
10
+ * injects `data-astro-source-file` and `data-astro-source-loc` attributes in dev mode.
11
+ * Our html-processor now recognizes both Astro's native attributes and our custom ones.
12
+ *
13
+ * HISTORICAL CONTEXT: This plugin was created before we discovered Astro's native
14
+ * source tracking. It caused Vite's build-import-analysis to fail with parsing errors
15
+ * because modifying .astro source files confuses Vite's JavaScript parser.
16
+ *
17
+ * KEEPING FOR: Potential future use cases where custom source attribute injection
18
+ * might be needed, or for testing purposes.
19
+ */
20
+ export declare function createAstroTransformPlugin(options?: AstroTransformOptions): Plugin;
21
+ //# sourceMappingURL=astro-transform.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"astro-transform.d.ts","sourceRoot":"","sources":["../../src/astro-transform.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAElC,MAAM,WAAW,qBAAqB;IACrC,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,OAAO,CAAC,EAAE,OAAO,CAAA;CACjB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,GAAE,qBAA0B,GAAG,MAAM,CAgDtF"}
@@ -0,0 +1,10 @@
1
+ import type { AstroIntegrationLogger } from 'astro';
2
+ import type { ManifestWriter } from './manifest-writer';
3
+ import type { CmsMarkerOptions } from './types';
4
+ /**
5
+ * Process build output - processes all HTML files in parallel
6
+ */
7
+ export declare function processBuildOutput(dir: URL, config: Required<CmsMarkerOptions>, manifestWriter: ManifestWriter, idCounter: {
8
+ value: number;
9
+ }, logger?: AstroIntegrationLogger): Promise<void>;
10
+ //# sourceMappingURL=build-processor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-processor.d.ts","sourceRoot":"","sources":["../../src/build-processor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,OAAO,CAAA;AAKnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAEvD,OAAO,KAAK,EAAE,gBAAgB,EAAmB,MAAM,SAAS,CAAA;AA0KhE;;GAEG;AACH,wBAAsB,kBAAkB,CACvC,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,QAAQ,CAAC,gBAAgB,CAAC,EAClC,cAAc,EAAE,cAAc,EAC9B,SAAS,EAAE;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,EAC5B,MAAM,CAAC,EAAE,sBAAsB,GAC7B,OAAO,CAAC,IAAI,CAAC,CA2Bf"}
@@ -0,0 +1,63 @@
1
+ import type { ComponentDefinition } from './types';
2
+ /**
3
+ * Scans Astro component files and extracts their definitions including props
4
+ */
5
+ export declare class ComponentRegistry {
6
+ private components;
7
+ private componentDirs;
8
+ constructor(componentDirs?: string[]);
9
+ /**
10
+ * Scan all component directories and build the registry
11
+ */
12
+ scan(): Promise<void>;
13
+ /**
14
+ * Get all registered components
15
+ */
16
+ getComponents(): Record<string, ComponentDefinition>;
17
+ /**
18
+ * Get a specific component by name
19
+ */
20
+ getComponent(name: string): ComponentDefinition | undefined;
21
+ /**
22
+ * Scan a directory recursively for .astro files
23
+ */
24
+ private scanDirectory;
25
+ /**
26
+ * Parse a single Astro component file
27
+ */
28
+ private parseComponent;
29
+ /**
30
+ * Parse Props content and extract individual property definitions
31
+ * Handles multi-line properties with nested types
32
+ */
33
+ private parsePropsContent;
34
+ /**
35
+ * Extract content between balanced braces after a pattern match
36
+ * Properly handles nested objects
37
+ */
38
+ private extractBalancedBraces;
39
+ /**
40
+ * Extract props from component frontmatter
41
+ */
42
+ private extractProps;
43
+ /**
44
+ * Parse a single prop line from interface/type
45
+ */
46
+ private parsePropLine;
47
+ /**
48
+ * Extract slot names from template
49
+ */
50
+ private extractSlots;
51
+ /**
52
+ * Extract component description from JSDoc comment
53
+ */
54
+ private extractDescription;
55
+ }
56
+ /**
57
+ * Parse component usage in an Astro file to extract prop values
58
+ */
59
+ export declare function parseComponentUsage(content: string, componentName: string): Array<{
60
+ line: number;
61
+ props: Record<string, string>;
62
+ }>;
63
+ //# sourceMappingURL=component-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component-registry.d.ts","sourceRoot":"","sources":["../../src/component-registry.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAiB,MAAM,SAAS,CAAA;AAEjE;;GAEG;AACH,qBAAa,iBAAiB;IAC7B,OAAO,CAAC,UAAU,CAA8C;IAChE,OAAO,CAAC,aAAa,CAAU;gBAEnB,aAAa,GAAE,MAAM,EAAuB;IAIxD;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAW3B;;OAEG;IACH,aAAa,IAAI,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC;IAIpD;;OAEG;IACH,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,mBAAmB,GAAG,SAAS;IAI3D;;OAEG;YACW,aAAa;IAe3B;;OAEG;YACW,cAAc;IAqB5B;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IA2FzB;;;OAGG;IACH,OAAO,CAAC,qBAAqB;IAyB7B;;OAEG;YACW,YAAY;IA2C1B;;OAEG;IACH,OAAO,CAAC,aAAa;IAoBrB;;OAEG;IACH,OAAO,CAAC,YAAY;IA2BpB;;OAEG;IACH,OAAO,CAAC,kBAAkB;CAY1B;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAClC,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,MAAM,GACnB,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,CAAC,CA6BxD"}
@@ -0,0 +1,7 @@
1
+ import type { ViteDevServer } from 'vite';
2
+ import type { ManifestWriter } from './manifest-writer';
3
+ import type { CmsMarkerOptions, ComponentDefinition } from './types';
4
+ export declare function createDevMiddleware(server: ViteDevServer, config: Required<CmsMarkerOptions>, manifestWriter: ManifestWriter, componentDefinitions: Record<string, ComponentDefinition>, idCounter: {
5
+ value: number;
6
+ }): void;
7
+ //# sourceMappingURL=dev-middleware.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dev-middleware.d.ts","sourceRoot":"","sources":["../../src/dev-middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAA;AAEzC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAEvD,OAAO,KAAK,EAAE,gBAAgB,EAAmB,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAkBrF,wBAAgB,mBAAmB,CAClC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,QAAQ,CAAC,gBAAgB,CAAC,EAClC,cAAc,EAAE,cAAc,EAC9B,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,EACzD,SAAS,EAAE;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,QA0H5B"}
@@ -0,0 +1,51 @@
1
+ import type { ComponentInstance, ManifestEntry } from './types';
2
+ /**
3
+ * Inline text styling elements that should NOT be marked with CMS IDs.
4
+ * These elements are text formatting and should be part of their parent's content.
5
+ * They will be preserved as HTML when editing the parent element.
6
+ */
7
+ export declare const INLINE_STYLE_TAGS: readonly ["strong", "b", "em", "i", "u", "s", "strike", "del", "ins", "mark", "small", "sub", "sup", "abbr", "cite", "code", "kbd", "samp", "var", "time", "dfn", "q"];
8
+ export interface ProcessHtmlOptions {
9
+ attributeName: string;
10
+ includeTags: string[] | null;
11
+ excludeTags: string[];
12
+ includeEmptyText: boolean;
13
+ generateManifest: boolean;
14
+ markComponents?: boolean;
15
+ componentDirs?: string[];
16
+ excludeComponentDirs?: string[];
17
+ markStyledSpans?: boolean;
18
+ /** When true, only mark elements that have source file attributes (from Astro templates) */
19
+ skipMarkdownContent?: boolean;
20
+ /**
21
+ * When true, skip marking inline text styling elements (strong, b, em, i, etc.).
22
+ * These elements will be preserved as part of their parent's HTML content.
23
+ * Defaults to true.
24
+ */
25
+ skipInlineStyleTags?: boolean;
26
+ /** Collection info for marking the wrapper element containing markdown content */
27
+ collectionInfo?: {
28
+ name: string;
29
+ slug: string;
30
+ /** First line of the markdown body (used to find wrapper element in build mode) */
31
+ bodyFirstLine?: string;
32
+ /** Path to the markdown file (e.g., 'src/content/blog/my-post.md') */
33
+ contentPath?: string;
34
+ };
35
+ }
36
+ export interface ProcessHtmlResult {
37
+ html: string;
38
+ entries: Record<string, ManifestEntry>;
39
+ components: Record<string, ComponentInstance>;
40
+ /** ID of the element wrapping collection markdown content */
41
+ collectionWrapperId?: string;
42
+ }
43
+ /**
44
+ * Process HTML to inject CMS markers and extract manifest entries
45
+ */
46
+ export declare function processHtml(html: string, fileId: string, options: ProcessHtmlOptions, getNextId: () => string, sourcePath?: string): Promise<ProcessHtmlResult>;
47
+ /**
48
+ * Clean text for comparison (normalize whitespace)
49
+ */
50
+ export declare function cleanText(text: string): string;
51
+ //# sourceMappingURL=html-processor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html-processor.d.ts","sourceRoot":"","sources":["../../src/html-processor.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAiB,MAAM,SAAS,CAAA;AAG9E;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,wKAuBpB,CAAA;AAEV,MAAM,WAAW,kBAA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egration } from 'astro';
2
+ import type { CmsMarkerOptions } from './types';
3
+ export default function cmsMarker(options?: CmsMarkerOptions): AstroIntegration;
4
+ export { findCollectionSource, parseMarkdownContent } from './source-finder';
5
+ export type { CollectionInfo, MarkdownContent } from './source-finder';
6
+ export type { CmsManifest, CmsMarkerOptions, CollectionEntry, ComponentDefinition, ComponentInstance, ManifestEntry } from './types';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAA;AAK7C,OAAO,KAAK,EAAE,gBAAgB,EAAuB,MAAM,SAAS,CAAA;AAGpE,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,OAAO,GAAE,gBAAqB,GAAG,gBAAgB,CAkFlF;AAGD,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AAC5E,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACtE,YAAY,EAAE,WAAW,EAAE,gBAAgB,EAAE,eAAe,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA"}
@@ -0,0 +1,75 @@
1
+ import type { AvailableColors, CmsManifest, CollectionEntry, ComponentDefinition, ComponentInstance, ManifestEntry } from './types';
2
+ /**
3
+ * Manages streaming manifest writes during build.
4
+ * Accumulates entries and writes per-page manifests as pages are processed.
5
+ */
6
+ export declare class ManifestWriter {
7
+ private globalManifest;
8
+ private pageManifests;
9
+ private outDir;
10
+ private manifestFile;
11
+ private componentDefinitions;
12
+ private availableColors;
13
+ private writeQueue;
14
+ constructor(manifestFile: string, componentDefinitions?: Record<string, ComponentDefinition>);
15
+ /**
16
+ * Set the output directory for manifest files
17
+ */
18
+ setOutDir(dir: string): void;
19
+ /**
20
+ * Update component definitions (called after initial scan)
21
+ */
22
+ setComponentDefinitions(definitions: Record<string, ComponentDefinition>): void;
23
+ /**
24
+ * Load available Tailwind colors from the project's CSS config
25
+ */
26
+ loadAvailableColors(projectRoot?: string): Promise<void>;
27
+ /**
28
+ * Set available colors directly (for testing or custom colors)
29
+ */
30
+ setAvailableColors(colors: AvailableColors): void;
31
+ /**
32
+ * Get the manifest path for a given page
33
+ * Places manifest next to the page: /about -> /about.json, / -> /index.json
34
+ */
35
+ private getPageManifestPath;
36
+ /**
37
+ * Add a page's entries to the manifest (called after each page is processed)
38
+ * This is non-blocking - writes are queued
39
+ */
40
+ addPage(pagePath: string, entries: Record<string, ManifestEntry>, components: Record<string, ComponentInstance>, collection?: CollectionEntry): void;
41
+ /**
42
+ * Write a single page manifest to disk
43
+ */
44
+ private writePageManifest;
45
+ /**
46
+ * Finalize manifest writes
47
+ * Call this in astro:build:done to ensure all writes complete
48
+ */
49
+ finalize(): Promise<{
50
+ totalEntries: number;
51
+ totalPages: number;
52
+ totalComponents: number;
53
+ }>;
54
+ /**
55
+ * Get the global manifest (for virtual module support)
56
+ */
57
+ getGlobalManifest(): CmsManifest;
58
+ /**
59
+ * Get a page's manifest data (for dev mode)
60
+ */
61
+ getPageManifest(pagePath: string): {
62
+ entries: Record<string, ManifestEntry>;
63
+ components: Record<string, ComponentInstance>;
64
+ collection?: CollectionEntry;
65
+ } | undefined;
66
+ /**
67
+ * Reset state (for dev mode reloads)
68
+ */
69
+ reset(): void;
70
+ /**
71
+ * Get available colors (for use in dev middleware)
72
+ */
73
+ getAvailableColors(): AvailableColors | undefined;
74
+ }
75
+ //# sourceMappingURL=manifest-writer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest-writer.d.ts","sourceRoot":"","sources":["../../src/manifest-writer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,eAAe,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,aAAa,EAAoB,MAAM,SAAS,CAAA;AAMrJ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EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAA;QAC7C,UAAU,CAAC,EAAE,eAAe,CAAA;KAC5B,GAAG,SAAS;IAIb;;OAEG;IACH,KAAK,IAAI,IAAI;IAYb;;OAEG;IACH,kBAAkB,IAAI,eAAe,GAAG,SAAS;CAGjD"}
@@ -0,0 +1,97 @@
1
+ import type { ManifestEntry } from './types';
2
+ export interface SourceLocation {
3
+ file: string;
4
+ line: number;
5
+ snippet?: string;
6
+ type?: 'static' | 'variable' | 'prop' | 'computed' | 'collection';
7
+ variableName?: string;
8
+ definitionLine?: number;
9
+ /** Collection name for collection entries */
10
+ collectionName?: string;
11
+ /** Entry slug for collection entries */
12
+ collectionSlug?: string;
13
+ }
14
+ export interface VariableReference {
15
+ name: string;
16
+ pattern: string;
17
+ definitionLine: number;
18
+ }
19
+ export interface CollectionInfo {
20
+ name: string;
21
+ slug: string;
22
+ file: string;
23
+ }
24
+ export interface MarkdownContent {
25
+ /** Frontmatter fields as key-value pairs with line numbers */
26
+ frontmatter: Record<string, {
27
+ value: string;
28
+ line: number;
29
+ }>;
30
+ /** The full markdown body content */
31
+ body: string;
32
+ /** Line number where body starts */
33
+ bodyStartLine: number;
34
+ /** File path relative to cwd */
35
+ file: string;
36
+ /** Collection name */
37
+ collectionName: string;
38
+ /** Collection slug */
39
+ collectionSlug: string;
40
+ }
41
+ /**
42
+ * Find source file and line number for text content
43
+ */
44
+ export declare function findSourceLocation(textContent: string, tag: string): Promise<SourceLocation | undefined>;
45
+ /**
46
+ * Extract complete tag snippet including content and indentation.
47
+ * Exported for use in html-processor to populate sourceSnippet.
48
+ */
49
+ export declare function extractCompleteTagSnippet(lines: string[], startLine: number, tag: string): string;
50
+ /**
51
+ * Extract innerHTML from a complete tag snippet.
52
+ * Given `<p class="foo">content here</p>`, returns `content here`.
53
+ *
54
+ * @param snippet - The complete tag snippet from source
55
+ * @param tag - The tag name (e.g., 'p', 'h1')
56
+ * @returns The innerHTML portion, or undefined if can't extract
57
+ */
58
+ export declare function extractInnerHtmlFromSnippet(snippet: string, tag: string): string | undefined;
59
+ /**
60
+ * Read source file and extract the innerHTML at the specified line.
61
+ *
62
+ * @param sourceFile - Path to source file (relative to cwd)
63
+ * @param sourceLine - 1-indexed line number
64
+ * @param tag - The tag name
65
+ * @returns The innerHTML from source, or undefined if can't extract
66
+ */
67
+ export declare function extractSourceInnerHtml(sourceFile: string, sourceLine: number, tag: string): Promise<string | undefined>;
68
+ /**
69
+ * Find markdown collection file for a given page path
70
+ * @param pagePath - The URL path of the page (e.g., '/services/3d-tisk')
71
+ * @param contentDir - The content directory (default: 'src/content')
72
+ * @returns Collection info if found, undefined otherwise
73
+ */
74
+ export declare function findCollectionSource(pagePath: string, contentDir?: string): Promise<CollectionInfo | undefined>;
75
+ /**
76
+ * Find text content in a markdown file and return source location
77
+ * Only matches frontmatter fields, not body content (body is handled separately as a whole)
78
+ * @param textContent - The text content to search for
79
+ * @param collectionInfo - Collection information (name, slug, file path)
80
+ * @returns Source location if found in frontmatter
81
+ */
82
+ export declare function findMarkdownSourceLocation(textContent: string, collectionInfo: CollectionInfo): Promise<SourceLocation | undefined>;
83
+ /**
84
+ * Parse markdown file and extract frontmatter fields and full body content
85
+ * @param collectionInfo - Collection information (name, slug, file path)
86
+ * @returns Parsed markdown content with frontmatter and body
87
+ */
88
+ export declare function parseMarkdownContent(collectionInfo: CollectionInfo): Promise<MarkdownContent | undefined>;
89
+ /**
90
+ * Enhance manifest entries with actual source snippets from source files.
91
+ * This reads the source files and extracts the innerHTML at the specified locations.
92
+ *
93
+ * @param entries - Manifest entries to enhance
94
+ * @returns Enhanced entries with sourceSnippet populated
95
+ */
96
+ export declare function enhanceManifestWithSourceSnippets(entries: Record<string, ManifestEntry>): Promise<Record<string, ManifestEntry>>;
97
+ //# sourceMappingURL=source-finder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source-finder.d.ts","sourceRoot":"","sources":["../../src/source-finder.ts"],"names":[],"mapp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AgB,yBAAyB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAmCjG;AAED;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAqB5F;AAED;;;;;;;GAOG;AACH,wBAAsB,sBAAsB,CAC3C,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,GAAG,EAAE,MAAM,GACT,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAiB7B;AAoHD;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACzC,QAAQ,EAAE,MAAM,EAChB,UAAU,GAAE,MAAsB,GAChC,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC,CAoDrC;AA0DD;;;;;;GAMG;AACH,wBAAsB,0BAA0B,CAC/C,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,cAAc,GAC5B,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC,CAiErC;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,CACzC,cAAc,EAAE,cAAc,GAC5B,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC,CAqEtC;AAmBD;;;;;;GAMG;AACH,wBAAsB,iCAAiC,CACtD,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,GACpC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAgCxC"}
@@ -0,0 +1,66 @@
1
+ import type { AvailableColors, ColorClasses } from './types';
2
+ /**
3
+ * Default Tailwind CSS v4 color names.
4
+ * These are available by default in Tailwind v4.
5
+ */
6
+ export declare const DEFAULT_TAILWIND_COLORS: readonly ["slate", "gray", "zinc", "neutral", "stone", "red", "orange", "amber", "yellow", "lime", "green", "emerald", "teal", "cyan", "sky", "blue", "indigo", "violet", "purple", "fuchsia", "pink", "rose"];
7
+ /**
8
+ * Standard Tailwind color shades.
9
+ */
10
+ export declare const STANDARD_SHADES: readonly ["50", "100", "200", "300", "400", "500", "600", "700", "800", "900", "950"];
11
+ /**
12
+ * Special color values that don't have shades.
13
+ */
14
+ export declare const SPECIAL_COLORS: readonly ["transparent", "current", "inherit", "white", "black"];
15
+ /**
16
+ * Parse Tailwind v4 CSS config to extract available colors.
17
+ * Tailwind v4 uses CSS-based configuration with @theme directive.
18
+ *
19
+ * Example CSS:
20
+ * ```css
21
+ * @theme {
22
+ * --color-primary-50: #eff6ff;
23
+ * --color-primary-500: #3b82f6;
24
+ * --color-accent: #f59e0b;
25
+ * }
26
+ * ```
27
+ */
28
+ export declare function parseTailwindConfig(projectRoot?: string): Promise<AvailableColors>;
29
+ /**
30
+ * Extract color classes from an element's class attribute.
31
+ */
32
+ export declare function extractColorClasses(classAttr: string | null | undefined): ColorClasses | undefined;
33
+ /**
34
+ * Check if a class is a color class.
35
+ */
36
+ export declare function isColorClass(className: string): boolean;
37
+ /**
38
+ * Generate a new class string with a color class replaced.
39
+ * @param currentClasses - Current class attribute value
40
+ * @param oldColorClass - The color class to replace (e.g., 'bg-blue-500')
41
+ * @param newColorClass - The new color class (e.g., 'bg-red-500')
42
+ * @returns New class string with the replacement
43
+ */
44
+ export declare function replaceColorClass(currentClasses: string, oldColorClass: string, newColorClass: string): string;
45
+ /**
46
+ * Get the color type from a color class.
47
+ * @param colorClass - e.g., 'bg-blue-500', 'text-white', 'hover:bg-red-600'
48
+ * @returns The type: 'bg', 'text', 'border', 'hoverBg', 'hoverText', or undefined
49
+ */
50
+ export declare function getColorType(colorClass: string): keyof ColorClasses | undefined;
51
+ /**
52
+ * Parse a color class into its components.
53
+ * @param colorClass - e.g., 'bg-blue-500', 'text-white', 'hover:bg-red-600'
54
+ * @returns Object with prefix, colorName, and shade (if any)
55
+ */
56
+ export declare function parseColorClass(colorClass: string): {
57
+ prefix: string;
58
+ colorName: string;
59
+ shade?: string;
60
+ isHover: boolean;
61
+ } | undefined;
62
+ /**
63
+ * Build a color class from components.
64
+ */
65
+ export declare function buildColorClass(prefix: string, colorName: string, shade?: string): string;
66
+ //# sourceMappingURL=tailwind-colors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tailwind-colors.d.ts","sourceRoot":"","sources":["../../src/tailwind-colors.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAiB,MAAM,SAAS,CAAA;AAE3E;;;GAGG;AACH,eAAO,MAAM,uBAAuB,gNAuB1B,CAAA;AAEV;;GAEG;AACH,eAAO,MAAM,eAAe,uFAAwF,CAAA;AAEpH;;GAEG;AACH,eAAO,MAAM,cAAc,kEAAmE,CAAA;AAgC9F;;;;;;;;;;;;GAYG;AACH,wBAAsB,mBAAmB,CAAC,WAAW,GAAE,MAAsB,GAAG,OAAO,CAAC,eAAe,CAAC,CA+CvG;AA6FD;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,YAAY,GAAG,SAAS,CA4BlG;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAEvD;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAChC,cAAc,EAAE,MAAM,EACtB,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,MAAM,GACnB,MAAM,CAIR;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,YAAY,GAAG,SAAS,CAO/E;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG;IACpD,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,OAAO,CAAA;CAChB,GAAG,SAAS,CAgBZ;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC9B,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,KAAK,CAAC,EAAE,MAAM,GACZ,MAAM,CAKR"}