@pikacss/unplugin-pikacss 0.0.58 → 0.0.60

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.
@@ -1,4 +1,4 @@
1
- import { n as ResolvedPluginOptions, r as ScanOptions, t as PluginOptions } from "./types-lr98kclY.mjs";
1
+ import { n as ResolvedPluginOptions, r as ScanOptions, t as PluginOptions } from "./types-CBBDRP-6.mjs";
2
2
  import * as _$unplugin from "unplugin";
3
3
  export * from "@pikacss/integration";
4
4
 
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { n as ResolvedPluginOptions, r as ScanOptions, t as PluginOptions } from "./types-lr98kclY.mjs";
1
+ import { n as ResolvedPluginOptions, r as ScanOptions, t as PluginOptions } from "./types-CBBDRP-6.mjs";
2
2
  import * as _$unplugin from "unplugin";
3
3
  import { UnpluginFactory } from "unplugin";
4
4
  export * from "@pikacss/integration";
package/dist/index.mjs CHANGED
@@ -1,6 +1,7 @@
1
1
  import { readFileSync } from "node:fs";
2
+ import { writeFile } from "node:fs/promises";
2
3
  import process from "node:process";
3
- import { createCtx, log } from "@pikacss/integration";
4
+ import { consoleDiagnosticHandler, createCtx, log } from "@pikacss/integration";
4
5
  import { resolve } from "pathe";
5
6
  import { debounce } from "perfect-debounce";
6
7
  import { createUnplugin } from "unplugin";
