@pikacss/integration 0.0.42 → 0.0.44
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.mjs +37 -37
- package/package.json +5 -10
- package/dist/index.cjs +0 -615
- package/dist/index.d.cts +0 -88
package/dist/index.mjs
CHANGED
|
@@ -206,9 +206,9 @@ function useConfig({ cwd, tsCodegenFilepath, currentPackageName, autoCreateConfi
|
|
|
206
206
|
content: null
|
|
207
207
|
};
|
|
208
208
|
}
|
|
209
|
-
let resolvedConfigPath
|
|
209
|
+
let resolvedConfigPath = await findFirstExistingConfigPath();
|
|
210
210
|
const _cwd = cwd();
|
|
211
|
-
if (resolvedConfigPath
|
|
211
|
+
if (resolvedConfigPath == null) {
|
|
212
212
|
if (autoCreateConfig === false) {
|
|
213
213
|
log.warn("Config file not found and autoCreateConfig is false");
|
|
214
214
|
return {
|
|
@@ -217,11 +217,11 @@ function useConfig({ cwd, tsCodegenFilepath, currentPackageName, autoCreateConfi
|
|
|
217
217
|
content: null
|
|
218
218
|
};
|
|
219
219
|
}
|
|
220
|
-
resolvedConfigPath
|
|
221
|
-
await mkdir(dirname(resolvedConfigPath
|
|
220
|
+
resolvedConfigPath = join(_cwd, specificConfigPath() ?? "pika.config.js");
|
|
221
|
+
await mkdir(dirname(resolvedConfigPath), { recursive: true }).catch(() => {});
|
|
222
222
|
const _tsCodegenFilepath = tsCodegenFilepath();
|
|
223
|
-
const relativeTsCodegenFilepath = _tsCodegenFilepath == null ? null : `./${relative(dirname(resolvedConfigPath
|
|
224
|
-
await writeFile(resolvedConfigPath
|
|
223
|
+
const relativeTsCodegenFilepath = _tsCodegenFilepath == null ? null : `./${relative(dirname(resolvedConfigPath), _tsCodegenFilepath)}`;
|
|
224
|
+
await writeFile(resolvedConfigPath, [
|
|
225
225
|
...relativeTsCodegenFilepath == null ? [] : [`/// <reference path="${relativeTsCodegenFilepath}" />`],
|
|
226
226
|
`import { defineEngineConfig } from '${currentPackageName}'`,
|
|
227
227
|
"",
|
|
@@ -230,17 +230,17 @@ function useConfig({ cwd, tsCodegenFilepath, currentPackageName, autoCreateConfi
|
|
|
230
230
|
"})"
|
|
231
231
|
].join("\n"));
|
|
232
232
|
}
|
|
233
|
-
log.info(`Using config file: ${resolvedConfigPath
|
|
233
|
+
log.info(`Using config file: ${resolvedConfigPath}`);
|
|
234
234
|
const { createJiti } = await import("jiti");
|
|
235
235
|
const jiti = createJiti(import.meta.url, { interopDefault: true });
|
|
236
|
-
const content = await readFile(resolvedConfigPath
|
|
236
|
+
const content = await readFile(resolvedConfigPath, "utf-8");
|
|
237
237
|
const config = (await jiti.evalModule(content, {
|
|
238
|
-
id: resolvedConfigPath
|
|
238
|
+
id: resolvedConfigPath,
|
|
239
239
|
forceTranspile: true
|
|
240
240
|
})).default;
|
|
241
241
|
return {
|
|
242
242
|
config: klona(config),
|
|
243
|
-
file: resolvedConfigPath
|
|
243
|
+
file: resolvedConfigPath,
|
|
244
244
|
content
|
|
245
245
|
};
|
|
246
246
|
} catch (error) {
|
|
@@ -271,40 +271,40 @@ function useConfig({ cwd, tsCodegenFilepath, currentPackageName, autoCreateConfi
|
|
|
271
271
|
}
|
|
272
272
|
function useTransform({ cwd, cssCodegenFilepath, tsCodegenFilepath, scan, fnName, usages, engine, transformedFormat, triggerStyleUpdated, triggerTsCodegenUpdated }) {
|
|
273
273
|
const ESCAPE_REPLACE_RE = /[.*+?^${}()|[\]\\/]/g;
|
|
274
|
-
function createFnUtils(fnName
|
|
274
|
+
function createFnUtils(fnName) {
|
|
275
275
|
const available = {
|
|
276
|
-
normal: new Set([fnName
|
|
276
|
+
normal: new Set([fnName]),
|
|
277
277
|
forceString: new Set([
|
|
278
|
-
`${fnName
|
|
279
|
-
`${fnName
|
|
280
|
-
`${fnName
|
|
281
|
-
`${fnName
|
|
278
|
+
`${fnName}.str`,
|
|
279
|
+
`${fnName}['str']`,
|
|
280
|
+
`${fnName}["str"]`,
|
|
281
|
+
`${fnName}[\`str\`]`
|
|
282
282
|
]),
|
|
283
283
|
forceArray: new Set([
|
|
284
|
-
`${fnName
|
|
285
|
-
`${fnName
|
|
286
|
-
`${fnName
|
|
287
|
-
`${fnName
|
|
284
|
+
`${fnName}.arr`,
|
|
285
|
+
`${fnName}['arr']`,
|
|
286
|
+
`${fnName}["arr"]`,
|
|
287
|
+
`${fnName}[\`arr\`]`
|
|
288
288
|
]),
|
|
289
|
-
normalPreview: new Set([`${fnName
|
|
289
|
+
normalPreview: new Set([`${fnName}p`]),
|
|
290
290
|
forceStringPreview: new Set([
|
|
291
|
-
`${fnName
|
|
292
|
-
`${fnName
|
|
293
|
-
`${fnName
|
|
294
|
-
`${fnName
|
|
291
|
+
`${fnName}p.str`,
|
|
292
|
+
`${fnName}p['str']`,
|
|
293
|
+
`${fnName}p["str"]`,
|
|
294
|
+
`${fnName}p[\`str\`]`
|
|
295
295
|
]),
|
|
296
296
|
forceArrayPreview: new Set([
|
|
297
|
-
`${fnName
|
|
298
|
-
`${fnName
|
|
299
|
-
`${fnName
|
|
300
|
-
`${fnName
|
|
297
|
+
`${fnName}p.arr`,
|
|
298
|
+
`${fnName}p['arr']`,
|
|
299
|
+
`${fnName}p["arr"]`,
|
|
300
|
+
`${fnName}p[\`arr\`]`
|
|
301
301
|
])
|
|
302
302
|
};
|
|
303
303
|
return {
|
|
304
|
-
isNormal: (fnName
|
|
305
|
-
isForceString: (fnName
|
|
306
|
-
isForceArray: (fnName
|
|
307
|
-
isPreview: (fnName
|
|
304
|
+
isNormal: (fnName) => available.normal.has(fnName) || available.normalPreview.has(fnName),
|
|
305
|
+
isForceString: (fnName) => available.forceString.has(fnName) || available.forceStringPreview.has(fnName),
|
|
306
|
+
isForceArray: (fnName) => available.forceArray.has(fnName) || available.forceArrayPreview.has(fnName),
|
|
307
|
+
isPreview: (fnName) => available.normalPreview.has(fnName) || available.forceStringPreview.has(fnName) || available.forceArrayPreview.has(fnName),
|
|
308
308
|
RE: new RegExp(`\\b(${Object.values(available).flatMap((s) => [...s].map((f) => `(${f.replace(ESCAPE_REPLACE_RE, "\\$&")})`)).join("|")})\\(`, "g")
|
|
309
309
|
};
|
|
310
310
|
}
|
|
@@ -314,9 +314,9 @@ function useTransform({ cwd, cssCodegenFilepath, tsCodegenFilepath, scan, fnName
|
|
|
314
314
|
const result = [];
|
|
315
315
|
let matched = RE.exec(code);
|
|
316
316
|
while (matched != null) {
|
|
317
|
-
const fnName
|
|
317
|
+
const fnName = matched[1];
|
|
318
318
|
const start = matched.index;
|
|
319
|
-
let end = start + fnName
|
|
319
|
+
let end = start + fnName.length;
|
|
320
320
|
let depth = 1;
|
|
321
321
|
let inString = false;
|
|
322
322
|
let isEscaped = false;
|
|
@@ -365,7 +365,7 @@ function useTransform({ cwd, cssCodegenFilepath, tsCodegenFilepath, scan, fnName
|
|
|
365
365
|
}
|
|
366
366
|
const snippet = code.slice(start, end + 1);
|
|
367
367
|
result.push({
|
|
368
|
-
fnName
|
|
368
|
+
fnName,
|
|
369
369
|
start,
|
|
370
370
|
end,
|
|
371
371
|
snippet
|
|
@@ -493,7 +493,7 @@ function createCtx(options) {
|
|
|
493
493
|
getCssCodegenContent: async () => {
|
|
494
494
|
await ctx.setupPromise;
|
|
495
495
|
log.debug("Generating CSS code");
|
|
496
|
-
const atomicStyleIds = [...new Set([...ctx.usages.values()].flatMap((i) => [...new Set(i.flatMap((i
|
|
496
|
+
const atomicStyleIds = [...new Set([...ctx.usages.values()].flatMap((i) => [...new Set(i.flatMap((i) => i.atomicStyleIds))]))];
|
|
497
497
|
log.debug(`Collecting ${atomicStyleIds.length} atomic style IDs`);
|
|
498
498
|
const layerDecl = ctx.engine.renderLayerOrderDeclaration();
|
|
499
499
|
const preflightsCss = await ctx.engine.renderPreflights(true);
|
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.44",
|
|
5
5
|
"author": "DevilTea <ch19980814@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -23,14 +23,9 @@
|
|
|
23
23
|
"import": {
|
|
24
24
|
"types": "./dist/index.d.mts",
|
|
25
25
|
"default": "./dist/index.mjs"
|
|
26
|
-
},
|
|
27
|
-
"require": {
|
|
28
|
-
"types": "./dist/index.d.cts",
|
|
29
|
-
"default": "./dist/index.cjs"
|
|
30
26
|
}
|
|
31
27
|
}
|
|
32
28
|
},
|
|
33
|
-
"main": "dist/index.cjs",
|
|
34
29
|
"module": "dist/index.mjs",
|
|
35
30
|
"types": "dist/index.d.mts",
|
|
36
31
|
"publishConfig": {
|
|
@@ -40,16 +35,16 @@
|
|
|
40
35
|
"dist"
|
|
41
36
|
],
|
|
42
37
|
"dependencies": {
|
|
43
|
-
"alien-signals": "^
|
|
44
|
-
"globby": "^16.
|
|
38
|
+
"alien-signals": "^3.1.2",
|
|
39
|
+
"globby": "^16.1.1",
|
|
45
40
|
"jiti": "^2.6.1",
|
|
46
41
|
"klona": "^2.0.6",
|
|
47
42
|
"local-pkg": "^1.1.2",
|
|
48
43
|
"magic-string": "^0.30.21",
|
|
49
44
|
"micromatch": "^4.0.8",
|
|
50
45
|
"pathe": "^2.0.3",
|
|
51
|
-
"perfect-debounce": "^2.
|
|
52
|
-
"@pikacss/core": "0.0.
|
|
46
|
+
"perfect-debounce": "^2.1.0",
|
|
47
|
+
"@pikacss/core": "0.0.44"
|
|
53
48
|
},
|
|
54
49
|
"devDependencies": {
|
|
55
50
|
"@types/micromatch": "^4.0.10"
|
package/dist/index.cjs
DELETED
|
@@ -1,615 +0,0 @@
|
|
|
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
|
-
let node_fs = require("node:fs");
|
|
29
|
-
let node_fs_promises = require("node:fs/promises");
|
|
30
|
-
let _pikacss_core = require("@pikacss/core");
|
|
31
|
-
let alien_signals = require("alien-signals");
|
|
32
|
-
let globby = require("globby");
|
|
33
|
-
let klona = require("klona");
|
|
34
|
-
let local_pkg = require("local-pkg");
|
|
35
|
-
let magic_string = require("magic-string");
|
|
36
|
-
magic_string = __toESM(magic_string);
|
|
37
|
-
let pathe = require("pathe");
|
|
38
|
-
|
|
39
|
-
//#region src/eventHook.ts
|
|
40
|
-
function createEventHook() {
|
|
41
|
-
const listeners = /* @__PURE__ */ new Set();
|
|
42
|
-
function trigger(payload) {
|
|
43
|
-
if (listeners.size === 0) return;
|
|
44
|
-
listeners.forEach((listener) => listener(payload));
|
|
45
|
-
}
|
|
46
|
-
function off(listener) {
|
|
47
|
-
listeners.delete(listener);
|
|
48
|
-
}
|
|
49
|
-
function on(listener) {
|
|
50
|
-
listeners.add(listener);
|
|
51
|
-
const offListener = () => off(listener);
|
|
52
|
-
return offListener;
|
|
53
|
-
}
|
|
54
|
-
return {
|
|
55
|
-
listeners,
|
|
56
|
-
trigger,
|
|
57
|
-
on,
|
|
58
|
-
off
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
//#endregion
|
|
63
|
-
//#region src/tsCodegen.ts
|
|
64
|
-
function formatUnionStringType(list) {
|
|
65
|
-
return list.length > 0 ? list.map((i) => typeof i === "number" ? String(i) : JSON.stringify(i)).join(" | ") : "never";
|
|
66
|
-
}
|
|
67
|
-
function generateAutocomplete(ctx) {
|
|
68
|
-
const autocomplete = ctx.engine.config.autocomplete;
|
|
69
|
-
const { layers } = ctx.engine.config;
|
|
70
|
-
const layerNames = (0, _pikacss_core.sortLayerNames)(layers);
|
|
71
|
-
return [
|
|
72
|
-
"export type Autocomplete = DefineAutocomplete<{",
|
|
73
|
-
` Selector: ${formatUnionStringType([...autocomplete.selectors])}`,
|
|
74
|
-
` StyleItemString: ${formatUnionStringType([...autocomplete.styleItemStrings])}`,
|
|
75
|
-
` ExtraProperty: ${formatUnionStringType([...autocomplete.extraProperties])}`,
|
|
76
|
-
` ExtraCssProperty: ${formatUnionStringType([...autocomplete.extraCssProperties])}`,
|
|
77
|
-
` PropertiesValue: { ${Array.from(autocomplete.properties.entries(), ([k, v]) => `'${k}': ${v.join(" | ")}`).join(",")} }`,
|
|
78
|
-
` CssPropertiesValue: { ${Array.from(autocomplete.cssProperties.entries(), ([k, v]) => `'${k}': ${formatUnionStringType(v)}`).join(",")} }`,
|
|
79
|
-
` Layer: ${formatUnionStringType(layerNames)}`,
|
|
80
|
-
"}>",
|
|
81
|
-
""
|
|
82
|
-
];
|
|
83
|
-
}
|
|
84
|
-
function generateStyleFn(ctx) {
|
|
85
|
-
const { transformedFormat } = ctx;
|
|
86
|
-
const lines = [
|
|
87
|
-
"type StyleFn_Array = (...params: StyleItem[]) => string[]",
|
|
88
|
-
"type StyleFn_String = (...params: StyleItem[]) => string",
|
|
89
|
-
"type StyleFn_Inline = (...params: StyleItem[]) => void"
|
|
90
|
-
];
|
|
91
|
-
if (transformedFormat === "array") lines.push("type StyleFn_Normal = StyleFn_Array");
|
|
92
|
-
else if (transformedFormat === "string") lines.push("type StyleFn_Normal = StyleFn_String");
|
|
93
|
-
else if (transformedFormat === "inline") lines.push("type StyleFn_Normal = StyleFn_Inline");
|
|
94
|
-
lines.push("type StyleFn = StyleFn_Normal & {", " str: StyleFn_String", " arr: StyleFn_Array", " inl: StyleFn_Inline", "}", `type StyleFnWithPreview = PreviewOverloads<StyleFn_Normal>[\'fn\'] & {`, ` str: PreviewOverloads<StyleFn_String>[\'fn\']`, ` arr: PreviewOverloads<StyleFn_Array>[\'fn\']`, ` inl: PreviewOverloads<StyleFn_Inline>[\'fn\']`, "}", "");
|
|
95
|
-
return lines;
|
|
96
|
-
}
|
|
97
|
-
function generateGlobalDeclaration(ctx) {
|
|
98
|
-
const { fnName } = ctx;
|
|
99
|
-
return [
|
|
100
|
-
"declare global {",
|
|
101
|
-
" /**",
|
|
102
|
-
" * PikaCSS",
|
|
103
|
-
" */",
|
|
104
|
-
` const ${fnName}: StyleFn`,
|
|
105
|
-
"",
|
|
106
|
-
" /**",
|
|
107
|
-
" * PikaCSS Preview",
|
|
108
|
-
" */",
|
|
109
|
-
` const ${fnName}p: StyleFnWithPreview`,
|
|
110
|
-
"}",
|
|
111
|
-
""
|
|
112
|
-
];
|
|
113
|
-
}
|
|
114
|
-
function generateVueDeclaration(ctx) {
|
|
115
|
-
const { hasVue, fnName } = ctx;
|
|
116
|
-
if (!hasVue) return [];
|
|
117
|
-
return [
|
|
118
|
-
"declare module 'vue' {",
|
|
119
|
-
" interface ComponentCustomProperties {",
|
|
120
|
-
" /**",
|
|
121
|
-
" * PikaCSS",
|
|
122
|
-
" */",
|
|
123
|
-
` ${fnName}: StyleFn`,
|
|
124
|
-
"",
|
|
125
|
-
" /**",
|
|
126
|
-
" * PikaCSS Preview",
|
|
127
|
-
" */",
|
|
128
|
-
` ${fnName}p: StyleFnWithPreview`,
|
|
129
|
-
" }",
|
|
130
|
-
"}",
|
|
131
|
-
""
|
|
132
|
-
];
|
|
133
|
-
}
|
|
134
|
-
async function generateOverloadContent(ctx) {
|
|
135
|
-
_pikacss_core.log.debug("Generating TypeScript overload content");
|
|
136
|
-
const paramsLines = [];
|
|
137
|
-
const fnsLines = [];
|
|
138
|
-
const usages = [...ctx.usages.values()].flat();
|
|
139
|
-
_pikacss_core.log.debug(`Processing ${usages.length} style usages for overload generation`);
|
|
140
|
-
for (let i = 0; i < usages.length; i++) {
|
|
141
|
-
const usage = usages[i];
|
|
142
|
-
try {
|
|
143
|
-
const addedParamsLines = usage.params.map((param, index) => `type P${i}_${index} = ${JSON.stringify(param)}`);
|
|
144
|
-
const addedFnLines = [
|
|
145
|
-
" /**",
|
|
146
|
-
" * ### PikaCSS Preview",
|
|
147
|
-
" * ```css",
|
|
148
|
-
...(await ctx.engine.renderAtomicStyles(true, {
|
|
149
|
-
atomicStyleIds: usage.atomicStyleIds,
|
|
150
|
-
isPreview: true
|
|
151
|
-
})).trim().split("\n").map((line) => ` * ${line.replace(/^(\s*)/, "$1")}`),
|
|
152
|
-
" * ```",
|
|
153
|
-
" */",
|
|
154
|
-
` fn(...params: [${usage.params.map((_, index) => `p${index}: P${i}_${index}`).join(", ")}]): ReturnType<StyleFn>`
|
|
155
|
-
];
|
|
156
|
-
paramsLines.push(...addedParamsLines);
|
|
157
|
-
fnsLines.push(...addedFnLines);
|
|
158
|
-
} catch {}
|
|
159
|
-
}
|
|
160
|
-
return [
|
|
161
|
-
"interface PreviewOverloads<StyleFn extends (StyleFn_Array | StyleFn_String | StyleFn_Inline)> {",
|
|
162
|
-
...fnsLines,
|
|
163
|
-
" /**",
|
|
164
|
-
" * PikaCSS Preview",
|
|
165
|
-
" * Save the current file to see the preview.",
|
|
166
|
-
" */",
|
|
167
|
-
` fn(...params: Parameters<StyleFn>): ReturnType<StyleFn>`,
|
|
168
|
-
"}",
|
|
169
|
-
...paramsLines
|
|
170
|
-
];
|
|
171
|
-
}
|
|
172
|
-
async function generateTsCodegenContent(ctx) {
|
|
173
|
-
_pikacss_core.log.debug("Generating TypeScript code generation content");
|
|
174
|
-
const lines = [
|
|
175
|
-
`// Auto-generated by ${ctx.currentPackageName}`,
|
|
176
|
-
`import type { CSSProperty, CSSSelector, DefineAutocomplete, Properties, StyleDefinition, StyleItem } from \'${ctx.currentPackageName}\'`,
|
|
177
|
-
"",
|
|
178
|
-
`declare module \'${ctx.currentPackageName}\' {`,
|
|
179
|
-
" interface PikaAugment {",
|
|
180
|
-
" Autocomplete: Autocomplete",
|
|
181
|
-
" Selector: Autocomplete['Selector'] | CSSSelector",
|
|
182
|
-
" CSSProperty: Autocomplete['ExtraCssProperty'] | CSSProperty",
|
|
183
|
-
" Properties: Properties",
|
|
184
|
-
" StyleDefinition: StyleDefinition",
|
|
185
|
-
" StyleItem: StyleItem",
|
|
186
|
-
" }",
|
|
187
|
-
"}",
|
|
188
|
-
""
|
|
189
|
-
];
|
|
190
|
-
lines.push(...generateAutocomplete(ctx));
|
|
191
|
-
lines.push(...generateStyleFn(ctx));
|
|
192
|
-
lines.push(...generateGlobalDeclaration(ctx));
|
|
193
|
-
lines.push(...generateVueDeclaration(ctx));
|
|
194
|
-
lines.push(...await generateOverloadContent(ctx));
|
|
195
|
-
_pikacss_core.log.debug("TypeScript code generation content completed");
|
|
196
|
-
return lines.join("\n");
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
//#endregion
|
|
200
|
-
//#region src/ctx.ts
|
|
201
|
-
function usePaths({ cwd: _cwd, cssCodegen, tsCodegen }) {
|
|
202
|
-
const cwd = (0, alien_signals.signal)(_cwd);
|
|
203
|
-
return {
|
|
204
|
-
cwd,
|
|
205
|
-
cssCodegenFilepath: (0, alien_signals.computed)(() => (0, pathe.isAbsolute)(cssCodegen) ? (0, pathe.resolve)(cssCodegen) : (0, pathe.join)(cwd(), cssCodegen)),
|
|
206
|
-
tsCodegenFilepath: (0, alien_signals.computed)(() => tsCodegen === false ? null : (0, pathe.isAbsolute)(tsCodegen) ? (0, pathe.resolve)(tsCodegen) : (0, pathe.join)(cwd(), tsCodegen))
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
function useConfig({ cwd, tsCodegenFilepath, currentPackageName, autoCreateConfig, configOrPath, scan }) {
|
|
210
|
-
const RE_VALID_CONFIG_EXT = /\.(?:js|cjs|mjs|ts|cts|mts)$/;
|
|
211
|
-
const specificConfigPath = (0, alien_signals.computed)(() => {
|
|
212
|
-
if (typeof configOrPath === "string" && RE_VALID_CONFIG_EXT.test(configOrPath)) return (0, pathe.isAbsolute)(configOrPath) ? configOrPath : (0, pathe.join)(cwd(), configOrPath);
|
|
213
|
-
return null;
|
|
214
|
-
});
|
|
215
|
-
async function findFirstExistingConfigPath() {
|
|
216
|
-
const _cwd = cwd();
|
|
217
|
-
const _specificConfigPath = specificConfigPath();
|
|
218
|
-
if (_specificConfigPath != null && (0, node_fs.statSync)(_specificConfigPath, { throwIfNoEntry: false })?.isFile()) return _specificConfigPath;
|
|
219
|
-
const stream = (0, globby.globbyStream)("**/{pika,pikacss}.config.{js,cjs,mjs,ts,cts,mts}", { ignore: scan.exclude });
|
|
220
|
-
for await (const entry of stream) return (0, pathe.join)(_cwd, entry);
|
|
221
|
-
return null;
|
|
222
|
-
}
|
|
223
|
-
const inlineConfig = typeof configOrPath === "object" ? configOrPath : null;
|
|
224
|
-
async function _loadConfig() {
|
|
225
|
-
try {
|
|
226
|
-
_pikacss_core.log.debug("Loading engine config");
|
|
227
|
-
if (inlineConfig != null) {
|
|
228
|
-
_pikacss_core.log.debug("Using inline config");
|
|
229
|
-
return {
|
|
230
|
-
config: (0, klona.klona)(inlineConfig),
|
|
231
|
-
file: null,
|
|
232
|
-
content: null
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
let resolvedConfigPath$1 = await findFirstExistingConfigPath();
|
|
236
|
-
const _cwd = cwd();
|
|
237
|
-
if (resolvedConfigPath$1 == null) {
|
|
238
|
-
if (autoCreateConfig === false) {
|
|
239
|
-
_pikacss_core.log.warn("Config file not found and autoCreateConfig is false");
|
|
240
|
-
return {
|
|
241
|
-
config: null,
|
|
242
|
-
file: null,
|
|
243
|
-
content: null
|
|
244
|
-
};
|
|
245
|
-
}
|
|
246
|
-
resolvedConfigPath$1 = (0, pathe.join)(_cwd, specificConfigPath() ?? "pika.config.js");
|
|
247
|
-
await (0, node_fs_promises.mkdir)((0, pathe.dirname)(resolvedConfigPath$1), { recursive: true }).catch(() => {});
|
|
248
|
-
const _tsCodegenFilepath = tsCodegenFilepath();
|
|
249
|
-
const relativeTsCodegenFilepath = _tsCodegenFilepath == null ? null : `./${(0, pathe.relative)((0, pathe.dirname)(resolvedConfigPath$1), _tsCodegenFilepath)}`;
|
|
250
|
-
await (0, node_fs_promises.writeFile)(resolvedConfigPath$1, [
|
|
251
|
-
...relativeTsCodegenFilepath == null ? [] : [`/// <reference path="${relativeTsCodegenFilepath}" />`],
|
|
252
|
-
`import { defineEngineConfig } from '${currentPackageName}'`,
|
|
253
|
-
"",
|
|
254
|
-
"export default defineEngineConfig({",
|
|
255
|
-
" // Add your PikaCSS engine config here",
|
|
256
|
-
"})"
|
|
257
|
-
].join("\n"));
|
|
258
|
-
}
|
|
259
|
-
_pikacss_core.log.info(`Using config file: ${resolvedConfigPath$1}`);
|
|
260
|
-
const { createJiti } = await import("jiti");
|
|
261
|
-
const jiti = createJiti(require("url").pathToFileURL(__filename).href, { interopDefault: true });
|
|
262
|
-
const content = await (0, node_fs_promises.readFile)(resolvedConfigPath$1, "utf-8");
|
|
263
|
-
const config = (await jiti.evalModule(content, {
|
|
264
|
-
id: resolvedConfigPath$1,
|
|
265
|
-
forceTranspile: true
|
|
266
|
-
})).default;
|
|
267
|
-
return {
|
|
268
|
-
config: (0, klona.klona)(config),
|
|
269
|
-
file: resolvedConfigPath$1,
|
|
270
|
-
content
|
|
271
|
-
};
|
|
272
|
-
} catch (error) {
|
|
273
|
-
_pikacss_core.log.error(`Failed to load config file: ${error.message}`, error);
|
|
274
|
-
return {
|
|
275
|
-
config: null,
|
|
276
|
-
file: null,
|
|
277
|
-
content: null
|
|
278
|
-
};
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
const resolvedConfig = (0, alien_signals.signal)(inlineConfig);
|
|
282
|
-
const resolvedConfigPath = (0, alien_signals.signal)(null);
|
|
283
|
-
const resolvedConfigContent = (0, alien_signals.signal)(null);
|
|
284
|
-
async function loadConfig() {
|
|
285
|
-
const result = await _loadConfig();
|
|
286
|
-
resolvedConfig(result.config);
|
|
287
|
-
resolvedConfigPath(result.file);
|
|
288
|
-
resolvedConfigContent(result.content);
|
|
289
|
-
return result;
|
|
290
|
-
}
|
|
291
|
-
return {
|
|
292
|
-
resolvedConfig,
|
|
293
|
-
resolvedConfigPath,
|
|
294
|
-
resolvedConfigContent,
|
|
295
|
-
loadConfig
|
|
296
|
-
};
|
|
297
|
-
}
|
|
298
|
-
function useTransform({ cwd, cssCodegenFilepath, tsCodegenFilepath, scan, fnName, usages, engine, transformedFormat, triggerStyleUpdated, triggerTsCodegenUpdated }) {
|
|
299
|
-
const ESCAPE_REPLACE_RE = /[.*+?^${}()|[\]\\/]/g;
|
|
300
|
-
function createFnUtils(fnName$1) {
|
|
301
|
-
const available = {
|
|
302
|
-
normal: new Set([fnName$1]),
|
|
303
|
-
forceString: new Set([
|
|
304
|
-
`${fnName$1}.str`,
|
|
305
|
-
`${fnName$1}['str']`,
|
|
306
|
-
`${fnName$1}["str"]`,
|
|
307
|
-
`${fnName$1}[\`str\`]`
|
|
308
|
-
]),
|
|
309
|
-
forceArray: new Set([
|
|
310
|
-
`${fnName$1}.arr`,
|
|
311
|
-
`${fnName$1}['arr']`,
|
|
312
|
-
`${fnName$1}["arr"]`,
|
|
313
|
-
`${fnName$1}[\`arr\`]`
|
|
314
|
-
]),
|
|
315
|
-
normalPreview: new Set([`${fnName$1}p`]),
|
|
316
|
-
forceStringPreview: new Set([
|
|
317
|
-
`${fnName$1}p.str`,
|
|
318
|
-
`${fnName$1}p['str']`,
|
|
319
|
-
`${fnName$1}p["str"]`,
|
|
320
|
-
`${fnName$1}p[\`str\`]`
|
|
321
|
-
]),
|
|
322
|
-
forceArrayPreview: new Set([
|
|
323
|
-
`${fnName$1}p.arr`,
|
|
324
|
-
`${fnName$1}p['arr']`,
|
|
325
|
-
`${fnName$1}p["arr"]`,
|
|
326
|
-
`${fnName$1}p[\`arr\`]`
|
|
327
|
-
])
|
|
328
|
-
};
|
|
329
|
-
return {
|
|
330
|
-
isNormal: (fnName$2) => available.normal.has(fnName$2) || available.normalPreview.has(fnName$2),
|
|
331
|
-
isForceString: (fnName$2) => available.forceString.has(fnName$2) || available.forceStringPreview.has(fnName$2),
|
|
332
|
-
isForceArray: (fnName$2) => available.forceArray.has(fnName$2) || available.forceArrayPreview.has(fnName$2),
|
|
333
|
-
isPreview: (fnName$2) => available.normalPreview.has(fnName$2) || available.forceStringPreview.has(fnName$2) || available.forceArrayPreview.has(fnName$2),
|
|
334
|
-
RE: new RegExp(`\\b(${Object.values(available).flatMap((s) => [...s].map((f) => `(${f.replace(ESCAPE_REPLACE_RE, "\\$&")})`)).join("|")})\\(`, "g")
|
|
335
|
-
};
|
|
336
|
-
}
|
|
337
|
-
const fnUtils = createFnUtils(fnName);
|
|
338
|
-
function findFunctionCalls(code) {
|
|
339
|
-
const RE = fnUtils.RE;
|
|
340
|
-
const result = [];
|
|
341
|
-
let matched = RE.exec(code);
|
|
342
|
-
while (matched != null) {
|
|
343
|
-
const fnName$1 = matched[1];
|
|
344
|
-
const start = matched.index;
|
|
345
|
-
let end = start + fnName$1.length;
|
|
346
|
-
let depth = 1;
|
|
347
|
-
let inString = false;
|
|
348
|
-
let isEscaped = false;
|
|
349
|
-
while (depth > 0 && end < code.length) {
|
|
350
|
-
end++;
|
|
351
|
-
const char = code[end];
|
|
352
|
-
if (isEscaped) {
|
|
353
|
-
isEscaped = false;
|
|
354
|
-
continue;
|
|
355
|
-
}
|
|
356
|
-
if (char === "\\") {
|
|
357
|
-
isEscaped = true;
|
|
358
|
-
continue;
|
|
359
|
-
}
|
|
360
|
-
if (inString !== false) {
|
|
361
|
-
if (char === inString) inString = false;
|
|
362
|
-
else if (inString === "`" && char === "$" && code[end + 1] === "{") {
|
|
363
|
-
end++;
|
|
364
|
-
depth++;
|
|
365
|
-
}
|
|
366
|
-
continue;
|
|
367
|
-
}
|
|
368
|
-
if (char === "(") depth++;
|
|
369
|
-
else if (char === ")") depth--;
|
|
370
|
-
else if (char === "'" || char === "\"" || char === "`") inString = char;
|
|
371
|
-
else if (char === "/" && code[end + 1] === "/") {
|
|
372
|
-
const lineEnd = code.indexOf("\n", end);
|
|
373
|
-
if (lineEnd === -1) {
|
|
374
|
-
_pikacss_core.log.warn(`Unclosed function call at position ${start}`);
|
|
375
|
-
break;
|
|
376
|
-
}
|
|
377
|
-
end = lineEnd;
|
|
378
|
-
} else if (char === "/" && code[end + 1] === "*") {
|
|
379
|
-
const commentEnd = code.indexOf("*/", end + 2);
|
|
380
|
-
if (commentEnd === -1) {
|
|
381
|
-
_pikacss_core.log.warn(`Unclosed comment in function call at position ${start}`);
|
|
382
|
-
break;
|
|
383
|
-
}
|
|
384
|
-
end = commentEnd + 1;
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
if (depth !== 0) {
|
|
388
|
-
_pikacss_core.log.warn(`Malformed function call at position ${start}, skipping`);
|
|
389
|
-
matched = RE.exec(code);
|
|
390
|
-
continue;
|
|
391
|
-
}
|
|
392
|
-
const snippet = code.slice(start, end + 1);
|
|
393
|
-
result.push({
|
|
394
|
-
fnName: fnName$1,
|
|
395
|
-
start,
|
|
396
|
-
end,
|
|
397
|
-
snippet
|
|
398
|
-
});
|
|
399
|
-
matched = RE.exec(code);
|
|
400
|
-
}
|
|
401
|
-
return result;
|
|
402
|
-
}
|
|
403
|
-
async function transform(code, id) {
|
|
404
|
-
const _engine = engine();
|
|
405
|
-
if (_engine == null) return null;
|
|
406
|
-
try {
|
|
407
|
-
_pikacss_core.log.debug(`Transforming file: ${id}`);
|
|
408
|
-
usages.delete(id);
|
|
409
|
-
const functionCalls = findFunctionCalls(code);
|
|
410
|
-
if (functionCalls.length === 0) return;
|
|
411
|
-
_pikacss_core.log.debug(`Found ${functionCalls.length} style function calls in ${id}`);
|
|
412
|
-
const usageList = [];
|
|
413
|
-
const transformed = new magic_string.default(code);
|
|
414
|
-
for (const fnCall of functionCalls) {
|
|
415
|
-
const argsStr = `[${fnCall.snippet.slice(fnCall.fnName.length + 1, -1)}]`;
|
|
416
|
-
const args = new Function(`return ${argsStr}`)();
|
|
417
|
-
const names = await _engine.use(...args);
|
|
418
|
-
const usage = {
|
|
419
|
-
atomicStyleIds: names,
|
|
420
|
-
params: args
|
|
421
|
-
};
|
|
422
|
-
usageList.push(usage);
|
|
423
|
-
let transformedContent;
|
|
424
|
-
if (fnUtils.isNormal(fnCall.fnName)) transformedContent = transformedFormat === "array" ? `[${names.map((n) => `'${n}'`).join(", ")}]` : transformedFormat === "string" ? `'${names.join(" ")}'` : names.join(" ");
|
|
425
|
-
else if (fnUtils.isForceString(fnCall.fnName)) transformedContent = `'${names.join(" ")}'`;
|
|
426
|
-
else if (fnUtils.isForceArray(fnCall.fnName)) transformedContent = `[${names.map((n) => `'${n}'`).join(", ")}]`;
|
|
427
|
-
else throw new Error(`Unexpected function name: ${fnCall.fnName}`);
|
|
428
|
-
transformed.update(fnCall.start, fnCall.end + 1, transformedContent);
|
|
429
|
-
}
|
|
430
|
-
usages.set(id, usageList);
|
|
431
|
-
triggerStyleUpdated();
|
|
432
|
-
triggerTsCodegenUpdated();
|
|
433
|
-
_pikacss_core.log.debug(`Transformed ${usageList.length} style usages in ${id}`);
|
|
434
|
-
return {
|
|
435
|
-
code: transformed.toString(),
|
|
436
|
-
map: transformed.generateMap({ hires: true })
|
|
437
|
-
};
|
|
438
|
-
} catch (error) {
|
|
439
|
-
_pikacss_core.log.error(`Failed to transform code (${(0, pathe.join)(cwd(), id)}): ${error.message}`, error);
|
|
440
|
-
return;
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
return {
|
|
444
|
-
transformFilter: {
|
|
445
|
-
include: scan.include,
|
|
446
|
-
exclude: [
|
|
447
|
-
...scan.exclude,
|
|
448
|
-
cssCodegenFilepath(),
|
|
449
|
-
...tsCodegenFilepath() ? [tsCodegenFilepath()] : []
|
|
450
|
-
]
|
|
451
|
-
},
|
|
452
|
-
transform
|
|
453
|
-
};
|
|
454
|
-
}
|
|
455
|
-
function createCtx(options) {
|
|
456
|
-
const { cwd, cssCodegenFilepath, tsCodegenFilepath } = usePaths(options);
|
|
457
|
-
const { resolvedConfig, resolvedConfigPath, resolvedConfigContent, loadConfig } = useConfig({
|
|
458
|
-
...options,
|
|
459
|
-
cwd,
|
|
460
|
-
tsCodegenFilepath
|
|
461
|
-
});
|
|
462
|
-
const usages = /* @__PURE__ */ new Map();
|
|
463
|
-
const engine = (0, alien_signals.signal)(null);
|
|
464
|
-
const hooks = {
|
|
465
|
-
styleUpdated: createEventHook(),
|
|
466
|
-
tsCodegenUpdated: createEventHook()
|
|
467
|
-
};
|
|
468
|
-
const { transformFilter, transform } = useTransform({
|
|
469
|
-
...options,
|
|
470
|
-
cwd,
|
|
471
|
-
cssCodegenFilepath,
|
|
472
|
-
tsCodegenFilepath,
|
|
473
|
-
usages,
|
|
474
|
-
engine,
|
|
475
|
-
triggerStyleUpdated: () => hooks.styleUpdated.trigger(),
|
|
476
|
-
triggerTsCodegenUpdated: () => hooks.tsCodegenUpdated.trigger()
|
|
477
|
-
});
|
|
478
|
-
const ctx = {
|
|
479
|
-
currentPackageName: options.currentPackageName,
|
|
480
|
-
fnName: options.fnName,
|
|
481
|
-
transformedFormat: options.transformedFormat,
|
|
482
|
-
get cwd() {
|
|
483
|
-
return cwd();
|
|
484
|
-
},
|
|
485
|
-
set cwd(v) {
|
|
486
|
-
cwd(v);
|
|
487
|
-
},
|
|
488
|
-
get cssCodegenFilepath() {
|
|
489
|
-
return cssCodegenFilepath();
|
|
490
|
-
},
|
|
491
|
-
get tsCodegenFilepath() {
|
|
492
|
-
return tsCodegenFilepath();
|
|
493
|
-
},
|
|
494
|
-
get hasVue() {
|
|
495
|
-
return (0, local_pkg.isPackageExists)("vue", { paths: [cwd()] });
|
|
496
|
-
},
|
|
497
|
-
get resolvedConfig() {
|
|
498
|
-
return resolvedConfig();
|
|
499
|
-
},
|
|
500
|
-
get resolvedConfigPath() {
|
|
501
|
-
return resolvedConfigPath();
|
|
502
|
-
},
|
|
503
|
-
get resolvedConfigContent() {
|
|
504
|
-
return resolvedConfigContent();
|
|
505
|
-
},
|
|
506
|
-
loadConfig,
|
|
507
|
-
usages,
|
|
508
|
-
hooks,
|
|
509
|
-
get engine() {
|
|
510
|
-
const _engine = engine();
|
|
511
|
-
if (_engine == null) throw new Error("Engine is not initialized yet");
|
|
512
|
-
return _engine;
|
|
513
|
-
},
|
|
514
|
-
transformFilter,
|
|
515
|
-
transform: async (code, id) => {
|
|
516
|
-
await ctx.setupPromise;
|
|
517
|
-
return transform(code, id);
|
|
518
|
-
},
|
|
519
|
-
getCssCodegenContent: async () => {
|
|
520
|
-
await ctx.setupPromise;
|
|
521
|
-
_pikacss_core.log.debug("Generating CSS code");
|
|
522
|
-
const atomicStyleIds = [...new Set([...ctx.usages.values()].flatMap((i) => [...new Set(i.flatMap((i$1) => i$1.atomicStyleIds))]))];
|
|
523
|
-
_pikacss_core.log.debug(`Collecting ${atomicStyleIds.length} atomic style IDs`);
|
|
524
|
-
const layerDecl = ctx.engine.renderLayerOrderDeclaration();
|
|
525
|
-
const preflightsCss = await ctx.engine.renderPreflights(true);
|
|
526
|
-
const atomicCss = await ctx.engine.renderAtomicStyles(true, { atomicStyleIds });
|
|
527
|
-
return [
|
|
528
|
-
`/* Auto-generated by ${ctx.currentPackageName} */`,
|
|
529
|
-
layerDecl,
|
|
530
|
-
preflightsCss,
|
|
531
|
-
atomicCss
|
|
532
|
-
].filter((s) => s.trim() !== "").join("\n").trim();
|
|
533
|
-
},
|
|
534
|
-
getTsCodegenContent: async () => {
|
|
535
|
-
await ctx.setupPromise;
|
|
536
|
-
if (ctx.tsCodegenFilepath == null) return null;
|
|
537
|
-
return await generateTsCodegenContent(ctx);
|
|
538
|
-
},
|
|
539
|
-
writeCssCodegenFile: async () => {
|
|
540
|
-
await ctx.setupPromise;
|
|
541
|
-
const content = await ctx.getCssCodegenContent();
|
|
542
|
-
if (content == null) return;
|
|
543
|
-
await (0, node_fs_promises.mkdir)((0, pathe.dirname)(ctx.cssCodegenFilepath), { recursive: true }).catch(() => {});
|
|
544
|
-
_pikacss_core.log.debug(`Writing CSS code generation file: ${ctx.cssCodegenFilepath}`);
|
|
545
|
-
await (0, node_fs_promises.writeFile)(ctx.cssCodegenFilepath, content);
|
|
546
|
-
},
|
|
547
|
-
writeTsCodegenFile: async () => {
|
|
548
|
-
await ctx.setupPromise;
|
|
549
|
-
if (ctx.tsCodegenFilepath == null) return;
|
|
550
|
-
const content = await ctx.getTsCodegenContent();
|
|
551
|
-
if (content == null) return;
|
|
552
|
-
await (0, node_fs_promises.mkdir)((0, pathe.dirname)(ctx.tsCodegenFilepath), { recursive: true }).catch(() => {});
|
|
553
|
-
_pikacss_core.log.debug(`Writing TypeScript code generation file: ${ctx.tsCodegenFilepath}`);
|
|
554
|
-
await (0, node_fs_promises.writeFile)(ctx.tsCodegenFilepath, content);
|
|
555
|
-
},
|
|
556
|
-
fullyCssCodegen: async () => {
|
|
557
|
-
await ctx.setupPromise;
|
|
558
|
-
_pikacss_core.log.debug("Starting full CSS code generation scan");
|
|
559
|
-
const stream = (0, globby.globbyStream)(options.scan.include, { ignore: options.scan.exclude });
|
|
560
|
-
let fileCount = 0;
|
|
561
|
-
const _cwd = cwd();
|
|
562
|
-
for await (const entry of stream) {
|
|
563
|
-
const code = await (0, node_fs_promises.readFile)((0, pathe.join)(_cwd, entry), "utf-8");
|
|
564
|
-
await ctx.transform(code, entry);
|
|
565
|
-
fileCount++;
|
|
566
|
-
}
|
|
567
|
-
_pikacss_core.log.debug(`Scanned ${fileCount} files for style collection`);
|
|
568
|
-
await ctx.writeCssCodegenFile();
|
|
569
|
-
},
|
|
570
|
-
setupPromise: null,
|
|
571
|
-
setup: () => {
|
|
572
|
-
ctx.setupPromise = setup().catch((error) => {
|
|
573
|
-
_pikacss_core.log.error(`Failed to setup integration context: ${error.message}`, error);
|
|
574
|
-
}).then(() => {
|
|
575
|
-
ctx.setupPromise = null;
|
|
576
|
-
});
|
|
577
|
-
return ctx.setupPromise;
|
|
578
|
-
}
|
|
579
|
-
};
|
|
580
|
-
async function setup() {
|
|
581
|
-
_pikacss_core.log.debug("Setting up integration context");
|
|
582
|
-
usages.clear();
|
|
583
|
-
hooks.styleUpdated.listeners.clear();
|
|
584
|
-
hooks.tsCodegenUpdated.listeners.clear();
|
|
585
|
-
engine(null);
|
|
586
|
-
await loadConfig();
|
|
587
|
-
const devPlugin = (0, _pikacss_core.defineEnginePlugin)({
|
|
588
|
-
name: "@pikacss/integration:dev",
|
|
589
|
-
preflightUpdated: () => hooks.styleUpdated.trigger(),
|
|
590
|
-
atomicStyleAdded: () => hooks.styleUpdated.trigger(),
|
|
591
|
-
autocompleteConfigUpdated: () => hooks.tsCodegenUpdated.trigger()
|
|
592
|
-
});
|
|
593
|
-
try {
|
|
594
|
-
const config = resolvedConfig() ?? {};
|
|
595
|
-
config.plugins = config.plugins ?? [];
|
|
596
|
-
config.plugins.unshift(devPlugin);
|
|
597
|
-
_pikacss_core.log.debug("Creating engine with loaded/default config");
|
|
598
|
-
engine(await (0, _pikacss_core.createEngine)(config));
|
|
599
|
-
} catch (error) {
|
|
600
|
-
_pikacss_core.log.error(`Failed to create engine: ${error.message}. Falling back to default config.`, error);
|
|
601
|
-
engine(await (0, _pikacss_core.createEngine)({ plugins: [devPlugin] }));
|
|
602
|
-
}
|
|
603
|
-
_pikacss_core.log.debug("Integration context setup successfully");
|
|
604
|
-
}
|
|
605
|
-
return ctx;
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
//#endregion
|
|
609
|
-
exports.createCtx = createCtx;
|
|
610
|
-
Object.keys(_pikacss_core).forEach(function (k) {
|
|
611
|
-
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
612
|
-
enumerable: true,
|
|
613
|
-
get: function () { return _pikacss_core[k]; }
|
|
614
|
-
});
|
|
615
|
-
});
|
package/dist/index.d.cts
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { Engine, EngineConfig, Nullish } from "@pikacss/core";
|
|
2
|
-
import { SourceMap } from "magic-string";
|
|
3
|
-
export * from "@pikacss/core";
|
|
4
|
-
|
|
5
|
-
//#region src/eventHook.d.ts
|
|
6
|
-
type EventHookListener<EventPayload> = (payload: EventPayload) => void | Promise<void>;
|
|
7
|
-
interface EventHook<EventPayload> {
|
|
8
|
-
listeners: Set<EventHookListener<EventPayload>>;
|
|
9
|
-
trigger: (payload: EventPayload) => void;
|
|
10
|
-
on: (listener: EventHookListener<EventPayload>) => () => void;
|
|
11
|
-
off: (listener: EventHookListener<EventPayload>) => void;
|
|
12
|
-
}
|
|
13
|
-
declare function createEventHook<EventPayload>(): EventHook<EventPayload>;
|
|
14
|
-
//#endregion
|
|
15
|
-
//#region src/types.d.ts
|
|
16
|
-
interface UsageRecord {
|
|
17
|
-
atomicStyleIds: string[];
|
|
18
|
-
params: Parameters<Engine['use']>;
|
|
19
|
-
}
|
|
20
|
-
interface FnUtils {
|
|
21
|
-
isNormal: (fnName: string) => boolean;
|
|
22
|
-
isForceString: (fnName: string) => boolean;
|
|
23
|
-
isForceArray: (fnName: string) => boolean;
|
|
24
|
-
isPreview: (fnName: string) => boolean;
|
|
25
|
-
RE: RegExp;
|
|
26
|
-
}
|
|
27
|
-
interface IntegrationContextOptions {
|
|
28
|
-
cwd: string;
|
|
29
|
-
currentPackageName: string;
|
|
30
|
-
scan: {
|
|
31
|
-
include: string[];
|
|
32
|
-
exclude: string[];
|
|
33
|
-
};
|
|
34
|
-
configOrPath: EngineConfig | string | Nullish;
|
|
35
|
-
fnName: string;
|
|
36
|
-
transformedFormat: 'string' | 'array' | 'inline';
|
|
37
|
-
tsCodegen: false | string;
|
|
38
|
-
cssCodegen: string;
|
|
39
|
-
autoCreateConfig: boolean;
|
|
40
|
-
}
|
|
41
|
-
interface IntegrationContext {
|
|
42
|
-
cwd: string;
|
|
43
|
-
currentPackageName: string;
|
|
44
|
-
fnName: string;
|
|
45
|
-
transformedFormat: 'string' | 'array' | 'inline';
|
|
46
|
-
cssCodegenFilepath: string;
|
|
47
|
-
tsCodegenFilepath: string | Nullish;
|
|
48
|
-
hasVue: boolean;
|
|
49
|
-
resolvedConfig: EngineConfig | Nullish;
|
|
50
|
-
resolvedConfigPath: string | Nullish;
|
|
51
|
-
resolvedConfigContent: string | Nullish;
|
|
52
|
-
loadConfig: () => Promise<{
|
|
53
|
-
config: EngineConfig;
|
|
54
|
-
file: null;
|
|
55
|
-
} | {
|
|
56
|
-
config: null;
|
|
57
|
-
file: null;
|
|
58
|
-
} | {
|
|
59
|
-
config: EngineConfig;
|
|
60
|
-
file: string;
|
|
61
|
-
}>;
|
|
62
|
-
usages: Map<string, UsageRecord[]>;
|
|
63
|
-
hooks: {
|
|
64
|
-
styleUpdated: ReturnType<typeof createEventHook<void>>;
|
|
65
|
-
tsCodegenUpdated: ReturnType<typeof createEventHook<void>>;
|
|
66
|
-
};
|
|
67
|
-
engine: Engine;
|
|
68
|
-
transformFilter: {
|
|
69
|
-
include: string[];
|
|
70
|
-
exclude: string[];
|
|
71
|
-
};
|
|
72
|
-
transform: (code: string, id: string) => Promise<{
|
|
73
|
-
code: string;
|
|
74
|
-
map: SourceMap;
|
|
75
|
-
} | Nullish>;
|
|
76
|
-
getCssCodegenContent: () => Promise<string | Nullish>;
|
|
77
|
-
getTsCodegenContent: () => Promise<string | Nullish>;
|
|
78
|
-
writeCssCodegenFile: () => Promise<void>;
|
|
79
|
-
writeTsCodegenFile: () => Promise<void>;
|
|
80
|
-
fullyCssCodegen: () => Promise<void>;
|
|
81
|
-
setupPromise: Promise<void> | null;
|
|
82
|
-
setup: () => Promise<void>;
|
|
83
|
-
}
|
|
84
|
-
//#endregion
|
|
85
|
-
//#region src/ctx.d.ts
|
|
86
|
-
declare function createCtx(options: IntegrationContextOptions): IntegrationContext;
|
|
87
|
-
//#endregion
|
|
88
|
-
export { FnUtils, IntegrationContext, IntegrationContextOptions, UsageRecord, createCtx };
|