@mekari/pixel3-postcss 1.0.16 → 2.0.0-next.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.
@@ -0,0 +1,21 @@
1
+ declare function injectAutoImports(filePath: string, content: string): string | undefined;
2
+ declare const pixelAutoImportPlugin: {
3
+ name: string;
4
+ hooks: {
5
+ 'parser:before': {
6
+ filter: {
7
+ id: {
8
+ include: string[];
9
+ exclude: string[];
10
+ };
11
+ code: RegExp;
12
+ };
13
+ handler: ({ filePath, content }: {
14
+ filePath: string;
15
+ content: string;
16
+ }) => string | undefined;
17
+ };
18
+ };
19
+ };
20
+
21
+ export { injectAutoImports, pixelAutoImportPlugin };
@@ -0,0 +1,46 @@
1
+ // src/auto-import-plugin.ts
2
+ var AUTO_IMPORTS = ["css", "cx", "token"];
3
+ var IMPORT_SOURCE = "@mekari/pixel3";
4
+ var isBound = (code, name) => new RegExp(
5
+ `import\\s*\\{[^}]*\\b${name}\\b[^}]*\\}\\s*from|\\b(const|let|var|function)\\s+${name}\\b`
6
+ ).test(code);
7
+ function injectAutoImports(filePath, content) {
8
+ const names = AUTO_IMPORTS.filter(
9
+ (name) => new RegExp(`\\b${name}\\(`).test(content) && !isBound(content, name)
10
+ );
11
+ if (!names.length)
12
+ return;
13
+ const line = `import { ${names.join(", ")} } from '${IMPORT_SOURCE}'
14
+ `;
15
+ if (!filePath.endsWith(".vue"))
16
+ return line + content;
17
+ const scriptOpen = /<script\b[^>]*\bsetup\b[^>]*>/.exec(content) ?? /<script\b[^>]*>/.exec(content);
18
+ if (!scriptOpen)
19
+ return `${content}
20
+ <script setup>
21
+ ${line}</script>
22
+ `;
23
+ const at = scriptOpen.index + scriptOpen[0].length;
24
+ return `${content.slice(0, at)}
25
+ ${line}${content.slice(at)}`;
26
+ }
27
+ var pixelAutoImportPlugin = {
28
+ name: "pixel3-auto-import",
29
+ hooks: {
30
+ "parser:before": {
31
+ // Filters run natively, so files that cannot need the import never cross into JS
32
+ filter: {
33
+ id: {
34
+ include: ["**/*.vue", "**/*.{js,jsx,ts,tsx}"],
35
+ exclude: ["**/node_modules/**", "**/dist/**"]
36
+ },
37
+ code: /\b(css|cx|token)\(/
38
+ },
39
+ handler: ({ filePath, content }) => injectAutoImports(filePath, content)
40
+ }
41
+ }
42
+ };
43
+ export {
44
+ injectAutoImports,
45
+ pixelAutoImportPlugin
46
+ };
package/dist/index.cjs ADDED
@@ -0,0 +1,350 @@
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 __esm = (fn, res) => function __init() {
9
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
10
+ };
11
+ var __export = (target, all) => {
12
+ for (var name in all)
13
+ __defProp(target, name, { get: all[name], enumerable: true });
14
+ };
15
+ var __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (let key of __getOwnPropNames(from))
18
+ if (!__hasOwnProp.call(to, key) && key !== except)
19
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
+ }
21
+ return to;
22
+ };
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
+ // If the importer is in node compatibility mode or this is not an ESM
25
+ // file that has been converted to a CommonJS file using a Babel-
26
+ // compatible transform (i.e. "__esModule" has not been set), then set
27
+ // "default" to the CommonJS "module.exports" for node compatibility.
28
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
+ mod
30
+ ));
31
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
+
33
+ // ../../node_modules/.pnpm/tsup@7.2.0_postcss@8.4.33_ts-node@10.9.2_@types+node@20.11.21_typescript@5.4.3__typescript@5.4.3/node_modules/tsup/assets/cjs_shims.js
34
+ var getImportMetaUrl, importMetaUrl;
35
+ var init_cjs_shims = __esm({
36
+ "../../node_modules/.pnpm/tsup@7.2.0_postcss@8.4.33_ts-node@10.9.2_@types+node@20.11.21_typescript@5.4.3__typescript@5.4.3/node_modules/tsup/assets/cjs_shims.js"() {
37
+ "use strict";
38
+ getImportMetaUrl = () => typeof document === "undefined" ? new URL("file:" + __filename).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
39
+ importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
40
+ }
41
+ });
42
+
43
+ // src/default-config.ts
44
+ var defaultConfig;
45
+ var init_default_config = __esm({
46
+ "src/default-config.ts"() {
47
+ "use strict";
48
+ init_cjs_shims();
49
+ defaultConfig = {
50
+ preflight: true,
51
+ include: ["./src/**/*.{js,jsx,ts,tsx,vue}", "./app/**/*.{js,jsx,ts,tsx,vue}"],
52
+ exclude: [],
53
+ // Panda v2 only extracts style functions whose source module is listed here: the styled-system
54
+ // package for Pixel dist, and @mekari/pixel3 for `css`/`cx`/`token` in apps.
55
+ importMap: [
56
+ "@mekari/pixel3-styled-system",
57
+ { css: "@mekari/pixel3", tokens: "@mekari/pixel3", jsx: "@mekari/pixel3" }
58
+ ],
59
+ layers: {
60
+ reset: "pixel_reset",
61
+ base: "pixel_base",
62
+ tokens: "pixel_tokens",
63
+ recipes: "pixel_recipes",
64
+ utilities: "pixel_utilities"
65
+ },
66
+ prefix: "mp",
67
+ jsxFramework: "vue",
68
+ jsxFactory: "Pixel",
69
+ jsxStyleProps: "all"
70
+ };
71
+ }
72
+ });
73
+
74
+ // src/create-config.ts
75
+ function resolveEsmEntry(name) {
76
+ const readManifest = (dir2) => {
77
+ const file = import_path.default.join(dir2, "package.json");
78
+ return import_fs.default.existsSync(file) ? JSON.parse(import_fs.default.readFileSync(file, "utf8")) : void 0;
79
+ };
80
+ let dir = import_path.default.dirname(require2.resolve(name));
81
+ while (readManifest(dir)?.name !== name) {
82
+ if (dir === import_path.default.dirname(dir))
83
+ throw new Error(`[pixel3-postcss] package.json of ${name} not found`);
84
+ dir = import_path.default.dirname(dir);
85
+ }
86
+ const manifestPath = import_path.default.join(dir, "package.json");
87
+ const manifest = readManifest(dir);
88
+ const root = manifest.exports?.["."];
89
+ const entry = (typeof root === "string" ? root : root?.import ?? root?.default) ?? manifest.module ?? manifest.main;
90
+ return import_path.default.join(import_path.default.dirname(manifestPath), entry);
91
+ }
92
+ function siblingModule(name) {
93
+ const dir = import_path.default.dirname((0, import_url.fileURLToPath)(importMetaUrl));
94
+ const file = [".mjs", ".js", ".ts"].map((ext) => import_path.default.join(dir, name + ext)).find(import_fs.default.existsSync);
95
+ if (!file)
96
+ throw new Error(`[pixel3-postcss] ${name} not found next to ${dir}`);
97
+ return file;
98
+ }
99
+ function findRealModulePath(cwd, moduleName) {
100
+ try {
101
+ return import_fs.default.realpathSync(import_path.default.join(cwd, "node_modules", moduleName));
102
+ } catch (error) {
103
+ console.error("Error finding real module path:", error);
104
+ return null;
105
+ }
106
+ }
107
+ function mergeConfig(base, { replaceConfig = [], ...options }) {
108
+ const merged = { ...base };
109
+ for (const key of ["include", "exclude"]) {
110
+ const value = options[key];
111
+ if (!Array.isArray(value))
112
+ continue;
113
+ merged[key] = replaceConfig.includes(key) ? value : [...base[key] ?? [], ...value];
114
+ }
115
+ return merged;
116
+ }
117
+ function createConfigFile(cwd, options) {
118
+ const base = { ...defaultConfig };
119
+ const realPath = findRealModulePath(cwd, "@mekari/pixel3");
120
+ if (realPath) {
121
+ base.include = [...base.include ?? [], `${import_path.default.dirname(realPath)}/**/dist/**/*.{js,mjs}`];
122
+ }
123
+ const config = mergeConfig(base, options);
124
+ const dir = import_fs.default.mkdtempSync(import_path.default.join(import_os.default.tmpdir(), "pixel3-postcss-"));
125
+ const configPath = import_path.default.join(dir, "panda.config.cts");
126
+ const lines = [
127
+ `import pixelTheme from ${JSON.stringify(resolveEsmEntry("@mekari/pixel3-theme"))}`,
128
+ `import { pixelAutoImportPlugin } from ${JSON.stringify(siblingModule("auto-import-plugin"))}`,
129
+ "export default {",
130
+ ` ...${JSON.stringify(config, null, 2)},`,
131
+ " presets: [pixelTheme],",
132
+ " plugins: [pixelAutoImportPlugin]",
133
+ "}"
134
+ ];
135
+ import_fs.default.writeFileSync(configPath, lines.join("\n") + "\n");
136
+ return { configPath, dir };
137
+ }
138
+ var import_fs, import_os, import_path, import_module, import_url, require2;
139
+ var init_create_config = __esm({
140
+ "src/create-config.ts"() {
141
+ "use strict";
142
+ init_cjs_shims();
143
+ import_fs = __toESM(require("fs"), 1);
144
+ import_os = __toESM(require("os"), 1);
145
+ import_path = __toESM(require("path"), 1);
146
+ import_module = require("module");
147
+ import_url = require("url");
148
+ init_default_config();
149
+ require2 = (0, import_module.createRequire)(importMetaUrl);
150
+ }
151
+ });
152
+
153
+ // src/index.ts
154
+ var src_exports = {};
155
+ __export(src_exports, {
156
+ default: () => src_default,
157
+ pixelcss: () => pixelcss
158
+ });
159
+ async function getState(cwd, configPath, outdir) {
160
+ const key = `${cwd}:${configPath}`;
161
+ let state = states.get(key);
162
+ if (!state) {
163
+ const driver2 = await (0, import_node.createNodeDriver)({ cwd, configPath });
164
+ driver2.codegen({ cwd, outdir });
165
+ driver2.parseFiles();
166
+ state = { driver: driver2, configStamp: stampAll(configFiles(driver2)), sources: scanSources(driver2) };
167
+ states.set(key, state);
168
+ return state;
169
+ }
170
+ const { driver } = state;
171
+ if (stampAll(configFiles(driver)) !== state.configStamp) {
172
+ const diff = await driver.reload();
173
+ state.configStamp = stampAll(configFiles(driver));
174
+ if (diff.hasChanged) {
175
+ driver.codegen({ cwd, outdir });
176
+ driver.parseFiles();
177
+ state.sources = scanSources(driver);
178
+ return state;
179
+ }
180
+ }
181
+ const changes = [];
182
+ const scanned = driver.scan();
183
+ const seen = new Set(scanned);
184
+ for (const file of state.sources.keys()) {
185
+ if (!seen.has(file)) {
186
+ changes.push({ path: file, kind: "unlink" });
187
+ state.sources.delete(file);
188
+ }
189
+ }
190
+ for (const file of scanned) {
191
+ const stamp = fileStamp(file);
192
+ const known = state.sources.get(file);
193
+ if (known === stamp)
194
+ continue;
195
+ changes.push({ path: file, kind: known === void 0 ? "add" : "change" });
196
+ state.sources.set(file, stamp);
197
+ }
198
+ if (changes.length)
199
+ driver.applyChanges(changes);
200
+ return state;
201
+ }
202
+ function registerDependencies(driver, result, cwd) {
203
+ const parent = result.opts.from;
204
+ for (const source of driver.compiler.sources()) {
205
+ const dir = import_path2.default.resolve(cwd, source.base);
206
+ result.messages.push({
207
+ type: "dir-dependency",
208
+ dir,
209
+ glob: source.pattern,
210
+ plugin: PLUGIN_NAME,
211
+ parent
212
+ });
213
+ }
214
+ for (const file of configFiles(driver)) {
215
+ result.messages.push({
216
+ type: "dependency",
217
+ file: import_path2.default.resolve(cwd, file),
218
+ plugin: PLUGIN_NAME,
219
+ parent
220
+ });
221
+ }
222
+ }
223
+ function formatLocation(d, cwd) {
224
+ const file = d.file ? import_path2.default.relative(cwd, d.file) : "<unknown file>";
225
+ const start = d.location?.start;
226
+ return start ? `${file}:${start.line}:${start.column}` : file;
227
+ }
228
+ function reportDiagnostics(root, result, diagnostics, cwd) {
229
+ const error = diagnostics.find((d) => d.severity === "error");
230
+ if (error)
231
+ throw root.error(`${error.code}: ${error.message}`, { plugin: PLUGIN_NAME });
232
+ const warnings = diagnostics.filter(
233
+ (d) => d.severity === "warning" && !ignoredWarnings.has(d.code)
234
+ );
235
+ const key = warnings.map((d) => `${d.code}${d.file}${d.span?.start}`).join("|");
236
+ if (!warnings.length || key === reportedWarnings)
237
+ return;
238
+ reportedWarnings = key;
239
+ const byCode = {};
240
+ for (const d of warnings)
241
+ (byCode[d.code] ??= []).push(d);
242
+ const counts = Object.fromEntries(
243
+ Object.entries(byCode).map(([code, list]) => [code, list.length])
244
+ );
245
+ const lines = [`Style extraction reported ${warnings.length} warnings: ${JSON.stringify(counts)}`];
246
+ for (const [code, list] of Object.entries(byCode)) {
247
+ const byLocation = /* @__PURE__ */ new Map();
248
+ for (const d of list) {
249
+ const location = formatLocation(d, cwd);
250
+ if (!byLocation.has(location))
251
+ byLocation.set(location, d);
252
+ }
253
+ const entries = [...byLocation];
254
+ for (const [location, d] of entries.slice(0, MAX_LOCATIONS_PER_CODE)) {
255
+ lines.push(` ${code} ${location} ${d.message}`);
256
+ }
257
+ if (entries.length > MAX_LOCATIONS_PER_CODE) {
258
+ lines.push(` ${code} \u2026 and ${entries.length - MAX_LOCATIONS_PER_CODE} more locations`);
259
+ }
260
+ }
261
+ result.warn(lines.join("\n"), { plugin: PLUGIN_NAME });
262
+ }
263
+ var import_fs2, import_path2, import_node, PLUGIN_NAME, fileStamp, stampAll, configFiles, scanSources, nodeModulesRegex, shouldSkip, states, ignoredWarnings, MAX_LOCATIONS_PER_CODE, reportedWarnings, guard, pixelcss, src_default;
264
+ var init_src = __esm({
265
+ "src/index.ts"() {
266
+ "use strict";
267
+ init_cjs_shims();
268
+ import_fs2 = __toESM(require("fs"), 1);
269
+ import_path2 = __toESM(require("path"), 1);
270
+ import_node = require("@pandacss/dev/node");
271
+ init_create_config();
272
+ PLUGIN_NAME = "pixel3-postcss";
273
+ fileStamp = (file) => {
274
+ try {
275
+ const stat = import_fs2.default.statSync(file);
276
+ return `${stat.mtimeMs}:${stat.size}`;
277
+ } catch {
278
+ return "missing";
279
+ }
280
+ };
281
+ stampAll = (files) => files.map((file) => `${file}\0${fileStamp(file)}`).join("\0");
282
+ configFiles = (driver) => {
283
+ const files = driver.configPath ? [driver.configPath] : [];
284
+ for (const dep of driver.configDependencies)
285
+ files.push(driver.resolvePath(dep));
286
+ return files;
287
+ };
288
+ scanSources = (driver) => new Map(driver.scan().map((file) => [file, fileStamp(file)]));
289
+ nodeModulesRegex = /node_modules/;
290
+ shouldSkip = (fileName, allow) => {
291
+ if (!fileName)
292
+ return true;
293
+ if (import_path2.default.extname(fileName.split("?")[0]) !== ".css")
294
+ return true;
295
+ if (allow.some((pattern) => pattern.test(fileName)))
296
+ return false;
297
+ return nodeModulesRegex.test(fileName);
298
+ };
299
+ states = /* @__PURE__ */ new Map();
300
+ ignoredWarnings = /* @__PURE__ */ new Set(["pure_helper_unevaluated"]);
301
+ MAX_LOCATIONS_PER_CODE = 5;
302
+ reportedWarnings = "";
303
+ pixelcss = (options = {}) => {
304
+ const { cwd: cwdOption, allow = [], outdir: outdirOption, ...configOptions } = options;
305
+ const cwd = import_path2.default.resolve(cwdOption ?? process.cwd());
306
+ const { configPath, dir } = createConfigFile(cwd, configOptions);
307
+ const outdir = outdirOption ?? import_path2.default.join(dir, "styled-system");
308
+ const allowList = [/@mekari\/pixel3-nuxt/, ...allow];
309
+ console.log("Pixel Config (auto-generated) :", configPath);
310
+ const run = async (root, result, inputCss) => {
311
+ const { driver } = await getState(cwd, configPath, outdir);
312
+ if (!driver.compiler.hasLayerDeclaration(inputCss))
313
+ return;
314
+ registerDependencies(driver, result, cwd);
315
+ const output = driver.cssgen({ emitLayerDeclaration: false });
316
+ reportDiagnostics(
317
+ root,
318
+ result,
319
+ [...driver.designSystemDiagnostics ?? [], ...output.diagnostics],
320
+ cwd
321
+ );
322
+ root.append(output.css);
323
+ root.walk((node) => {
324
+ if (!node.source)
325
+ node.source = root.source;
326
+ });
327
+ };
328
+ return {
329
+ postcssPlugin: PLUGIN_NAME,
330
+ Once(root, { result }) {
331
+ if (shouldSkip(result.opts.from, allowList))
332
+ return;
333
+ const inputCss = root.toString();
334
+ if (!inputCss.includes("@layer"))
335
+ return;
336
+ guard = Promise.resolve(guard).catch(() => {
337
+ }).then(() => run(root, result, inputCss));
338
+ return guard;
339
+ }
340
+ };
341
+ };
342
+ pixelcss.postcss = true;
343
+ src_default = pixelcss;
344
+ }
345
+ });
346
+
347
+ // index.cts
348
+ init_cjs_shims();
349
+ var pixel = (init_src(), __toCommonJS(src_exports));
350
+ module.exports = pixel.default;
@@ -0,0 +1,20 @@
1
+ import * as postcss from 'postcss';
2
+ import { PluginCreator } from 'postcss';
3
+ import { Config } from '@pandacss/dev';
4
+
5
+ interface ConfigOptions extends Pick<Config, 'include' | 'exclude'> {
6
+ replaceConfig?: string[];
7
+ }
8
+
9
+ interface PixelPostcssOptions extends ConfigOptions {
10
+ cwd?: string;
11
+ /** Files under `node_modules` matching any of these patterns are processed instead of skipped */
12
+ allow?: RegExp[];
13
+ /** Where the generated styled-system is written. Defaults to a temp dir: apps import @mekari/pixel3 instead */
14
+ outdir?: string;
15
+ }
16
+ declare const pixelcss: PluginCreator<PixelPostcssOptions>;
17
+
18
+ declare const _default: postcss.PluginCreator<pixelcss.PixelPostcssOptions>;
19
+
20
+ export { _default as default };
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@mekari/pixel3-postcss",
3
- "version": "1.0.16",
3
+ "version": "2.0.0-next.0",
4
4
  "description": "PostCSS integration for Pixel 3",
