@pikacss/integration 0.0.37 → 0.0.38
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 +55 -0
- package/dist/index.cjs +32 -32
- package/dist/index.mjs +2 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1 +1,56 @@
|
|
|
1
1
|
# @pikacss/integration
|
|
2
|
+
|
|
3
|
+
Internal integration utilities for PikaCSS build tool plugins.
|
|
4
|
+
|
|
5
|
+
## ⚠️ Internal Package
|
|
6
|
+
|
|
7
|
+
**This is an internal package** used by official PikaCSS integration plugins.
|
|
8
|
+
|
|
9
|
+
**Most users should use these instead:**
|
|
10
|
+
- **[`@pikacss/unplugin-pikacss`](../unplugin/)** - Universal plugin for multiple bundlers
|
|
11
|
+
- **[`@pikacss/nuxt-pikacss`](../nuxt/)** - Nuxt module
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
Only needed for plugin development:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pnpm add @pikacss/integration
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## What This Package Provides
|
|
22
|
+
|
|
23
|
+
Low-level utilities for building PikaCSS integrations:
|
|
24
|
+
|
|
25
|
+
- 🔧 Core integration context management
|
|
26
|
+
- 📁 File scanning and code transformation
|
|
27
|
+
- 🎯 Config file loading and resolution
|
|
28
|
+
- 📦 Code generation (TypeScript and CSS)
|
|
29
|
+
- ⚡ Build-time optimizations
|
|
30
|
+
|
|
31
|
+
## Exports
|
|
32
|
+
|
|
33
|
+
This package exports utilities from `@pikacss/core` and provides integration-specific functionality:
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
// Main exports
|
|
37
|
+
export * from './ctx' // Integration context system
|
|
38
|
+
export * from './types' // TypeScript type definitions
|
|
39
|
+
export * from '@pikacss/core' // Re-exports all core exports
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## For Plugin Authors
|
|
43
|
+
|
|
44
|
+
If you're building a new integration for a bundler or framework, this package provides the foundation.
|
|
45
|
+
|
|
46
|
+
See how it's used in existing integrations:
|
|
47
|
+
- [`@pikacss/unplugin-pikacss`](../unplugin/) - Universal plugin implementation
|
|
48
|
+
- [`@pikacss/nuxt-pikacss`](../nuxt/) - Nuxt module implementation
|
|
49
|
+
|
|
50
|
+
## Documentation
|
|
51
|
+
|
|
52
|
+
For complete documentation, visit: [PikaCSS Documentation](https://pikacss.dev)
|
|
53
|
+
|
|
54
|
+
## License
|
|
55
|
+
|
|
56
|
+
MIT © DevilTea
|
package/dist/index.cjs
CHANGED
|
@@ -27,7 +27,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
27
|
//#endregion
|
|
28
28
|
let node_fs = require("node:fs");
|
|
29
29
|
let node_fs_promises = require("node:fs/promises");
|
|
30
|
-
let
|
|
30
|
+
let _pikacss_core = require("@pikacss/core");
|
|
31
31
|
let alien_signals = require("alien-signals");
|
|
32
32
|
let globby = require("globby");
|
|
33
33
|
let klona = require("klona");
|
|
@@ -129,11 +129,11 @@ function generateVueDeclaration(ctx) {
|
|
|
129
129
|
];
|
|
130
130
|
}
|
|
131
131
|
async function generateOverloadContent(ctx) {
|
|
132
|
-
|
|
132
|
+
_pikacss_core.log.debug("Generating TypeScript overload content");
|
|
133
133
|
const paramsLines = [];
|
|
134
134
|
const fnsLines = [];
|
|
135
135
|
const usages = [...ctx.usages.values()].flat();
|
|
136
|
-
|
|
136
|
+
_pikacss_core.log.debug(`Processing ${usages.length} style usages for overload generation`);
|
|
137
137
|
for (let i = 0; i < usages.length; i++) {
|
|
138
138
|
const usage = usages[i];
|
|
139
139
|
try {
|
|
@@ -167,15 +167,15 @@ async function generateOverloadContent(ctx) {
|
|
|
167
167
|
];
|
|
168
168
|
}
|
|
169
169
|
async function generateTsCodegenContent(ctx) {
|
|
170
|
-
|
|
170
|
+
_pikacss_core.log.debug("Generating TypeScript code generation content");
|
|
171
171
|
const lines = [
|
|
172
172
|
`// Auto-generated by ${ctx.currentPackageName}`,
|
|
173
|
-
`import type { CSSProperty,
|
|
173
|
+
`import type { CSSProperty, CSSSelector, DefineAutocomplete, Properties, StyleDefinition, StyleItem } from \'${ctx.currentPackageName}\'`,
|
|
174
174
|
"",
|
|
175
175
|
`declare module \'${ctx.currentPackageName}\' {`,
|
|
176
176
|
" interface PikaAugment {",
|
|
177
177
|
" Autocomplete: Autocomplete",
|
|
178
|
-
" Selector: Autocomplete['Selector'] |
|
|
178
|
+
" Selector: Autocomplete['Selector'] | CSSSelector",
|
|
179
179
|
" CSSProperty: Autocomplete['ExtraCssProperty'] | CSSProperty",
|
|
180
180
|
" Properties: Properties",
|
|
181
181
|
" StyleDefinition: StyleDefinition",
|
|
@@ -189,7 +189,7 @@ async function generateTsCodegenContent(ctx) {
|
|
|
189
189
|
lines.push(...generateGlobalDeclaration(ctx));
|
|
190
190
|
lines.push(...generateVueDeclaration(ctx));
|
|
191
191
|
lines.push(...await generateOverloadContent(ctx));
|
|
192
|
-
|
|
192
|
+
_pikacss_core.log.debug("TypeScript code generation content completed");
|
|
193
193
|
return lines.join("\n");
|
|
194
194
|
}
|
|
195
195
|
|
|
@@ -220,9 +220,9 @@ function useConfig({ cwd, tsCodegenFilepath, currentPackageName, autoCreateConfi
|
|
|
220
220
|
const inlineConfig = typeof configOrPath === "object" ? configOrPath : null;
|
|
221
221
|
async function _loadConfig() {
|
|
222
222
|
try {
|
|
223
|
-
|
|
223
|
+
_pikacss_core.log.debug("Loading engine config");
|
|
224
224
|
if (inlineConfig != null) {
|
|
225
|
-
|
|
225
|
+
_pikacss_core.log.debug("Using inline config");
|
|
226
226
|
return {
|
|
227
227
|
config: (0, klona.klona)(inlineConfig),
|
|
228
228
|
file: null,
|
|
@@ -233,7 +233,7 @@ function useConfig({ cwd, tsCodegenFilepath, currentPackageName, autoCreateConfi
|
|
|
233
233
|
const _cwd = cwd();
|
|
234
234
|
if (resolvedConfigPath$1 == null) {
|
|
235
235
|
if (autoCreateConfig === false) {
|
|
236
|
-
|
|
236
|
+
_pikacss_core.log.warn("Config file not found and autoCreateConfig is false");
|
|
237
237
|
return {
|
|
238
238
|
config: null,
|
|
239
239
|
file: null,
|
|
@@ -253,7 +253,7 @@ function useConfig({ cwd, tsCodegenFilepath, currentPackageName, autoCreateConfi
|
|
|
253
253
|
"})"
|
|
254
254
|
].join("\n"));
|
|
255
255
|
}
|
|
256
|
-
|
|
256
|
+
_pikacss_core.log.info(`Using config file: ${resolvedConfigPath$1}`);
|
|
257
257
|
const { createJiti } = await import("jiti");
|
|
258
258
|
const jiti = createJiti(require("url").pathToFileURL(__filename).href, { interopDefault: true });
|
|
259
259
|
const content = await (0, node_fs_promises.readFile)(resolvedConfigPath$1, "utf-8");
|
|
@@ -267,7 +267,7 @@ function useConfig({ cwd, tsCodegenFilepath, currentPackageName, autoCreateConfi
|
|
|
267
267
|
content
|
|
268
268
|
};
|
|
269
269
|
} catch (error) {
|
|
270
|
-
|
|
270
|
+
_pikacss_core.log.error(`Failed to load config file: ${error.message}`, error);
|
|
271
271
|
return {
|
|
272
272
|
config: null,
|
|
273
273
|
file: null,
|
|
@@ -377,11 +377,11 @@ function useTransform({ cwd, cssCodegenFilepath, tsCodegenFilepath, scan, fnName
|
|
|
377
377
|
const _engine = engine();
|
|
378
378
|
if (_engine == null) return null;
|
|
379
379
|
try {
|
|
380
|
-
|
|
380
|
+
_pikacss_core.log.debug(`Transforming file: ${id}`);
|
|
381
381
|
usages.delete(id);
|
|
382
382
|
const functionCalls = findFunctionCalls(code);
|
|
383
383
|
if (functionCalls.length === 0) return;
|
|
384
|
-
|
|
384
|
+
_pikacss_core.log.debug(`Found ${functionCalls.length} style function calls in ${id}`);
|
|
385
385
|
const usageList = [];
|
|
386
386
|
const transformed = new magic_string.default(code);
|
|
387
387
|
for (const fnCall of functionCalls) {
|
|
@@ -404,13 +404,13 @@ function useTransform({ cwd, cssCodegenFilepath, tsCodegenFilepath, scan, fnName
|
|
|
404
404
|
usages.set(id, usageList);
|
|
405
405
|
triggerStyleUpdated();
|
|
406
406
|
triggerTsCodegenUpdated();
|
|
407
|
-
|
|
407
|
+
_pikacss_core.log.debug(`Transformed ${usageList.length} style usages in ${id}`);
|
|
408
408
|
return {
|
|
409
409
|
code: transformed.toString(),
|
|
410
410
|
map: transformed.generateMap({ hires: true })
|
|
411
411
|
};
|
|
412
412
|
} catch (error) {
|
|
413
|
-
|
|
413
|
+
_pikacss_core.log.error(`Failed to transform code (${(0, pathe.join)(cwd(), id)}): ${error.message}`, error);
|
|
414
414
|
return;
|
|
415
415
|
}
|
|
416
416
|
}
|
|
@@ -492,9 +492,9 @@ function createCtx(options) {
|
|
|
492
492
|
},
|
|
493
493
|
getCssCodegenContent: async () => {
|
|
494
494
|
await ctx.setupPromise;
|
|
495
|
-
|
|
495
|
+
_pikacss_core.log.debug("Generating CSS code");
|
|
496
496
|
const atomicStyleIds = [...new Set([...ctx.usages.values()].flatMap((i) => [...new Set(i.flatMap((i$1) => i$1.atomicStyleIds))]))];
|
|
497
|
-
|
|
497
|
+
_pikacss_core.log.debug(`Collecting ${atomicStyleIds.length} atomic style IDs`);
|
|
498
498
|
return [
|
|
499
499
|
`/* Auto-generated by ${ctx.currentPackageName} */`,
|
|
500
500
|
await ctx.engine.renderPreflights(true),
|
|
@@ -511,7 +511,7 @@ function createCtx(options) {
|
|
|
511
511
|
const content = await ctx.getCssCodegenContent();
|
|
512
512
|
if (content == null) return;
|
|
513
513
|
await (0, node_fs_promises.mkdir)((0, pathe.dirname)(ctx.cssCodegenFilepath), { recursive: true }).catch(() => {});
|
|
514
|
-
|
|
514
|
+
_pikacss_core.log.debug(`Writing CSS code generation file: ${ctx.cssCodegenFilepath}`);
|
|
515
515
|
await (0, node_fs_promises.writeFile)(ctx.cssCodegenFilepath, content);
|
|
516
516
|
},
|
|
517
517
|
writeTsCodegenFile: async () => {
|
|
@@ -520,12 +520,12 @@ function createCtx(options) {
|
|
|
520
520
|
const content = await ctx.getTsCodegenContent();
|
|
521
521
|
if (content == null) return;
|
|
522
522
|
await (0, node_fs_promises.mkdir)((0, pathe.dirname)(ctx.tsCodegenFilepath), { recursive: true }).catch(() => {});
|
|
523
|
-
|
|
523
|
+
_pikacss_core.log.debug(`Writing TypeScript code generation file: ${ctx.tsCodegenFilepath}`);
|
|
524
524
|
await (0, node_fs_promises.writeFile)(ctx.tsCodegenFilepath, content);
|
|
525
525
|
},
|
|
526
526
|
fullyCssCodegen: async () => {
|
|
527
527
|
await ctx.setupPromise;
|
|
528
|
-
|
|
528
|
+
_pikacss_core.log.debug("Starting full CSS code generation scan");
|
|
529
529
|
const stream = (0, globby.globbyStream)(options.scan.include, { ignore: options.scan.exclude });
|
|
530
530
|
let fileCount = 0;
|
|
531
531
|
const _cwd = cwd();
|
|
@@ -534,13 +534,13 @@ function createCtx(options) {
|
|
|
534
534
|
await ctx.transform(code, entry);
|
|
535
535
|
fileCount++;
|
|
536
536
|
}
|
|
537
|
-
|
|
537
|
+
_pikacss_core.log.debug(`Scanned ${fileCount} files for style collection`);
|
|
538
538
|
await ctx.writeCssCodegenFile();
|
|
539
539
|
},
|
|
540
540
|
setupPromise: null,
|
|
541
541
|
setup: () => {
|
|
542
542
|
ctx.setupPromise = setup().catch((error) => {
|
|
543
|
-
|
|
543
|
+
_pikacss_core.log.error(`Failed to setup integration context: ${error.message}`, error);
|
|
544
544
|
}).then(() => {
|
|
545
545
|
ctx.setupPromise = null;
|
|
546
546
|
});
|
|
@@ -548,13 +548,13 @@ function createCtx(options) {
|
|
|
548
548
|
}
|
|
549
549
|
};
|
|
550
550
|
async function setup() {
|
|
551
|
-
|
|
551
|
+
_pikacss_core.log.debug("Setting up integration context");
|
|
552
552
|
usages.clear();
|
|
553
553
|
hooks.styleUpdated.listeners.clear();
|
|
554
554
|
hooks.tsCodegenUpdated.listeners.clear();
|
|
555
555
|
engine(null);
|
|
556
556
|
await loadConfig();
|
|
557
|
-
const devPlugin = (0,
|
|
557
|
+
const devPlugin = (0, _pikacss_core.defineEnginePlugin)({
|
|
558
558
|
name: "@pikacss/integration:dev",
|
|
559
559
|
preflightUpdated: () => hooks.styleUpdated.trigger(),
|
|
560
560
|
atomicStyleAdded: () => hooks.styleUpdated.trigger(),
|
|
@@ -564,22 +564,22 @@ function createCtx(options) {
|
|
|
564
564
|
const config = resolvedConfig() ?? {};
|
|
565
565
|
config.plugins = config.plugins ?? [];
|
|
566
566
|
config.plugins.unshift(devPlugin);
|
|
567
|
-
|
|
568
|
-
engine(await (0,
|
|
567
|
+
_pikacss_core.log.debug("Creating engine with loaded/default config");
|
|
568
|
+
engine(await (0, _pikacss_core.createEngine)(config));
|
|
569
569
|
} catch (error) {
|
|
570
|
-
|
|
571
|
-
engine(await (0,
|
|
570
|
+
_pikacss_core.log.error(`Failed to create engine: ${error.message}. Falling back to default config.`, error);
|
|
571
|
+
engine(await (0, _pikacss_core.createEngine)({ plugins: [devPlugin] }));
|
|
572
572
|
}
|
|
573
|
-
|
|
573
|
+
_pikacss_core.log.debug("Integration context setup successfully");
|
|
574
574
|
}
|
|
575
575
|
return ctx;
|
|
576
576
|
}
|
|
577
577
|
|
|
578
578
|
//#endregion
|
|
579
579
|
exports.createCtx = createCtx;
|
|
580
|
-
Object.keys(
|
|
580
|
+
Object.keys(_pikacss_core).forEach(function (k) {
|
|
581
581
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
582
582
|
enumerable: true,
|
|
583
|
-
get: function () { return
|
|
583
|
+
get: function () { return _pikacss_core[k]; }
|
|
584
584
|
});
|
|
585
585
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -144,12 +144,12 @@ async function generateTsCodegenContent(ctx) {
|
|
|
144
144
|
log.debug("Generating TypeScript code generation content");
|
|
145
145
|
const lines = [
|
|
146
146
|
`// Auto-generated by ${ctx.currentPackageName}`,
|
|
147
|
-
`import type { CSSProperty,
|
|
147
|
+
`import type { CSSProperty, CSSSelector, DefineAutocomplete, Properties, StyleDefinition, StyleItem } from \'${ctx.currentPackageName}\'`,
|
|
148
148
|
"",
|
|
149
149
|
`declare module \'${ctx.currentPackageName}\' {`,
|
|
150
150
|
" interface PikaAugment {",
|
|
151
151
|
" Autocomplete: Autocomplete",
|
|
152
|
-
" Selector: Autocomplete['Selector'] |
|
|
152
|
+
" Selector: Autocomplete['Selector'] | CSSSelector",
|
|
153
153
|
" CSSProperty: Autocomplete['ExtraCssProperty'] | CSSProperty",
|
|
154
154
|
" Properties: Properties",
|
|
155
155
|
" StyleDefinition: StyleDefinition",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pikacss/integration",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.38",
|
|
5
5
|
"author": "DevilTea <ch19980814@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"micromatch": "^4.0.8",
|
|
50
50
|
"pathe": "^2.0.3",
|
|
51
51
|
"perfect-debounce": "^2.0.0",
|
|
52
|
-
"@pikacss/core": "0.0.
|
|
52
|
+
"@pikacss/core": "0.0.38"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@types/micromatch": "^4.0.10"
|