@@ -32,7 +33,9 @@ const PLUGIN_NAME = "unplugin-pikacss";
32
33
  * ```
33
34
  */
34
35
  const unpluginFactory = (options, meta) => {
35
- const { cwd: userCwd, currentPackageName = "@pikacss/unplugin-pikacss", config: configOrPath, tsCodegen = true, cssCodegen = true, scan = {}, fnName = "pika", transformedFormat = "string", autoCreateConfig = false } = options ?? {};
36
+ const { cwd: userCwd, currentPackageName = "@pikacss/unplugin-pikacss", config: configOrPath, tsCodegen = true, cssCodegen = true, scan = {}, fnName = "pika", transformedFormat = "string", autoCreateConfig = false, report = false } = options ?? {};
37
+ const reportEnabled = report === true || typeof report === "object" && report != null;
38
+ const reportOutputPath = typeof report === "object" && report != null ? report.output : void 0;
36
39
  log.debug("Creating unplugin factory with options:", options);
37
40
  const resolvedOptions = {
38
41
  currentPackageName,
@@ -58,10 +61,35 @@ const unpluginFactory = (options, meta) => {
58
61
  let mode = "build";
59
62
  const viteServers = [];
60
63
  const rspackCompilers = [];
64
+ const collectedErrors = [];
65
+ let currentModuleId = null;
66
+ const onDiagnostic = (diagnostic) => {
67
+ consoleDiagnosticHandler(diagnostic);
68
+ if (diagnostic.level === "error") collectedErrors.push({
69
+ diagnostic,
70
+ moduleId: currentModuleId
71
+ });
72
+ };
61
73
  const ctx = createCtx({
62
74
  cwd: resolve(userCwd ?? process.cwd()),
63
- ...resolvedOptions
75
+ ...resolvedOptions,
76
+ onDiagnostic
64
77
  });
78
+ async function emitTokenReport() {
79
+ const reportFn = ctx.engine.designTokens?.report;
80
+ if (typeof reportFn !== "function") {
81
+ log.debug("Design-token report requested, but no design-tokens plugin surface is present.");
82
+ return;
83
+ }
84
+ const result = reportFn();
85
+ log.info(`[design-tokens] ${result.totalTokens} tokens, ${result.used.length} used, ${result.unused.length} unused`);
86
+ log.info(`[design-tokens] ${result.deprecatedInUse.length} deprecated in use, ${result.strictViolations.error} strict error(s), ${result.strictViolations.warning} strict warning(s)`);
87
+ if (reportOutputPath != null) {
88
+ const outPath = resolve(ctx.cwd, reportOutputPath);
89
+ await writeFile(outPath, `${JSON.stringify(result, null, 2)}\n`, "utf-8");
90
+ log.info(`[design-tokens] report written to ${outPath}`);
91
+ }
92
+ }
65
93
  function applyRuntimeContext(nextCwd, nextMode) {
66
94
  if (userCwd == null) ctx.cwd = resolve(nextCwd);
67
95
  mode = nextMode;
@@ -243,9 +271,11 @@ const unpluginFactory = (options, meta) => {
243
271
  this.addWatchFile(ctx.resolvedConfigPath);
244
272
  log.debug(`Added watch file: ${ctx.resolvedConfigPath}`);
245
273
  }
274
+ currentModuleId = id;
246
275
  try {
247
276
  return await ctx.transform(code, id);
248
277
  } finally {
278
+ currentModuleId = null;
249
279
  if (ctx.isIdle) await flushPendingGeneratedWrites();
250
280
  }
251
281
  }
@@ -254,6 +284,14 @@ const unpluginFactory = (options, meta) => {
254
284
  if (mode !== "build") return;
255
285
  await ctx.waitForIdle();
256
286
  for (const file of ctx.getScannedButNotTransformedFiles()) log.warn(`Styles from ${file} were included in the generated CSS but the file was never reached by the bundler — dead file or missing import?`);
287
+ if (reportEnabled) await emitTokenReport();
288
+ if (collectedErrors.length > 0) {
289
+ const details = collectedErrors.map(({ diagnostic, moduleId }) => {
290
+ const where = moduleId != null ? ` (${moduleId})` : "";
291
+ return ` - ${diagnostic.plugin != null ? `[${diagnostic.plugin}] ` : ""}${diagnostic.code}${where}: ${diagnostic.message}`;
292
+ }).join("\n");
293
+ throw new Error(`PikaCSS reported ${collectedErrors.length} error diagnostic(s):\n${details}`);
294
+ }
257
295
  },
258
296
  watchChange(id, change) {
259
297
  if (change?.event === "delete") {
@@ -1,4 +1,4 @@
1
- import { n as ResolvedPluginOptions, r as ScanOptions, t as PluginOptions } from "./types-lr98kclY.mjs";
1
+ import { n as ResolvedPluginOptions, r as ScanOptions, t as PluginOptions } from "./types-CBBDRP-6.mjs";
2
2
  export * from "@pikacss/integration";
3
3
 
4
4
  //#region ../../node_modules/.pnpm/rolldown@1.0.0-rc.12_@emnapi+core@1.11.1_@emnapi+runtime@1.11.1/node_modules/rolldown/dist/shared/logging-C6h4g8dA.d.mts
package/dist/rollup.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { n as ResolvedPluginOptions, r as ScanOptions, t as PluginOptions } from "./types-lr98kclY.mjs";
1
+ import { n as ResolvedPluginOptions, r as ScanOptions, t as PluginOptions } from "./types-CBBDRP-6.mjs";
2
2
  import * as _$unplugin from "unplugin";
3
3
  export * from "@pikacss/integration";
4
4
 
package/dist/rspack.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { n as ResolvedPluginOptions, r as ScanOptions, t as PluginOptions } from "./types-lr98kclY.mjs";
1
+ import { n as ResolvedPluginOptions, r as ScanOptions, t as PluginOptions } from "./types-CBBDRP-6.mjs";
2
2
  export * from "@pikacss/integration";
3
3
 
4
4
  //#region src/rspack.d.ts
@@ -118,6 +118,22 @@ interface PluginOptions {
118
118
  * @default `'@pikacss/unplugin-pikacss'`
119
119
  */
120
120
  currentPackageName?: string;
121
+ /**
122
+ * Emit a design-token usage report at the end of a production build. Requires
123
+ * `@pikacss/plugin-design-tokens` to be registered; a no-op otherwise.
124
+ *
125
+ * @remarks
126
+ * `true` logs a concise summary (total tokens, used/unused counts, deprecated
127
+ * tokens in use, and strict-violation counts) once per build. Passing
128
+ * `{ output }` additionally writes the full report as JSON to that path,
129
+ * resolved against the project root. The report is emitted only in build mode,
130
+ * so a dev server never spams it per HMR update.
131
+ *
132
+ * @default `false` (no report)
133
+ */
134
+ report?: boolean | {
135
+ /** File path (resolved against the project root) to write the full report JSON to. */output?: string;
136
+ };
121
137
  }
122
138
  /**
123
139
  * Normalized plugin configuration with all defaults applied and boolean shorthands expanded.
package/dist/vite.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { n as ResolvedPluginOptions, r as ScanOptions, t as PluginOptions } from "./types-lr98kclY.mjs";
1
+ import { n as ResolvedPluginOptions, r as ScanOptions, t as PluginOptions } from "./types-CBBDRP-6.mjs";
2
2
  import { Plugin } from "vite";
3
3
  export * from "@pikacss/integration";
4
4
 
@@ -1,4 +1,4 @@
1
- import { n as ResolvedPluginOptions, r as ScanOptions, t as PluginOptions } from "./types-lr98kclY.mjs";
1
+ import { n as ResolvedPluginOptions, r as ScanOptions, t as PluginOptions } from "./types-CBBDRP-6.mjs";
2
2
  export * from "@pikacss/integration";
3
3
 
4
4
  //#region src/webpack.d.ts
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pikacss/unplugin-pikacss",
3
3
  "type": "module",
4
- "version": "0.0.58",
4
+ "version": "0.0.60",
5
5
  "author": "DevilTea <ch19980814@gmail.com>",
6
6
  "license": "MIT",
7
7
  "homepage": "https://pikacss.github.io",
@@ -94,7 +94,7 @@
94
94
  "pathe": "^2.0.3",
95
95
  "perfect-debounce": "^2.1.0",
96
96
  "unplugin": "^3.3.0",
97
- "@pikacss/integration": "0.0.58"
97
+ "@pikacss/integration": "0.0.60"
98
98
  },
99
99
  "devDependencies": {
100
100
  "esbuild": "^0.28.1",