@pikacss/integration 0.0.44 → 0.0.46
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.d.mts +2 -2
- package/dist/index.mjs +7 -12
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -33,7 +33,7 @@ interface IntegrationContextOptions {
|
|
|
33
33
|
};
|
|
34
34
|
configOrPath: EngineConfig | string | Nullish;
|
|
35
35
|
fnName: string;
|
|
36
|
-
transformedFormat: 'string' | 'array'
|
|
36
|
+
transformedFormat: 'string' | 'array';
|
|
37
37
|
tsCodegen: false | string;
|
|
38
38
|
cssCodegen: string;
|
|
39
39
|
autoCreateConfig: boolean;
|
|
@@ -42,7 +42,7 @@ interface IntegrationContext {
|
|
|
42
42
|
cwd: string;
|
|
43
43
|
currentPackageName: string;
|
|
44
44
|
fnName: string;
|
|
45
|
-
transformedFormat: 'string' | 'array'
|
|
45
|
+
transformedFormat: 'string' | 'array';
|
|
46
46
|
cssCodegenFilepath: string;
|
|
47
47
|
tsCodegenFilepath: string | Nullish;
|
|
48
48
|
hasVue: boolean;
|
package/dist/index.mjs
CHANGED
|
@@ -36,7 +36,7 @@ function createEventHook() {
|
|
|
36
36
|
//#endregion
|
|
37
37
|
//#region src/tsCodegen.ts
|
|
38
38
|
function formatUnionStringType(list) {
|
|
39
|
-
return list.length > 0 ? list.map((i) =>
|
|
39
|
+
return list.length > 0 ? list.map((i) => JSON.stringify(i)).join(" | ") : "never";
|
|
40
40
|
}
|
|
41
41
|
function generateAutocomplete(ctx) {
|
|
42
42
|
const autocomplete = ctx.engine.config.autocomplete;
|
|
@@ -48,8 +48,8 @@ function generateAutocomplete(ctx) {
|
|
|
48
48
|
` StyleItemString: ${formatUnionStringType([...autocomplete.styleItemStrings])}`,
|
|
49
49
|
` ExtraProperty: ${formatUnionStringType([...autocomplete.extraProperties])}`,
|
|
50
50
|
` ExtraCssProperty: ${formatUnionStringType([...autocomplete.extraCssProperties])}`,
|
|
51
|
-
` PropertiesValue: { ${Array.from(autocomplete.properties.entries(), ([k, v]) =>
|
|
52
|
-
` CssPropertiesValue: { ${Array.from(autocomplete.cssProperties.entries(), ([k, v]) =>
|
|
51
|
+
` PropertiesValue: { ${Array.from(autocomplete.properties.entries(), ([k, v]) => `${JSON.stringify(k)}: ${v.length > 0 ? v.join(" | ") : "never"}`).join(", ")} }`,
|
|
52
|
+
` CssPropertiesValue: { ${Array.from(autocomplete.cssProperties.entries(), ([k, v]) => `${JSON.stringify(k)}: ${formatUnionStringType(v)}`).join(", ")} }`,
|
|
53
53
|
` Layer: ${formatUnionStringType(layerNames)}`,
|
|
54
54
|
"}>",
|
|
55
55
|
""
|
|
@@ -57,15 +57,10 @@ function generateAutocomplete(ctx) {
|
|
|
57
57
|
}
|
|
58
58
|
function generateStyleFn(ctx) {
|
|
59
59
|
const { transformedFormat } = ctx;
|
|
60
|
-
const lines = [
|
|
61
|
-
"type StyleFn_Array = (...params: StyleItem[]) => string[]",
|
|
62
|
-
"type StyleFn_String = (...params: StyleItem[]) => string",
|
|
63
|
-
"type StyleFn_Inline = (...params: StyleItem[]) => void"
|
|
64
|
-
];
|
|
60
|
+
const lines = ["type StyleFn_Array = (...params: StyleItem[]) => string[]", "type StyleFn_String = (...params: StyleItem[]) => string"];
|
|
65
61
|
if (transformedFormat === "array") lines.push("type StyleFn_Normal = StyleFn_Array");
|
|
66
62
|
else if (transformedFormat === "string") lines.push("type StyleFn_Normal = StyleFn_String");
|
|
67
|
-
|
|
68
|
-
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\']`, "}", "");
|
|
63
|
+
lines.push("type StyleFn = StyleFn_Normal & {", " str: StyleFn_String", " arr: StyleFn_Array", "}", `type StyleFnWithPreview = PreviewOverloads<StyleFn_Normal>[\'fn\'] & {`, ` str: PreviewOverloads<StyleFn_String>[\'fn\']`, ` arr: PreviewOverloads<StyleFn_Array>[\'fn\']`, "}", "");
|
|
69
64
|
return lines;
|
|
70
65
|
}
|
|
71
66
|
function generateGlobalDeclaration(ctx) {
|
|
@@ -132,7 +127,7 @@ async function generateOverloadContent(ctx) {
|
|
|
132
127
|
} catch {}
|
|
133
128
|
}
|
|
134
129
|
return [
|
|
135
|
-
"interface PreviewOverloads<StyleFn extends (StyleFn_Array | StyleFn_String
|
|
130
|
+
"interface PreviewOverloads<StyleFn extends (StyleFn_Array | StyleFn_String)> {",
|
|
136
131
|
...fnsLines,
|
|
137
132
|
" /**",
|
|
138
133
|
" * PikaCSS Preview",
|
|
@@ -395,7 +390,7 @@ function useTransform({ cwd, cssCodegenFilepath, tsCodegenFilepath, scan, fnName
|
|
|
395
390
|
};
|
|
396
391
|
usageList.push(usage);
|
|
397
392
|
let transformedContent;
|
|
398
|
-
if (fnUtils.isNormal(fnCall.fnName)) transformedContent = transformedFormat === "array" ? `[${names.map((n) => `'${n}'`).join(", ")}]` :
|
|
393
|
+
if (fnUtils.isNormal(fnCall.fnName)) transformedContent = transformedFormat === "array" ? `[${names.map((n) => `'${n}'`).join(", ")}]` : `'${names.join(" ")}'`;
|
|
399
394
|
else if (fnUtils.isForceString(fnCall.fnName)) transformedContent = `'${names.join(" ")}'`;
|
|
400
395
|
else if (fnUtils.isForceArray(fnCall.fnName)) transformedContent = `[${names.map((n) => `'${n}'`).join(", ")}]`;
|
|
401
396
|
else throw new Error(`Unexpected function name: ${fnCall.fnName}`);
|
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.46",
|
|
5
5
|
"author": "DevilTea <ch19980814@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"micromatch": "^4.0.8",
|
|
45
45
|
"pathe": "^2.0.3",
|
|
46
46
|
"perfect-debounce": "^2.1.0",
|
|
47
|
-
"@pikacss/core": "0.0.
|
|
47
|
+
"@pikacss/core": "0.0.46"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@types/micromatch": "^4.0.10"
|