@pikacss/core 0.0.39 → 0.0.40
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/README.md +146 -109
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +12 -14
- package/dist/index.d.mts +12 -14
- package/dist/index.mjs +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -10,39 +10,28 @@ pnpm add @pikacss/core
|
|
|
10
10
|
|
|
11
11
|
## Quick Start
|
|
12
12
|
|
|
13
|
-
**pika.config.ts**:
|
|
14
|
-
```typescript
|
|
15
|
-
import { defineEngineConfig } from '@pikacss/core'
|
|
16
|
-
|
|
17
|
-
export default defineEngineConfig({
|
|
18
|
-
// Your configuration
|
|
19
|
-
})
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
**Your code**:
|
|
23
13
|
```typescript
|
|
24
14
|
import { createEngine, defineEngineConfig } from '@pikacss/core'
|
|
25
15
|
|
|
26
16
|
const config = defineEngineConfig({
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
17
|
+
// Engine configuration
|
|
18
|
+
prefix: 'pk-',
|
|
19
|
+
defaultSelector: '.%',
|
|
20
|
+
plugins: []
|
|
31
21
|
})
|
|
32
22
|
|
|
33
|
-
|
|
34
|
-
await
|
|
23
|
+
// createEngine is async and returns a fully initialized engine
|
|
24
|
+
const engine = await createEngine(config)
|
|
35
25
|
```
|
|
36
26
|
|
|
37
27
|
## Features
|
|
38
28
|
|
|
39
29
|
- ⚡ High-performance Atomic CSS-in-JS engine
|
|
40
30
|
- 🎯 Type-safe with full TypeScript support
|
|
41
|
-
- 🔌 Extensible plugin system
|
|
42
|
-
- 🎨 Built-in support for shortcuts, selectors, variables, keyframes
|
|
43
|
-
-
|
|
44
|
-
-
|
|
45
|
-
- 🌐 Framework-agnostic core
|
|
31
|
+
- 🔌 Extensible plugin system with hooks
|
|
32
|
+
- 🎨 Built-in support for shortcuts, selectors, variables, keyframes, and important rules
|
|
33
|
+
- 🔧 Fully configurable with type-safe helpers
|
|
34
|
+
- 🌐 Framework-agnostic core (zero dependencies except csstype)
|
|
46
35
|
|
|
47
36
|
## Usage for Integration Developers
|
|
48
37
|
|
|
@@ -52,37 +41,52 @@ await engine.setup()
|
|
|
52
41
|
import { createEngine, defineEngineConfig } from '@pikacss/core'
|
|
53
42
|
|
|
54
43
|
const config = defineEngineConfig({
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
44
|
+
// Prefix for generated atomic CSS class names
|
|
45
|
+
prefix: 'pk-',
|
|
46
|
+
|
|
47
|
+
// Default selector format (% will be replaced with atomic ID)
|
|
48
|
+
defaultSelector: '.%',
|
|
49
|
+
|
|
50
|
+
// Plugins to extend functionality
|
|
51
|
+
plugins: [],
|
|
52
|
+
|
|
53
|
+
// Global CSS preflights
|
|
54
|
+
preflights: [],
|
|
66
55
|
})
|
|
67
56
|
|
|
68
|
-
|
|
69
|
-
await
|
|
57
|
+
// createEngine is async - it returns a fully initialized engine
|
|
58
|
+
const engine = await createEngine(config)
|
|
70
59
|
```
|
|
71
60
|
|
|
72
|
-
### Engine Methods
|
|
61
|
+
### Engine Methods and Properties
|
|
73
62
|
|
|
74
|
-
The
|
|
63
|
+
The `Engine` instance provides methods and sub-systems for managing CSS generation:
|
|
75
64
|
|
|
76
65
|
```typescript
|
|
77
|
-
// Add global CSS
|
|
66
|
+
// Add global CSS preflight
|
|
78
67
|
engine.addPreflight('* { box-sizing: border-box; }')
|
|
79
68
|
|
|
80
|
-
//
|
|
81
|
-
engine.
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
69
|
+
// Process style items and get atomic class IDs
|
|
70
|
+
const classNames = await engine.use({ color: 'red' }, { display: 'flex' })
|
|
71
|
+
|
|
72
|
+
// Render generated preflights
|
|
73
|
+
const preflightCSS = await engine.renderPreflights(true)
|
|
74
|
+
|
|
75
|
+
// Render generated atomic styles
|
|
76
|
+
const atomicCSS = await engine.renderAtomicStyles(true)
|
|
77
|
+
|
|
78
|
+
// Access sub-systems (provided by built-in plugins)
|
|
79
|
+
engine.variables // { store: Map, add: (variables) => void }
|
|
80
|
+
engine.keyframes // { store: Map, add: (...keyframes) => void }
|
|
81
|
+
engine.selectors // { resolver: SelectorResolver, add: (...selectors) => void }
|
|
82
|
+
engine.shortcuts // { resolver: ShortcutResolver, add: (...shortcuts) => void }
|
|
83
|
+
|
|
84
|
+
// Access configuration
|
|
85
|
+
engine.config // ResolvedEngineConfig
|
|
86
|
+
|
|
87
|
+
// Autocomplete helpers
|
|
88
|
+
engine.appendAutocompleteSelectors('hover', 'focus')
|
|
89
|
+
engine.appendAutocompleteStyleItemStrings('flex-center')
|
|
86
90
|
```
|
|
87
91
|
|
|
88
92
|
### Configuration
|
|
@@ -93,32 +97,32 @@ Use `defineEngineConfig` for type-safe configuration:
|
|
|
93
97
|
import { defineEngineConfig } from '@pikacss/core'
|
|
94
98
|
|
|
95
99
|
export default defineEngineConfig({
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
100
|
+
// Prefix for atomic class IDs
|
|
101
|
+
prefix: 'pk-',
|
|
102
|
+
|
|
103
|
+
// Default selector format (% = atomic ID)
|
|
104
|
+
defaultSelector: '.%',
|
|
105
|
+
|
|
106
|
+
// Global CSS preflights (string or function)
|
|
107
|
+
preflights: [
|
|
108
|
+
':root { --primary: #3b82f6; }',
|
|
109
|
+
// Or function:
|
|
110
|
+
(engine, isFormatted) => '/* Generated CSS */'
|
|
111
|
+
],
|
|
112
|
+
|
|
113
|
+
// Shortcuts configuration
|
|
114
|
+
shortcuts: {
|
|
115
|
+
shortcuts: [
|
|
116
|
+
['flex-center', {
|
|
117
|
+
display: 'flex',
|
|
118
|
+
alignItems: 'center',
|
|
119
|
+
justifyContent: 'center'
|
|
120
|
+
}],
|
|
121
|
+
]
|
|
122
|
+
},
|
|
123
|
+
|
|
124
|
+
// Plugins to extend functionality
|
|
125
|
+
plugins: []
|
|
122
126
|
})
|
|
123
127
|
```
|
|
124
128
|
|
|
@@ -127,8 +131,8 @@ export default defineEngineConfig({
|
|
|
127
131
|
### Main Exports
|
|
128
132
|
|
|
129
133
|
```typescript
|
|
130
|
-
// Engine creation
|
|
131
|
-
export function createEngine(config
|
|
134
|
+
// Engine creation (async)
|
|
135
|
+
export function createEngine(config?: EngineConfig): Promise<Engine>
|
|
132
136
|
|
|
133
137
|
// Type-safe config helpers
|
|
134
138
|
export function defineEngineConfig(config: EngineConfig): EngineConfig
|
|
@@ -141,54 +145,87 @@ export function defineShortcut(shortcut: Shortcut): Shortcut
|
|
|
141
145
|
export function defineVariables(variables: VariablesDefinition): VariablesDefinition
|
|
142
146
|
|
|
143
147
|
// Utilities
|
|
144
|
-
export {
|
|
148
|
+
export {
|
|
149
|
+
appendAutocompleteCssPropertyValues,
|
|
150
|
+
appendAutocompleteExtraCssProperties,
|
|
151
|
+
appendAutocompleteExtraProperties,
|
|
152
|
+
appendAutocompletePropertyValues,
|
|
153
|
+
appendAutocompleteSelectors,
|
|
154
|
+
appendAutocompleteStyleItemStrings,
|
|
155
|
+
createLogger,
|
|
156
|
+
log,
|
|
157
|
+
renderCSSStyleBlocks,
|
|
158
|
+
}
|
|
145
159
|
```
|
|
146
160
|
|
|
147
161
|
### Engine Instance
|
|
148
162
|
|
|
149
|
-
The `Engine` instance provides
|
|
163
|
+
The `Engine` instance provides:
|
|
164
|
+
|
|
165
|
+
**Core methods:**
|
|
166
|
+
- `engine.addPreflight(css)` - Add global CSS preflight
|
|
167
|
+
- `engine.use(...styleItems)` - Process style items and return atomic class IDs
|
|
168
|
+
- `engine.renderPreflights(isFormatted)` - Render all preflight CSS
|
|
169
|
+
- `engine.renderAtomicStyles(isFormatted, options?)` - Render atomic style CSS
|
|
170
|
+
|
|
171
|
+
**Sub-systems (provided by built-in plugins):**
|
|
172
|
+
- `engine.variables` - CSS variables management with `store` and `add()`
|
|
173
|
+
- `engine.keyframes` - CSS keyframes management with `store` and `add()`
|
|
174
|
+
- `engine.selectors` - CSS selectors management with `resolver` and `add()`
|
|
175
|
+
- `engine.shortcuts` - CSS shortcuts management with `resolver` and `add()`
|
|
150
176
|
|
|
151
|
-
|
|
152
|
-
- `engine.
|
|
153
|
-
- `engine.
|
|
154
|
-
- `engine.
|
|
155
|
-
- `engine.selectors` - Manage CSS selectors
|
|
156
|
-
- `engine.shortcuts` - Manage CSS shortcuts
|
|
157
|
-
- `engine.important` - Manage important rules
|
|
177
|
+
**Properties:**
|
|
178
|
+
- `engine.config` - Resolved engine configuration
|
|
179
|
+
- `engine.store` - Internal storage for atomic styles and IDs
|
|
180
|
+
- `engine.extract` - Style extraction function
|
|
158
181
|
|
|
159
182
|
## Plugin Development
|
|
160
183
|
|
|
161
|
-
Create custom plugins to extend PikaCSS:
|
|
184
|
+
Create custom plugins to extend PikaCSS using the `EnginePlugin` interface:
|
|
162
185
|
|
|
163
186
|
```typescript
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
187
|
+
/* eslint-disable pikacss/pika-module-augmentation */
|
|
188
|
+
import type { EnginePlugin } from '@pikacss/core'
|
|
189
|
+
import { defineEnginePlugin } from '@pikacss/core'
|
|
190
|
+
|
|
191
|
+
export function myPlugin(): EnginePlugin {
|
|
192
|
+
return defineEnginePlugin({
|
|
193
|
+
name: 'my-plugin',
|
|
194
|
+
|
|
195
|
+
// Optional: Control execution order ('pre' | 'post')
|
|
196
|
+
order: 'pre',
|
|
197
|
+
|
|
198
|
+
// Hook into engine lifecycle
|
|
199
|
+
async configureEngine(engine) {
|
|
200
|
+
// Add global CSS
|
|
201
|
+
engine.addPreflight('/* plugin styles */')
|
|
202
|
+
|
|
203
|
+
// Add custom shortcuts
|
|
204
|
+
engine.shortcuts.add([
|
|
205
|
+
'my-shortcut',
|
|
206
|
+
{ display: 'flex', gap: '1rem' }
|
|
207
|
+
])
|
|
208
|
+
|
|
209
|
+
// Add custom selectors
|
|
210
|
+
engine.selectors.add(['hover', '$:hover'])
|
|
211
|
+
},
|
|
212
|
+
|
|
213
|
+
// Transform style definitions
|
|
214
|
+
async transformStyleDefinitions(definitions) {
|
|
215
|
+
// Modify or add style definitions
|
|
216
|
+
return definitions
|
|
217
|
+
},
|
|
218
|
+
|
|
219
|
+
// Other available hooks:
|
|
220
|
+
// - configureRawConfig(config)
|
|
221
|
+
// - rawConfigConfigured(config)
|
|
222
|
+
// - configureResolvedConfig(config)
|
|
223
|
+
// - transformSelectors(selectors)
|
|
224
|
+
// - transformStyleItems(styleItems)
|
|
225
|
+
// - preflightUpdated()
|
|
226
|
+
// - atomicStyleAdded(atomicStyle)
|
|
227
|
+
// - autocompleteConfigUpdated()
|
|
228
|
+
})
|
|
192
229
|
}
|
|
193
230
|
```
|
|
194
231
|
|
package/dist/index.cjs
CHANGED
|
@@ -223,7 +223,7 @@ const hooks = {
|
|
|
223
223
|
transformStyleItems: (plugins, styleItems) => execAsyncHook(plugins, "transformStyleItems", styleItems),
|
|
224
224
|
transformStyleDefinitions: (plugins, styleDefinitions) => execAsyncHook(plugins, "transformStyleDefinitions", styleDefinitions),
|
|
225
225
|
preflightUpdated: (plugins) => execSyncHook(plugins, "preflightUpdated", void 0),
|
|
226
|
-
atomicStyleAdded: (plugins) => execSyncHook(plugins, "atomicStyleAdded",
|
|
226
|
+
atomicStyleAdded: (plugins, atomicStyle) => execSyncHook(plugins, "atomicStyleAdded", atomicStyle),
|
|
227
227
|
autocompleteConfigUpdated: (plugins) => execSyncHook(plugins, "autocompleteConfigUpdated", void 0)
|
|
228
228
|
};
|
|
229
229
|
const orderMap = new Map([
|
package/dist/index.d.cts
CHANGED
|
@@ -326,20 +326,18 @@ declare class Engine {
|
|
|
326
326
|
}
|
|
327
327
|
//#endregion
|
|
328
328
|
//#region src/internal/plugin.d.ts
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
}>;
|
|
342
|
-
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 };
|
|
329
|
+
interface EnginePluginHooksOptions {
|
|
330
|
+
configureRawConfig?: (config: EngineConfig$1) => Awaitable<EngineConfig$1 | void>;
|
|
331
|
+
rawConfigConfigured?: (config: EngineConfig$1) => void;
|
|
332
|
+
configureResolvedConfig?: (resolvedConfig: ResolvedEngineConfig) => Awaitable<ResolvedEngineConfig | void>;
|
|
333
|
+
configureEngine?: (engine: Engine) => Awaitable<void>;
|
|
334
|
+
transformSelectors?: (selectors: string[]) => Awaitable<string[] | void>;
|
|
335
|
+
transformStyleItems?: (styleItems: ResolvedStyleItem[]) => Awaitable<ResolvedStyleItem[] | void>;
|
|
336
|
+
transformStyleDefinitions?: (styleDefinitions: ResolvedStyleDefinition[]) => Awaitable<ResolvedStyleDefinition[] | void>;
|
|
337
|
+
preflightUpdated?: () => void;
|
|
338
|
+
atomicStyleAdded?: (atomicStyle: AtomicStyle) => void;
|
|
339
|
+
autocompleteConfigUpdated?: () => void;
|
|
340
|
+
}
|
|
343
341
|
interface EnginePlugin extends EnginePluginHooksOptions {
|
|
344
342
|
name: string;
|
|
345
343
|
order?: 'pre' | 'post';
|
package/dist/index.d.mts
CHANGED
|
@@ -326,20 +326,18 @@ declare class Engine {
|
|
|
326
326
|
}
|
|
327
327
|
//#endregion
|
|
328
328
|
//#region src/internal/plugin.d.ts
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
}>;
|
|
342
|
-
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 };
|
|
329
|
+
interface EnginePluginHooksOptions {
|
|
330
|
+
configureRawConfig?: (config: EngineConfig$1) => Awaitable<EngineConfig$1 | void>;
|
|
331
|
+
rawConfigConfigured?: (config: EngineConfig$1) => void;
|
|
332
|
+
configureResolvedConfig?: (resolvedConfig: ResolvedEngineConfig) => Awaitable<ResolvedEngineConfig | void>;
|
|
333
|
+
configureEngine?: (engine: Engine) => Awaitable<void>;
|
|
334
|
+
transformSelectors?: (selectors: string[]) => Awaitable<string[] | void>;
|
|
335
|
+
transformStyleItems?: (styleItems: ResolvedStyleItem[]) => Awaitable<ResolvedStyleItem[] | void>;
|
|
336
|
+
transformStyleDefinitions?: (styleDefinitions: ResolvedStyleDefinition[]) => Awaitable<ResolvedStyleDefinition[] | void>;
|
|
337
|
+
preflightUpdated?: () => void;
|
|
338
|
+
atomicStyleAdded?: (atomicStyle: AtomicStyle) => void;
|
|
339
|
+
autocompleteConfigUpdated?: () => void;
|
|
340
|
+
}
|
|
343
341
|
interface EnginePlugin extends EnginePluginHooksOptions {
|
|
344
342
|
name: string;
|
|
345
343
|
order?: 'pre' | 'post';
|
package/dist/index.mjs
CHANGED
|
@@ -222,7 +222,7 @@ const hooks = {
|
|
|
222
222
|
transformStyleItems: (plugins, styleItems) => execAsyncHook(plugins, "transformStyleItems", styleItems),
|
|
223
223
|
transformStyleDefinitions: (plugins, styleDefinitions) => execAsyncHook(plugins, "transformStyleDefinitions", styleDefinitions),
|
|
224
224
|
preflightUpdated: (plugins) => execSyncHook(plugins, "preflightUpdated", void 0),
|
|
225
|
-
atomicStyleAdded: (plugins) => execSyncHook(plugins, "atomicStyleAdded",
|
|
225
|
+
atomicStyleAdded: (plugins, atomicStyle) => execSyncHook(plugins, "atomicStyleAdded", atomicStyle),
|
|
226
226
|
autocompleteConfigUpdated: (plugins) => execSyncHook(plugins, "autocompleteConfigUpdated", void 0)
|
|
227
227
|
};
|
|
228
228
|
const orderMap = new Map([
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pikacss/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.40",
|
|
5
5
|
"author": "DevilTea <ch19980814@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "https://github.com/pikacss/pikacss.git",
|
|
9
|
+
"url": "https://github.com/pikacss/pikacss.github.io.git",
|
|
10
10
|
"directory": "packages/core"
|
|
11
11
|
},
|
|
12
12
|
"bugs": {
|
|
13
|
-
"url": "https://github.com/pikacss/pikacss/issues"
|
|
13
|
+
"url": "https://github.com/pikacss/pikacss.github.io/issues"
|
|
14
14
|
},
|
|
15
15
|
"keywords": [
|
|
16
16
|
"pikacss",
|