@pikacss/unplugin-pikacss 0.0.51 → 0.0.54
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 +1 -1
- package/dist/esbuild.d.mts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +60 -16
- package/dist/rolldown.d.mts +4 -4
- package/dist/rollup.d.mts +1 -1
- package/dist/rspack.d.mts +1 -1
- package/dist/{types-237J7YdE.d.mts → types-CooOKDFP.d.mts} +20 -2
- package/dist/vite.d.mts +1 -1
- package/dist/webpack.d.mts +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
package/dist/esbuild.d.mts
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as ResolvedPluginOptions, t as PluginOptions } from "./types-
|
|
1
|
+
import { n as ResolvedPluginOptions, t as PluginOptions } from "./types-CooOKDFP.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,6 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
2
|
import process from "node:process";
|
|
3
|
-
import { createCtx, log } from "@pikacss/integration";
|
|
3
|
+
import { DEFAULT_MARKUP_EXTENSIONS, createCtx, log, normalizeMarkupExtensions } from "@pikacss/integration";
|
|
4
4
|
import { resolve } from "pathe";
|
|
5
5
|
import { debounce } from "perfect-debounce";
|
|
6
6
|
import { createUnplugin } from "unplugin";
|
|
@@ -32,18 +32,26 @@ const PLUGIN_NAME = "unplugin-pikacss";
|
|
|
32
32
|
* ```
|
|
33
33
|
*/
|
|
34
34
|
const unpluginFactory = (options, meta) => {
|
|
35
|
-
const { cwd: userCwd, currentPackageName = "@pikacss/unplugin-pikacss", config: configOrPath, tsCodegen = true, cssCodegen = true, scan = {}, fnName = "pika", transformedFormat = "string", autoCreateConfig = true } = options ?? {};
|
|
35
|
+
const { cwd: userCwd, currentPackageName = "@pikacss/unplugin-pikacss", config: configOrPath, tsCodegen = true, cssCodegen = true, scan = {}, fnName = "pika", markupExtensions, transformedFormat = "string", autoCreateConfig = true } = options ?? {};
|
|
36
36
|
log.debug("Creating unplugin factory with options:", options);
|
|
37
|
+
const defaultInclude = [`**/*.{${[
|
|
38
|
+
"js",
|
|
39
|
+
"ts",
|
|
40
|
+
"jsx",
|
|
41
|
+
"tsx",
|
|
42
|
+
...normalizeMarkupExtensions([...DEFAULT_MARKUP_EXTENSIONS, ...markupExtensions ?? []])
|
|
43
|
+
].join(",")}}`];
|
|
37
44
|
const resolvedOptions = {
|
|
38
45
|
currentPackageName,
|
|
39
46
|
configOrPath,
|
|
40
47
|
tsCodegen: tsCodegen === true ? "pika.gen.ts" : tsCodegen,
|
|
41
48
|
cssCodegen: cssCodegen === true ? "pika.gen.css" : cssCodegen,
|
|
42
49
|
scan: {
|
|
43
|
-
include: typeof scan?.include === "string" ? [scan.include] : scan?.include ||
|
|
50
|
+
include: typeof scan?.include === "string" ? [scan.include] : scan?.include || defaultInclude,
|
|
44
51
|
exclude: typeof scan?.exclude === "string" ? [scan.exclude] : scan?.exclude || ["node_modules/**", "dist/**"]
|
|
45
52
|
},
|
|
46
53
|
fnName,
|
|
54
|
+
markupExtensions,
|
|
47
55
|
transformedFormat,
|
|
48
56
|
autoCreateConfig
|
|
49
57
|
};
|
|
@@ -65,13 +73,12 @@ const unpluginFactory = (options, meta) => {
|
|
|
65
73
|
const debouncedWriteTsCodegenFile = debounce(async () => {
|
|
66
74
|
await ctx.writeTsCodegenFile();
|
|
67
75
|
}, 300);
|
|
68
|
-
let activeTransforms = 0;
|
|
69
76
|
let pendingCssWrite = false;
|
|
70
77
|
let pendingTsWrite = false;
|
|
71
78
|
let generatedWritePromise = Promise.resolve();
|
|
72
79
|
function flushPendingGeneratedWrites() {
|
|
73
80
|
generatedWritePromise = generatedWritePromise.catch(() => {}).then(async () => {
|
|
74
|
-
if (
|
|
81
|
+
if (!ctx.isIdle) return;
|
|
75
82
|
const shouldWriteCss = pendingCssWrite;
|
|
76
83
|
const shouldWriteTs = pendingTsWrite;
|
|
77
84
|
pendingCssWrite = false;
|
|
@@ -94,11 +101,16 @@ const unpluginFactory = (options, meta) => {
|
|
|
94
101
|
}
|
|
95
102
|
function queueCssWrite() {
|
|
96
103
|
pendingCssWrite = true;
|
|
97
|
-
|
|
104
|
+
scheduleGeneratedWritesFlush();
|
|
98
105
|
}
|
|
99
106
|
function queueTsWrite() {
|
|
100
107
|
pendingTsWrite = true;
|
|
101
|
-
|
|
108
|
+
scheduleGeneratedWritesFlush();
|
|
109
|
+
}
|
|
110
|
+
function scheduleGeneratedWritesFlush() {
|
|
111
|
+
flushPendingGeneratedWrites().catch((error) => {
|
|
112
|
+
log.error(`Failed to write generated files: ${error?.message ?? error}`, error);
|
|
113
|
+
});
|
|
102
114
|
}
|
|
103
115
|
let hooksBound = false;
|
|
104
116
|
function bindHooks() {
|
|
@@ -106,22 +118,23 @@ const unpluginFactory = (options, meta) => {
|
|
|
106
118
|
hooksBound = true;
|
|
107
119
|
ctx.hooks.styleUpdated.on(() => {
|
|
108
120
|
log.debug(`Style updated, ${ctx.engine.store.atomicStyleIds.size} atomic styles generated`);
|
|
109
|
-
|
|
121
|
+
queueCssWrite();
|
|
110
122
|
});
|
|
111
123
|
ctx.hooks.tsCodegenUpdated.on(() => {
|
|
112
124
|
log.debug("TypeScript code generation updated");
|
|
113
|
-
|
|
125
|
+
queueTsWrite();
|
|
114
126
|
});
|
|
115
127
|
}
|
|
116
128
|
let setupPromise = Promise.resolve();
|
|
117
129
|
let lastSetupCwd = null;
|
|
118
130
|
let pendingSetupCwd = null;
|
|
131
|
+
let pendingReload = false;
|
|
119
132
|
function setup(reload = false) {
|
|
120
133
|
pendingSetupCwd = ctx.cwd;
|
|
134
|
+
pendingReload = false;
|
|
121
135
|
setupPromise = setupPromise.then(async () => {
|
|
122
136
|
log.debug("Setting up integration context...");
|
|
123
137
|
const moduleIds = Array.from(ctx.usages.keys());
|
|
124
|
-
activeTransforms = 0;
|
|
125
138
|
pendingCssWrite = false;
|
|
126
139
|
pendingTsWrite = false;
|
|
127
140
|
hooksBound = false;
|
|
@@ -152,10 +165,13 @@ const unpluginFactory = (options, meta) => {
|
|
|
152
165
|
compiler.watching.invalidate();
|
|
153
166
|
});
|
|
154
167
|
}
|
|
168
|
+
}).catch((error) => {
|
|
169
|
+
log.error(`Failed to setup integration context: ${error?.message ?? error}`, error);
|
|
155
170
|
});
|
|
156
171
|
return setupPromise;
|
|
157
172
|
}
|
|
158
173
|
function ensureSetup(reload = false) {
|
|
174
|
+
if (pendingReload) return setup(true);
|
|
159
175
|
if (!reload && (lastSetupCwd === ctx.cwd || pendingSetupCwd === ctx.cwd)) return setupPromise;
|
|
160
176
|
return setup(reload);
|
|
161
177
|
}
|
|
@@ -196,10 +212,15 @@ const unpluginFactory = (options, meta) => {
|
|
|
196
212
|
log.debug("Running full CSS code generation in build mode");
|
|
197
213
|
await ctx.fullyCssCodegen();
|
|
198
214
|
}
|
|
215
|
+
if (meta.framework === "esbuild") return;
|
|
199
216
|
if (ctx.resolvedConfigPath != null) {
|
|
200
217
|
this.addWatchFile(ctx.resolvedConfigPath);
|
|
201
218
|
log.debug(`Added watch file: ${ctx.resolvedConfigPath}`);
|
|
202
219
|
}
|
|
220
|
+
for (const dep of ctx.engine.configDependencies ?? []) {
|
|
221
|
+
this.addWatchFile(dep);
|
|
222
|
+
log.debug(`Added config dependency watch file: ${dep}`);
|
|
223
|
+
}
|
|
203
224
|
},
|
|
204
225
|
resolveId: meta.framework === "esbuild" ? void 0 : async function(id) {
|
|
205
226
|
if (RE_VIRTUAL_PIKA_CSS_ID.test(id)) {
|
|
@@ -215,7 +236,7 @@ const unpluginFactory = (options, meta) => {
|
|
|
215
236
|
} },
|
|
216
237
|
async handler(code, id) {
|
|
217
238
|
await ensureSetup();
|
|
218
|
-
|
|
239
|
+
if (!ctx.isTransformTarget(id)) return null;
|
|
219
240
|
if (meta.framework === "webpack" && ctx.resolvedConfigPath != null) {
|
|
220
241
|
this.addWatchFile(ctx.resolvedConfigPath);
|
|
221
242
|
log.debug(`Added watch file: ${ctx.resolvedConfigPath}`);
|
|
@@ -223,14 +244,37 @@ const unpluginFactory = (options, meta) => {
|
|
|
223
244
|
try {
|
|
224
245
|
return await ctx.transform(code, id);
|
|
225
246
|
} finally {
|
|
226
|
-
if (
|
|
227
|
-
if (activeTransforms === 0) await flushPendingGeneratedWrites();
|
|
247
|
+
if (ctx.isIdle) await flushPendingGeneratedWrites();
|
|
228
248
|
}
|
|
229
249
|
}
|
|
230
250
|
},
|
|
231
|
-
watchChange(id) {
|
|
232
|
-
if (
|
|
233
|
-
log.
|
|
251
|
+
watchChange(id, change) {
|
|
252
|
+
if (change?.event === "delete" && (ctx.usages.has(id) || ctx.previewUsages.has(id))) {
|
|
253
|
+
log.debug(`Source file deleted, dropping its usages: ${id}`);
|
|
254
|
+
ctx.usages.delete(id);
|
|
255
|
+
ctx.previewUsages.delete(id);
|
|
256
|
+
queueCssWrite();
|
|
257
|
+
queueTsWrite();
|
|
258
|
+
}
|
|
259
|
+
if (id === ctx.resolvedConfigPath) {
|
|
260
|
+
let currentContent = null;
|
|
261
|
+
try {
|
|
262
|
+
currentContent = readFileSync(id, "utf-8");
|
|
263
|
+
} catch {}
|
|
264
|
+
if (currentContent !== ctx.resolvedConfigContent) {
|
|
265
|
+
log.info("Configuration file changed, reloading...");
|
|
266
|
+
pendingReload = true;
|
|
267
|
+
debouncedSetup(true);
|
|
268
|
+
}
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
let isConfigDependency = false;
|
|
272
|
+
try {
|
|
273
|
+
isConfigDependency = ctx.engine.configDependencies.has(id);
|
|
274
|
+
} catch {}
|
|
275
|
+
if (isConfigDependency) {
|
|
276
|
+
log.info(`Config dependency changed: ${id}, reloading...`);
|
|
277
|
+
pendingReload = true;
|
|
234
278
|
debouncedSetup(true);
|
|
235
279
|
}
|
|
236
280
|
}
|
package/dist/rolldown.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { n as ResolvedPluginOptions, t as PluginOptions } from "./types-
|
|
1
|
+
import { n as ResolvedPluginOptions, t as PluginOptions } from "./types-CooOKDFP.mjs";
|
|
2
2
|
export * from "@pikacss/integration";
|
|
3
3
|
|
|
4
|
-
//#region ../../node_modules/.pnpm/rolldown@1.0.0-rc.12_@emnapi+core@1.
|
|
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.
|
|
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.
|
|
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
package/dist/rspack.d.mts
CHANGED
|
@@ -37,12 +37,15 @@ interface PluginOptions {
|
|
|
37
37
|
/**
|
|
38
38
|
* Glob patterns controlling which source files are scanned for `pika()` calls.
|
|
39
39
|
*
|
|
40
|
-
* @default `{ include: ['**\/*.{js,ts,jsx,tsx,vue}'], exclude: ['node_modules/**', 'dist/**'] }`
|
|
40
|
+
* @default `{ include: ['**\/*.{js,ts,jsx,tsx,vue,svelte,astro,html,htm}'], exclude: ['node_modules/**', 'dist/**'] }`
|
|
41
41
|
*/
|
|
42
42
|
scan?: {
|
|
43
43
|
/**
|
|
44
44
|
* File glob patterns to scan. Supports a single string or array of strings.
|
|
45
|
-
*
|
|
45
|
+
* When omitted, the default covers the JS family plus every supported markup
|
|
46
|
+
* extension (the built-in markup defaults merged with `markupExtensions`).
|
|
47
|
+
* An explicit value wins verbatim and is not extended by `markupExtensions`.
|
|
48
|
+
* @default ['**\/*.{js,ts,jsx,tsx,vue,svelte,astro,html,htm}']
|
|
46
49
|
*/
|
|
47
50
|
include?: string | string[];
|
|
48
51
|
/**
|
|
@@ -71,6 +74,19 @@ interface PluginOptions {
|
|
|
71
74
|
* @default `'pika'`
|
|
72
75
|
*/
|
|
73
76
|
fnName?: string;
|
|
77
|
+
/**
|
|
78
|
+
* Additional file extensions (leading dots optional) whose sources are scanned in markup
|
|
79
|
+
* mode. Markup files' top-level syntax is not JavaScript — `pika()` calls live inside
|
|
80
|
+
* quoted template attributes (e.g., `:class="pika({...})"` in Vue SFCs) — so string and
|
|
81
|
+
* comment detection works differently there. Extensions listed here are merged with the
|
|
82
|
+
* built-in defaults `['vue', 'svelte', 'astro', 'html', 'htm']`; pass `['riot']` to also
|
|
83
|
+
* scan `.riot` files in markup mode. When `scan.include` is not set, the default include
|
|
84
|
+
* glob is extended with these extensions too, so the files are actually selected for
|
|
85
|
+
* scanning without further configuration.
|
|
86
|
+
*
|
|
87
|
+
* @default `undefined` (built-in defaults only)
|
|
88
|
+
*/
|
|
89
|
+
markupExtensions?: string[];
|
|
74
90
|
/**
|
|
75
91
|
* Default output format for normal `pika()` calls. `'string'` produces a space-joined class string;
|
|
76
92
|
* `'array'` produces a string array of class names.
|
|
@@ -121,6 +137,8 @@ interface ResolvedPluginOptions {
|
|
|
121
137
|
scan: IntegrationContextOptions['scan'];
|
|
122
138
|
/** Base function name to recognize in source transforms (e.g., `'pika'`). */
|
|
123
139
|
fnName: string;
|
|
140
|
+
/** Additional file extensions scanned in markup mode, merged with the integration defaults. */
|
|
141
|
+
markupExtensions?: string[];
|
|
124
142
|
/** Default output format for normal `pika()` calls: `'string'` or `'array'`. */
|
|
125
143
|
transformedFormat: 'string' | 'array';
|
|
126
144
|
/** Whether to scaffold a default config file when none is found. */
|
package/dist/vite.d.mts
CHANGED
package/dist/webpack.d.mts
CHANGED
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pikacss/unplugin-pikacss",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.54",
|
|
5
5
|
"author": "DevilTea <ch19980814@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"homepage": "https://pikacss.
|
|
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.
|
|
97
|
-
"@pikacss/integration": "0.0.
|
|
96
|
+
"unplugin": "^3.3.0",
|
|
97
|
+
"@pikacss/integration": "0.0.54"
|
|
98
98
|
},
|
|
99
99
|
"devDependencies": {
|
|
100
|
-
"esbuild": "^0.
|
|
101
|
-
"vite": "^8.
|
|
100
|
+
"esbuild": "^0.28.1",
|
|
101
|
+
"vite": "^8.1.3"
|
|
102
102
|
},
|
|
103
103
|
"scripts": {
|
|
104
104
|
"build": "tsdown",
|