@pikacss/unplugin-pikacss 0.0.52 → 0.0.55

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/README.md CHANGED
@@ -36,7 +36,7 @@ import pikacss from '@pikacss/unplugin-pikacss/webpack'
36
36
 
37
37
  ## Documentation
38
38
 
39
- See the [full documentation](https://pikacss.com/integrations/unplugin).
39
+ See the [full documentation](https://pikacss.github.io/integrations/unplugin).
40
40
 
41
41
  ## License
42
42
 
@@ -1,4 +1,4 @@
1
- import { n as ResolvedPluginOptions, t as PluginOptions } from "./types-237J7YdE.mjs";
1
+ import { n as ResolvedPluginOptions, t as PluginOptions } from "./types-vzKzLeMH.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, t as PluginOptions } from "./types-237J7YdE.mjs";
1
+ import { n as ResolvedPluginOptions, t as PluginOptions } from "./types-vzKzLeMH.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
@@ -65,13 +65,12 @@ const unpluginFactory = (options, meta) => {
65
65
  const debouncedWriteTsCodegenFile = debounce(async () => {
66
66
  await ctx.writeTsCodegenFile();
67
67
  }, 300);
68
- let activeTransforms = 0;
69
68
  let pendingCssWrite = false;
70
69
  let pendingTsWrite = false;
71
70
  let generatedWritePromise = Promise.resolve();
72
71
  function flushPendingGeneratedWrites() {
73
72
  generatedWritePromise = generatedWritePromise.catch(() => {}).then(async () => {
74
- if (activeTransforms > 0) return;
73
+ if (!ctx.isIdle) return;
75
74
  const shouldWriteCss = pendingCssWrite;
76
75
  const shouldWriteTs = pendingTsWrite;
77
76
  pendingCssWrite = false;
@@ -94,11 +93,16 @@ const unpluginFactory = (options, meta) => {
94
93
  }
95
94
  function queueCssWrite() {
96
95
  pendingCssWrite = true;
97
- return flushPendingGeneratedWrites();
96
+ scheduleGeneratedWritesFlush();
98
97
  }
99
98
  function queueTsWrite() {
100
99
  pendingTsWrite = true;
101
- return flushPendingGeneratedWrites();
100
+ scheduleGeneratedWritesFlush();
101
+ }
102
+ function scheduleGeneratedWritesFlush() {
103
+ flushPendingGeneratedWrites().catch((error) => {
104
+ log.error(`Failed to write generated files: ${error?.message ?? error}`, error);
105
+ });
102
106
  }
103
107
  let hooksBound = false;
104
108
  function bindHooks() {
@@ -106,22 +110,23 @@ const unpluginFactory = (options, meta) => {
106
110
  hooksBound = true;
107
111
  ctx.hooks.styleUpdated.on(() => {
108
112
  log.debug(`Style updated, ${ctx.engine.store.atomicStyleIds.size} atomic styles generated`);
109
- return queueCssWrite();
113
+ queueCssWrite();
110
114
  });
111
115
  ctx.hooks.tsCodegenUpdated.on(() => {
112
116
  log.debug("TypeScript code generation updated");
113
- return queueTsWrite();
117
+ queueTsWrite();
114
118
  });
115
119
  }
116
120
  let setupPromise = Promise.resolve();
117
121
  let lastSetupCwd = null;
118
122
  let pendingSetupCwd = null;
123
+ let pendingReload = false;
119
124
  function setup(reload = false) {
120
125
  pendingSetupCwd = ctx.cwd;
126
+ pendingReload = false;
121
127
  setupPromise = setupPromise.then(async () => {
122
128
  log.debug("Setting up integration context...");
123
129
  const moduleIds = Array.from(ctx.usages.keys());
124
- activeTransforms = 0;
125
130
  pendingCssWrite = false;
126
131
  pendingTsWrite = false;
127
132
  hooksBound = false;
@@ -152,10 +157,13 @@ const unpluginFactory = (options, meta) => {
152
157
  compiler.watching.invalidate();
153
158
  });
154
159
  }
160
+ }).catch((error) => {
161
+ log.error(`Failed to setup integration context: ${error?.message ?? error}`, error);
155
162
  });
156
163
  return setupPromise;
157
164
  }
158
165
  function ensureSetup(reload = false) {
166
+ if (pendingReload) return setup(true);
159
167
  if (!reload && (lastSetupCwd === ctx.cwd || pendingSetupCwd === ctx.cwd)) return setupPromise;
160
168
  return setup(reload);
161
169
  }
@@ -196,10 +204,15 @@ const unpluginFactory = (options, meta) => {
196
204
  log.debug("Running full CSS code generation in build mode");
197
205
  await ctx.fullyCssCodegen();
198
206
  }
207
+ if (meta.framework === "esbuild") return;
199
208
  if (ctx.resolvedConfigPath != null) {
200
209
  this.addWatchFile(ctx.resolvedConfigPath);
201
210
  log.debug(`Added watch file: ${ctx.resolvedConfigPath}`);
202
211
  }
212
+ for (const dep of ctx.engine.configDependencies ?? []) {
213
+ this.addWatchFile(dep);
214
+ log.debug(`Added config dependency watch file: ${dep}`);
215
+ }
203
216
  },
204
217
  resolveId: meta.framework === "esbuild" ? void 0 : async function(id) {
205
218
  if (RE_VIRTUAL_PIKA_CSS_ID.test(id)) {
@@ -215,7 +228,7 @@ const unpluginFactory = (options, meta) => {
215
228
  } },
216
229
  async handler(code, id) {
217
230
  await ensureSetup();
218
- activeTransforms++;
231
+ if (!ctx.isTransformTarget(id)) return null;
219
232
  if (meta.framework === "webpack" && ctx.resolvedConfigPath != null) {
220
233
  this.addWatchFile(ctx.resolvedConfigPath);
221
234
  log.debug(`Added watch file: ${ctx.resolvedConfigPath}`);
@@ -223,14 +236,39 @@ const unpluginFactory = (options, meta) => {
223
236
  try {
224
237
  return await ctx.transform(code, id);
225
238
  } finally {
226
- if (activeTransforms > 0) activeTransforms--;
227
- if (activeTransforms === 0) await flushPendingGeneratedWrites();
239
+ if (ctx.isIdle) await flushPendingGeneratedWrites();
228
240
  }
229
241
  }
230
242
  },
231
- watchChange(id) {
232
- if (id === ctx.resolvedConfigPath && readFileSync(id, "utf-8") !== ctx.resolvedConfigContent) {
233
- log.info("Configuration file changed, reloading...");
243
+ async buildEnd() {
244
+ if (mode !== "build") return;
245
+ await ctx.waitForIdle();
246
+ 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?`);
247
+ },
248
+ watchChange(id, change) {
249
+ if (change?.event === "delete") {
250
+ log.debug(`Source file deleted, dropping its state: ${id}`);
251
+ ctx.dropModule(id);
252
+ }
253
+ if (id === ctx.resolvedConfigPath) {
254
+ let currentContent = null;
255
+ try {
256
+ currentContent = readFileSync(id, "utf-8");
257
+ } catch {}
258
+ if (currentContent !== ctx.resolvedConfigContent) {
259
+ log.info("Configuration file changed, reloading...");
260
+ pendingReload = true;
261
+ debouncedSetup(true);
262
+ }
263
+ return;
264
+ }
265
+ let isConfigDependency = false;
266
+ try {
267
+ isConfigDependency = ctx.engine.configDependencies.has(id);
268
+ } catch {}
269
+ if (isConfigDependency) {
270
+ log.info(`Config dependency changed: ${id}, reloading...`);
271
+ pendingReload = true;
234
272
  debouncedSetup(true);
235
273
  }
236
274
  }
@@ -1,7 +1,7 @@
1
- import { n as ResolvedPluginOptions, t as PluginOptions } from "./types-237J7YdE.mjs";
1
+ import { n as ResolvedPluginOptions, t as PluginOptions } from "./types-vzKzLeMH.mjs";
2
2
  export * from "@pikacss/integration";
3
3
 
4
- //#region ../../node_modules/.pnpm/rolldown@1.0.0-rc.12_@emnapi+core@1.7.1_@emnapi+runtime@1.7.1/node_modules/rolldown/dist/shared/logging-C6h4g8dA.d.mts
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
5
5
  //#region src/log/logging.d.ts
6
6
  /** @inline */
7
7
  type LogLevel = "info" | "debug" | "warn";
@@ -1350,7 +1350,7 @@ type UnaryOperator = "+" | "-" | "!" | "~" | "typeof" | "void" | "delete";
1350
1350
  type UpdateOperator = "++" | "--";
1351
1351
  type Node = Program | IdentifierName | IdentifierReference | BindingIdentifier | LabelIdentifier | ThisExpression | ArrayExpression | ObjectExpression | ObjectProperty | TemplateLiteral | TaggedTemplateExpression | TemplateElement | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression | CallExpression | NewExpression | MetaProperty | SpreadElement | UpdateExpression | UnaryExpression | BinaryExpression | PrivateInExpression | LogicalExpression | ConditionalExpression | AssignmentExpression | ArrayAssignmentTarget | ObjectAssignmentTarget | AssignmentTargetRest | AssignmentTargetWithDefault | AssignmentTargetPropertyIdentifier | AssignmentTargetPropertyProperty | SequenceExpression | Super | AwaitExpression | ChainExpression | ParenthesizedExpression | Directive | Hashbang | BlockStatement | VariableDeclaration | VariableDeclarator | EmptyStatement | ExpressionStatement | IfStatement | DoWhileStatement | WhileStatement | ForStatement | ForInStatement | ForOfStatement | ContinueStatement | BreakStatement | ReturnStatement | WithStatement | SwitchStatement | SwitchCase | LabeledStatement | ThrowStatement | TryStatement | CatchClause | DebuggerStatement | AssignmentPattern | ObjectPattern | BindingProperty | ArrayPattern | BindingRestElement | Function | FunctionBody | ArrowFunctionExpression | YieldExpression | Class | ClassBody | MethodDefinition | PropertyDefinition | PrivateIdentifier | StaticBlock | AccessorProperty | ImportExpression | ImportDeclaration | ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ImportAttribute | ExportNamedDeclaration | ExportDefaultDeclaration | ExportAllDeclaration | ExportSpecifier | V8IntrinsicExpression | BooleanLiteral | NullLiteral | NumericLiteral | StringLiteral | BigIntLiteral | RegExpLiteral | JSXElement | JSXOpeningElement | JSXClosingElement | JSXFragment | JSXOpeningFragment | JSXClosingFragment | JSXNamespacedName | JSXMemberExpression | JSXExpressionContainer | JSXEmptyExpression | JSXAttribute | JSXSpreadAttribute | JSXIdentifier | JSXSpreadChild | JSXText | TSThisParameter | TSEnumDeclaration | TSEnumBody | TSEnumMember | TSTypeAnnotation | TSLiteralType | TSConditionalType | TSUnionType | TSIntersectionType | TSParenthesizedType | TSTypeOperator | TSArrayType | TSIndexedAccessType | TSTupleType | TSNamedTupleMember | TSOptionalType | TSRestType | TSAnyKeyword | TSStringKeyword | TSBooleanKeyword | TSNumberKeyword | TSNeverKeyword | TSIntrinsicKeyword | TSUnknownKeyword | TSNullKeyword | TSUndefinedKeyword | TSVoidKeyword | TSSymbolKeyword | TSThisType | TSObjectKeyword | TSBigIntKeyword | TSTypeReference | TSQualifiedName | TSTypeParameterInstantiation | TSTypeParameter | TSTypeParameterDeclaration | TSTypeAliasDeclaration | TSClassImplements | TSInterfaceDeclaration | TSInterfaceBody | TSPropertySignature | TSIndexSignature | TSCallSignatureDeclaration | TSMethodSignature | TSConstructSignatureDeclaration | TSIndexSignatureName | TSInterfaceHeritage | TSTypePredicate | TSModuleDeclaration | TSGlobalDeclaration | TSModuleBlock | TSTypeLiteral | TSInferType | TSTypeQuery | TSImportType | TSImportTypeQualifiedName | TSFunctionType | TSConstructorType | TSMappedType | TSTemplateLiteralType | TSAsExpression | TSSatisfiesExpression | TSTypeAssertion | TSImportEqualsDeclaration | TSExternalModuleReference | TSNonNullExpression | Decorator | TSExportAssignment | TSNamespaceExportDeclaration | TSInstantiationExpression | JSDocNullableType | JSDocNonNullableType | JSDocUnknownType | ParamPattern;
1352
1352
  //#endregion
1353
- //#region ../../node_modules/.pnpm/rolldown@1.0.0-rc.12_@emnapi+core@1.7.1_@emnapi+runtime@1.7.1/node_modules/rolldown/dist/shared/binding-CYVfiOV3.d.mts
1353
+ //#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/binding-CYVfiOV3.d.mts
1354
1354
  interface CodegenOptions {
1355
1355
  /**
1356
1356
  * Remove whitespace.
@@ -2295,7 +2295,7 @@ declare class Exclude$1 {
2295
2295
  constructor(expr: FilterExpression);
2296
2296
  }
2297
2297
  //#endregion
2298
- //#region ../../node_modules/.pnpm/rolldown@1.0.0-rc.12_@emnapi+core@1.7.1_@emnapi+runtime@1.7.1/node_modules/rolldown/dist/shared/define-config-BkRKRADp.d.mts
2298
+ //#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/define-config-BkRKRADp.d.mts
2299
2299
  //#region src/types/misc.d.ts
2300
2300
  /** @inline */
2301
2301
  type SourcemapPathTransformOption = (relativeSourcePath: string, sourcemapPath: string) => string;
package/dist/rollup.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { n as ResolvedPluginOptions, t as PluginOptions } from "./types-237J7YdE.mjs";
1
+ import { n as ResolvedPluginOptions, t as PluginOptions } from "./types-vzKzLeMH.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, t as PluginOptions } from "./types-237J7YdE.mjs";
1
+ import { n as ResolvedPluginOptions, t as PluginOptions } from "./types-vzKzLeMH.mjs";
2
2
  export * from "@pikacss/integration";
3
3
 
4
4
  //#region src/rspack.d.ts
@@ -42,6 +42,8 @@ interface PluginOptions {
42
42
  scan?: {
43
43
  /**
44
44
  * File glob patterns to scan. Supports a single string or array of strings.
45
+ * When omitted, the default covers every extension the AST compiler
46
+ * supports: the JS family plus Vue SFCs. An explicit value wins verbatim.
45
47
  * @default ['**\/*.{js,ts,jsx,tsx,vue}']
46
48
  */
47
49
  include?: string | string[];
package/dist/vite.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { n as ResolvedPluginOptions, t as PluginOptions } from "./types-237J7YdE.mjs";
1
+ import { n as ResolvedPluginOptions, t as PluginOptions } from "./types-vzKzLeMH.mjs";
2
2
  import { Plugin } from "vite";
3
3
  export * from "@pikacss/integration";
4
4
 
@@ -1,4 +1,4 @@
1
- import { n as ResolvedPluginOptions, t as PluginOptions } from "./types-237J7YdE.mjs";
1
+ import { n as ResolvedPluginOptions, t as PluginOptions } from "./types-vzKzLeMH.mjs";
2
2
  export * from "@pikacss/integration";
3
3
 
4
4
  //#region src/webpack.d.ts
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@pikacss/unplugin-pikacss",
3
3
  "type": "module",
4
- "version": "0.0.52",
4
+ "version": "0.0.55",
5
5
  "author": "DevilTea <ch19980814@gmail.com>",
6
6
  "license": "MIT",
7
- "homepage": "https://pikacss.com",
7
+ "homepage": "https://pikacss.github.io",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "git+https://github.com/pikacss/pikacss.git",
@@ -93,12 +93,12 @@
93
93
  "dependencies": {
94
94
  "pathe": "^2.0.3",
95
95
  "perfect-debounce": "^2.1.0",
96
- "unplugin": "^3.0.0",
97
- "@pikacss/integration": "0.0.52"
96
+ "unplugin": "^3.3.0",
97
+ "@pikacss/integration": "0.0.55"
98
98
  },
99
99
  "devDependencies": {
100
- "esbuild": "^0.27.4",
101
- "vite": "^8.0.3"
100
+ "esbuild": "^0.28.1",
101
+ "vite": "^8.1.3"
102
102
  },
103
103
  "scripts": {
104
104
  "build": "tsdown",