@pikacss/unplugin-pikacss 0.0.32
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/LICENSE +21 -0
- package/README.md +183 -0
- package/dist/constants-BZD3cDZM.d.mts +54 -0
- package/dist/constants-CMnZxq7U.d.cts +54 -0
- package/dist/constants-DL-V0xb8.mjs +6 -0
- package/dist/constants-GQSLYzoi.cjs +18 -0
- package/dist/core-BDg4auAX.cjs +154 -0
- package/dist/core-DHDR8xgK.mjs +103 -0
- package/dist/esbuild.cjs +20 -0
- package/dist/esbuild.d.cts +11 -0
- package/dist/esbuild.d.mts +11 -0
- package/dist/esbuild.mjs +13 -0
- package/dist/farm.cjs +20 -0
- package/dist/farm.d.cts +10 -0
- package/dist/farm.d.mts +10 -0
- package/dist/farm.mjs +13 -0
- package/dist/index.cjs +14 -0
- package/dist/index.d.cts +12 -0
- package/dist/index.d.mts +12 -0
- package/dist/index.mjs +6 -0
- package/dist/rolldown.cjs +20 -0
- package/dist/rolldown.d.cts +11 -0
- package/dist/rolldown.d.mts +11 -0
- package/dist/rolldown.mjs +13 -0
- package/dist/rollup.cjs +20 -0
- package/dist/rollup.d.cts +11 -0
- package/dist/rollup.d.mts +11 -0
- package/dist/rollup.mjs +13 -0
- package/dist/rspack.cjs +20 -0
- package/dist/rspack.d.cts +10 -0
- package/dist/rspack.d.mts +10 -0
- package/dist/rspack.mjs +13 -0
- package/dist/vite.cjs +179 -0
- package/dist/vite.d.cts +29 -0
- package/dist/vite.d.mts +29 -0
- package/dist/vite.mjs +172 -0
- package/dist/webpack.cjs +20 -0
- package/dist/webpack.d.cts +10 -0
- package/dist/webpack.d.mts +10 -0
- package/dist/webpack.mjs +13 -0
- package/package.json +130 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 DevilTea
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
# @pikacss/unplugin-pikacss
|
|
2
|
+
|
|
3
|
+
Universal plugin for PikaCSS that works with multiple bundlers.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @pikacss/unplugin-pikacss
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### Vite
|
|
14
|
+
|
|
15
|
+
For full Vite support with hot reloading and build optimizations, use the Vite-specific export:
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
// vite.config.ts
|
|
19
|
+
import PikaCSSPlugin from '@pikacss/unplugin-pikacss/vite'
|
|
20
|
+
|
|
21
|
+
export default {
|
|
22
|
+
plugins: [
|
|
23
|
+
PikaCSSPlugin({
|
|
24
|
+
// options
|
|
25
|
+
}),
|
|
26
|
+
],
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Rollup
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
// rollup.config.js
|
|
34
|
+
import PikaCSSPlugin from '@pikacss/unplugin-pikacss/rollup'
|
|
35
|
+
|
|
36
|
+
export default {
|
|
37
|
+
plugins: [
|
|
38
|
+
PikaCSSPlugin({
|
|
39
|
+
// options
|
|
40
|
+
}),
|
|
41
|
+
],
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Webpack
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
// webpack.config.js
|
|
49
|
+
import PikaCSSPlugin from '@pikacss/unplugin-pikacss/webpack'
|
|
50
|
+
|
|
51
|
+
export default {
|
|
52
|
+
plugins: [
|
|
53
|
+
PikaCSSPlugin({
|
|
54
|
+
// options
|
|
55
|
+
}),
|
|
56
|
+
],
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### esbuild
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
// esbuild.config.js
|
|
64
|
+
import PikaCSSPlugin from '@pikacss/unplugin-pikacss/esbuild'
|
|
65
|
+
import esbuild from 'esbuild'
|
|
66
|
+
|
|
67
|
+
esbuild.build({
|
|
68
|
+
plugins: [
|
|
69
|
+
PikaCSSPlugin({
|
|
70
|
+
// options
|
|
71
|
+
}),
|
|
72
|
+
],
|
|
73
|
+
})
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Rspack
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
// rspack.config.js
|
|
80
|
+
import PikaCSSPlugin from '@pikacss/unplugin-pikacss/rspack'
|
|
81
|
+
|
|
82
|
+
export default {
|
|
83
|
+
plugins: [
|
|
84
|
+
PikaCSSPlugin({
|
|
85
|
+
// options
|
|
86
|
+
}),
|
|
87
|
+
],
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Farm
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
// farm.config.ts
|
|
95
|
+
import PikaCSSPlugin from '@pikacss/unplugin-pikacss/farm'
|
|
96
|
+
|
|
97
|
+
export default {
|
|
98
|
+
plugins: [
|
|
99
|
+
PikaCSSPlugin({
|
|
100
|
+
// options
|
|
101
|
+
}),
|
|
102
|
+
],
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Rolldown
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
// rolldown.config.js
|
|
110
|
+
import PikaCSSPlugin from '@pikacss/unplugin-pikacss/rolldown'
|
|
111
|
+
|
|
112
|
+
export default {
|
|
113
|
+
plugins: [
|
|
114
|
+
PikaCSSPlugin({
|
|
115
|
+
// options
|
|
116
|
+
}),
|
|
117
|
+
],
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Options
|
|
122
|
+
|
|
123
|
+
```ts
|
|
124
|
+
interface PluginOptions {
|
|
125
|
+
/**
|
|
126
|
+
* Patterns of files to be transformed if they are matched.
|
|
127
|
+
* @default `['**\/*.vue', '**\/*.tsx', '**\/*.jsx']`
|
|
128
|
+
*/
|
|
129
|
+
target?: string[]
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Configure the pika engine.
|
|
133
|
+
*/
|
|
134
|
+
config?: EngineConfig | string
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Customize the name of the pika function.
|
|
138
|
+
* @default 'pika'
|
|
139
|
+
*/
|
|
140
|
+
fnName?: string
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Decide the format of the transformed result.
|
|
144
|
+
*
|
|
145
|
+
* - `string`: The transformed result will be a js string (e.g. `'a b c'`).
|
|
146
|
+
* - `array`: The transformed result will be a js array (e.g. `['a', 'b', 'c']`).
|
|
147
|
+
* - `inline`: The transformed result will be directly used in the code (e.g. `a b c`).
|
|
148
|
+
*
|
|
149
|
+
* @default 'string'
|
|
150
|
+
*/
|
|
151
|
+
transformedFormat?: 'string' | 'array' | 'inline'
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Enable/disable the generation of d.ts files.
|
|
155
|
+
* If a string is provided, it will be used as the path to the d.ts file.
|
|
156
|
+
* @default true
|
|
157
|
+
*/
|
|
158
|
+
tsCodegen?: boolean | string
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Path to the dev css file.
|
|
162
|
+
* @default 'pika.dev.css'
|
|
163
|
+
*/
|
|
164
|
+
devCss?: string
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Automatically create a pika config file if it doesn't exist and without inline config.
|
|
168
|
+
* @default true
|
|
169
|
+
*/
|
|
170
|
+
autoCreateConfig?: boolean
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Migration from @pikacss/vite-plugin-pikacss
|
|
175
|
+
|
|
176
|
+
If you were using `@pikacss/vite-plugin-pikacss`, you can migrate to `@pikacss/unplugin-pikacss/vite`:
|
|
177
|
+
|
|
178
|
+
```diff
|
|
179
|
+
- import PikaCSSPlugin from '@pikacss/vite-plugin-pikacss'
|
|
180
|
+
+ import PikaCSSPlugin from '@pikacss/unplugin-pikacss/vite'
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
The API is fully compatible.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { EngineConfig } from "@pikacss/integration";
|
|
2
|
+
|
|
3
|
+
//#region src/types.d.ts
|
|
4
|
+
interface PluginOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Patterns of files to be transformed if they are matched.
|
|
7
|
+
* @default ['**/*.vue', '**/*.tsx', '**/*.jsx']
|
|
8
|
+
*/
|
|
9
|
+
target?: string[];
|
|
10
|
+
/**
|
|
11
|
+
* Configure the pika engine.
|
|
12
|
+
*/
|
|
13
|
+
config?: EngineConfig | string;
|
|
14
|
+
/**
|
|
15
|
+
* Customize the name of the pika function.
|
|
16
|
+
* @default 'pika'
|
|
17
|
+
*/
|
|
18
|
+
fnName?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Decide the format of the transformed result.
|
|
21
|
+
*
|
|
22
|
+
* - `string`: The transformed result will be a js string (e.g. `'a b c'`).
|
|
23
|
+
* - `array`: The transformed result will be a js array (e.g. `['a', 'b', 'c']`).
|
|
24
|
+
* - `inline`: The transformed result will be directly used in the code (e.g. `a b c`).
|
|
25
|
+
*
|
|
26
|
+
* @default 'string'
|
|
27
|
+
*/
|
|
28
|
+
transformedFormat?: 'string' | 'array' | 'inline';
|
|
29
|
+
/**
|
|
30
|
+
* Enable/disable the generation of d.ts files.
|
|
31
|
+
* If a string is provided, it will be used as the path to the d.ts file.
|
|
32
|
+
* Default path is `<path to config>/pika.d.ts`.
|
|
33
|
+
* @default false
|
|
34
|
+
*/
|
|
35
|
+
tsCodegen?: boolean | string;
|
|
36
|
+
/**
|
|
37
|
+
* Path to the dev css file.
|
|
38
|
+
* @default 'pika.dev.css'
|
|
39
|
+
*/
|
|
40
|
+
devCss?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Automatically create a pika config file if it doesn't exist and without inline config.
|
|
43
|
+
*
|
|
44
|
+
* @default true
|
|
45
|
+
*/
|
|
46
|
+
autoCreateConfig?: boolean;
|
|
47
|
+
/** @internal */
|
|
48
|
+
currentPackageName?: string;
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/constants.d.ts
|
|
52
|
+
declare const VIRTUAL_PIKA_CSS_ID = "virtual:pika.css";
|
|
53
|
+
//#endregion
|
|
54
|
+
export { PluginOptions as n, VIRTUAL_PIKA_CSS_ID as t };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { EngineConfig } from "@pikacss/integration";
|
|
2
|
+
|
|
3
|
+
//#region src/types.d.ts
|
|
4
|
+
interface PluginOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Patterns of files to be transformed if they are matched.
|
|
7
|
+
* @default ['**/*.vue', '**/*.tsx', '**/*.jsx']
|
|
8
|
+
*/
|
|
9
|
+
target?: string[];
|
|
10
|
+
/**
|
|
11
|
+
* Configure the pika engine.
|
|
12
|
+
*/
|
|
13
|
+
config?: EngineConfig | string;
|
|
14
|
+
/**
|
|
15
|
+
* Customize the name of the pika function.
|
|
16
|
+
* @default 'pika'
|
|
17
|
+
*/
|
|
18
|
+
fnName?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Decide the format of the transformed result.
|
|
21
|
+
*
|
|
22
|
+
* - `string`: The transformed result will be a js string (e.g. `'a b c'`).
|
|
23
|
+
* - `array`: The transformed result will be a js array (e.g. `['a', 'b', 'c']`).
|
|
24
|
+
* - `inline`: The transformed result will be directly used in the code (e.g. `a b c`).
|
|
25
|
+
*
|
|
26
|
+
* @default 'string'
|
|
27
|
+
*/
|
|
28
|
+
transformedFormat?: 'string' | 'array' | 'inline';
|
|
29
|
+
/**
|
|
30
|
+
* Enable/disable the generation of d.ts files.
|
|
31
|
+
* If a string is provided, it will be used as the path to the d.ts file.
|
|
32
|
+
* Default path is `<path to config>/pika.d.ts`.
|
|
33
|
+
* @default false
|
|
34
|
+
*/
|
|
35
|
+
tsCodegen?: boolean | string;
|
|
36
|
+
/**
|
|
37
|
+
* Path to the dev css file.
|
|
38
|
+
* @default 'pika.dev.css'
|
|
39
|
+
*/
|
|
40
|
+
devCss?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Automatically create a pika config file if it doesn't exist and without inline config.
|
|
43
|
+
*
|
|
44
|
+
* @default true
|
|
45
|
+
*/
|
|
46
|
+
autoCreateConfig?: boolean;
|
|
47
|
+
/** @internal */
|
|
48
|
+
currentPackageName?: string;
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/constants.d.ts
|
|
52
|
+
declare const VIRTUAL_PIKA_CSS_ID = "virtual:pika.css";
|
|
53
|
+
//#endregion
|
|
54
|
+
export { PluginOptions as n, VIRTUAL_PIKA_CSS_ID as t };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/constants.ts
|
|
3
|
+
const VIRTUAL_PIKA_CSS_ID = "virtual:pika.css";
|
|
4
|
+
const PLUGIN_NAME = "unplugin-pikacss";
|
|
5
|
+
|
|
6
|
+
//#endregion
|
|
7
|
+
Object.defineProperty(exports, 'PLUGIN_NAME', {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return PLUGIN_NAME;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(exports, 'VIRTUAL_PIKA_CSS_ID', {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () {
|
|
16
|
+
return VIRTUAL_PIKA_CSS_ID;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
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 (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
const require_constants = require('./constants-GQSLYzoi.cjs');
|
|
29
|
+
let node_process = require("node:process");
|
|
30
|
+
node_process = __toESM(node_process);
|
|
31
|
+
let __pikacss_integration = require("@pikacss/integration");
|
|
32
|
+
let unplugin = require("unplugin");
|
|
33
|
+
|
|
34
|
+
//#region src/core.ts
|
|
35
|
+
function createPromise() {
|
|
36
|
+
let resolve;
|
|
37
|
+
let reject;
|
|
38
|
+
return {
|
|
39
|
+
promise: new Promise((res, rej) => {
|
|
40
|
+
resolve = res;
|
|
41
|
+
reject = rej;
|
|
42
|
+
}),
|
|
43
|
+
resolve,
|
|
44
|
+
reject
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
const unpluginFactory = (options, _meta) => {
|
|
48
|
+
const { currentPackageName = "@pikacss/unplugin-pikacss", config: configOrPath, tsCodegen = true, devCss = "pika.dev.css", target = [
|
|
49
|
+
"**/*.vue",
|
|
50
|
+
"**/*.tsx",
|
|
51
|
+
"**/*.jsx"
|
|
52
|
+
], fnName = "pika", transformedFormat = "string", autoCreateConfig = true } = options ?? {};
|
|
53
|
+
const resolvedOptions = {
|
|
54
|
+
currentPackageName,
|
|
55
|
+
configOrPath,
|
|
56
|
+
tsCodegen: tsCodegen === true ? "pika.gen.ts" : tsCodegen,
|
|
57
|
+
devCss,
|
|
58
|
+
target,
|
|
59
|
+
fnName,
|
|
60
|
+
transformedFormat,
|
|
61
|
+
autoCreateConfig
|
|
62
|
+
};
|
|
63
|
+
const { promise, resolve } = createPromise();
|
|
64
|
+
function getCtx() {
|
|
65
|
+
return promise;
|
|
66
|
+
}
|
|
67
|
+
let ctx = null;
|
|
68
|
+
let cwd = node_process.default.cwd();
|
|
69
|
+
return {
|
|
70
|
+
name: require_constants.PLUGIN_NAME,
|
|
71
|
+
enforce: "pre",
|
|
72
|
+
async buildStart() {
|
|
73
|
+
ctx = await (0, __pikacss_integration.createCtx)({
|
|
74
|
+
cwd,
|
|
75
|
+
...resolvedOptions
|
|
76
|
+
});
|
|
77
|
+
resolve(ctx);
|
|
78
|
+
ctx.hooks.styleUpdated.on(() => ctx.writeDevCssFile());
|
|
79
|
+
ctx.hooks.tsCodegenUpdated.on(() => ctx.writeTsCodegenFile());
|
|
80
|
+
},
|
|
81
|
+
resolveId(id) {
|
|
82
|
+
if (id === require_constants.VIRTUAL_PIKA_CSS_ID) {
|
|
83
|
+
if (ctx?.devCssFilepath) return ctx.devCssFilepath;
|
|
84
|
+
return id;
|
|
85
|
+
}
|
|
86
|
+
return null;
|
|
87
|
+
},
|
|
88
|
+
load(id) {
|
|
89
|
+
if (id === require_constants.VIRTUAL_PIKA_CSS_ID) return "";
|
|
90
|
+
return null;
|
|
91
|
+
},
|
|
92
|
+
transform(code, id) {
|
|
93
|
+
if (!ctx) return null;
|
|
94
|
+
return ctx.transform(code, id);
|
|
95
|
+
},
|
|
96
|
+
vite: {
|
|
97
|
+
async configResolved(config) {
|
|
98
|
+
cwd = config.root;
|
|
99
|
+
},
|
|
100
|
+
configureServer(server) {
|
|
101
|
+
getCtx().then((ctx$1) => {
|
|
102
|
+
server.watcher.add(ctx$1.configSources);
|
|
103
|
+
server.watcher.on("add", handleFileChange);
|
|
104
|
+
server.watcher.on("unlink", handleFileChange);
|
|
105
|
+
server.watcher.on("change", handleFileChange);
|
|
106
|
+
async function handleFileChange(file) {
|
|
107
|
+
if (ctx$1.configSources.includes(file)) {
|
|
108
|
+
const moduleIds = Array.from(ctx$1.usages.keys());
|
|
109
|
+
await ctx$1.init();
|
|
110
|
+
moduleIds.forEach((id) => {
|
|
111
|
+
const mod = server.moduleGraph.getModuleById(id);
|
|
112
|
+
if (mod) {
|
|
113
|
+
server.moduleGraph.invalidateModule(mod);
|
|
114
|
+
server.reloadModule(mod);
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}).catch((error) => {
|
|
120
|
+
console.error("[pikacss] Failed to initialize plugin:", error);
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
getCtx
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
const unplugin$1 = /* @__PURE__ */ (0, unplugin.createUnplugin)(unpluginFactory);
|
|
128
|
+
var core_default = unplugin$1;
|
|
129
|
+
|
|
130
|
+
//#endregion
|
|
131
|
+
Object.defineProperty(exports, '__toESM', {
|
|
132
|
+
enumerable: true,
|
|
133
|
+
get: function () {
|
|
134
|
+
return __toESM;
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
Object.defineProperty(exports, 'core_default', {
|
|
138
|
+
enumerable: true,
|
|
139
|
+
get: function () {
|
|
140
|
+
return core_default;
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
Object.defineProperty(exports, 'unplugin', {
|
|
144
|
+
enumerable: true,
|
|
145
|
+
get: function () {
|
|
146
|
+
return unplugin$1;
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
Object.defineProperty(exports, 'unpluginFactory', {
|
|
150
|
+
enumerable: true,
|
|
151
|
+
get: function () {
|
|
152
|
+
return unpluginFactory;
|
|
153
|
+
}
|
|
154
|
+
});
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { n as VIRTUAL_PIKA_CSS_ID, t as PLUGIN_NAME } from "./constants-DL-V0xb8.mjs";
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
import { createCtx } from "@pikacss/integration";
|
|
4
|
+
import { createUnplugin } from "unplugin";
|
|
5
|
+
|
|
6
|
+
//#region src/core.ts
|
|
7
|
+
function createPromise() {
|
|
8
|
+
let resolve;
|
|
9
|
+
let reject;
|
|
10
|
+
return {
|
|
11
|
+
promise: new Promise((res, rej) => {
|
|
12
|
+
resolve = res;
|
|
13
|
+
reject = rej;
|
|
14
|
+
}),
|
|
15
|
+
resolve,
|
|
16
|
+
reject
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
const unpluginFactory = (options, _meta) => {
|
|
20
|
+
const { currentPackageName = "@pikacss/unplugin-pikacss", config: configOrPath, tsCodegen = true, devCss = "pika.dev.css", target = [
|
|
21
|
+
"**/*.vue",
|
|
22
|
+
"**/*.tsx",
|
|
23
|
+
"**/*.jsx"
|
|
24
|
+
], fnName = "pika", transformedFormat = "string", autoCreateConfig = true } = options ?? {};
|
|
25
|
+
const resolvedOptions = {
|
|
26
|
+
currentPackageName,
|
|
27
|
+
configOrPath,
|
|
28
|
+
tsCodegen: tsCodegen === true ? "pika.gen.ts" : tsCodegen,
|
|
29
|
+
devCss,
|
|
30
|
+
target,
|
|
31
|
+
fnName,
|
|
32
|
+
transformedFormat,
|
|
33
|
+
autoCreateConfig
|
|
34
|
+
};
|
|
35
|
+
const { promise, resolve } = createPromise();
|
|
36
|
+
function getCtx() {
|
|
37
|
+
return promise;
|
|
38
|
+
}
|
|
39
|
+
let ctx = null;
|
|
40
|
+
let cwd = process.cwd();
|
|
41
|
+
return {
|
|
42
|
+
name: PLUGIN_NAME,
|
|
43
|
+
enforce: "pre",
|
|
44
|
+
async buildStart() {
|
|
45
|
+
ctx = await createCtx({
|
|
46
|
+
cwd,
|
|
47
|
+
...resolvedOptions
|
|
48
|
+
});
|
|
49
|
+
resolve(ctx);
|
|
50
|
+
ctx.hooks.styleUpdated.on(() => ctx.writeDevCssFile());
|
|
51
|
+
ctx.hooks.tsCodegenUpdated.on(() => ctx.writeTsCodegenFile());
|
|
52
|
+
},
|
|
53
|
+
resolveId(id) {
|
|
54
|
+
if (id === VIRTUAL_PIKA_CSS_ID) {
|
|
55
|
+
if (ctx?.devCssFilepath) return ctx.devCssFilepath;
|
|
56
|
+
return id;
|
|
57
|
+
}
|
|
58
|
+
return null;
|
|
59
|
+
},
|
|
60
|
+
load(id) {
|
|
61
|
+
if (id === VIRTUAL_PIKA_CSS_ID) return "";
|
|
62
|
+
return null;
|
|
63
|
+
},
|
|
64
|
+
transform(code, id) {
|
|
65
|
+
if (!ctx) return null;
|
|
66
|
+
return ctx.transform(code, id);
|
|
67
|
+
},
|
|
68
|
+
vite: {
|
|
69
|
+
async configResolved(config) {
|
|
70
|
+
cwd = config.root;
|
|
71
|
+
},
|
|
72
|
+
configureServer(server) {
|
|
73
|
+
getCtx().then((ctx$1) => {
|
|
74
|
+
server.watcher.add(ctx$1.configSources);
|
|
75
|
+
server.watcher.on("add", handleFileChange);
|
|
76
|
+
server.watcher.on("unlink", handleFileChange);
|
|
77
|
+
server.watcher.on("change", handleFileChange);
|
|
78
|
+
async function handleFileChange(file) {
|
|
79
|
+
if (ctx$1.configSources.includes(file)) {
|
|
80
|
+
const moduleIds = Array.from(ctx$1.usages.keys());
|
|
81
|
+
await ctx$1.init();
|
|
82
|
+
moduleIds.forEach((id) => {
|
|
83
|
+
const mod = server.moduleGraph.getModuleById(id);
|
|
84
|
+
if (mod) {
|
|
85
|
+
server.moduleGraph.invalidateModule(mod);
|
|
86
|
+
server.reloadModule(mod);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}).catch((error) => {
|
|
92
|
+
console.error("[pikacss] Failed to initialize plugin:", error);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
getCtx
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
const unplugin = /* @__PURE__ */ createUnplugin(unpluginFactory);
|
|
100
|
+
var core_default = unplugin;
|
|
101
|
+
|
|
102
|
+
//#endregion
|
|
103
|
+
export { unplugin as n, unpluginFactory as r, core_default as t };
|
package/dist/esbuild.cjs
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
+
const require_core = require('./core-BDg4auAX.cjs');
|
|
3
|
+
const require_constants = require('./constants-GQSLYzoi.cjs');
|
|
4
|
+
|
|
5
|
+
//#region src/esbuild.ts
|
|
6
|
+
/**
|
|
7
|
+
* esbuild plugin for PikaCSS
|
|
8
|
+
*/
|
|
9
|
+
var esbuild_default = require_core.core_default.esbuild;
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
exports.VIRTUAL_PIKA_CSS_ID = require_constants.VIRTUAL_PIKA_CSS_ID;
|
|
13
|
+
exports.default = esbuild_default;
|
|
14
|
+
var __pikacss_integration = require("@pikacss/integration");
|
|
15
|
+
Object.keys(__pikacss_integration).forEach(function (k) {
|
|
16
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () { return __pikacss_integration[k]; }
|
|
19
|
+
});
|
|
20
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { n as PluginOptions, t as VIRTUAL_PIKA_CSS_ID } from "./constants-CMnZxq7U.cjs";
|
|
2
|
+
import * as unplugin0 from "unplugin";
|
|
3
|
+
export * from "@pikacss/integration";
|
|
4
|
+
|
|
5
|
+
//#region src/esbuild.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* esbuild plugin for PikaCSS
|
|
8
|
+
*/
|
|
9
|
+
declare const _default: (options?: PluginOptions | undefined) => unplugin0.EsbuildPlugin;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { type PluginOptions, VIRTUAL_PIKA_CSS_ID, _default as default };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { n as PluginOptions, t as VIRTUAL_PIKA_CSS_ID } from "./constants-BZD3cDZM.mjs";
|
|
2
|
+
import * as unplugin0 from "unplugin";
|
|
3
|
+
export * from "@pikacss/integration";
|
|
4
|
+
|
|
5
|
+
//#region src/esbuild.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* esbuild plugin for PikaCSS
|
|
8
|
+
*/
|
|
9
|
+
declare const _default: (options?: PluginOptions | undefined) => unplugin0.EsbuildPlugin;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { type PluginOptions, VIRTUAL_PIKA_CSS_ID, _default as default };
|
package/dist/esbuild.mjs
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { n as VIRTUAL_PIKA_CSS_ID } from "./constants-DL-V0xb8.mjs";
|
|
2
|
+
import { t as core_default } from "./core-DHDR8xgK.mjs";
|
|
3
|
+
|
|
4
|
+
export * from "@pikacss/integration"
|
|
5
|
+
|
|
6
|
+
//#region src/esbuild.ts
|
|
7
|
+
/**
|
|
8
|
+
* esbuild plugin for PikaCSS
|
|
9
|
+
*/
|
|
10
|
+
var esbuild_default = core_default.esbuild;
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { VIRTUAL_PIKA_CSS_ID, esbuild_default as default };
|
package/dist/farm.cjs
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
+
const require_core = require('./core-BDg4auAX.cjs');
|
|
3
|
+
const require_constants = require('./constants-GQSLYzoi.cjs');
|
|
4
|
+
|
|
5
|
+
//#region src/farm.ts
|
|
6
|
+
/**
|
|
7
|
+
* Farm plugin for PikaCSS
|
|
8
|
+
*/
|
|
9
|
+
var farm_default = require_core.core_default.farm;
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
exports.VIRTUAL_PIKA_CSS_ID = require_constants.VIRTUAL_PIKA_CSS_ID;
|
|
13
|
+
exports.default = farm_default;
|
|
14
|
+
var __pikacss_integration = require("@pikacss/integration");
|
|
15
|
+
Object.keys(__pikacss_integration).forEach(function (k) {
|
|
16
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () { return __pikacss_integration[k]; }
|
|
19
|
+
});
|
|
20
|
+
});
|
package/dist/farm.d.cts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { n as PluginOptions, t as VIRTUAL_PIKA_CSS_ID } from "./constants-CMnZxq7U.cjs";
|
|
2
|
+
export * from "@pikacss/integration";
|
|
3
|
+
|
|
4
|
+
//#region src/farm.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Farm plugin for PikaCSS
|
|
7
|
+
*/
|
|
8
|
+
declare const _default: (options?: PluginOptions | undefined) => JsPlugin;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { type PluginOptions, VIRTUAL_PIKA_CSS_ID, _default as default };
|