@kimesh/tailwindcss 0.1.0-nightly.20260119170404 → 0.1.0-nightly.20260120063147
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 +1 -4
- package/dist/index.js +1 -2
- package/package.json +3 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -37,7 +37,6 @@ interface KimeshTailwindConfig {
|
|
|
37
37
|
*/
|
|
38
38
|
referenceAlias?: string;
|
|
39
39
|
}
|
|
40
|
-
//# sourceMappingURL=types.d.ts.map
|
|
41
40
|
//#endregion
|
|
42
41
|
//#region src/module.d.ts
|
|
43
42
|
|
|
@@ -98,7 +97,5 @@ declare function hasTailwindDirectives(content: string): boolean;
|
|
|
98
97
|
* @returns true if @reference is already present
|
|
99
98
|
*/
|
|
100
99
|
declare function hasReferenceDirective(content: string): boolean;
|
|
101
|
-
//# sourceMappingURL=transform.d.ts.map
|
|
102
100
|
//#endregion
|
|
103
|
-
export { type KimeshTailwindConfig, createReferenceTransformer, _default as default, hasReferenceDirective, hasTailwindDirectives, _default as tailwindcss };
|
|
104
|
-
//# sourceMappingURL=index.d.ts.map
|
|
101
|
+
export { type KimeshTailwindConfig, createReferenceTransformer, _default as default, hasReferenceDirective, hasTailwindDirectives, _default as tailwindcss };
|
package/dist/index.js
CHANGED
|
@@ -179,5 +179,4 @@ var module_default = defineKimeshModule({
|
|
|
179
179
|
});
|
|
180
180
|
|
|
181
181
|
//#endregion
|
|
182
|
-
export { createReferenceTransformer, module_default as default, hasReferenceDirective, hasTailwindDirectives, module_default as tailwindcss };
|
|
183
|
-
//# sourceMappingURL=index.js.map
|
|
182
|
+
export { createReferenceTransformer, module_default as default, hasReferenceDirective, hasTailwindDirectives, module_default as tailwindcss };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kimesh/tailwindcss",
|
|
3
|
-
"version": "0.1.0-nightly.
|
|
3
|
+
"version": "0.1.0-nightly.20260120063147",
|
|
4
4
|
"description": "TailwindCSS module for Kimesh framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
"magic-string": "^0.30.17"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
|
-
"@kimesh/kit": "0.1.0-nightly.
|
|
29
|
+
"@kimesh/kit": "0.1.0-nightly.20260120063147",
|
|
30
30
|
"vite": "^8.0.0-beta.8",
|
|
31
31
|
"tailwindcss": "^4.0.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@kimesh/kit": "0.1.0-nightly.
|
|
34
|
+
"@kimesh/kit": "0.1.0-nightly.20260120063147",
|
|
35
35
|
"tsdown": "^0.11.6",
|
|
36
36
|
"typescript": "^5.8.3",
|
|
37
37
|
"vite": "^8.0.0-beta.8"
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/module.ts","../src/transform.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AAOA;;UAAiB,oBAAA;;ACYmC;;;;;;;;ECuBpC;AAsEhB;AAUA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAhFA;AAsEA;AAUA;;;;;;;;cDvGoD;;;;;;ADZpD;;;;ACYoD;;;;;;;;ACuBpD;AAsEA;AAUA;;;;;iBAhFgB,0BAAA,iBAA2C;;;;;;;iBAsE3C,qBAAA;;;;;;;iBAUA,qBAAA"}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["alias: string","code: string","id: string","match: RegExpExecArray | null","content: string","kimesh: Kimesh","additionalSources: string[]","lines: string[]","kimesh"],"sources":["../src/transform.ts","../src/module.ts"],"sourcesContent":["import type { VitePlugin } from \"@kimesh/kit\";\nimport MagicString from \"magic-string\";\n\n/**\n * Regex to match <style> blocks in Vue SFC files\n * Captures the opening tag, content, and closing tag\n */\nconst STYLE_BLOCK_RE = /<style([^>]*)>([\\s\\S]*?)<\\/style>/gi;\n\n/**\n * Regex to detect Tailwind directives that require @reference\n * Matches @apply, @screen, @layer (Tailwind-specific), and @variant\n */\nconst TAILWIND_DIRECTIVE_RE = /@(?:apply|screen|variant)\\b/;\n\n/**\n * Regex to detect existing @reference directive\n */\nconst EXISTING_REFERENCE_RE = /@reference\\s/;\n\n/**\n * Creates a Vite transform plugin that auto-injects @reference in Vue <style> blocks\n *\n * This plugin detects Vue SFC files with <style> blocks that use Tailwind directives\n * (like @apply, @screen, @variant) and automatically injects the @reference directive\n * at the beginning of the style block if not already present.\n *\n * @param alias - The alias to use for @reference (e.g., '#kimesh/tailwind')\n * @returns Vite plugin configuration\n *\n * @example\n * // Input Vue SFC:\n * // <style scoped>\n * // .btn { @apply px-4 py-2 bg-blue-500; }\n * // </style>\n * //\n * // Output:\n * // <style scoped>\n * // @reference '#kimesh/tailwind';\n * // .btn { @apply px-4 py-2 bg-blue-500; }\n * // </style>\n */\nexport function createReferenceTransformer(alias: string): VitePlugin {\n return {\n name: \"kimesh:tailwind:reference\",\n enforce: \"pre\",\n\n transform(code: string, id: string) {\n // Only process .vue files\n if (!id.endsWith(\".vue\")) {\n return null;\n }\n\n // Check if file has any style blocks\n if (!code.includes(\"<style\")) {\n return null;\n }\n\n const s = new MagicString(code);\n let hasChanges = false;\n\n // Find and process all <style> blocks\n let match: RegExpExecArray | null;\n STYLE_BLOCK_RE.lastIndex = 0;\n\n while ((match = STYLE_BLOCK_RE.exec(code)) !== null) {\n const [fullMatch, attributes, styleContent] = match;\n const matchStart = match.index;\n const contentStart =\n matchStart + \"<style\".length + attributes.length + 1;\n\n // Skip if this style block doesn't use Tailwind directives\n if (!TAILWIND_DIRECTIVE_RE.test(styleContent)) {\n continue;\n }\n\n // Skip if @reference already present\n if (EXISTING_REFERENCE_RE.test(styleContent)) {\n continue;\n }\n\n // Calculate position after the opening <style> tag\n const insertPosition = contentStart;\n\n // Inject @reference directive\n const referenceDirective = `@reference '${alias}';\\n`;\n s.appendLeft(insertPosition, referenceDirective);\n hasChanges = true;\n }\n\n if (!hasChanges) {\n return null;\n }\n\n return {\n code: s.toString(),\n map: s.generateMap({\n source: id,\n hires: true,\n includeContent: true,\n }),\n };\n },\n };\n}\n\n/**\n * Detects if a CSS/style content uses Tailwind directives\n *\n * @param content - CSS content to check\n * @returns true if Tailwind directives are detected\n */\nexport function hasTailwindDirectives(content: string): boolean {\n return TAILWIND_DIRECTIVE_RE.test(content);\n}\n\n/**\n * Detects if a CSS/style content already has @reference\n *\n * @param content - CSS content to check\n * @returns true if @reference is already present\n */\nexport function hasReferenceDirective(content: string): boolean {\n return EXISTING_REFERENCE_RE.test(content);\n}\n","/**\n * @kimesh/tailwindcss - Module Implementation (v2)\n *\n * Kimesh module for TailwindCSS integration.\n * - Generates @source directives for all layer srcDirs\n * - Creates physical CSS files for @tailwindcss/vite compatibility\n * - Auto-injects @reference in Vue <style> blocks\n */\n\nimport { existsSync } from \"node:fs\";\nimport { join, relative } from \"node:path\";\nimport {\n defineKimeshModule,\n addTemplate,\n addAlias,\n addVitePlugin,\n createResolver,\n} from \"@kimesh/kit\";\nimport type { Kimesh } from \"@kimesh/kit\";\nimport type { KimeshTailwindConfig } from \"./types\";\nimport { createReferenceTransformer } from \"./transform\";\n\n/**\n * Generate CSS content with @source directives for all layers\n */\nfunction generateSourcesCSS(\n kimesh: Kimesh,\n additionalSources: string[]\n): string {\n const lines: string[] = [\n \"/* Auto-generated by @kimesh/tailwindcss */\",\n \"\",\n ];\n\n // Generate @source directive for each layer's srcDir\n for (const layer of kimesh.layers) {\n const srcDir = `${layer.path}/src`;\n const sourcePath = relative(kimesh.buildDir, srcDir);\n const normalizedPath = sourcePath.replace(/\\\\/g, \"/\");\n lines.push(`@source \"${normalizedPath}\";`);\n }\n\n // Add additional sources\n if (additionalSources.length > 0) {\n lines.push(\"\");\n lines.push(\"/* Additional sources */\");\n for (const source of additionalSources) {\n const normalizedPath = source.replace(/\\\\/g, \"/\");\n lines.push(`@source \"${normalizedPath}\";`);\n }\n }\n\n return lines.join(\"\\n\");\n}\n\n/**\n * Generate the main CSS content\n */\nfunction generateMainCSS(kimesh: Kimesh, additionalSources: string[]): string {\n const sourcesCSS = generateSourcesCSS(kimesh, additionalSources);\n\n return [\n `/* Generated by @kimesh/tailwindcss - DO NOT EDIT */`,\n ``,\n `@import 'tailwindcss';`,\n ``,\n `/* Layer sources */`,\n sourcesCSS || \"/* No layers configured */\",\n ].join(\"\\n\");\n}\n\n/**\n * @kimesh/tailwindcss module\n *\n * @example\n * ```typescript\n * // kimesh.config.ts\n * import tailwindcss from '@kimesh/tailwindcss'\n *\n * export default defineKmConfig({\n * modules: [\n * tailwindcss,\n * // or with options:\n * [tailwindcss, { autoReference: false }]\n * ]\n * })\n * ```\n */\nexport default defineKimeshModule<KimeshTailwindConfig>({\n meta: {\n name: \"@kimesh/tailwindcss\",\n version: \"2.0.0\",\n configKey: \"tailwindcss\",\n },\n\n defaults: {\n additionalSources: [],\n cssFileName: \"tailwind.css\",\n autoReference: true,\n alias: \"#kimesh/tailwind\",\n mainCss: \"src/app.css\",\n referenceAlias: \"#tailwind\",\n },\n\n hooks: {\n // Regenerate CSS when layers change\n \"layers:extend\": async (layers) => {\n // Templates will be regenerated automatically\n },\n },\n\n async setup(options, kimesh) {\n const {\n additionalSources = [],\n cssFileName = \"tailwind.css\",\n autoReference = true,\n alias = \"#kimesh/tailwind\",\n mainCss = \"src/app.css\",\n referenceAlias = \"#tailwind\",\n } = options;\n\n const cssFilePath = join(kimesh.buildDir, cssFileName);\n\n // Add template for the CSS file\n // Using template system instead of manual writeFileSync\n addTemplate({\n filename: cssFileName,\n write: true,\n getContents: ({ kimesh }) => generateMainCSS(kimesh, additionalSources),\n });\n\n // Register alias for the generated CSS\n addAlias(alias, cssFilePath);\n\n // Setup reference alias for Vue <style> @reference\n const mainCssPath = join(kimesh.root, mainCss);\n const effectiveReferenceAlias = existsSync(mainCssPath)\n ? referenceAlias\n : alias;\n\n if (existsSync(mainCssPath)) {\n addAlias(referenceAlias, mainCssPath);\n }\n\n // Add reference transformer if enabled\n if (autoReference) {\n addVitePlugin(createReferenceTransformer(effectiveReferenceAlias));\n }\n },\n});\n"],"mappings":";;;;;;;;;;AAOA,MAAM,iBAAiB;;;;;AAMvB,MAAM,wBAAwB;;;;AAK9B,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;AAwB9B,SAAgB,2BAA2BA,OAA2B;AACpE,QAAO;EACL,MAAM;EACN,SAAS;EAET,UAAUC,MAAcC,IAAY;AAElC,QAAK,GAAG,SAAS,OAAO,CACtB,QAAO;AAIT,QAAK,KAAK,SAAS,SAAS,CAC1B,QAAO;GAGT,MAAM,IAAI,IAAI,YAAY;GAC1B,IAAI,aAAa;GAGjB,IAAIC;AACJ,kBAAe,YAAY;AAE3B,WAAQ,QAAQ,eAAe,KAAK,KAAK,MAAM,MAAM;IACnD,MAAM,CAAC,WAAW,YAAY,aAAa,GAAG;IAC9C,MAAM,aAAa,MAAM;IACzB,MAAM,eACJ,aAAa,IAAkB,WAAW,SAAS;AAGrD,SAAK,sBAAsB,KAAK,aAAa,CAC3C;AAIF,QAAI,sBAAsB,KAAK,aAAa,CAC1C;IAIF,MAAM,iBAAiB;IAGvB,MAAM,sBAAsB,cAAc,MAAM;AAChD,MAAE,WAAW,gBAAgB,mBAAmB;AAChD,iBAAa;GACd;AAED,QAAK,WACH,QAAO;AAGT,UAAO;IACL,MAAM,EAAE,UAAU;IAClB,KAAK,EAAE,YAAY;KACjB,QAAQ;KACR,OAAO;KACP,gBAAgB;IACjB,EAAC;GACH;EACF;CACF;AACF;;;;;;;AAQD,SAAgB,sBAAsBC,SAA0B;AAC9D,QAAO,sBAAsB,KAAK,QAAQ;AAC3C;;;;;;;AAQD,SAAgB,sBAA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