@pikacss/integration 0.0.11 → 0.0.13
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/dist/index.cjs +34 -10
- package/dist/index.d.cts +1 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +35 -11
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -66,6 +66,11 @@ function generateStyleFn(ctx) {
|
|
|
66
66
|
else if (transformedFormat === "inline")
|
|
67
67
|
lines.push("type StyleFn_Normal = StyleFn_Inline");
|
|
68
68
|
lines.push(
|
|
69
|
+
"type StyleFn = StyleFn_Normal & {",
|
|
70
|
+
" str: StyleFn_String",
|
|
71
|
+
" arr: StyleFn_Array",
|
|
72
|
+
" inl: StyleFn_Inline",
|
|
73
|
+
"}",
|
|
69
74
|
`type StyleFnWithPreview = PreviewOverloads<StyleFn_Normal>['fn'] & {`,
|
|
70
75
|
` str: PreviewOverloads<StyleFn_String>['fn']`,
|
|
71
76
|
` arr: PreviewOverloads<StyleFn_Array>['fn']`,
|
|
@@ -82,7 +87,12 @@ function generateGlobalDeclaration(ctx) {
|
|
|
82
87
|
" /**",
|
|
83
88
|
" * PikaCSS",
|
|
84
89
|
" */",
|
|
85
|
-
` const ${fnName}:
|
|
90
|
+
` const ${fnName}: StyleFn`,
|
|
91
|
+
"",
|
|
92
|
+
" /**",
|
|
93
|
+
" * PikaCSS Preview",
|
|
94
|
+
" */",
|
|
95
|
+
` const ${fnName}p: StyleFnWithPreview`,
|
|
86
96
|
"}",
|
|
87
97
|
""
|
|
88
98
|
];
|
|
@@ -97,7 +107,12 @@ function generateVueDeclaration(ctx) {
|
|
|
97
107
|
" /**",
|
|
98
108
|
" * PikaCSS",
|
|
99
109
|
" */",
|
|
100
|
-
` ${fnName}:
|
|
110
|
+
` ${fnName}: StyleFn`,
|
|
111
|
+
"",
|
|
112
|
+
" /**",
|
|
113
|
+
" * PikaCSS Preview",
|
|
114
|
+
" */",
|
|
115
|
+
` ${fnName}p: StyleFnWithPreview`,
|
|
101
116
|
" }",
|
|
102
117
|
"}",
|
|
103
118
|
""
|
|
@@ -189,14 +204,20 @@ function createFnUtils(fnName) {
|
|
|
189
204
|
normal: /* @__PURE__ */ new Set([fnName]),
|
|
190
205
|
forceString: /* @__PURE__ */ new Set([`${fnName}.str`, `${fnName}['str']`, `${fnName}["str"]`, `${fnName}[\`str\`]`]),
|
|
191
206
|
forceArray: /* @__PURE__ */ new Set([`${fnName}.arr`, `${fnName}['arr']`, `${fnName}["arr"]`, `${fnName}[\`arr\`]`]),
|
|
192
|
-
forceInline: /* @__PURE__ */ new Set([`${fnName}.inl`, `${fnName}['inl']`, `${fnName}["inl"]`, `${fnName}[\`inl\`]`])
|
|
207
|
+
forceInline: /* @__PURE__ */ new Set([`${fnName}.inl`, `${fnName}['inl']`, `${fnName}["inl"]`, `${fnName}[\`inl\`]`]),
|
|
208
|
+
// preview
|
|
209
|
+
normalPreview: /* @__PURE__ */ new Set([`${fnName}p`]),
|
|
210
|
+
forceStringPreview: /* @__PURE__ */ new Set([`${fnName}p.str`, `${fnName}p['str']`, `${fnName}p["str"]`, `${fnName}p[\`str\`]`]),
|
|
211
|
+
forceArrayPreview: /* @__PURE__ */ new Set([`${fnName}p.arr`, `${fnName}p['arr']`, `${fnName}p["arr"]`, `${fnName}p[\`arr\`]`]),
|
|
212
|
+
forceInlinePreview: /* @__PURE__ */ new Set([`${fnName}p.inl`, `${fnName}p['inl']`, `${fnName}p["inl"]`, `${fnName}p[\`inl\`]`])
|
|
193
213
|
};
|
|
194
214
|
const RE = new RegExp(`\\b(${Object.values(available).flatMap((s) => [...s].map((f) => `(${f.replace(ESCAPE_REPLACE_RE, "\\$&")})`)).join("|")})\\(`, "g");
|
|
195
215
|
return {
|
|
196
|
-
isNormal: (fnName2) => available.normal.has(fnName2),
|
|
197
|
-
isForceString: (fnName2) => available.forceString.has(fnName2),
|
|
198
|
-
isForceArray: (fnName2) => available.forceArray.has(fnName2),
|
|
199
|
-
isForceInline: (fnName2) => available.forceInline.has(fnName2),
|
|
216
|
+
isNormal: (fnName2) => available.normal.has(fnName2) || available.normalPreview.has(fnName2),
|
|
217
|
+
isForceString: (fnName2) => available.forceString.has(fnName2) || available.forceStringPreview.has(fnName2),
|
|
218
|
+
isForceArray: (fnName2) => available.forceArray.has(fnName2) || available.forceArrayPreview.has(fnName2),
|
|
219
|
+
isForceInline: (fnName2) => available.forceInline.has(fnName2) || available.forceInlinePreview.has(fnName2),
|
|
220
|
+
isPreview: (fnName2) => available.normalPreview.has(fnName2) || available.forceStringPreview.has(fnName2) || available.forceArrayPreview.has(fnName2) || available.forceInlinePreview.has(fnName2),
|
|
200
221
|
RE
|
|
201
222
|
};
|
|
202
223
|
}
|
|
@@ -212,6 +233,9 @@ async function createCtx(options) {
|
|
|
212
233
|
devCss,
|
|
213
234
|
autoCreateConfig
|
|
214
235
|
} = options;
|
|
236
|
+
core.setWarnFn((...args) => {
|
|
237
|
+
console.warn(`[${currentPackageName}]`, ...args);
|
|
238
|
+
});
|
|
215
239
|
const devCssFilepath = pathe.isAbsolute(devCss) ? pathe.resolve(devCss) : pathe.join(cwd, devCss);
|
|
216
240
|
const tsCodegenFilepath = tsCodegen === false ? null : pathe.isAbsolute(tsCodegen) ? pathe.resolve(tsCodegen) : pathe.join(cwd, tsCodegen);
|
|
217
241
|
const inlineConfig = typeof configOrPath === "object" ? configOrPath : null;
|
|
@@ -279,14 +303,14 @@ async function createCtx(options) {
|
|
|
279
303
|
}
|
|
280
304
|
ctx.usages.clear();
|
|
281
305
|
const { config, file } = await ctx.loadConfig().catch((error) => {
|
|
282
|
-
|
|
306
|
+
core.warn(`Failed to load config file: ${error.message}`, error);
|
|
283
307
|
return { config: null, file: null };
|
|
284
308
|
});
|
|
285
309
|
ctx.resolvedConfigPath = file;
|
|
286
310
|
try {
|
|
287
311
|
ctx.engine = await core.createEngine(config ?? {});
|
|
288
312
|
} catch (error) {
|
|
289
|
-
|
|
313
|
+
core.warn(`Failed to create engine: ${error.message}. Maybe the config file is invalid, falling back to default config.`, error);
|
|
290
314
|
ctx.engine = await core.createEngine({});
|
|
291
315
|
}
|
|
292
316
|
ctx.engine.config.plugins.unshift({
|
|
@@ -343,7 +367,7 @@ async function createCtx(options) {
|
|
|
343
367
|
map: transformed.generateMap({ hires: true })
|
|
344
368
|
};
|
|
345
369
|
} catch (error) {
|
|
346
|
-
|
|
370
|
+
core.warn(`Failed to transform code: ${error.message}`, error);
|
|
347
371
|
return void 0;
|
|
348
372
|
}
|
|
349
373
|
},
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { statSync } from 'node:fs';
|
|
2
2
|
import { writeFile, mkdir, stat } from 'node:fs/promises';
|
|
3
|
-
import { createEngine } from '@pikacss/core';
|
|
3
|
+
import { setWarnFn, warn, createEngine } from '@pikacss/core';
|
|
4
4
|
export * from '@pikacss/core';
|
|
5
5
|
import { createJiti } from 'jiti';
|
|
6
6
|
import { isPackageExists } from 'local-pkg';
|
|
@@ -60,6 +60,11 @@ function generateStyleFn(ctx) {
|
|
|
60
60
|
else if (transformedFormat === "inline")
|
|
61
61
|
lines.push("type StyleFn_Normal = StyleFn_Inline");
|
|
62
62
|
lines.push(
|
|
63
|
+
"type StyleFn = StyleFn_Normal & {",
|
|
64
|
+
" str: StyleFn_String",
|
|
65
|
+
" arr: StyleFn_Array",
|
|
66
|
+
" inl: StyleFn_Inline",
|
|
67
|
+
"}",
|
|
63
68
|
`type StyleFnWithPreview = PreviewOverloads<StyleFn_Normal>['fn'] & {`,
|
|
64
69
|
` str: PreviewOverloads<StyleFn_String>['fn']`,
|
|
65
70
|
` arr: PreviewOverloads<StyleFn_Array>['fn']`,
|
|
@@ -76,7 +81,12 @@ function generateGlobalDeclaration(ctx) {
|
|
|
76
81
|
" /**",
|
|
77
82
|
" * PikaCSS",
|
|
78
83
|
" */",
|
|
79
|
-
` const ${fnName}:
|
|
84
|
+
` const ${fnName}: StyleFn`,
|
|
85
|
+
"",
|
|
86
|
+
" /**",
|
|
87
|
+
" * PikaCSS Preview",
|
|
88
|
+
" */",
|
|
89
|
+
` const ${fnName}p: StyleFnWithPreview`,
|
|
80
90
|
"}",
|
|
81
91
|
""
|
|
82
92
|
];
|
|
@@ -91,7 +101,12 @@ function generateVueDeclaration(ctx) {
|
|
|
91
101
|
" /**",
|
|
92
102
|
" * PikaCSS",
|
|
93
103
|
" */",
|
|
94
|
-
` ${fnName}:
|
|
104
|
+
` ${fnName}: StyleFn`,
|
|
105
|
+
"",
|
|
106
|
+
" /**",
|
|
107
|
+
" * PikaCSS Preview",
|
|
108
|
+
" */",
|
|
109
|
+
` ${fnName}p: StyleFnWithPreview`,
|
|
95
110
|
" }",
|
|
96
111
|
"}",
|
|
97
112
|
""
|
|
@@ -183,14 +198,20 @@ function createFnUtils(fnName) {
|
|
|
183
198
|
normal: /* @__PURE__ */ new Set([fnName]),
|
|
184
199
|
forceString: /* @__PURE__ */ new Set([`${fnName}.str`, `${fnName}['str']`, `${fnName}["str"]`, `${fnName}[\`str\`]`]),
|
|
185
200
|
forceArray: /* @__PURE__ */ new Set([`${fnName}.arr`, `${fnName}['arr']`, `${fnName}["arr"]`, `${fnName}[\`arr\`]`]),
|
|
186
|
-
forceInline: /* @__PURE__ */ new Set([`${fnName}.inl`, `${fnName}['inl']`, `${fnName}["inl"]`, `${fnName}[\`inl\`]`])
|
|
201
|
+
forceInline: /* @__PURE__ */ new Set([`${fnName}.inl`, `${fnName}['inl']`, `${fnName}["inl"]`, `${fnName}[\`inl\`]`]),
|
|
202
|
+
// preview
|
|
203
|
+
normalPreview: /* @__PURE__ */ new Set([`${fnName}p`]),
|
|
204
|
+
forceStringPreview: /* @__PURE__ */ new Set([`${fnName}p.str`, `${fnName}p['str']`, `${fnName}p["str"]`, `${fnName}p[\`str\`]`]),
|
|
205
|
+
forceArrayPreview: /* @__PURE__ */ new Set([`${fnName}p.arr`, `${fnName}p['arr']`, `${fnName}p["arr"]`, `${fnName}p[\`arr\`]`]),
|
|
206
|
+
forceInlinePreview: /* @__PURE__ */ new Set([`${fnName}p.inl`, `${fnName}p['inl']`, `${fnName}p["inl"]`, `${fnName}p[\`inl\`]`])
|
|
187
207
|
};
|
|
188
208
|
const RE = new RegExp(`\\b(${Object.values(available).flatMap((s) => [...s].map((f) => `(${f.replace(ESCAPE_REPLACE_RE, "\\$&")})`)).join("|")})\\(`, "g");
|
|
189
209
|
return {
|
|
190
|
-
isNormal: (fnName2) => available.normal.has(fnName2),
|
|
191
|
-
isForceString: (fnName2) => available.forceString.has(fnName2),
|
|
192
|
-
isForceArray: (fnName2) => available.forceArray.has(fnName2),
|
|
193
|
-
isForceInline: (fnName2) => available.forceInline.has(fnName2),
|
|
210
|
+
isNormal: (fnName2) => available.normal.has(fnName2) || available.normalPreview.has(fnName2),
|
|
211
|
+
isForceString: (fnName2) => available.forceString.has(fnName2) || available.forceStringPreview.has(fnName2),
|
|
212
|
+
isForceArray: (fnName2) => available.forceArray.has(fnName2) || available.forceArrayPreview.has(fnName2),
|
|
213
|
+
isForceInline: (fnName2) => available.forceInline.has(fnName2) || available.forceInlinePreview.has(fnName2),
|
|
214
|
+
isPreview: (fnName2) => available.normalPreview.has(fnName2) || available.forceStringPreview.has(fnName2) || available.forceArrayPreview.has(fnName2) || available.forceInlinePreview.has(fnName2),
|
|
194
215
|
RE
|
|
195
216
|
};
|
|
196
217
|
}
|
|
@@ -206,6 +227,9 @@ async function createCtx(options) {
|
|
|
206
227
|
devCss,
|
|
207
228
|
autoCreateConfig
|
|
208
229
|
} = options;
|
|
230
|
+
setWarnFn((...args) => {
|
|
231
|
+
console.warn(`[${currentPackageName}]`, ...args);
|
|
232
|
+
});
|
|
209
233
|
const devCssFilepath = isAbsolute(devCss) ? resolve(devCss) : join(cwd, devCss);
|
|
210
234
|
const tsCodegenFilepath = tsCodegen === false ? null : isAbsolute(tsCodegen) ? resolve(tsCodegen) : join(cwd, tsCodegen);
|
|
211
235
|
const inlineConfig = typeof configOrPath === "object" ? configOrPath : null;
|
|
@@ -273,14 +297,14 @@ async function createCtx(options) {
|
|
|
273
297
|
}
|
|
274
298
|
ctx.usages.clear();
|
|
275
299
|
const { config, file } = await ctx.loadConfig().catch((error) => {
|
|
276
|
-
|
|
300
|
+
warn(`Failed to load config file: ${error.message}`, error);
|
|
277
301
|
return { config: null, file: null };
|
|
278
302
|
});
|
|
279
303
|
ctx.resolvedConfigPath = file;
|
|
280
304
|
try {
|
|
281
305
|
ctx.engine = await createEngine(config ?? {});
|
|
282
306
|
} catch (error) {
|
|
283
|
-
|
|
307
|
+
warn(`Failed to create engine: ${error.message}. Maybe the config file is invalid, falling back to default config.`, error);
|
|
284
308
|
ctx.engine = await createEngine({});
|
|
285
309
|
}
|
|
286
310
|
ctx.engine.config.plugins.unshift({
|
|
@@ -337,7 +361,7 @@ async function createCtx(options) {
|
|
|
337
361
|
map: transformed.generateMap({ hires: true })
|
|
338
362
|
};
|
|
339
363
|
} catch (error) {
|
|
340
|
-
|
|
364
|
+
warn(`Failed to transform code: ${error.message}`, error);
|
|
341
365
|
return void 0;
|
|
342
366
|
}
|
|
343
367
|
},
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.0.
|
|
7
|
+
"version": "0.0.13",
|
|
8
8
|
"author": "DevilTea <ch19980814@gmail.com>",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"repository": {
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"magic-string": "^0.30.12",
|
|
41
41
|
"micromatch": "^4.0.8",
|
|
42
42
|
"pathe": "^2.0.3",
|
|
43
|
-
"@pikacss/core": "0.0.
|
|
43
|
+
"@pikacss/core": "0.0.13"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/micromatch": "^4.0.9"
|