5
- "main": "./dist/index.js",
5
+ "type": "module",
6
+ "main": "./dist/index.cjs",
6
7
  "author": "Sastra Nababan",
7
8
  "sideEffects": false,
8
9
  "publishConfig": {
@@ -12,14 +13,15 @@
12
13
  "dist"
13
14
  ],
14
15
  "dependencies": {
15
- "@pandacss/dev": "1.12.0",
16
- "@pandacss/node": "1.12.0",
17
- "postcss": "^8.4.31",
18
- "tmp": "^0.2.1"
16
+ "@pandacss/dev": "2.1.2",
17
+ "postcss": "^8.4.31"
18
+ },
19
+ "engines": {
20
+ "node": ">=22.12"
19
21
  },
20
22
  "scripts": {
21
- "build": "tsup index.ts --format=cjs,esm --shims --dts",
22
- "build-fast": "tsup src/index.ts --format=cjs,esm --shims --no-dts",
23
- "dev": "pnpm build-fast --watch"
23
+ "build": "tsup",
24
+ "build-fast": "tsup --no-dts",
25
+ "dev": "tsup --no-dts --watch"
24
26
  }
25
27
  }
package/dist/index.d.mts DELETED
@@ -1,2 +0,0 @@
1
-
2
- export { }
package/dist/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
-
2
- export { }
package/dist/index.js DELETED
@@ -1,172 +0,0 @@
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 __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") {
10
- for (let key of __getOwnPropNames(from))
11
- if (!__hasOwnProp.call(to, key) && key !== except)
12
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
- }
14
- return to;
15
- };
16
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
- // If the importer is in node compatibility mode or this is not an ESM
18
- // file that has been converted to a CommonJS file using a Babel-
19
- // compatible transform (i.e. "__esModule" has not been set), then set
20
- // "default" to the CommonJS "module.exports" for node compatibility.
21
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
- mod
23
- ));
24
-
25
- // ../../node_modules/.pnpm/tsup@7.2.0_postcss@8.4.33_ts-node@10.9.2_@types+node@20.11.21_typescript@5.4.3__typescript@5.4.3/node_modules/tsup/assets/cjs_shims.js
26
- var getImportMetaUrl = () => typeof document === "undefined" ? new URL("file:" + __filename).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
27
- var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
28
-
29
- // src/index.ts
30
- var import_node = require("@pandacss/node");
31
- var import_module = require("module");
32
-
33
- // src/create-config.ts
34
- var import_fs = __toESM(require("fs"));
35
- var import_path = __toESM(require("path"));
36
-
37
- // src/default-config.ts
38
- var import_dev = require("@pandacss/dev");
39
- var defaultConfig = {
40
- preflight: true,
41
- presets: ["@mekari/pixel3-theme"],
42
- include: ["./src/**/*.{js,jsx,ts,tsx,vue}", "./app/**/*.{js,jsx,ts,tsx,vue}"],
43
- exclude: [],
44
- layers: {
45
- reset: "pixel_reset",
46
- base: "pixel_base",
47
- tokens: "pixel_tokens",
48
- recipes: "pixel_recipes",
49
- utilities: "pixel_utilities"
50
- },
51
- prefix: "mp",
52
- jsxFramework: "vue",
53
- jsxFactory: "Pixel",
54
- jsxStyleProps: "all"
55
- };
56
-
57
- // src/create-config.ts
58
- var import_dev2 = require("@pandacss/dev");
59
- function findRealModulePath(moduleName) {
60
- try {
61
- const symlinkPath = import_path.default.join("node_modules", moduleName);
62
- const realPath = import_fs.default.realpathSync(symlinkPath);
63
- return realPath;
64
- } catch (error) {
65
- console.error("Error finding real module path:", error);
66
- return null;
67
- }
68
- }
69
- function mergeConfig(obj1, obj2) {
70
- const mergeKey = ["include", "exclude"];
71
- const tempObj = {};
72
- const hasReplaceConfig = obj2.replaceConfig && obj2.replaceConfig.length > 0;
73
- mergeKey.forEach((item) => {
74
- if (Object.prototype.hasOwnProperty.call(obj2, item)) {
75
- if (hasReplaceConfig && obj2.replaceConfig?.includes(item)) {
76
- tempObj[item] = obj2[item];
77
- return;
78
- }
79
- const obj1Value = obj1[item];
80
- const obj2Value = obj2[item];
81
- if (Array.isArray(obj1Value) && Array.isArray(obj2Value)) {
82
- tempObj[item] = [...obj1Value, ...obj2Value];
83
- }
84
- }
85
- });
86
- return { ...obj1, ...tempObj };
87
- }
88
- var createConfigFile = (filePath, options) => {
89
- const _defaultConfig = { ...defaultConfig };
90
- const realPath = findRealModulePath("@mekari/pixel3");
91
- if (realPath) {
92
- const pixelDir = import_path.default.dirname(realPath);
93
- const extend = `${pixelDir}/**/dist/**/*.{js,mjs}`;
94
- const finalInclude = [..._defaultConfig.include || [], extend];
95
- _defaultConfig.include = finalInclude;
96
- }
97
- const configs = mergeConfig(_defaultConfig, options);
98
- const data = "export default" + JSON.stringify(configs, null, 2);
99
- try {
100
- import_fs.default.writeFileSync(filePath, data, "utf-8");
101
- } catch (error) {
102
- if (error instanceof Error) {
103
- console.error(error.message);
104
- } else {
105
- console.error("An unknown error occurred");
106
- }
107
- }
108
- };
109
-
110
- // src/index.ts
111
- var import_path2 = __toESM(require("path"));
112
- var require2 = (0, import_module.createRequire)(importMetaUrl);
113
- var tmp = require2("tmp");
114
- var PLUGIN_NAME = "pixel3-postcss";
115
- var tmpobj = tmp.fileSync({ postfix: ".ts" });
116
- var configPath = tmpobj.name;
117
- tmp.setGracefulCleanup();
118
- var builder = new import_node.Builder();
119
- var nodeModulesRegex = /node_modules/;
120
- function isValidCss(file) {
121
- const [filePath] = file.split("?");
122
- return import_path2.default.extname(filePath) === ".css";
123
- }
124
- var shouldSkip = (fileName) => {
125
- if (!fileName)
126
- return true;
127
- if (!isValidCss(fileName))
128
- return true;
129
- if (fileName.includes("@mekari/pixel3-nuxt"))
130
- return false;
131
- return nodeModulesRegex.test(fileName);
132
- };
133
- var pixelcss = (options = {}) => {
134
- const { cwd } = options;
135
- createConfigFile(configPath, options);
136
- console.log("Pixel Config (auto-generated) :", configPath);
137
- return {
138
- postcssPlugin: PLUGIN_NAME,
139
- plugins: [
140
- async function(root, result) {
141
- const fileName = result.opts.from;
142
- const skip = shouldSkip(fileName);
143
- if (skip)
144
- return;
145
- await builder.setup({ configPath, cwd });
146
- if (!builder.isValidRoot(root)) {
147
- return;
148
- }
149
- await builder.emit();
150
- builder.extract();
151
- builder.registerDependency((dep) => {
152
- result.messages.push({
153
- ...dep,
154
- plugin: PLUGIN_NAME,
155
- parent: result.opts.from
156
- });
157
- });
158
- builder.write(root);
159
- root.walk((node) => {
160
- if (!node.source) {
161
- node.source = root.source;
162
- }
163
- });
164
- }
165
- ]
166
- };
167
- };
168
- pixelcss.postcss = true;
169
- var src_default = pixelcss;
170
-
171
- // index.ts
172
- module.exports = src_default;
package/dist/index.mjs DELETED
@@ -1,185 +0,0 @@
1
- var __getOwnPropNames = Object.getOwnPropertyNames;
2
- var __esm = (fn, res) => function __init() {
3
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
4
- };
5
- var __commonJS = (cb, mod) => function __require() {
6
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
7
- };
8
-
9
- // ../../node_modules/.pnpm/tsup@7.2.0_postcss@8.4.33_ts-node@10.9.2_@types+node@20.11.21_typescript@5.4.3__typescript@5.4.3/node_modules/tsup/assets/esm_shims.js
10
- var init_esm_shims = __esm({
11
- "../../node_modules/.pnpm/tsup@7.2.0_postcss@8.4.33_ts-node@10.9.2_@types+node@20.11.21_typescript@5.4.3__typescript@5.4.3/node_modules/tsup/assets/esm_shims.js"() {
12
- "use strict";
13
- }
14
- });
15
-
16
- // src/default-config.ts
17
- import "@pandacss/dev";
18
- var defaultConfig;
19
- var init_default_config = __esm({
20
- "src/default-config.ts"() {
21
- "use strict";
22
- init_esm_shims();
23
- defaultConfig = {
24
- preflight: true,
25
- presets: ["@mekari/pixel3-theme"],
26
- include: ["./src/**/*.{js,jsx,ts,tsx,vue}", "./app/**/*.{js,jsx,ts,tsx,vue}"],
27
- exclude: [],
28
- layers: {
29
- reset: "pixel_reset",
30
- base: "pixel_base",
31
- tokens: "pixel_tokens",
32
- recipes: "pixel_recipes",
33
- utilities: "pixel_utilities"
34
- },
35
- prefix: "mp",
36
- jsxFramework: "vue",
37
- jsxFactory: "Pixel",
38
- jsxStyleProps: "all"
39
- };
40
- }
41
- });
42
-
43
- // src/create-config.ts
44
- import fs from "fs";
45
- import path from "path";
46
- import "@pandacss/dev";
47
- function findRealModulePath(moduleName) {
48
- try {
49
- const symlinkPath = path.join("node_modules", moduleName);
50
- const realPath = fs.realpathSync(symlinkPath);
51
- return realPath;
52
- } catch (error) {
53
- console.error("Error finding real module path:", error);
54
- return null;
55
- }
56
- }
57
- function mergeConfig(obj1, obj2) {
58
- const mergeKey = ["include", "exclude"];
59
- const tempObj = {};
60
- const hasReplaceConfig = obj2.replaceConfig && obj2.replaceConfig.length > 0;
61
- mergeKey.forEach((item) => {
62
- if (Object.prototype.hasOwnProperty.call(obj2, item)) {
63
- if (hasReplaceConfig && obj2.replaceConfig?.includes(item)) {
64
- tempObj[item] = obj2[item];
65
- return;
66
- }
67
- const obj1Value = obj1[item];
68
- const obj2Value = obj2[item];
69
- if (Array.isArray(obj1Value) && Array.isArray(obj2Value)) {
70
- tempObj[item] = [...obj1Value, ...obj2Value];
71
- }
72
- }
73
- });
74
- return { ...obj1, ...tempObj };
75
- }
76
- var createConfigFile;
77
- var init_create_config = __esm({
78
- "src/create-config.ts"() {
79
- "use strict";
80
- init_esm_shims();
81
- init_default_config();
82
- createConfigFile = (filePath, options) => {
83
- const _defaultConfig = { ...defaultConfig };
84
- const realPath = findRealModulePath("@mekari/pixel3");
85
- if (realPath) {
86
- const pixelDir = path.dirname(realPath);
87
- const extend = `${pixelDir}/**/dist/**/*.{js,mjs}`;
88
- const finalInclude = [..._defaultConfig.include || [], extend];
89
- _defaultConfig.include = finalInclude;
90
- }
91
- const configs = mergeConfig(_defaultConfig, options);
92
- const data = "export default" + JSON.stringify(configs, null, 2);
93
- try {
94
- fs.writeFileSync(filePath, data, "utf-8");
95
- } catch (error) {
96
- if (error instanceof Error) {
97
- console.error(error.message);
98
- } else {
99
- console.error("An unknown error occurred");
100
- }
101
- }
102
- };
103
- }
104
- });
105
-
106
- // src/index.ts
107
- import { Builder } from "@pandacss/node";
108
- import { createRequire } from "module";
109
- import path2 from "path";
110
- function isValidCss(file) {
111
- const [filePath] = file.split("?");
112
- return path2.extname(filePath) === ".css";
113
- }
114
- var require2, tmp, PLUGIN_NAME, tmpobj, configPath, builder, nodeModulesRegex, shouldSkip, pixelcss, src_default;
115
- var init_src = __esm({
116
- "src/index.ts"() {
117
- "use strict";
118
- init_esm_shims();
119
- init_create_config();
120
- require2 = createRequire(import.meta.url);
121
- tmp = require2("tmp");
122
- PLUGIN_NAME = "pixel3-postcss";
123
- tmpobj = tmp.fileSync({ postfix: ".ts" });
124
- configPath = tmpobj.name;
125
- tmp.setGracefulCleanup();
126
- builder = new Builder();
127
- nodeModulesRegex = /node_modules/;
128
- shouldSkip = (fileName) => {
129
- if (!fileName)
130
- return true;
131
- if (!isValidCss(fileName))
132
- return true;
133
- if (fileName.includes("@mekari/pixel3-nuxt"))
134
- return false;
135
- return nodeModulesRegex.test(fileName);
136
- };
137
- pixelcss = (options = {}) => {
138
- const { cwd } = options;
139
- createConfigFile(configPath, options);
140
- console.log("Pixel Config (auto-generated) :", configPath);
141
- return {
142
- postcssPlugin: PLUGIN_NAME,
143
- plugins: [
144
- async function(root, result) {
145
- const fileName = result.opts.from;
146
- const skip = shouldSkip(fileName);
147
- if (skip)
148
- return;
149
- await builder.setup({ configPath, cwd });
150
- if (!builder.isValidRoot(root)) {
151
- return;
152
- }
153
- await builder.emit();
154
- builder.extract();
155
- builder.registerDependency((dep) => {
156
- result.messages.push({
157
- ...dep,
158
- plugin: PLUGIN_NAME,
159
- parent: result.opts.from
160
- });
161
- });
162
- builder.write(root);
163
- root.walk((node) => {
164
- if (!node.source) {
165
- node.source = root.source;
166
- }
167
- });
168
- }
169
- ]
170
- };
171
- };
172
- pixelcss.postcss = true;
173
- src_default = pixelcss;
174
- }
175
- });
176
-
177
- // index.ts
178
- var require_postcss = __commonJS({
179
- "index.ts"(exports, module) {
180
- init_esm_shims();
181
- init_src();
182
- module.exports = src_default;
183
- }
184
- });
185
- export default require_postcss();