@pikacss/core 0.0.30 → 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/dist/index.cjs +851 -983
- package/dist/index.d.cts +429 -427
- package/dist/index.d.mts +429 -427
- package/dist/index.mjs +851 -982
- package/package.json +4 -5
- package/dist/index.d.ts +0 -539
package/dist/index.d.cts
CHANGED
|
@@ -1,391 +1,393 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import * as CSS from 'csstype';
|
|
1
|
+
import * as CSS from "csstype";
|
|
3
2
|
|
|
3
|
+
//#region src/internal/plugins/important.d.ts
|
|
4
4
|
interface ImportantConfig {
|
|
5
|
-
|
|
5
|
+
default?: boolean;
|
|
6
6
|
}
|
|
7
7
|
declare module '@pikacss/core' {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
interface EngineConfig {
|
|
9
|
+
important?: ImportantConfig;
|
|
10
|
+
}
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/internal/plugins/keyframes.d.ts
|
|
13
14
|
interface Progress {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
from?: ResolvedProperties;
|
|
16
|
+
to?: ResolvedProperties;
|
|
17
|
+
[K: `${number}%`]: ResolvedProperties;
|
|
17
18
|
}
|
|
18
19
|
type Keyframes = string | [name: string, frames?: Progress, autocomplete?: string[], pruneUnused?: boolean] | {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
name: string;
|
|
21
|
+
frames?: Progress;
|
|
22
|
+
autocomplete?: string[];
|
|
23
|
+
pruneUnused?: boolean;
|
|
23
24
|
};
|
|
24
25
|
interface KeyframesConfig {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Define CSS @keyframes animations with support for frame definitions
|
|
28
|
+
* and autocomplete suggestions.
|
|
29
|
+
*
|
|
30
|
+
* @default []
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* {
|
|
34
|
+
* keyframes: [
|
|
35
|
+
* // Basic animation
|
|
36
|
+
* ['fade', {
|
|
37
|
+
* from: { opacity: 0 },
|
|
38
|
+
* to: { opacity: 1 }
|
|
39
|
+
* }],
|
|
40
|
+
* // With autocomplete suggestions
|
|
41
|
+
* ['slide', {
|
|
42
|
+
* from: { transform: 'translateX(-100%)' },
|
|
43
|
+
* to: { transform: 'translateX(0)' }
|
|
44
|
+
* }, ['slide 0.3s ease']]
|
|
45
|
+
* ]
|
|
46
|
+
* }
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
keyframes: Keyframes[];
|
|
50
|
+
/**
|
|
51
|
+
* Whether to prune unused keyframes from the final CSS.
|
|
52
|
+
*
|
|
53
|
+
* @default true
|
|
54
|
+
*/
|
|
55
|
+
pruneUnused?: boolean;
|
|
55
56
|
}
|
|
56
57
|
declare module '@pikacss/core' {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
58
|
+
interface EngineConfig {
|
|
59
|
+
keyframes?: KeyframesConfig;
|
|
60
|
+
}
|
|
61
|
+
interface Engine {
|
|
62
|
+
keyframes: {
|
|
63
|
+
store: Map<string, ResolvedKeyframesConfig>;
|
|
64
|
+
add: (...list: Keyframes[]) => void;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
66
67
|
}
|
|
67
68
|
interface ResolvedKeyframesConfig {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
69
|
+
name: string;
|
|
70
|
+
frames: Progress | Nullish;
|
|
71
|
+
pruneUnused: boolean;
|
|
72
|
+
autocomplete: string[];
|
|
73
|
+
}
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region src/internal/resolver.d.ts
|
|
76
|
+
interface ResolvedResult<T$1> {
|
|
77
|
+
value: T$1;
|
|
78
|
+
}
|
|
79
|
+
interface StaticRule<T$1> {
|
|
80
|
+
key: string;
|
|
81
|
+
string: string;
|
|
82
|
+
resolved: T$1;
|
|
83
|
+
}
|
|
84
|
+
interface DynamicRule<T$1> {
|
|
85
|
+
key: string;
|
|
86
|
+
stringPattern: RegExp;
|
|
87
|
+
createResolved: (matched: RegExpMatchArray) => Awaitable<T$1>;
|
|
88
|
+
}
|
|
89
|
+
declare abstract class AbstractResolver<T$1> {
|
|
90
|
+
protected _resolvedResultsMap: Map<string, ResolvedResult<T$1>>;
|
|
91
|
+
staticRulesMap: Map<string, StaticRule<T$1>>;
|
|
92
|
+
dynamicRulesMap: Map<string, DynamicRule<T$1>>;
|
|
93
|
+
onResolved: (string: string, type: 'static' | 'dynamic', result: ResolvedResult<T$1>) => void;
|
|
94
|
+
get staticRules(): StaticRule<T$1>[];
|
|
95
|
+
get dynamicRules(): DynamicRule<T$1>[];
|
|
96
|
+
addStaticRule(rule: StaticRule<T$1>): this;
|
|
97
|
+
removeStaticRule(key: string): this;
|
|
98
|
+
addDynamicRule(rule: DynamicRule<T$1>): this;
|
|
99
|
+
removeDynamicRule(key: string): this;
|
|
100
|
+
_resolve(string: string): Promise<ResolvedResult<T$1> | Nullish>;
|
|
101
|
+
_setResolvedResult(string: string, resolved: T$1): void;
|
|
102
|
+
}
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region src/internal/plugins/selectors.d.ts
|
|
102
105
|
type Selector = string | [selector: RegExp, value: (matched: RegExpMatchArray) => Awaitable<Arrayable<UnionString | ResolvedSelector>>, autocomplete?: Arrayable<string>] | [selector: string, value: Arrayable<UnionString | ResolvedSelector>] | {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
+
selector: RegExp;
|
|
107
|
+
value: (matched: RegExpMatchArray) => Awaitable<Arrayable<UnionString | ResolvedSelector>>;
|
|
108
|
+
autocomplete?: Arrayable<string>;
|
|
106
109
|
} | {
|
|
107
|
-
|
|
108
|
-
|
|
110
|
+
selector: string;
|
|
111
|
+
value: Arrayable<UnionString | ResolvedSelector>;
|
|
109
112
|
};
|
|
110
113
|
interface SelectorsConfig {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
114
|
+
/**
|
|
115
|
+
* Define custom selectors with support for dynamic and static selectors.
|
|
116
|
+
*
|
|
117
|
+
* @default []
|
|
118
|
+
* @example
|
|
119
|
+
* ```ts
|
|
120
|
+
* {
|
|
121
|
+
* selectors: [
|
|
122
|
+
* // Static selector
|
|
123
|
+
* ['hover', '$:hover'],
|
|
124
|
+
* // Dynamic selector
|
|
125
|
+
* [/^screen-(\d+)$/, m => `@media (min-width: ${m[1]}px)`,
|
|
126
|
+
* ['screen-768', 'screen-1024']], // Autocomplete suggestions
|
|
127
|
+
* ]
|
|
128
|
+
* }
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
131
|
+
selectors: Selector[];
|
|
129
132
|
}
|
|
130
133
|
declare module '@pikacss/core' {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
134
|
+
interface EngineConfig {
|
|
135
|
+
selectors?: SelectorsConfig;
|
|
136
|
+
}
|
|
137
|
+
interface Engine {
|
|
138
|
+
selectors: {
|
|
139
|
+
resolver: SelectorResolver;
|
|
140
|
+
add: (...list: Selector[]) => void;
|
|
141
|
+
};
|
|
142
|
+
}
|
|
140
143
|
}
|
|
141
144
|
declare class SelectorResolver extends AbstractResolver<string[]> {
|
|
142
|
-
|
|
145
|
+
resolve(selector: string): Promise<string[]>;
|
|
143
146
|
}
|
|
144
|
-
|
|
147
|
+
//#endregion
|
|
148
|
+
//#region src/internal/plugins/shortcuts.d.ts
|
|
145
149
|
type Shortcut = string | [shortcut: RegExp, value: (matched: RegExpMatchArray) => Awaitable<Arrayable<ResolvedStyleItem>>, autocomplete?: Arrayable<string>] | {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
150
|
+
shortcut: RegExp;
|
|
151
|
+
value: (matched: RegExpMatchArray) => Awaitable<Arrayable<ResolvedStyleItem>>;
|
|
152
|
+
autocomplete?: Arrayable<string>;
|
|
149
153
|
} | [shortcut: string, value: Arrayable<ResolvedStyleItem>] | {
|
|
150
|
-
|
|
151
|
-
|
|
154
|
+
shortcut: string;
|
|
155
|
+
value: Arrayable<ResolvedStyleItem>;
|
|
152
156
|
};
|
|
153
157
|
interface ShortcutsConfig {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
158
|
+
/**
|
|
159
|
+
* Define style shortcuts for reusable style combinations.
|
|
160
|
+
*
|
|
161
|
+
* @default []
|
|
162
|
+
* @example
|
|
163
|
+
* ```ts
|
|
164
|
+
* {
|
|
165
|
+
* shortcuts: [
|
|
166
|
+
* // Static shortcut
|
|
167
|
+
* ['flex-center', {
|
|
168
|
+
* display: 'flex',
|
|
169
|
+
* alignItems: 'center',
|
|
170
|
+
* justifyContent: 'center'
|
|
171
|
+
* }],
|
|
172
|
+
* // Dynamic shortcut
|
|
173
|
+
* [/^m-(\d+)$/, m => ({ margin: `${m[1]}px` }),
|
|
174
|
+
* ['m-4', 'm-8']] // Autocomplete suggestions
|
|
175
|
+
* ]
|
|
176
|
+
* }
|
|
177
|
+
* ```
|
|
178
|
+
*/
|
|
179
|
+
shortcuts: Shortcut[];
|
|
176
180
|
}
|
|
177
181
|
declare module '@pikacss/core' {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
182
|
+
interface EngineConfig {
|
|
183
|
+
shortcuts?: ShortcutsConfig;
|
|
184
|
+
}
|
|
185
|
+
interface Engine {
|
|
186
|
+
shortcuts: {
|
|
187
|
+
resolver: ShortcutResolver;
|
|
188
|
+
add: (...list: Shortcut[]) => void;
|
|
189
|
+
};
|
|
190
|
+
}
|
|
187
191
|
}
|
|
188
192
|
declare class ShortcutResolver extends AbstractResolver<StyleItem$1[]> {
|
|
189
|
-
|
|
193
|
+
resolve(shortcut: string): Promise<StyleItem$1[]>;
|
|
190
194
|
}
|
|
191
|
-
|
|
195
|
+
//#endregion
|
|
196
|
+
//#region src/internal/plugins/variables.d.ts
|
|
192
197
|
type ResolvedCSSProperty = keyof ResolvedCSSProperties;
|
|
193
198
|
type ResolvedCSSVarProperty = ResolvedCSSProperty extends infer T ? T extends `--${string}` ? T : never : never;
|
|
194
199
|
interface VariableAutocomplete {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
200
|
+
/**
|
|
201
|
+
* Specify the properties that the variable can be used as a value of.
|
|
202
|
+
*
|
|
203
|
+
* @default ['*']
|
|
204
|
+
*/
|
|
205
|
+
asValueOf?: Arrayable<UnionString | '*' | '-' | ResolvedCSSProperty>;
|
|
206
|
+
/**
|
|
207
|
+
* Whether to add the variable as a CSS property.
|
|
208
|
+
*
|
|
209
|
+
* @default true
|
|
210
|
+
*/
|
|
211
|
+
asProperty?: boolean;
|
|
207
212
|
}
|
|
208
213
|
interface VariableObject {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
214
|
+
value?: ResolvedCSSProperties[`--${string}`];
|
|
215
|
+
autocomplete?: VariableAutocomplete;
|
|
216
|
+
pruneUnused?: boolean;
|
|
212
217
|
}
|
|
213
218
|
type Variable = ResolvedCSSProperties[`--${string}`] | VariableObject;
|
|
214
|
-
type VariablesDefinition = {
|
|
215
|
-
[key in UnionString | ResolvedSelector | (`--${string}` & {}) | ResolvedCSSVarProperty]?: Variable | VariablesDefinition;
|
|
216
|
-
};
|
|
219
|
+
type VariablesDefinition = { [key in UnionString | ResolvedSelector | (`--${string}` & {}) | ResolvedCSSVarProperty]?: Variable | VariablesDefinition };
|
|
217
220
|
interface VariablesConfig {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
221
|
+
/**
|
|
222
|
+
* Define CSS variables with support for static values and autocomplete configuration.
|
|
223
|
+
*
|
|
224
|
+
* @default {}
|
|
225
|
+
* @example
|
|
226
|
+
* ```ts
|
|
227
|
+
* {
|
|
228
|
+
* variables: {
|
|
229
|
+
* // The variable with value "null" will not be included in the final CSS, but can be used in autocompletion.
|
|
230
|
+
* '--external-var': null,
|
|
231
|
+
*
|
|
232
|
+
* '--color-bg': '#fff',
|
|
233
|
+
* '--color-text': '#000',
|
|
234
|
+
*
|
|
235
|
+
* '[data-theme="dark"]': {
|
|
236
|
+
* '--color-bg': '#000',
|
|
237
|
+
* '--color-text': '#fff',
|
|
238
|
+
* },
|
|
239
|
+
* },
|
|
240
|
+
* }
|
|
241
|
+
* ```
|
|
242
|
+
*/
|
|
243
|
+
variables: VariablesDefinition;
|
|
244
|
+
/**
|
|
245
|
+
* Whether to prune unused variables from the final CSS.
|
|
246
|
+
*
|
|
247
|
+
* @default true
|
|
248
|
+
*/
|
|
249
|
+
pruneUnused?: boolean;
|
|
250
|
+
/**
|
|
251
|
+
* A list of CSS variables that should always be included in the final CSS, you can use this to prevent certain variables from being pruned.
|
|
252
|
+
*
|
|
253
|
+
* @default []
|
|
254
|
+
* @example
|
|
255
|
+
* ```ts
|
|
256
|
+
* {
|
|
257
|
+
* variables: {
|
|
258
|
+
* safeList: ['--external-var', '--color-bg', '--color-text'],
|
|
259
|
+
* },
|
|
260
|
+
* }
|
|
261
|
+
* ```
|
|
262
|
+
*/
|
|
263
|
+
safeList?: ((`--${string}` & {}) | ResolvedCSSVarProperty)[];
|
|
261
264
|
}
|
|
262
265
|
declare module '@pikacss/core' {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
};
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
interface ResolvedVariable {
|
|
274
|
-
name: string;
|
|
275
|
-
value: PropertyValue;
|
|
276
|
-
selector: string[];
|
|
277
|
-
pruneUnused: boolean;
|
|
278
|
-
autocomplete: {
|
|
279
|
-
asValueOf: string[];
|
|
280
|
-
asProperty: boolean;
|
|
266
|
+
interface EngineConfig {
|
|
267
|
+
variables?: VariablesConfig;
|
|
268
|
+
}
|
|
269
|
+
interface Engine {
|
|
270
|
+
variables: {
|
|
271
|
+
store: Map<string, ResolvedVariable[]>;
|
|
272
|
+
add: (variables: VariablesDefinition) => void;
|
|
281
273
|
};
|
|
274
|
+
}
|
|
282
275
|
}
|
|
283
|
-
|
|
276
|
+
interface ResolvedVariable {
|
|
277
|
+
name: string;
|
|
278
|
+
value: PropertyValue;
|
|
279
|
+
selector: string[];
|
|
280
|
+
pruneUnused: boolean;
|
|
281
|
+
autocomplete: {
|
|
282
|
+
asValueOf: string[];
|
|
283
|
+
asProperty: boolean;
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
//#endregion
|
|
287
|
+
//#region src/internal/types/utils.d.ts
|
|
284
288
|
type Nullish = null | undefined;
|
|
285
289
|
type UnionString = string & {};
|
|
286
290
|
type UnionNumber = number & {};
|
|
287
|
-
type Arrayable<T> = T | T[];
|
|
288
|
-
type Awaitable<T> = T | Promise<T>;
|
|
291
|
+
type Arrayable<T$1> = T$1 | T$1[];
|
|
292
|
+
type Awaitable<T$1> = T$1 | Promise<T$1>;
|
|
289
293
|
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
|
|
290
|
-
type IsEqual<X, Y> = (<T>() => T extends X ? 1 : 2) extends (<T>() => T extends Y ? 1 : 2) ? true : false;
|
|
291
|
-
type IsNever<T> = [T] extends [never] ? true : false;
|
|
292
|
-
type Simplify<T> = {
|
|
293
|
-
|
|
294
|
-
}
|
|
295
|
-
type
|
|
296
|
-
type
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
294
|
+
type IsEqual<X, Y> = (<T$1>() => T$1 extends X ? 1 : 2) extends (<T$1>() => T$1 extends Y ? 1 : 2) ? true : false;
|
|
295
|
+
type IsNever<T$1> = [T$1] extends [never] ? true : false;
|
|
296
|
+
type Simplify<T$1> = { [K in keyof T$1]: T$1[K] } & {};
|
|
297
|
+
type ToKebab<T$1 extends string> = T$1 extends `${infer A}${infer B}` ? [A extends Uppercase<A> ? 1 : 0, A extends Lowercase<A> ? 1 : 0] extends [1, 0] ? `-${Lowercase<A>}${ToKebab<`${B}`>}` : `${A}${ToKebab<`${B}`>}` : T$1;
|
|
298
|
+
type FromKebab<T$1 extends string> = T$1 extends `--${string}` ? T$1 : T$1 extends `-${infer A}${infer B}` ? `${Uppercase<A>}${FromKebab<`${B}`>}` : T$1 extends `${infer A}${infer B}` ? `${A}${FromKebab<`${B}`>}` : T$1;
|
|
299
|
+
type GetValue<Obj extends Record<string, any>, K$1 extends string> = (IsEqual<Obj, object> | IsEqual<Obj, {}> | IsEqual<Obj[K$1], unknown>) extends false ? Obj[K$1] : never;
|
|
300
|
+
type ResolveFrom<T$1, Key$1 extends string, I$1, Fallback extends I$1> = Key$1 extends keyof T$1 ? T$1[Key$1] extends I$1 ? T$1[Key$1] : Fallback : Fallback;
|
|
301
|
+
//#endregion
|
|
302
|
+
//#region src/internal/types/autocomplete.d.ts
|
|
300
303
|
interface ResolvedAutocompleteConfig {
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
304
|
+
selectors: Set<string>;
|
|
305
|
+
styleItemStrings: Set<string>;
|
|
306
|
+
extraProperties: Set<string>;
|
|
307
|
+
extraCssProperties: Set<string>;
|
|
308
|
+
properties: Map<string, string[]>;
|
|
309
|
+
cssProperties: Map<string, (string | number)[]>;
|
|
307
310
|
}
|
|
308
311
|
interface _Autocomplete {
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
}
|
|
316
|
-
type DefineAutocomplete<A extends _Autocomplete> = A;
|
|
312
|
+
Selector: UnionString;
|
|
313
|
+
StyleItemString: UnionString;
|
|
314
|
+
ExtraProperty: UnionString;
|
|
315
|
+
ExtraCssProperty: UnionString;
|
|
316
|
+
PropertiesValue: Record<string, unknown>;
|
|
317
|
+
CssPropertiesValue: Record<string, UnionString | UnionNumber>;
|
|
318
|
+
}
|
|
319
|
+
type DefineAutocomplete<A$1 extends _Autocomplete> = A$1;
|
|
317
320
|
type EmptyAutocomplete = DefineAutocomplete<{
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
321
|
+
Selector: never;
|
|
322
|
+
StyleItemString: never;
|
|
323
|
+
ExtraProperty: never;
|
|
324
|
+
ExtraCssProperty: never;
|
|
325
|
+
PropertiesValue: never;
|
|
326
|
+
CssPropertiesValue: never;
|
|
324
327
|
}>;
|
|
325
|
-
|
|
328
|
+
//#endregion
|
|
329
|
+
//#region src/internal/plugin.d.ts
|
|
326
330
|
type DefineHooks<Hooks extends Record<string, [type: 'sync' | 'async', payload: any, returnValue?: any]>> = Hooks;
|
|
327
331
|
type EngineHooksDefinition = DefineHooks<{
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
332
|
+
configureRawConfig: ['async', config: EngineConfig];
|
|
333
|
+
rawConfigConfigured: ['sync', config: EngineConfig, void];
|
|
334
|
+
configureResolvedConfig: ['async', resolvedConfig: ResolvedEngineConfig];
|
|
335
|
+
configureEngine: ['async', engine: Engine];
|
|
336
|
+
transformSelectors: ['async', selectors: string[]];
|
|
337
|
+
transformStyleItems: ['async', styleItems: ResolvedStyleItem[]];
|
|
338
|
+
transformStyleDefinitions: ['async', styleDefinitions: ResolvedStyleDefinition[]];
|
|
339
|
+
preflightUpdated: ['sync', void];
|
|
340
|
+
atomicStyleAdded: ['sync', AtomicStyle];
|
|
341
|
+
autocompleteConfigUpdated: ['sync', void];
|
|
338
342
|
}>;
|
|
339
|
-
type EnginePluginHooksOptions = {
|
|
340
|
-
[K in keyof EngineHooksDefinition]?: EngineHooksDefinition[K][0] extends 'async' ? (...params: EngineHooksDefinition[K][1] extends void ? [] : [payload: EngineHooksDefinition[K][1]]) => Awaitable<EngineHooksDefinition[K][1] | void> : (...params: EngineHooksDefinition[K][1] extends void ? [] : [payload: EngineHooksDefinition[K][1]]) => EngineHooksDefinition[K][1] | void;
|
|
341
|
-
};
|
|
343
|
+
type EnginePluginHooksOptions = { [K in keyof EngineHooksDefinition]?: EngineHooksDefinition[K][0] extends 'async' ? (...params: EngineHooksDefinition[K][1] extends void ? [] : [payload: EngineHooksDefinition[K][1]]) => Awaitable<EngineHooksDefinition[K][1] | void> : (...params: EngineHooksDefinition[K][1] extends void ? [] : [payload: EngineHooksDefinition[K][1]]) => EngineHooksDefinition[K][1] | void };
|
|
342
344
|
interface EnginePlugin extends EnginePluginHooksOptions {
|
|
343
|
-
|
|
344
|
-
|
|
345
|
+
name: string;
|
|
346
|
+
order?: 'pre' | 'post';
|
|
345
347
|
}
|
|
346
348
|
declare function defineEnginePlugin(plugin: EnginePlugin): EnginePlugin;
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
}
|
|
349
|
+
//#endregion
|
|
350
|
+
//#region src/internal/types/shared.d.ts
|
|
351
|
+
interface PikaAugment {}
|
|
350
352
|
type PropertyValue = string | number | [value: string | number, fallback: (string | number)[]] | Nullish;
|
|
351
353
|
type Properties$1 = Record<string, PropertyValue>;
|
|
352
354
|
interface StyleDefinition$1 {
|
|
353
|
-
|
|
355
|
+
[K: string]: PropertyValue | StyleDefinition$1 | StyleItem$1[];
|
|
354
356
|
}
|
|
355
357
|
type StyleItem$1 = string | StyleDefinition$1;
|
|
356
358
|
interface ExtractedStyleContent {
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
359
|
+
selector: string[];
|
|
360
|
+
property: string;
|
|
361
|
+
value: string[] | Nullish;
|
|
360
362
|
}
|
|
361
363
|
interface StyleContent {
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
364
|
+
selector: string[];
|
|
365
|
+
property: string;
|
|
366
|
+
value: string[];
|
|
365
367
|
}
|
|
366
368
|
interface AtomicStyle {
|
|
367
|
-
|
|
368
|
-
|
|
369
|
+
id: string;
|
|
370
|
+
content: StyleContent;
|
|
369
371
|
}
|
|
370
372
|
interface CSSStyleBlockBody {
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
373
|
+
properties: {
|
|
374
|
+
property: string;
|
|
375
|
+
value: string;
|
|
376
|
+
}[];
|
|
377
|
+
children?: CSSStyleBlocks;
|
|
376
378
|
}
|
|
377
379
|
type CSSStyleBlocks = Map<string, CSSStyleBlockBody>;
|
|
378
|
-
|
|
380
|
+
//#endregion
|
|
381
|
+
//#region src/internal/types/resolved.d.ts
|
|
379
382
|
type ResolvedAutocomplete = ResolveFrom<PikaAugment, 'Autocomplete', _Autocomplete, EmptyAutocomplete>;
|
|
380
383
|
type ResolvedSelector = ResolveFrom<PikaAugment, 'Selector', string, string>;
|
|
381
384
|
type ResolvedProperties = ResolveFrom<PikaAugment, 'Properties', any, Properties$1>;
|
|
382
385
|
type ResolvedCSSProperties = Omit<ResolvedProperties, ResolvedAutocomplete['ExtraProperty']>;
|
|
383
386
|
type ResolvedStyleDefinition = ResolveFrom<PikaAugment, 'StyleDefinition', any, StyleDefinition$1>;
|
|
384
387
|
type ResolvedStyleItem = ResolveFrom<PikaAugment, 'StyleItem', any, StyleItem$1>;
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
};
|
|
388
|
+
//#endregion
|
|
389
|
+
//#region src/internal/types/preflight.d.ts
|
|
390
|
+
type PreflightDefinition = { [selector in UnionString | ResolvedSelector]?: ResolvedCSSProperties | PreflightDefinition };
|
|
389
391
|
type PreflightFn = (engine: Engine, isFormatted: boolean) => Awaitable<string | PreflightDefinition>;
|
|
390
392
|
/**
|
|
391
393
|
* PreflightConfig can be a string or a function that returns a string.
|
|
@@ -394,118 +396,122 @@ type PreflightFn = (engine: Engine, isFormatted: boolean) => Awaitable<string |
|
|
|
394
396
|
* 2. A function is a dynamic preflight style that can use the engine instance to generate styles.
|
|
395
397
|
*/
|
|
396
398
|
type Preflight = string | PreflightDefinition | PreflightFn;
|
|
397
|
-
|
|
399
|
+
//#endregion
|
|
400
|
+
//#region src/internal/types/engine.d.ts
|
|
398
401
|
interface EngineConfig {
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
402
|
+
/**
|
|
403
|
+
* Register plugins to extend PikaCSS functionality.
|
|
404
|
+
*
|
|
405
|
+
* @example
|
|
406
|
+
* ```ts
|
|
407
|
+
* {
|
|
408
|
+
* plugins: [
|
|
409
|
+
* icons(), // Add icon support
|
|
410
|
+
* customPlugin() // Custom plugin
|
|
411
|
+
* ]
|
|
412
|
+
* }
|
|
413
|
+
* ```
|
|
414
|
+
*/
|
|
415
|
+
plugins?: EnginePlugin[];
|
|
416
|
+
/**
|
|
417
|
+
* Set the prefix for generated atomic style id.
|
|
418
|
+
*
|
|
419
|
+
* @default ''
|
|
420
|
+
* @example
|
|
421
|
+
* ```ts
|
|
422
|
+
* {
|
|
423
|
+
* prefix: 'pika-' // Generated atomic id will be 'pika-xxx'
|
|
424
|
+
* }
|
|
425
|
+
* ```
|
|
426
|
+
*/
|
|
427
|
+
prefix?: string;
|
|
428
|
+
/**
|
|
429
|
+
* Set the default selector format. '%' will be replaced with the atomic style id.
|
|
430
|
+
*
|
|
431
|
+
* @default '.%'
|
|
432
|
+
* @example
|
|
433
|
+
* ```ts
|
|
434
|
+
* {
|
|
435
|
+
* defaultSelector: '.%' // Use with class attribute: <div class="a b c">
|
|
436
|
+
* // or
|
|
437
|
+
* defaultSelector: '[data-pika~="%"]' // Use with attribute selector: <div data-pika="a b c">
|
|
438
|
+
* }
|
|
439
|
+
* ```
|
|
440
|
+
*/
|
|
441
|
+
defaultSelector?: string;
|
|
442
|
+
/**
|
|
443
|
+
* Define global CSS styles that will be injected before atomic styles.
|
|
444
|
+
* Can be used for CSS variables, global animations, base styles, etc.
|
|
445
|
+
*
|
|
446
|
+
* @default []
|
|
447
|
+
* @example
|
|
448
|
+
* ```ts
|
|
449
|
+
* {
|
|
450
|
+
* preflights: [
|
|
451
|
+
* // Use CSS string directly
|
|
452
|
+
* ':root { --color: blue }',
|
|
453
|
+
* // Or use function to generate dynamically
|
|
454
|
+
* (engine) => ':root { --theme: dark }'
|
|
455
|
+
* ]
|
|
456
|
+
* }
|
|
457
|
+
* ```
|
|
458
|
+
*/
|
|
459
|
+
preflights?: Preflight[];
|
|
457
460
|
}
|
|
458
461
|
interface ResolvedEngineConfig {
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
}
|
|
466
|
-
|
|
462
|
+
rawConfig: EngineConfig;
|
|
463
|
+
prefix: string;
|
|
464
|
+
defaultSelector: string;
|
|
465
|
+
plugins: EnginePlugin[];
|
|
466
|
+
preflights: PreflightFn[];
|
|
467
|
+
autocomplete: ResolvedAutocompleteConfig;
|
|
468
|
+
}
|
|
469
|
+
//#endregion
|
|
470
|
+
//#region src/internal/extractor.d.ts
|
|
467
471
|
type ExtractFn = (styleDefinition: StyleDefinition$1) => Promise<ExtractedStyleContent[]>;
|
|
468
|
-
|
|
472
|
+
//#endregion
|
|
473
|
+
//#region src/internal/engine.d.ts
|
|
469
474
|
declare function defineEngineConfig(config: EngineConfig): EngineConfig;
|
|
470
475
|
declare function createEngine(config?: EngineConfig): Promise<Engine>;
|
|
471
476
|
declare class Engine {
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
}
|
|
508
|
-
|
|
477
|
+
config: ResolvedEngineConfig;
|
|
478
|
+
pluginHooks: {
|
|
479
|
+
configureRawConfig: (plugins: EnginePlugin[], payload: EngineConfig) => Promise<EngineConfig>;
|
|
480
|
+
rawConfigConfigured: (plugins: EnginePlugin[], payload: EngineConfig) => void;
|
|
481
|
+
configureResolvedConfig: (plugins: EnginePlugin[], payload: ResolvedEngineConfig) => Promise<ResolvedEngineConfig>;
|
|
482
|
+
configureEngine: (plugins: EnginePlugin[], payload: Engine) => Promise<Engine>;
|
|
483
|
+
transformSelectors: (plugins: EnginePlugin[], payload: string[]) => Promise<string[]>;
|
|
484
|
+
transformStyleItems: (plugins: EnginePlugin[], payload: StyleItem$1[]) => Promise<StyleItem$1[]>;
|
|
485
|
+
transformStyleDefinitions: (plugins: EnginePlugin[], payload: StyleDefinition$1[]) => Promise<StyleDefinition$1[]>;
|
|
486
|
+
preflightUpdated: (plugins: EnginePlugin[]) => void;
|
|
487
|
+
atomicStyleAdded: (plugins: EnginePlugin[], payload: AtomicStyle) => AtomicStyle;
|
|
488
|
+
autocompleteConfigUpdated: (plugins: EnginePlugin[]) => void;
|
|
489
|
+
};
|
|
490
|
+
extract: ExtractFn;
|
|
491
|
+
store: {
|
|
492
|
+
atomicStyleIds: Map<string, string>;
|
|
493
|
+
atomicStyles: Map<string, AtomicStyle>;
|
|
494
|
+
};
|
|
495
|
+
constructor(config: ResolvedEngineConfig);
|
|
496
|
+
notifyPreflightUpdated(): void;
|
|
497
|
+
notifyAtomicStyleAdded(atomicStyle: AtomicStyle): void;
|
|
498
|
+
notifyAutocompleteConfigUpdated(): void;
|
|
499
|
+
appendAutocompleteSelectors(...selectors: string[]): void;
|
|
500
|
+
appendAutocompleteStyleItemStrings(...styleItemStrings: string[]): void;
|
|
501
|
+
appendAutocompleteExtraProperties(...properties: string[]): void;
|
|
502
|
+
appendAutocompleteExtraCssProperties(...properties: string[]): void;
|
|
503
|
+
appendAutocompletePropertyValues(property: string, ...tsTypes: string[]): void;
|
|
504
|
+
appendAutocompleteCssPropertyValues(property: string, ...values: (string | number)[]): void;
|
|
505
|
+
addPreflight(preflight: Preflight): void;
|
|
506
|
+
use(...itemList: StyleItem$1[]): Promise<string[]>;
|
|
507
|
+
renderPreflights(isFormatted: boolean): Promise<string>;
|
|
508
|
+
renderAtomicStyles(isFormatted: boolean, options?: {
|
|
509
|
+
atomicStyleIds?: string[];
|
|
510
|
+
isPreview?: boolean;
|
|
511
|
+
}): Promise<string>;
|
|
512
|
+
}
|
|
513
|
+
//#endregion
|
|
514
|
+
//#region src/internal/utils.d.ts
|
|
509
515
|
declare function setWarnFn(fn: (...args: any[]) => void): void;
|
|
510
516
|
declare function warn(...args: any[]): void;
|
|
511
517
|
declare function appendAutocompleteSelectors(config: Pick<ResolvedEngineConfig, 'autocomplete'>, ...selectors: string[]): void;
|
|
@@ -515,25 +521,21 @@ declare function appendAutocompleteExtraCssProperties(config: Pick<ResolvedEngin
|
|
|
515
521
|
declare function appendAutocompletePropertyValues(config: Pick<ResolvedEngineConfig, 'autocomplete'>, property: string, ...tsTypes: string[]): void;
|
|
516
522
|
declare function appendAutocompleteCssPropertyValues(config: Pick<ResolvedEngineConfig, 'autocomplete'>, property: string, ...values: (string | number)[]): void;
|
|
517
523
|
declare function renderCSSStyleBlocks(blocks: CSSStyleBlocks, isFormatted: boolean, depth?: number): string;
|
|
518
|
-
|
|
524
|
+
//#endregion
|
|
525
|
+
//#region src/types.d.ts
|
|
519
526
|
interface CSSVariables {
|
|
520
|
-
|
|
521
|
-
}
|
|
522
|
-
interface CSSProperties extends CSS.Properties, CSS.PropertiesHyphen, CSSVariables {
|
|
527
|
+
[K: (`--${string}` & {})]: UnionString | UnionNumber;
|
|
523
528
|
}
|
|
529
|
+
interface CSSProperties extends CSS.Properties, CSS.PropertiesHyphen, CSSVariables {}
|
|
524
530
|
type CSSProperty = keyof CSSProperties;
|
|
525
|
-
type MakePropertyValue<T> = T | [value: T, fallback: T[]] | Nullish;
|
|
526
|
-
type Properties = {
|
|
527
|
-
[Key in keyof CSSProperties | ResolvedAutocomplete['ExtraCssProperty'] | ResolvedAutocomplete['ExtraProperty']]?: Key extends ResolvedAutocomplete['ExtraProperty'] ? GetValue<ResolvedAutocomplete['PropertiesValue'], Key> : MakePropertyValue<Exclude<UnionString | UnionNumber | GetValue<CSSProperties, Key> | GetValue<ResolvedAutocomplete['CssPropertiesValue'], ToKebab<Key>> | GetValue<ResolvedAutocomplete['CssPropertiesValue'], FromKebab<Key>> | GetValue<ResolvedAutocomplete['CssPropertiesValue'], '*'>, Nullish>>;
|
|
528
|
-
};
|
|
531
|
+
type MakePropertyValue<T$1> = T$1 | [value: T$1, fallback: T$1[]] | Nullish;
|
|
532
|
+
type Properties = { [Key in keyof CSSProperties | ResolvedAutocomplete['ExtraCssProperty'] | ResolvedAutocomplete['ExtraProperty']]?: Key extends ResolvedAutocomplete['ExtraProperty'] ? GetValue<ResolvedAutocomplete['PropertiesValue'], Key> : MakePropertyValue<Exclude<UnionString | UnionNumber | GetValue<CSSProperties, Key> | GetValue<ResolvedAutocomplete['CssPropertiesValue'], ToKebab<Key>> | GetValue<ResolvedAutocomplete['CssPropertiesValue'], FromKebab<Key>> | GetValue<ResolvedAutocomplete['CssPropertiesValue'], '*'>, Nullish>> };
|
|
529
533
|
type CSSPseudos = `${'$'}${CSS.Pseudos}`;
|
|
530
534
|
type CSSBlockAtRules = Exclude<CSS.AtRules, '@charset' | 'import' | '@namespace'>;
|
|
531
535
|
type CSSSelectors = CSSBlockAtRules | CSSPseudos;
|
|
532
|
-
type WrapWithSelector<T> = {
|
|
533
|
-
[S in UnionString | ResolvedAutocomplete['Selector'] | CSSSelectors]?: T | StyleItem[];
|
|
534
|
-
};
|
|
536
|
+
type WrapWithSelector<T$1> = { [S in UnionString | ResolvedAutocomplete['Selector'] | CSSSelectors]?: T$1 | StyleItem[] };
|
|
535
537
|
type MakeStyleDefinition<MaxDepth extends number, Tuple extends any[] = []> = Tuple['length'] extends MaxDepth ? Tuple[number] : Tuple['length'] extends 0 ? MakeStyleDefinition<MaxDepth, [Properties]> : MakeStyleDefinition<MaxDepth, [...Tuple, WrapWithSelector<[0, ...Tuple][Tuple['length']]>]>;
|
|
536
538
|
type StyleDefinition = MakeStyleDefinition<5>;
|
|
537
539
|
type StyleItem = UnionString | ResolvedAutocomplete['StyleItemString'] | StyleDefinition;
|
|
538
|
-
|
|
539
|
-
export {
|
|
540
|
+
//#endregion
|
|
541
|
+
export { Arrayable, Awaitable, type CSSProperty, type CSSSelectors, type CSSStyleBlockBody, type CSSStyleBlocks, type DefineAutocomplete, type Engine, type EngineConfig, type EnginePlugin, FromKebab, GetValue, IsEqual, IsNever, Nullish, type PikaAugment, type Properties, ResolveFrom, Simplify, type StyleDefinition, type StyleItem, ToKebab, UnionNumber, UnionString, UnionToIntersection, appendAutocompleteCssPropertyValues, appendAutocompleteExtraCssProperties, appendAutocompleteExtraProperties, appendAutocompletePropertyValues, appendAutocompleteSelectors, appendAutocompleteStyleItemStrings, createEngine, defineEngineConfig, defineEnginePlugin, renderCSSStyleBlocks, setWarnFn, warn };
|