@udixio/tailwind 1.3.0 → 1.5.0
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/CHANGELOG.md +31 -0
- package/dist/browser/assets.d.ts +7 -0
- package/dist/browser/assets.d.ts.map +1 -0
- package/dist/browser/instrumentation.d.ts +7 -0
- package/dist/browser/instrumentation.d.ts.map +1 -0
- package/dist/browser/tailwind-browser.d.ts +2 -0
- package/dist/browser/tailwind-browser.d.ts.map +1 -0
- package/dist/browser/tailwind.plugin.d.ts +21 -0
- package/dist/browser/tailwind.plugin.d.ts.map +1 -0
- package/dist/browser.cjs +8 -0
- package/dist/browser.js +9 -0
- package/dist/index.browser.d.ts +5 -0
- package/dist/index.browser.d.ts.map +1 -0
- package/dist/{index.d.ts → index.node.d.ts} +2 -2
- package/dist/index.node.d.ts.map +1 -0
- package/dist/main.d.ts +9 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/node/file.d.ts +6 -0
- package/dist/node/file.d.ts.map +1 -0
- package/dist/node/index.d.ts +3 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/node/tailwind.plugin.d.ts +13 -0
- package/dist/node/tailwind.plugin.d.ts.map +1 -0
- package/dist/node.cjs +370 -0
- package/dist/node.js +332 -0
- package/dist/plugins-tailwind/font.d.ts +7 -0
- package/dist/plugins-tailwind/font.d.ts.map +1 -0
- package/dist/plugins-tailwind/shadow.d.ts +2 -0
- package/dist/plugins-tailwind/shadow.d.ts.map +1 -0
- package/dist/plugins-tailwind/state.d.ts +5 -0
- package/dist/plugins-tailwind/state.d.ts.map +1 -0
- package/dist/tailwind-browser-COFzjMN4.cjs +249 -0
- package/dist/tailwind-browser-CTGKNrKy.js +232 -0
- package/dist/tailwind.plugin-Ce1R9Jc0.js +222 -0
- package/dist/tailwind.plugin-JU5cwZvP.cjs +221 -0
- package/package.json +22 -10
- package/src/browser/assets.ts +11 -0
- package/src/browser/instrumentation.ts +29 -0
- package/src/browser/tailwind-browser.ts +327 -0
- package/src/browser/tailwind.plugin.ts +74 -0
- package/src/index.browser.ts +5 -0
- package/src/{index.ts → index.node.ts} +1 -1
- package/src/node/file.ts +340 -0
- package/src/node/index.ts +2 -0
- package/src/{tailwind.plugin.ts → node/tailwind.plugin.ts} +57 -71
- package/tsconfig.lib.json +1 -0
- package/vite.config.ts +21 -4
- package/dist/file.d.ts +0 -6
- package/dist/file.d.ts.map +0 -1
- package/dist/index.cjs +0 -428
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -410
- package/dist/tailwind.plugin.d.ts +0 -16
- package/dist/tailwind.plugin.d.ts.map +0 -1
- package/src/file.ts +0 -227
- package/src/index.test.ts +0 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,34 @@
|
|
|
1
|
+
## 1.5.0 (2025-08-28)
|
|
2
|
+
|
|
3
|
+
### 🚀 Features
|
|
4
|
+
|
|
5
|
+
- **tailwind:** enhance browser integration with direct CSS compilation ([ac2caad](https://github.com/Udixio/UI/commit/ac2caad))
|
|
6
|
+
- **tailwind:** refactor browser integration and update dependencies ([3698754](https://github.com/Udixio/UI/commit/3698754))
|
|
7
|
+
- **tailwind:** implement browser-specific runtime for dynamic stylesheet handling ([da29439](https://github.com/Udixio/UI/commit/da29439))
|
|
8
|
+
|
|
9
|
+
### ❤️ Thank You
|
|
10
|
+
|
|
11
|
+
- Joël VIGREUX
|
|
12
|
+
|
|
13
|
+
## 1.4.0 (2025-08-27)
|
|
14
|
+
|
|
15
|
+
### 🚀 Features
|
|
16
|
+
|
|
17
|
+
- **theme, tailwind, ui-react:** update package entries and async plugin resolution ([be9c65c](https://github.com/Udixio/UI/commit/be9c65c))
|
|
18
|
+
- **tailwind:** split browser and node-specific logic with updated exports ([5335caa](https://github.com/Udixio/UI/commit/5335caa))
|
|
19
|
+
- **theme, ui-react, tailwind:** introduce node polyfills and improve async support ([f5c816a](https://github.com/Udixio/UI/commit/f5c816a))
|
|
20
|
+
- **tailwind:** add `@tailwindcss/browser` support and improve environment handling ([166d850](https://github.com/Udixio/UI/commit/166d850))
|
|
21
|
+
- integrate `rollup-plugin-visualizer` into Vite configs ([c92311a](https://github.com/Udixio/UI/commit/c92311a))
|
|
22
|
+
- **tailwind:** improve file utilities with enhanced CLI logging using `chalk` ([a32de93](https://github.com/Udixio/UI/commit/a32de93))
|
|
23
|
+
|
|
24
|
+
### 🧱 Updated Dependencies
|
|
25
|
+
|
|
26
|
+
- Updated @udixio/theme to 1.2.0
|
|
27
|
+
|
|
28
|
+
### ❤️ Thank You
|
|
29
|
+
|
|
30
|
+
- Joël VIGREUX
|
|
31
|
+
|
|
1
32
|
## 1.3.0 (2025-08-25)
|
|
2
33
|
|
|
3
34
|
### 🚀 Features
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assets.d.ts","sourceRoot":"","sources":["../../src/browser/assets.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,GAAG;;;;;CAKf,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../../src/browser/instrumentation.ts"],"names":[],"mappings":"AAAA,qBAAa,eAAe;IAC1B,KAAK,CAAC,KAAK,EAAE,MAAM;IAInB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG;IAU/B,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG;IAM/B,KAAK,CAAC,KAAK,EAAE,GAAG;CAOjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tailwind-browser.d.ts","sourceRoot":"","sources":["../../src/browser/tailwind-browser.ts"],"names":[],"mappings":"AAqSA,wBAAsB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAiC3E"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { FontPlugin, PluginAbstract, PluginImplAbstract } from '@udixio/theme';
|
|
2
|
+
export interface TailwindPluginOptions {
|
|
3
|
+
responsiveBreakPoints?: Record<string, number>;
|
|
4
|
+
styleFilePath?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare class TailwindPlugin extends PluginAbstract<TailwindImplPluginBrowser, TailwindPluginOptions> {
|
|
7
|
+
dependencies: (typeof FontPlugin)[];
|
|
8
|
+
name: string;
|
|
9
|
+
pluginClass: typeof TailwindImplPluginBrowser;
|
|
10
|
+
}
|
|
11
|
+
export declare class TailwindImplPluginBrowser extends PluginImplAbstract<TailwindPluginOptions> {
|
|
12
|
+
outputCss: string;
|
|
13
|
+
protected colors: Record<string, {
|
|
14
|
+
light: string;
|
|
15
|
+
dark: string;
|
|
16
|
+
}>;
|
|
17
|
+
onInit(): void;
|
|
18
|
+
loadColor(): void;
|
|
19
|
+
onLoad(): Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=tailwind.plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tailwind.plugin.d.ts","sourceRoot":"","sources":["../../src/browser/tailwind.plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAE/E,MAAM,WAAW,qBAAqB;IAEpC,qBAAqB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/C,aAAa,CAAC,EAAE,MAAM,CAAC;CAExB;AAED,qBAAa,cAAe,SAAQ,cAAc,CAChD,yBAAyB,EACzB,qBAAqB,CACtB;IACQ,YAAY,wBAAgB;IAC5B,IAAI,SAAc;IACzB,WAAW,mCAA6B;CACzC;AAED,qBAAa,yBAA0B,SAAQ,kBAAkB,CAAC,qBAAqB,CAAC;IAC/E,SAAS,SAAM;IACtB,SAAS,CAAC,MAAM,EAAE,MAAM,CACtB,MAAM,EACN;QACE,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;KACd,CACF,CAAM;IAEP,MAAM;IAMN,SAAS;IAmBH,MAAM;CAoBb"}
|
package/dist/browser.cjs
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const tailwind_plugin = require("./tailwind.plugin-JU5cwZvP.cjs");
|
|
4
|
+
exports.TailwindImplPluginBrowser = tailwind_plugin.TailwindImplPluginBrowser;
|
|
5
|
+
exports.TailwindPlugin = tailwind_plugin.TailwindPlugin;
|
|
6
|
+
exports.default = tailwind_plugin.main;
|
|
7
|
+
exports.font = tailwind_plugin.font;
|
|
8
|
+
exports.state = tailwind_plugin.state;
|
package/dist/browser.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.browser.d.ts","sourceRoot":"","sources":["../src/index.browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.node.d.ts","sourceRoot":"","sources":["../src/index.node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,QAAQ,CAAC;AACvB,eAAe,IAAI,CAAC"}
|
package/dist/main.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FontPluginOptions, StateOptions } from './plugins-tailwind';
|
|
2
|
+
export type ConfigJs = FontPluginOptions & StateOptions;
|
|
3
|
+
export type ConfigCss = {
|
|
4
|
+
colorKeys: string[];
|
|
5
|
+
fontStyles: string[];
|
|
6
|
+
responsiveBreakPoints: string[];
|
|
7
|
+
};
|
|
8
|
+
export declare const main: import('node_modules/tailwindcss/dist/types-WlZgYgM8.mjs').c<ConfigJs>;
|
|
9
|
+
//# sourceMappingURL=main.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,iBAAiB,EAEjB,YAAY,EACb,MAAM,oBAAoB,CAAC;AAG5B,MAAM,MAAM,QAAQ,GAAG,iBAAiB,GAAG,YAAY,CAAC;AACxD,MAAM,MAAM,SAAS,GAAG;IACtB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,qBAAqB,EAAE,MAAM,EAAE,CAAC;CACjC,CAAC;AAEF,eAAO,MAAM,IAAI,wEAuCf,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const createOrUpdateFile: (filePath: string, content: string) => Promise<void>;
|
|
2
|
+
export declare const getFileContent: (filePath: string, searchPattern?: RegExp | string) => Promise<string | false | null>;
|
|
3
|
+
export declare const replaceFileContent: (filePath: string, searchPattern: RegExp | string, replacement: string) => Promise<void>;
|
|
4
|
+
export declare const findTailwindCssFile: (startDir: string, searchPattern: RegExp | string) => Promise<string | never>;
|
|
5
|
+
export declare function findProjectRoot(startPath: string): Promise<string>;
|
|
6
|
+
//# sourceMappingURL=file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../src/node/file.ts"],"names":[],"mappings":"AAqDA,eAAO,MAAM,kBAAkB,GAC7B,UAAU,MAAM,EAChB,SAAS,MAAM,KACd,OAAO,CAAC,IAAI,CA8Bd,CAAC;AAEF,eAAO,MAAM,cAAc,GACzB,UAAU,MAAM,EAChB,gBAAgB,MAAM,GAAG,MAAM,KAC9B,OAAO,CAAC,MAAM,GAAG,KAAK,GAAG,IAAI,CAuE/B,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAC7B,UAAU,MAAM,EAChB,eAAe,MAAM,GAAG,MAAM,EAC9B,aAAa,MAAM,KAClB,OAAO,CAAC,IAAI,CAmCd,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAC9B,UAAU,MAAM,EAChB,eAAe,MAAM,GAAG,MAAM,KAC7B,OAAO,CAAC,MAAM,GAAG,KAAK,CA4FxB,CAAC;AAEF,wBAAsB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAqCxE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,QAAQ,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FontPlugin, PluginAbstract } from '@udixio/theme';
|
|
2
|
+
import { TailwindImplPluginBrowser, TailwindPluginOptions } from '../browser/tailwind.plugin';
|
|
3
|
+
export declare class TailwindPlugin extends PluginAbstract<TailwindImplPlugin, TailwindPluginOptions> {
|
|
4
|
+
dependencies: (typeof FontPlugin)[];
|
|
5
|
+
name: string;
|
|
6
|
+
pluginClass: typeof TailwindImplPlugin;
|
|
7
|
+
}
|
|
8
|
+
declare class TailwindImplPlugin extends TailwindImplPluginBrowser {
|
|
9
|
+
private isNodeJs;
|
|
10
|
+
onLoad(): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=tailwind.plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tailwind.plugin.d.ts","sourceRoot":"","sources":["../../src/node/tailwind.plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE3D,OAAO,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAI9F,qBAAa,cAAe,SAAQ,cAAc,CAChD,kBAAkB,EAClB,qBAAqB,CACtB;IACQ,YAAY,wBAAgB;IAC5B,IAAI,SAAc;IACzB,WAAW,4BAAsB;CAClC;AAED,cAAM,kBAAmB,SAAQ,yBAAyB;IACxD,OAAO,CAAC,QAAQ;IAQD,MAAM;CA2FtB"}
|
package/dist/node.cjs
ADDED
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
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 __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
18
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
19
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
20
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
21
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
22
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
23
|
+
mod
|
|
24
|
+
));
|
|
25
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
26
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
27
|
+
const tailwind_plugin = require("./tailwind.plugin-JU5cwZvP.cjs");
|
|
28
|
+
const theme = require("@udixio/theme");
|
|
29
|
+
const fs = require("fs");
|
|
30
|
+
const console = require("node:console");
|
|
31
|
+
const pathe = require("pathe");
|
|
32
|
+
const chalk = require("chalk");
|
|
33
|
+
function _interopNamespaceDefault(e) {
|
|
34
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
35
|
+
if (e) {
|
|
36
|
+
for (const k in e) {
|
|
37
|
+
if (k !== "default") {
|
|
38
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
39
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
40
|
+
enumerable: true,
|
|
41
|
+
get: () => e[k]
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
n.default = e;
|
|
47
|
+
return Object.freeze(n);
|
|
48
|
+
}
|
|
49
|
+
const fs__namespace = /* @__PURE__ */ _interopNamespaceDefault(fs);
|
|
50
|
+
const console__namespace = /* @__PURE__ */ _interopNamespaceDefault(console);
|
|
51
|
+
class TailwindPlugin extends theme.PluginAbstract {
|
|
52
|
+
constructor() {
|
|
53
|
+
super(...arguments);
|
|
54
|
+
__publicField(this, "dependencies", [theme.FontPlugin]);
|
|
55
|
+
__publicField(this, "name", "tailwind");
|
|
56
|
+
__publicField(this, "pluginClass", TailwindImplPlugin);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
class TailwindImplPlugin extends tailwind_plugin.TailwindImplPluginBrowser {
|
|
60
|
+
isNodeJs() {
|
|
61
|
+
return typeof process !== "undefined" && process.versions != null && process.versions.node != null;
|
|
62
|
+
}
|
|
63
|
+
async onLoad() {
|
|
64
|
+
var _a;
|
|
65
|
+
if (!this.isNodeJs()) {
|
|
66
|
+
await super.onLoad();
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const { join, resolve } = await import("pathe");
|
|
70
|
+
const {
|
|
71
|
+
createOrUpdateFile: createOrUpdateFile2,
|
|
72
|
+
findProjectRoot: findProjectRoot2,
|
|
73
|
+
findTailwindCssFile: findTailwindCssFile2,
|
|
74
|
+
getFileContent: getFileContent2,
|
|
75
|
+
replaceFileContent: replaceFileContent2
|
|
76
|
+
} = await Promise.resolve().then(() => file);
|
|
77
|
+
this.colors = {};
|
|
78
|
+
for (const isDark of [false, true]) {
|
|
79
|
+
this.api.themes.update({ isDark });
|
|
80
|
+
for (const [key, value] of this.api.colors.getColors().entries()) {
|
|
81
|
+
const newKey = key.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
|
|
82
|
+
(_a = this.colors)[newKey] ?? (_a[newKey] = { light: "", dark: "" });
|
|
83
|
+
this.colors[newKey][isDark ? "dark" : "light"] = value.getHex();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
let udixioCssPath = this.options.styleFilePath;
|
|
87
|
+
const projectRoot = await findProjectRoot2(resolve());
|
|
88
|
+
if (!udixioCssPath) {
|
|
89
|
+
const searchPattern = /@import ["']tailwindcss["'];/;
|
|
90
|
+
const replacement = `@import 'tailwindcss';
|
|
91
|
+
@import "./udixio.css";`;
|
|
92
|
+
const tailwindCssPath = await findTailwindCssFile2(
|
|
93
|
+
projectRoot,
|
|
94
|
+
searchPattern
|
|
95
|
+
);
|
|
96
|
+
udixioCssPath = join(tailwindCssPath, "../udixio.css");
|
|
97
|
+
if (!await getFileContent2(tailwindCssPath, /@import\s+"\.\/udixio\.css";/)) {
|
|
98
|
+
await replaceFileContent2(tailwindCssPath, searchPattern, replacement);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
const { fontStyles, fontFamily } = this.api.plugins.getPlugin(theme.FontPlugin).getInstance().getFonts();
|
|
102
|
+
const configCss = {
|
|
103
|
+
colorKeys: Object.keys(this.colors).join(", "),
|
|
104
|
+
fontStyles: Object.entries(fontStyles).map(
|
|
105
|
+
([fontRole, fontStyle]) => Object.entries(fontStyle).map(
|
|
106
|
+
([fontSize, fontStyle2]) => `${fontRole}-${fontSize} ${Object.entries(fontStyle2).map(([name, value]) => `${name}[${value}]`).join(" ")}`
|
|
107
|
+
).join(", ")
|
|
108
|
+
).join(", "),
|
|
109
|
+
responsiveBreakPoints: Object.entries(
|
|
110
|
+
this.options.responsiveBreakPoints ?? {}
|
|
111
|
+
).map(([key, value]) => `${key} ${value}`).join(", ")
|
|
112
|
+
};
|
|
113
|
+
this.outputCss += `@plugin "@udixio/tailwind" {
|
|
114
|
+
colorKeys: ${configCss.colorKeys};
|
|
115
|
+
fontStyles: ${configCss.fontStyles};
|
|
116
|
+
responsiveBreakPoints: ${configCss.responsiveBreakPoints};
|
|
117
|
+
}`;
|
|
118
|
+
this.loadColor();
|
|
119
|
+
this.outputCss += `
|
|
120
|
+
@theme {
|
|
121
|
+
${Object.entries(fontFamily).map(
|
|
122
|
+
([key, values]) => `--font-${key}: ${values.map((value) => `"${value}"`).join(", ")};`
|
|
123
|
+
).join("\n ")}
|
|
124
|
+
}`;
|
|
125
|
+
await createOrUpdateFile2(udixioCssPath, this.outputCss);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
const normalizePath = async (filePath) => {
|
|
129
|
+
const { fileURLToPath } = await import("url");
|
|
130
|
+
try {
|
|
131
|
+
if (filePath.startsWith("file://")) {
|
|
132
|
+
return pathe.normalize(fileURLToPath(filePath));
|
|
133
|
+
}
|
|
134
|
+
return pathe.normalize(filePath);
|
|
135
|
+
} catch (error) {
|
|
136
|
+
console__namespace.warn(
|
|
137
|
+
chalk.yellow(
|
|
138
|
+
`⚠️ Could not process path ${filePath}, treating as regular path`
|
|
139
|
+
)
|
|
140
|
+
);
|
|
141
|
+
return pathe.normalize(filePath);
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
const safeExistsSync = async (filePath) => {
|
|
145
|
+
return fs__namespace.existsSync(await normalizePath(filePath));
|
|
146
|
+
};
|
|
147
|
+
const safeReadFileSync = async (filePath, encoding = "utf8") => {
|
|
148
|
+
return fs__namespace.readFileSync(await normalizePath(filePath), encoding);
|
|
149
|
+
};
|
|
150
|
+
const safeWriteFileSync = async (filePath, data) => {
|
|
151
|
+
const normalizedPath = await normalizePath(filePath);
|
|
152
|
+
const dirPath = pathe.dirname(normalizedPath);
|
|
153
|
+
if (!fs__namespace.existsSync(dirPath)) {
|
|
154
|
+
fs__namespace.mkdirSync(dirPath, { recursive: true });
|
|
155
|
+
}
|
|
156
|
+
fs__namespace.writeFileSync(normalizedPath, data);
|
|
157
|
+
};
|
|
158
|
+
const createOrUpdateFile = async (filePath, content) => {
|
|
159
|
+
try {
|
|
160
|
+
const normalizedPath = normalizePath(filePath);
|
|
161
|
+
if (!await safeExistsSync(filePath)) {
|
|
162
|
+
await safeWriteFileSync(filePath, content);
|
|
163
|
+
console__namespace.log(
|
|
164
|
+
chalk.green(`📄 Created`) + chalk.gray(` • `) + chalk.cyan(normalizedPath)
|
|
165
|
+
);
|
|
166
|
+
} else {
|
|
167
|
+
console__namespace.log(
|
|
168
|
+
chalk.blue(`📝 Exists`) + chalk.gray(` • `) + chalk.cyan(normalizedPath)
|
|
169
|
+
);
|
|
170
|
+
await replaceFileContent(filePath, /[\s\S]*/, content);
|
|
171
|
+
}
|
|
172
|
+
} catch (error) {
|
|
173
|
+
console__namespace.error(
|
|
174
|
+
chalk.red(`🚨 Failed to create file`) + chalk.gray(` • `) + chalk.cyan(filePath)
|
|
175
|
+
);
|
|
176
|
+
console__namespace.error(
|
|
177
|
+
chalk.gray(` `) + chalk.red(error instanceof Error ? error.message : error)
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
const getFileContent = async (filePath, searchPattern) => {
|
|
182
|
+
try {
|
|
183
|
+
const normalizedPath = normalizePath(filePath);
|
|
184
|
+
if (!await safeExistsSync(filePath)) {
|
|
185
|
+
console__namespace.error(
|
|
186
|
+
chalk.red(`❌ File not found`) + chalk.gray(` • `) + chalk.cyan(normalizedPath)
|
|
187
|
+
);
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
const fileContent = await safeReadFileSync(filePath);
|
|
191
|
+
if (searchPattern) {
|
|
192
|
+
if (typeof searchPattern === "string") {
|
|
193
|
+
const found = fileContent.includes(searchPattern) ? searchPattern : false;
|
|
194
|
+
if (found) {
|
|
195
|
+
console__namespace.log(
|
|
196
|
+
chalk.green(`🔍 Found`) + chalk.gray(` • `) + chalk.yellow(`"${searchPattern}"`)
|
|
197
|
+
);
|
|
198
|
+
} else {
|
|
199
|
+
console__namespace.log(
|
|
200
|
+
chalk.yellow(`🔍 Missing`) + chalk.gray(` • `) + chalk.yellow(`"${searchPattern}"`)
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
return found;
|
|
204
|
+
} else {
|
|
205
|
+
const match = fileContent.match(searchPattern);
|
|
206
|
+
if (match) {
|
|
207
|
+
console__namespace.log(
|
|
208
|
+
chalk.green(`🎯 Match`) + chalk.gray(` • `) + chalk.yellow(`"${match[0]}"`)
|
|
209
|
+
);
|
|
210
|
+
return match[0];
|
|
211
|
+
} else {
|
|
212
|
+
console__namespace.log(
|
|
213
|
+
chalk.yellow(`🎯 No match`) + chalk.gray(` • `) + chalk.magenta(searchPattern.toString())
|
|
214
|
+
);
|
|
215
|
+
return false;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
console__namespace.log(
|
|
220
|
+
chalk.blue(`📖 Read`) + chalk.gray(` • `) + chalk.cyan(normalizedPath)
|
|
221
|
+
);
|
|
222
|
+
return fileContent;
|
|
223
|
+
} catch (error) {
|
|
224
|
+
console__namespace.error(
|
|
225
|
+
chalk.red(`🚨 Read failed`) + chalk.gray(` • `) + chalk.cyan(filePath)
|
|
226
|
+
);
|
|
227
|
+
console__namespace.error(
|
|
228
|
+
chalk.gray(` `) + chalk.red(error instanceof Error ? error.message : error)
|
|
229
|
+
);
|
|
230
|
+
return null;
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
const replaceFileContent = async (filePath, searchPattern, replacement) => {
|
|
234
|
+
try {
|
|
235
|
+
const { replaceInFileSync } = await import("replace-in-file");
|
|
236
|
+
const normalizedPath = await normalizePath(filePath);
|
|
237
|
+
const results = replaceInFileSync({
|
|
238
|
+
files: normalizedPath,
|
|
239
|
+
from: searchPattern,
|
|
240
|
+
to: replacement
|
|
241
|
+
});
|
|
242
|
+
if (results.length > 0 && results[0].hasChanged) {
|
|
243
|
+
console__namespace.log(
|
|
244
|
+
chalk.green(`✏️ Updated`) + chalk.gray(` • `) + chalk.cyan(normalizedPath)
|
|
245
|
+
);
|
|
246
|
+
} else {
|
|
247
|
+
console__namespace.log(
|
|
248
|
+
chalk.yellow(`⏭️ Skipped`) + chalk.gray(` • `) + chalk.cyan(normalizedPath) + chalk.gray(` (no changes needed)`)
|
|
249
|
+
);
|
|
250
|
+
}
|
|
251
|
+
} catch (error) {
|
|
252
|
+
console__namespace.error(
|
|
253
|
+
chalk.red(`🚨 Update failed`) + chalk.gray(` • `) + chalk.cyan(filePath)
|
|
254
|
+
);
|
|
255
|
+
console__namespace.error(
|
|
256
|
+
chalk.gray(` `) + chalk.red(error instanceof Error ? error.message : error)
|
|
257
|
+
);
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
const findTailwindCssFile = async (startDir, searchPattern) => {
|
|
261
|
+
const normalizedStartDir = await normalizePath(startDir);
|
|
262
|
+
console__namespace.log(chalk.blue(`🔎 Searching for CSS file...`));
|
|
263
|
+
console__namespace.log(
|
|
264
|
+
chalk.gray(` Starting from: `) + chalk.cyan(normalizedStartDir)
|
|
265
|
+
);
|
|
266
|
+
const stack = [normalizedStartDir];
|
|
267
|
+
let filesScanned = 0;
|
|
268
|
+
while (stack.length > 0) {
|
|
269
|
+
const currentDir = stack.pop();
|
|
270
|
+
let files;
|
|
271
|
+
try {
|
|
272
|
+
files = fs__namespace.readdirSync(currentDir);
|
|
273
|
+
} catch (error) {
|
|
274
|
+
console__namespace.error(
|
|
275
|
+
chalk.gray(` `) + chalk.red(`❌ Cannot read directory: `) + chalk.cyan(currentDir)
|
|
276
|
+
);
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
279
|
+
for (const file2 of files) {
|
|
280
|
+
const filePath = pathe.join(currentDir, file2);
|
|
281
|
+
let stats;
|
|
282
|
+
try {
|
|
283
|
+
stats = fs__namespace.statSync(filePath);
|
|
284
|
+
} catch (error) {
|
|
285
|
+
console__namespace.error(
|
|
286
|
+
chalk.gray(` `) + chalk.red(`❌ Cannot access: `) + chalk.cyan(filePath)
|
|
287
|
+
);
|
|
288
|
+
continue;
|
|
289
|
+
}
|
|
290
|
+
if (stats.isDirectory()) {
|
|
291
|
+
if (file2 !== "node_modules" && !file2.startsWith(".")) {
|
|
292
|
+
stack.push(filePath);
|
|
293
|
+
}
|
|
294
|
+
} else if (stats.isFile() && (file2.endsWith(".css") || file2.endsWith(".scss") || file2.endsWith(".sass"))) {
|
|
295
|
+
try {
|
|
296
|
+
filesScanned++;
|
|
297
|
+
process.stdout.write(
|
|
298
|
+
chalk.gray(` 📂 Scanning: `) + chalk.yellow(file2) + `\r`
|
|
299
|
+
);
|
|
300
|
+
const content = await safeReadFileSync(filePath);
|
|
301
|
+
const hasMatch = typeof searchPattern === "string" ? content.includes(searchPattern) : searchPattern.test(content);
|
|
302
|
+
if (hasMatch) {
|
|
303
|
+
console__namespace.log(chalk.green(`
|
|
304
|
+
🎯 Found target file!`));
|
|
305
|
+
console__namespace.log(chalk.gray(` 📍 Location: `) + chalk.cyan(filePath));
|
|
306
|
+
return filePath;
|
|
307
|
+
}
|
|
308
|
+
} catch (readError) {
|
|
309
|
+
console__namespace.error(
|
|
310
|
+
chalk.gray(`
|
|
311
|
+
`) + chalk.red(`❌ Cannot read: `) + chalk.cyan(filePath)
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
console__namespace.log(
|
|
318
|
+
chalk.blue(`
|
|
319
|
+
📊 Scanned `) + chalk.white.bold(filesScanned.toString()) + chalk.blue(` CSS files`)
|
|
320
|
+
);
|
|
321
|
+
const errorMsg = chalk.red(`❌ No file found containing `) + chalk.yellow(`"${searchPattern}"`) + chalk.red(` in `) + chalk.cyan(`"${normalizedStartDir}"`);
|
|
322
|
+
throw new Error(errorMsg);
|
|
323
|
+
};
|
|
324
|
+
async function findProjectRoot(startPath) {
|
|
325
|
+
const normalizedStartPath = await normalizePath(startPath);
|
|
326
|
+
let currentPath = pathe.resolve(normalizedStartPath);
|
|
327
|
+
let levels = 0;
|
|
328
|
+
console__namespace.log(chalk.blue(`🏠 Finding project root...`));
|
|
329
|
+
console__namespace.log(
|
|
330
|
+
chalk.gray(` Starting from: `) + chalk.cyan(normalizedStartPath)
|
|
331
|
+
);
|
|
332
|
+
while (!fs__namespace.existsSync(pathe.join(currentPath, "package.json"))) {
|
|
333
|
+
const parentPath = pathe.dirname(currentPath);
|
|
334
|
+
if (currentPath === parentPath) {
|
|
335
|
+
console__namespace.error(
|
|
336
|
+
chalk.red(`❌ Project root not found after checking `) + chalk.white.bold(levels.toString()) + chalk.red(` levels`)
|
|
337
|
+
);
|
|
338
|
+
throw new Error(
|
|
339
|
+
chalk.red("Unable to locate project root (no package.json found)")
|
|
340
|
+
);
|
|
341
|
+
}
|
|
342
|
+
currentPath = parentPath;
|
|
343
|
+
levels++;
|
|
344
|
+
if (levels > 10) {
|
|
345
|
+
console__namespace.error(
|
|
346
|
+
chalk.red(`❌ Stopped after `) + chalk.white.bold(levels.toString()) + chalk.red(` levels (too deep)`)
|
|
347
|
+
);
|
|
348
|
+
throw new Error(chalk.red("Project root search exceeded maximum depth"));
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
console__namespace.log(chalk.green(`📁 Project root: `) + chalk.cyan(currentPath));
|
|
352
|
+
return currentPath;
|
|
353
|
+
}
|
|
354
|
+
const file = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
355
|
+
__proto__: null,
|
|
356
|
+
createOrUpdateFile,
|
|
357
|
+
findProjectRoot,
|
|
358
|
+
findTailwindCssFile,
|
|
359
|
+
getFileContent,
|
|
360
|
+
replaceFileContent
|
|
361
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
362
|
+
exports.default = tailwind_plugin.main;
|
|
363
|
+
exports.font = tailwind_plugin.font;
|
|
364
|
+
exports.state = tailwind_plugin.state;
|
|
365
|
+
exports.TailwindPlugin = TailwindPlugin;
|
|
366
|
+
exports.createOrUpdateFile = createOrUpdateFile;
|
|
367
|
+
exports.findProjectRoot = findProjectRoot;
|
|
368
|
+
exports.findTailwindCssFile = findTailwindCssFile;
|
|
369
|
+
exports.getFileContent = getFileContent;
|
|
370
|
+
exports.replaceFileContent = replaceFileContent;
|