@pikacss/core 0.0.61 → 0.0.63
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 +881 -1023
- package/dist/index.mjs +1345 -591
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -30,126 +30,119 @@ declare module '@pikacss/core' {
|
|
|
30
30
|
*
|
|
31
31
|
* @returns An `EnginePlugin` that intercepts `transformStyleDefinitions` to conditionally append `!important` to every property value.
|
|
32
32
|
*
|
|
33
|
-
* @remarks When `EngineConfig.important.default` is `true`, all property values receive `!important` unless the style definition explicitly sets `__important: false`. Individual style definitions can also opt-in with `__important: true` regardless of the default. An explicit `__important` flag is propagated into nested selector blocks (which may override it with their own explicit flag).
|
|
33
|
+
* @remarks When `EngineConfig.important.default` is `true`, all property values receive `!important` unless the style definition explicitly sets `__important: false`. Individual style definitions can also opt-in with `__important: true` regardless of the default. An explicit `__important` flag is propagated into nested selector blocks (which may override it with their own explicit flag).
|
|
34
34
|
*
|
|
35
35
|
* @example
|
|
36
36
|
* ```ts
|
|
37
37
|
* createEngine({ plugins: [important()] })
|
|
38
38
|
* ```
|
|
39
39
|
*/
|
|
40
|
-
declare function important(): EnginePlugin
|
|
40
|
+
declare function important(): EnginePlugin<{
|
|
41
|
+
defaultValue: boolean;
|
|
42
|
+
}>;
|
|
41
43
|
//#endregion
|
|
42
44
|
//#region src/plugins/keyframes.d.ts
|
|
43
|
-
/**
|
|
44
|
-
* Describes the progress stops of a CSS `@keyframes` animation.
|
|
45
|
-
*
|
|
46
|
-
* @remarks Accepts the named stops `from` and `to`, plus any percentage-based stop in the form `"N%"`. Each stop maps to a set of CSS properties applied at that point in the animation.
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* ```ts
|
|
50
|
-
* const progress: KeyframesProgress = {
|
|
51
|
-
* from: { opacity: '0' },
|
|
52
|
-
* '50%': { opacity: '0.5' },
|
|
53
|
-
* to: { opacity: '1' },
|
|
54
|
-
* }
|
|
55
|
-
* ```
|
|
56
|
-
*/
|
|
45
|
+
/** Describes the progress stops of a CSS `@keyframes` animation. */
|
|
57
46
|
interface KeyframesProgress {
|
|
58
47
|
/**
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
* @default undefined
|
|
48
|
+
* Declarations at the beginning of the animation.
|
|
49
|
+
* @default `undefined`
|
|
62
50
|
*/
|
|
63
51
|
from?: ResolvedCSSProperties;
|
|
64
52
|
/**
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
* @default undefined
|
|
53
|
+
* Declarations at the end of the animation.
|
|
54
|
+
* @default `undefined`
|
|
68
55
|
*/
|
|
69
56
|
to?: ResolvedCSSProperties;
|
|
70
57
|
[K: `${number}%`]: ResolvedCSSProperties;
|
|
71
58
|
}
|
|
72
|
-
/**
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
* @remarks
|
|
76
|
-
* - **String**: registers the name for autocomplete without defining animation frames.
|
|
77
|
-
* - **Tuple `[name, frames?, autocomplete?, pruneUnused?]`**: concise shorthand.
|
|
78
|
-
* - **Object `{ name, frames?, autocomplete?, pruneUnused? }`**: explicit form.
|
|
79
|
-
*
|
|
80
|
-
* @example
|
|
81
|
-
* ```ts
|
|
82
|
-
* const kf: Keyframes[] = [
|
|
83
|
-
* 'spin',
|
|
84
|
-
* ['fade-in', { from: { opacity: '0' }, to: { opacity: '1' } }],
|
|
85
|
-
* ]
|
|
86
|
-
* ```
|
|
87
|
-
*/
|
|
88
|
-
type Keyframes = string | [name: string, frames?: KeyframesProgress, autocomplete?: string[], pruneUnused?: boolean] | {
|
|
59
|
+
/** Local keyframes emitted and optionally pruned by PikaCSS. */
|
|
60
|
+
interface LocalKeyframesDefinition {
|
|
61
|
+
/** Name used for the local `@keyframes` rule. */
|
|
89
62
|
name: string;
|
|
90
|
-
|
|
91
|
-
|
|
63
|
+
/** CSS declarations grouped by animation progress stop. */
|
|
64
|
+
frames: KeyframesProgress;
|
|
65
|
+
/**
|
|
66
|
+
* Additional values accepted for the `animation` property autocomplete.
|
|
67
|
+
* @default `[]`
|
|
68
|
+
*/
|
|
69
|
+
animationValues?: Arrayable<string>;
|
|
70
|
+
/**
|
|
71
|
+
* Documentation rendered for the generated Typegen keyframe member.
|
|
72
|
+
* @default `undefined`
|
|
73
|
+
*/
|
|
74
|
+
description?: string;
|
|
75
|
+
/**
|
|
76
|
+
* Whether this local keyframe is removed when no generated style uses it.
|
|
77
|
+
* @default `KeyframesConfig.pruneUnused`
|
|
78
|
+
*/
|
|
92
79
|
pruneUnused?: boolean;
|
|
93
|
-
};
|
|
94
|
-
/**
|
|
95
|
-
* Configuration object for the `keyframes` engine option.
|
|
96
|
-
*
|
|
97
|
-
* @remarks Passed via `EngineConfig.keyframes` to register `@keyframes` definitions at engine creation time.
|
|
98
|
-
*
|
|
99
|
-
* @example
|
|
100
|
-
* ```ts
|
|
101
|
-
* const config: KeyframesConfig = {
|
|
102
|
-
* definitions: [['spin', { from: { transform: 'rotate(0deg)' }, to: { transform: 'rotate(360deg)' } }]],
|
|
103
|
-
* pruneUnused: true,
|
|
104
|
-
* }
|
|
105
|
-
* ```
|
|
106
|
-
*/
|
|
107
|
-
interface KeyframesConfig {
|
|
108
|
-
/** Array of keyframes definitions to register. */
|
|
109
|
-
definitions: Keyframes[];
|
|
110
80
|
/**
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
* @default true
|
|
81
|
+
* Discriminator reserved for external keyframe definitions.
|
|
82
|
+
* @default `undefined`
|
|
114
83
|
*/
|
|
84
|
+
external?: never;
|
|
85
|
+
}
|
|
86
|
+
/** External keyframes known to authoring but never emitted/pruned by PikaCSS. */
|
|
87
|
+
interface ExternalKeyframesDefinition {
|
|
88
|
+
/** Name of an externally defined `@keyframes` rule. */
|
|
89
|
+
external: string;
|
|
90
|
+
/**
|
|
91
|
+
* Additional values accepted for the `animation` property autocomplete.
|
|
92
|
+
* @default `[]`
|
|
93
|
+
*/
|
|
94
|
+
animationValues?: Arrayable<string>;
|
|
95
|
+
/**
|
|
96
|
+
* Documentation rendered for the generated Typegen keyframe member.
|
|
97
|
+
* @default `undefined`
|
|
98
|
+
*/
|
|
99
|
+
description?: string;
|
|
100
|
+
/**
|
|
101
|
+
* Discriminator excluding local keyframe definitions.
|
|
102
|
+
* @default `undefined`
|
|
103
|
+
*/
|
|
104
|
+
name?: never;
|
|
105
|
+
/**
|
|
106
|
+
* Discriminator excluding local keyframe definitions.
|
|
107
|
+
* @default `undefined`
|
|
108
|
+
*/
|
|
109
|
+
frames?: never;
|
|
110
|
+
/**
|
|
111
|
+
* External keyframes are never pruned by PikaCSS.
|
|
112
|
+
* @default `undefined`
|
|
113
|
+
*/
|
|
114
|
+
pruneUnused?: never;
|
|
115
|
+
}
|
|
116
|
+
/** Canonical object-only keyframes definition. */
|
|
117
|
+
type Keyframes = LocalKeyframesDefinition | ExternalKeyframesDefinition;
|
|
118
|
+
/** Configuration for the built-in keyframes subsystem. */
|
|
119
|
+
interface KeyframesConfig {
|
|
120
|
+
/** Local and external keyframe definitions available to the engine. */
|
|
121
|
+
definitions: Keyframes[];
|
|
122
|
+
/** Default pruning policy for local keyframes. @default true */
|
|
115
123
|
pruneUnused?: boolean;
|
|
116
124
|
}
|
|
117
125
|
declare module '@pikacss/core' {
|
|
118
126
|
interface EngineConfig {
|
|
119
|
-
/**
|
|
120
|
-
* Keyframes definitions configuration.
|
|
121
|
-
*
|
|
122
|
-
* @default undefined
|
|
123
|
-
*/
|
|
127
|
+
/** Keyframe definitions consumed once during Engine initialization. */
|
|
124
128
|
keyframes?: KeyframesConfig;
|
|
125
129
|
}
|
|
126
|
-
interface Engine {
|
|
127
|
-
/** Runtime keyframes management: resolved keyframes store and `add` method for registering keyframes after engine creation. */
|
|
128
|
-
keyframes: {
|
|
129
|
-
store: Map<string, ResolvedKeyframesConfig>;
|
|
130
|
-
add: (...list: Keyframes[]) => void;
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
130
|
}
|
|
134
|
-
/**
|
|
135
|
-
* Built-in engine plugin that provides CSS `@keyframes` registration, autocomplete integration, and smart pruning.
|
|
136
|
-
*
|
|
137
|
-
* @returns An `EnginePlugin` that registers keyframes definitions, wires up `animationName`/`animation` autocomplete entries, and emits a preflight containing only the `@keyframes` rules actually referenced by atomic styles.
|
|
138
|
-
*
|
|
139
|
-
* @remarks Reads `EngineConfig.keyframes` during `rawConfigConfigured` and attaches the `engine.keyframes` management interface during `configureEngine`. Unused keyframes are pruned from the output unless `pruneUnused: false` is set on the individual definition or globally.
|
|
140
|
-
*
|
|
141
|
-
* @example
|
|
142
|
-
* ```ts
|
|
143
|
-
* createEngine({ plugins: [keyframes()] })
|
|
144
|
-
* ```
|
|
145
|
-
*/
|
|
146
|
-
declare function keyframes(): EnginePlugin;
|
|
147
131
|
interface ResolvedKeyframesConfig {
|
|
148
132
|
name: string;
|
|
149
|
-
frames
|
|
133
|
+
frames?: KeyframesProgress;
|
|
150
134
|
pruneUnused: boolean;
|
|
151
|
-
|
|
135
|
+
animationValues: string[];
|
|
136
|
+
description?: string;
|
|
137
|
+
external: boolean;
|
|
152
138
|
}
|
|
139
|
+
interface KeyframesState {
|
|
140
|
+
definitions: Keyframes[];
|
|
141
|
+
defaultPruneUnused: boolean;
|
|
142
|
+
store: Map<string, ResolvedKeyframesConfig>;
|
|
143
|
+
}
|
|
144
|
+
/** Built-in keyframes subsystem with config-only semantic ingress. */
|
|
145
|
+
declare function keyframes(): EnginePlugin<KeyframesState>;
|
|
153
146
|
//#endregion
|
|
154
147
|
//#region src/diagnostics.d.ts
|
|
155
148
|
/** Severity of a PikaCSS diagnostic. */
|
|
@@ -176,6 +169,51 @@ interface Diagnostic {
|
|
|
176
169
|
}
|
|
177
170
|
/** Callback used by a host to receive structured diagnostics. */
|
|
178
171
|
type DiagnosticHandler = (diagnostic: Diagnostic) => void;
|
|
172
|
+
/**
|
|
173
|
+
* Host semantic metadata for one engine, supplied by the integration/bundler
|
|
174
|
+
* host and transported — never interpreted — by the platform-neutral core.
|
|
175
|
+
*
|
|
176
|
+
* @remarks
|
|
177
|
+
* The host (Vite adapter, Nuxt module, a programmatic caller) is the
|
|
178
|
+
* authority for these values. Plugins consume them through
|
|
179
|
+
* `context.host` so project-relative resources resolve against the same
|
|
180
|
+
* effective PikaCSS project root as config discovery, scans, and generated
|
|
181
|
+
* artifacts — never against `process.cwd()` once a host supplied a more
|
|
182
|
+
* specific root (#118). Core adds no filesystem, path, or bundler APIs here.
|
|
183
|
+
*/
|
|
184
|
+
interface EngineHostContext {
|
|
185
|
+
/**
|
|
186
|
+
* The effective PikaCSS project root for this engine (e.g. Vite's
|
|
187
|
+
* `config.root`, Nuxt's `rootDir`). Absent for standalone `createEngine()`
|
|
188
|
+
* callers that supply no host context.
|
|
189
|
+
*/
|
|
190
|
+
readonly projectRoot?: string;
|
|
191
|
+
/**
|
|
192
|
+
* Opaque discriminator for PikaCSS-private generated CSS identities.
|
|
193
|
+
*
|
|
194
|
+
* @remarks Core transports this value without interpreting it. Subsystems
|
|
195
|
+
* and plugins that own private generated CSS names may consume it through
|
|
196
|
+
* `context.host`.
|
|
197
|
+
*/
|
|
198
|
+
readonly privateCssDiscriminator?: string;
|
|
199
|
+
}
|
|
200
|
+
/** Context supplied when allocating a genuinely new atomic style ID. */
|
|
201
|
+
interface AtomicStyleIdContext {
|
|
202
|
+
/** Zero-based engine-local allocation index. */
|
|
203
|
+
readonly index: number;
|
|
204
|
+
/** Resolved atomic style ID prefix. */
|
|
205
|
+
readonly prefix: string;
|
|
206
|
+
}
|
|
207
|
+
/** Strategy used by Core to allocate a genuinely new atomic style ID. */
|
|
208
|
+
type AtomicStyleIdStrategy = (context: AtomicStyleIdContext) => string;
|
|
209
|
+
/** Finalized external dependency descriptor for one Engine. */
|
|
210
|
+
type EngineConfigDependency = Readonly<{
|
|
211
|
+
type: 'file';
|
|
212
|
+
path: string;
|
|
213
|
+
}> | Readonly<{
|
|
214
|
+
type: 'directory-membership';
|
|
215
|
+
path: string;
|
|
216
|
+
}>;
|
|
179
217
|
/** Runtime-only options accepted by {@link createEngine}. */
|
|
180
218
|
interface CreateEngineOptions {
|
|
181
219
|
/**
|
|
@@ -183,12 +221,55 @@ interface CreateEngineOptions {
|
|
|
183
221
|
*
|
|
184
222
|
* @default A no-op handler.
|
|
185
223
|
*/
|
|
186
|
-
onDiagnostic?: DiagnosticHandler;
|
|
224
|
+
readonly onDiagnostic?: DiagnosticHandler;
|
|
225
|
+
/**
|
|
226
|
+
* Host semantic metadata for this engine (e.g. the effective project
|
|
227
|
+
* root). Exposed to plugins as `context.host`.
|
|
228
|
+
*
|
|
229
|
+
* @default An empty context.
|
|
230
|
+
*/
|
|
231
|
+
readonly host?: EngineHostContext;
|
|
232
|
+
/**
|
|
233
|
+
* Overrides atomic-style ID allocation for host integrations.
|
|
234
|
+
*
|
|
235
|
+
* @internal
|
|
236
|
+
*/
|
|
237
|
+
readonly atomicStyleIdStrategy?: AtomicStyleIdStrategy;
|
|
238
|
+
/**
|
|
239
|
+
* Receives each genuinely-new config dependency while the Engine is still
|
|
240
|
+
* initializing, including registrations made before a later initialization
|
|
241
|
+
* failure. Hosts use this only to preserve recovery metadata.
|
|
242
|
+
*
|
|
243
|
+
* @internal
|
|
244
|
+
*/
|
|
245
|
+
readonly onConfigDependency?: (dependency: EngineConfigDependency) => void;
|
|
187
246
|
}
|
|
188
|
-
/**
|
|
189
|
-
|
|
247
|
+
/**
|
|
248
|
+
* Context passed to plugin hooks by the engine.
|
|
249
|
+
*
|
|
250
|
+
* @remarks
|
|
251
|
+
* One context object exists per plugin definition **per engine** (#116): the
|
|
252
|
+
* same object is passed to every hook invocation of that plugin/engine pair,
|
|
253
|
+
* from `configureRawConfig` through committed notifications. Long-lived
|
|
254
|
+
* callbacks a plugin registers (shortcut resolvers, preflight functions,
|
|
255
|
+
* engine service methods) should close over this context — never over mutable
|
|
256
|
+
* plugin-factory closure variables, which are shared across every engine
|
|
257
|
+
* reusing the definition.
|
|
258
|
+
*/
|
|
259
|
+
interface EnginePluginContext<State = void> {
|
|
190
260
|
/** Instance-scoped diagnostic handler. */
|
|
191
261
|
onDiagnostic: DiagnosticHandler;
|
|
262
|
+
/**
|
|
263
|
+
* Engine-local plugin state, created once per plugin/engine pair by the
|
|
264
|
+
* plugin's `createState()` initializer. `undefined` (typed `void`) for
|
|
265
|
+
* stateless plugins that omit the initializer.
|
|
266
|
+
*/
|
|
267
|
+
state: State;
|
|
268
|
+
/**
|
|
269
|
+
* Host semantic metadata for this engine (#118). Read-only from a
|
|
270
|
+
* plugin's perspective; empty when no host context was supplied.
|
|
271
|
+
*/
|
|
272
|
+
readonly host: EngineHostContext;
|
|
192
273
|
}
|
|
193
274
|
//#endregion
|
|
194
275
|
//#region src/resolver.d.ts
|
|
@@ -414,23 +495,7 @@ declare abstract class RecursiveResolver<T> extends AbstractResolver<T[]> {
|
|
|
414
495
|
*/
|
|
415
496
|
resolve(string: string, _visited?: Set<string>): Promise<T[]>;
|
|
416
497
|
}
|
|
417
|
-
/**
|
|
418
|
-
* Discriminated union describing a resolved rule configuration, either static or dynamic.
|
|
419
|
-
* @internal
|
|
420
|
-
*
|
|
421
|
-
* @typeParam T - The element type of the rule's resolved value array.
|
|
422
|
-
*
|
|
423
|
-
* @remarks Produced by `resolveRuleConfig` from user-supplied shorthand configurations. The `autocomplete` array feeds the autocomplete type surface so IDE completions stay in sync with runtime rules.
|
|
424
|
-
*
|
|
425
|
-
* @example
|
|
426
|
-
* ```ts
|
|
427
|
-
* const config: ResolvedRuleConfig<string> = {
|
|
428
|
-
* type: 'static',
|
|
429
|
-
* rule: { key: 'hover', string: 'hover', resolved: ['$:hover'] },
|
|
430
|
-
* autocomplete: ['hover'],
|
|
431
|
-
* }
|
|
432
|
-
* ```
|
|
433
|
-
*/
|
|
498
|
+
/** Discriminated normalized rule used by selector/shortcut private registries. */
|
|
434
499
|
type ResolvedRuleConfig<T> = {
|
|
435
500
|
type: 'static';
|
|
436
501
|
rule: StaticRule<T[]>;
|
|
@@ -442,324 +507,243 @@ type ResolvedRuleConfig<T> = {
|
|
|
442
507
|
};
|
|
443
508
|
//#endregion
|
|
444
509
|
//#region src/plugins/selectors.d.ts
|
|
445
|
-
/**
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
* - **Tuple `[string, value]`**: a static rule mapping an exact selector name to one or more resolved CSS selectors.
|
|
451
|
-
* - **Tuple `[RegExp, fn, autocomplete?]`**: a dynamic rule matching a pattern and lazily computing resolved CSS selectors.
|
|
452
|
-
* - **Object `{ selector, value, autocomplete? }`**: an explicit form of either static or dynamic rule.
|
|
453
|
-
*
|
|
454
|
-
* A dynamic rule's value function may return `undefined`/`null` to signal a retryable-unresolved result: nothing is cached and the rule is re-invoked on a later resolve call (e.g. after a transient failure).
|
|
455
|
-
*
|
|
456
|
-
* @example
|
|
457
|
-
* ```ts
|
|
458
|
-
* const rules: Selector[] = [
|
|
459
|
-
* ['hover', '$:hover'],
|
|
460
|
-
* [/^media-(\d+)$/, m => `@media (min-width: ${m[1]}px)`, 'media-${breakpoint}'],
|
|
461
|
-
* ]
|
|
462
|
-
* ```
|
|
463
|
-
*/
|
|
464
|
-
type Selector = string | [selector: RegExp, value: (matched: RegExpMatchArray) => Awaitable<Arrayable<UnionString | ResolvedSelector> | Nullish>, autocomplete?: Arrayable<string>] | [selector: string, value: Arrayable<UnionString | ResolvedSelector>] | {
|
|
465
|
-
selector: RegExp;
|
|
466
|
-
value: (matched: RegExpMatchArray) => Awaitable<Arrayable<UnionString | ResolvedSelector> | Nullish>;
|
|
467
|
-
autocomplete?: Arrayable<string>;
|
|
468
|
-
} | {
|
|
469
|
-
selector: string;
|
|
510
|
+
/** Static selector definition in the frozen object-only authoring grammar. */
|
|
511
|
+
interface StaticSelector {
|
|
512
|
+
/** Name used to reference the selector in a style definition. */
|
|
513
|
+
name: string;
|
|
514
|
+
/** Selector or selectors emitted when the named selector is resolved. */
|
|
470
515
|
value: Arrayable<UnionString | ResolvedSelector>;
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
*/
|
|
516
|
+
/**
|
|
517
|
+
* Documentation rendered for the generated Typegen selector member.
|
|
518
|
+
* @default `undefined`
|
|
519
|
+
*/
|
|
520
|
+
description?: string;
|
|
521
|
+
}
|
|
522
|
+
/** Dynamic selector definition with separate runtime and TypeScript input contracts. */
|
|
523
|
+
interface DynamicSelector {
|
|
524
|
+
/** Pattern matched against a selector reference. */
|
|
525
|
+
pattern: RegExp;
|
|
526
|
+
/** TypeScript input expression for selector references handled by this rule. */
|
|
527
|
+
inputType: string;
|
|
528
|
+
/** Resolves a matched selector reference to one or more CSS selectors. */
|
|
529
|
+
resolve: (matched: RegExpMatchArray) => Awaitable<Arrayable<UnionString | ResolvedSelector> | Nullish>;
|
|
530
|
+
/**
|
|
531
|
+
* Concrete selector references offered in Typegen autocomplete.
|
|
532
|
+
* @default `[]`
|
|
533
|
+
*/
|
|
534
|
+
autocomplete?: Arrayable<string>;
|
|
535
|
+
/**
|
|
536
|
+
* Documentation rendered for generated Typegen selector members.
|
|
537
|
+
* @default `undefined`
|
|
538
|
+
*/
|
|
539
|
+
description?: string;
|
|
540
|
+
}
|
|
541
|
+
/** User-facing selector definition. Tuple/string shorthand forms are intentionally unsupported. */
|
|
542
|
+
type Selector = StaticSelector | DynamicSelector;
|
|
543
|
+
/** Configuration for the built-in selector subsystem. */
|
|
484
544
|
interface SelectorsConfig {
|
|
485
|
-
/**
|
|
545
|
+
/** Static and dynamic selector definitions available to the engine. */
|
|
486
546
|
definitions: Selector[];
|
|
487
547
|
}
|
|
488
548
|
declare module '@pikacss/core' {
|
|
489
549
|
interface EngineConfig {
|
|
490
|
-
/**
|
|
491
|
-
* Selector rules configuration.
|
|
492
|
-
*
|
|
493
|
-
* @default undefined
|
|
494
|
-
*/
|
|
550
|
+
/** Selector definitions consumed once during Engine initialization. */
|
|
495
551
|
selectors?: SelectorsConfig;
|
|
496
552
|
}
|
|
497
|
-
interface Engine {
|
|
498
|
-
/** Runtime selector management: resolver instance and `add` method for registering selectors after engine creation. */
|
|
499
|
-
selectors: {
|
|
500
|
-
resolver: SelectorResolver;
|
|
501
|
-
add: (...list: Selector[]) => void;
|
|
502
|
-
};
|
|
503
|
-
}
|
|
504
553
|
}
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
*
|
|
512
|
-
* @example
|
|
513
|
-
* ```ts
|
|
514
|
-
* createEngine({ plugins: [selectors()] })
|
|
515
|
-
* ```
|
|
516
|
-
*/
|
|
517
|
-
declare function selectors$1(): EnginePlugin;
|
|
554
|
+
interface SelectorsState {
|
|
555
|
+
definitions: Selector[];
|
|
556
|
+
resolver?: SelectorResolver;
|
|
557
|
+
}
|
|
558
|
+
/** Built-in selector subsystem. Effective raw config is its only semantic ingress. */
|
|
559
|
+
declare function selectors$1(): EnginePlugin<SelectorsState>;
|
|
518
560
|
declare class SelectorResolver extends RecursiveResolver<string> {}
|
|
519
|
-
/**
|
|
520
|
-
|
|
521
|
-
*
|
|
522
|
-
* @param config - The selector rule configuration to resolve.
|
|
523
|
-
* @returns A resolved static/dynamic rule config, a redirect string, or `undefined` if the shape is unrecognized.
|
|
524
|
-
*
|
|
525
|
-
* @remarks Delegates to the generic `resolveRuleConfig` with `'selector'` as the key name.
|
|
526
|
-
*
|
|
527
|
-
* @example
|
|
528
|
-
* ```ts
|
|
529
|
-
* const resolved = resolveSelectorConfig(['hover', '$:hover'])
|
|
530
|
-
* ```
|
|
531
|
-
*/
|
|
532
|
-
declare function resolveSelectorConfig(config: Selector): string | Nullish | ResolvedRuleConfig<string>;
|
|
561
|
+
/** @internal */
|
|
562
|
+
declare function resolveSelectorConfig(config: Selector): Nullish | ResolvedRuleConfig<string>;
|
|
533
563
|
//#endregion
|
|
534
564
|
//#region src/plugins/shortcuts.d.ts
|
|
535
|
-
/**
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
* @example
|
|
541
|
-
* ```ts
|
|
542
|
-
* const rules: Shortcut[] = [
|
|
543
|
-
* ['btn', [{ padding: '0.5rem 1rem' }, { borderRadius: '0.25rem' }]],
|
|
544
|
-
* [/^btn-(.+)$/, m => ({ backgroundColor: m[1] }), 'btn-${color}'],
|
|
545
|
-
* ]
|
|
546
|
-
* ```
|
|
547
|
-
*/
|
|
548
|
-
type Shortcut = string | [shortcut: RegExp, value: (matched: RegExpMatchArray) => Awaitable<Arrayable<ResolvedStyleItem> | Nullish>, autocomplete?: Arrayable<string>] | {
|
|
549
|
-
shortcut: RegExp;
|
|
550
|
-
value: (matched: RegExpMatchArray) => Awaitable<Arrayable<ResolvedStyleItem> | Nullish>;
|
|
551
|
-
autocomplete?: Arrayable<string>;
|
|
552
|
-
} | [shortcut: string, value: Arrayable<ResolvedStyleItem>] | {
|
|
553
|
-
shortcut: string;
|
|
565
|
+
/** Static shortcut definition in the frozen object-only authoring grammar. */
|
|
566
|
+
interface StaticShortcut {
|
|
567
|
+
/** Name used to reference the shortcut in a `pika()` call. */
|
|
568
|
+
name: string;
|
|
569
|
+
/** Style items expanded when the named shortcut is resolved. */
|
|
554
570
|
value: Arrayable<ResolvedStyleItem>;
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
571
|
+
/**
|
|
572
|
+
* Documentation rendered for the generated Typegen shortcut member.
|
|
573
|
+
* @default `undefined`
|
|
574
|
+
*/
|
|
575
|
+
description?: string;
|
|
576
|
+
}
|
|
577
|
+
/** Path-free image metadata collected only while Core finalizes rich shortcut previews. */
|
|
578
|
+
interface ShortcutPreviewImage {
|
|
579
|
+
/** Raw image bytes or text content supplied by the resolver. */
|
|
580
|
+
readonly content: string;
|
|
581
|
+
/** MIME type describing `content`. */
|
|
582
|
+
readonly mediaType: string;
|
|
583
|
+
/**
|
|
584
|
+
* Optional alternative text for the generated Markdown preview image.
|
|
585
|
+
* @default `undefined`
|
|
586
|
+
*/
|
|
587
|
+
readonly alt?: string;
|
|
588
|
+
}
|
|
589
|
+
/** Documentation-only collector supplied to dynamic shortcut resolution during Typegen preview. */
|
|
590
|
+
interface ShortcutPreviewCollector {
|
|
591
|
+
/** Registers one path-free image for the shortcut's generated preview. */
|
|
592
|
+
image: (image: ShortcutPreviewImage) => void;
|
|
593
|
+
}
|
|
594
|
+
/** Optional resolution context. Runtime resolution omits it; Typegen preview supplies it. */
|
|
595
|
+
interface ShortcutResolutionContext {
|
|
596
|
+
/**
|
|
597
|
+
* Preview-only collector; absent during ordinary runtime resolution.
|
|
598
|
+
* @default `undefined`
|
|
599
|
+
*/
|
|
600
|
+
readonly preview?: ShortcutPreviewCollector;
|
|
601
|
+
}
|
|
602
|
+
/** Dynamic shortcut definition with separate runtime and TypeScript input contracts. */
|
|
603
|
+
interface DynamicShortcut {
|
|
604
|
+
/** Pattern matched against a shortcut reference. */
|
|
605
|
+
pattern: RegExp;
|
|
606
|
+
/** TypeScript input expression for shortcut references handled by this rule. */
|
|
607
|
+
inputType: string;
|
|
608
|
+
/** Resolves a matched shortcut reference to one or more style items. */
|
|
609
|
+
resolve: (matched: RegExpMatchArray, context?: ShortcutResolutionContext) => Awaitable<Arrayable<ResolvedStyleItem> | Nullish>;
|
|
610
|
+
/**
|
|
611
|
+
* Concrete shortcut references offered in Typegen autocomplete.
|
|
612
|
+
* @default `[]`
|
|
613
|
+
*/
|
|
614
|
+
autocomplete?: Arrayable<string>;
|
|
615
|
+
/**
|
|
616
|
+
* Documentation rendered for generated Typegen shortcut members.
|
|
617
|
+
* @default `undefined`
|
|
618
|
+
*/
|
|
619
|
+
description?: string;
|
|
620
|
+
}
|
|
621
|
+
/** User-facing shortcut definition. Tuple/string shorthand forms are intentionally unsupported. */
|
|
622
|
+
type Shortcut = StaticShortcut | DynamicShortcut;
|
|
623
|
+
/** Configuration for the built-in shortcut subsystem. */
|
|
568
624
|
interface ShortcutsConfig {
|
|
569
|
-
/**
|
|
625
|
+
/** Static and dynamic shortcut definitions available to the engine. */
|
|
570
626
|
definitions: Shortcut[];
|
|
571
627
|
}
|
|
572
628
|
declare module '@pikacss/core' {
|
|
573
629
|
interface EngineConfig {
|
|
574
|
-
/**
|
|
575
|
-
* Shortcut rules configuration.
|
|
576
|
-
*
|
|
577
|
-
* @default undefined
|
|
578
|
-
*/
|
|
630
|
+
/** Shortcut definitions consumed once during Engine initialization. */
|
|
579
631
|
shortcuts?: ShortcutsConfig;
|
|
580
632
|
}
|
|
581
|
-
interface Engine {
|
|
582
|
-
/** Runtime shortcut management: resolver instance and `add` method for registering shortcuts after engine creation. */
|
|
583
|
-
shortcuts: {
|
|
584
|
-
resolver: ShortcutResolver;
|
|
585
|
-
add: (...list: Shortcut[]) => void;
|
|
586
|
-
};
|
|
587
|
-
}
|
|
588
633
|
}
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
*
|
|
596
|
-
* @example
|
|
597
|
-
* ```ts
|
|
598
|
-
* createEngine({ plugins: [shortcuts()] })
|
|
599
|
-
* ```
|
|
600
|
-
*/
|
|
601
|
-
declare function shortcuts(): EnginePlugin;
|
|
634
|
+
interface ShortcutsState {
|
|
635
|
+
definitions: Shortcut[];
|
|
636
|
+
resolver?: ShortcutResolver;
|
|
637
|
+
}
|
|
638
|
+
/** Built-in shortcut subsystem. Effective raw config is its only semantic ingress. */
|
|
639
|
+
declare function shortcuts(): EnginePlugin<ShortcutsState>;
|
|
602
640
|
declare class ShortcutResolver extends RecursiveResolver<InternalStyleItem> {}
|
|
641
|
+
/** @internal */
|
|
642
|
+
declare function resolveShortcutConfig(config: Shortcut): Nullish | ResolvedRuleConfig<StyleItem>;
|
|
603
643
|
//#endregion
|
|
604
644
|
//#region src/plugins/variables.d.ts
|
|
605
|
-
type ResolvedCSSProperty = keyof ResolvedCSSProperties;
|
|
606
|
-
/**
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
*
|
|
611
|
-
*
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
*/
|
|
616
|
-
|
|
645
|
+
type ResolvedCSSProperty = keyof ResolvedCSSProperties & string;
|
|
646
|
+
/** Domain-local suggestion metadata for one CSS variable. */
|
|
647
|
+
interface VariableSuggest {
|
|
648
|
+
/** Whether the custom property itself is emitted as an explicit Typegen property symbol. @default true */
|
|
649
|
+
asProperty?: boolean;
|
|
650
|
+
/** CSS properties for which `var(--name)` is suggested; `'*'` is an explicit wildcard. @default false */
|
|
651
|
+
asValueOf?: Arrayable<'*' | ResolvedCSSProperty> | false;
|
|
652
|
+
}
|
|
653
|
+
/** Local CSS variable leaf emitted and optionally pruned by PikaCSS. */
|
|
654
|
+
interface LocalVariable {
|
|
655
|
+
/** Value emitted for the custom property. */
|
|
656
|
+
value: ResolvedCSSProperties[`--${string}`];
|
|
617
657
|
/**
|
|
618
|
-
*
|
|
619
|
-
*
|
|
620
|
-
* @default undefined (`'*'` when unset)
|
|
658
|
+
* Controls Typegen suggestions for this variable.
|
|
659
|
+
* @default `{ asProperty: true, asValueOf: false }`
|
|
621
660
|
*/
|
|
622
|
-
|
|
661
|
+
suggest?: VariableSuggest;
|
|
623
662
|
/**
|
|
624
|
-
*
|
|
625
|
-
*
|
|
626
|
-
* @default true
|
|
663
|
+
* Documentation rendered for the generated Typegen variable member.
|
|
664
|
+
* @default `undefined`
|
|
627
665
|
*/
|
|
628
|
-
|
|
666
|
+
description?: string;
|
|
667
|
+
/**
|
|
668
|
+
* Whether this variable is removed when no generated style uses it.
|
|
669
|
+
* @default `VariablesConfig.pruneUnused`
|
|
670
|
+
*/
|
|
671
|
+
pruneUnused?: boolean;
|
|
672
|
+
/**
|
|
673
|
+
* Discriminator reserved for external variable definitions.
|
|
674
|
+
* @default `undefined`
|
|
675
|
+
*/
|
|
676
|
+
external?: never;
|
|
629
677
|
}
|
|
630
|
-
/**
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
*
|
|
635
|
-
* @example
|
|
636
|
-
* ```ts
|
|
637
|
-
* const v: VariableObject = {
|
|
638
|
-
* value: '#3b82f6',
|
|
639
|
-
* autocomplete: { asValueOf: '*' },
|
|
640
|
-
* pruneUnused: false,
|
|
641
|
-
* }
|
|
642
|
-
* ```
|
|
643
|
-
*/
|
|
644
|
-
interface VariableObject {
|
|
678
|
+
/** External CSS variable leaf known to authoring but not emitted by PikaCSS. */
|
|
679
|
+
interface ExternalVariable {
|
|
680
|
+
/** Marks a variable as defined outside the generated stylesheet. */
|
|
681
|
+
external: true;
|
|
645
682
|
/**
|
|
646
|
-
*
|
|
647
|
-
*
|
|
648
|
-
* @default undefined (variable is registered for autocomplete only, no value emitted)
|
|
683
|
+
* Controls Typegen suggestions for this externally defined variable.
|
|
684
|
+
* @default `{ asProperty: true, asValueOf: false }`
|
|
649
685
|
*/
|
|
650
|
-
|
|
686
|
+
suggest?: VariableSuggest;
|
|
651
687
|
/**
|
|
652
|
-
*
|
|
653
|
-
*
|
|
654
|
-
* @default undefined (`'*'` value suggestions when unset)
|
|
688
|
+
* Documentation rendered for the generated Typegen variable member.
|
|
689
|
+
* @default `undefined`
|
|
655
690
|
*/
|
|
656
|
-
|
|
691
|
+
description?: string;
|
|
657
692
|
/**
|
|
658
|
-
*
|
|
659
|
-
*
|
|
660
|
-
* @default true (inherits from `VariablesConfig.pruneUnused`)
|
|
693
|
+
* Discriminator excluding local variable definitions.
|
|
694
|
+
* @default `undefined`
|
|
661
695
|
*/
|
|
662
|
-
|
|
696
|
+
value?: never;
|
|
697
|
+
/**
|
|
698
|
+
* External variables are never pruned by PikaCSS.
|
|
699
|
+
* @default `undefined`
|
|
700
|
+
*/
|
|
701
|
+
pruneUnused?: never;
|
|
663
702
|
}
|
|
664
|
-
/**
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
* @remarks Use the short form for simple values. Use `VariableObject` when autocomplete control or pruning opt-out is needed.
|
|
668
|
-
*
|
|
669
|
-
* @example
|
|
670
|
-
* ```ts
|
|
671
|
-
* const simple: Variable = '#fff'
|
|
672
|
-
* const rich: Variable = { value: '#fff', autocomplete: { asValueOf: ['color'] } }
|
|
673
|
-
* ```
|
|
674
|
-
*/
|
|
675
|
-
type Variable = ResolvedCSSProperties[`--${string}`] | VariableObject;
|
|
676
|
-
/**
|
|
677
|
-
* A nested record mapping CSS variable names (`--*`) and optional selector scopes to variable definitions.
|
|
678
|
-
*
|
|
679
|
-
* @remarks Non-`--` keys are treated as selector scopes (e.g. `'.dark'`, `'@media ...'`) that nest the enclosed variables under that selector. Keys starting with `--` define actual CSS variables.
|
|
680
|
-
*
|
|
681
|
-
* @example
|
|
682
|
-
* ```ts
|
|
683
|
-
* const def: VariablesDefinition = {
|
|
684
|
-
* '--color-primary': '#3b82f6',
|
|
685
|
-
* '.dark': { '--color-primary': '#60a5fa' },
|
|
686
|
-
* }
|
|
687
|
-
* ```
|
|
688
|
-
*/
|
|
703
|
+
/** Canonical object-only variable leaf. */
|
|
704
|
+
type Variable = LocalVariable | ExternalVariable;
|
|
705
|
+
/** CSS-like nested variable definition tree. Non-variable keys are selector scopes. */
|
|
689
706
|
type VariablesDefinition = { [key in UnionString | ResolvedSelector]?: Variable | VariablesDefinition };
|
|
690
|
-
/**
|
|
691
|
-
* Configuration object for the `variables` engine option.
|
|
692
|
-
*
|
|
693
|
-
* @remarks Passed via `EngineConfig.variables` to define CSS custom properties, control pruning, and specify a safe list.
|
|
694
|
-
*
|
|
695
|
-
* @example
|
|
696
|
-
* ```ts
|
|
697
|
-
* const config: VariablesConfig = {
|
|
698
|
-
* definitions: {
|
|
699
|
-
* '--color-primary': '#3b82f6',
|
|
700
|
-
* '--shadow-elevated': '0 12px 40px rgb(0 0 0 / 0.12)',
|
|
701
|
-
* },
|
|
702
|
-
* pruneUnused: true,
|
|
703
|
-
* safeList: ['--color-primary'],
|
|
704
|
-
* }
|
|
705
|
-
* ```
|
|
706
|
-
*/
|
|
707
|
+
/** Configuration for the built-in CSS variables subsystem. */
|
|
707
708
|
interface VariablesConfig {
|
|
708
|
-
/**
|
|
709
|
+
/** Variable definition trees. Later entries override earlier entries at the same selector/name path. */
|
|
709
710
|
definitions?: Arrayable<VariablesDefinition>;
|
|
710
|
-
/**
|
|
711
|
-
* Default pruning policy for variables that are not referenced by any atomic style or preflight.
|
|
712
|
-
*
|
|
713
|
-
* @default true
|
|
714
|
-
*/
|
|
711
|
+
/** Default pruning policy for local variables. @default true */
|
|
715
712
|
pruneUnused?: boolean;
|
|
716
|
-
/**
|
|
717
|
-
* Variable names that should always be emitted regardless of usage.
|
|
718
|
-
*
|
|
719
|
-
* @default []
|
|
720
|
-
*/
|
|
713
|
+
/** Variable names always emitted regardless of usage. */
|
|
721
714
|
safeList?: (`--${string}` & {})[];
|
|
722
715
|
}
|
|
723
716
|
declare module '@pikacss/core' {
|
|
724
717
|
interface EngineConfig {
|
|
725
|
-
/**
|
|
726
|
-
* CSS custom properties (variables) configuration.
|
|
727
|
-
*
|
|
728
|
-
* @default undefined
|
|
729
|
-
*/
|
|
718
|
+
/** CSS variable definitions consumed once during Engine initialization. */
|
|
730
719
|
variables?: VariablesConfig;
|
|
731
720
|
}
|
|
732
721
|
interface Engine {
|
|
733
|
-
/**
|
|
734
|
-
|
|
735
|
-
store: Map<string, ResolvedVariable[]>;
|
|
736
|
-
add: (variables: VariablesDefinition) => void;
|
|
737
|
-
};
|
|
722
|
+
/** Readonly semantic query of variable names referenced by current atomic styles, expanded transitively through configured variable values. */
|
|
723
|
+
getUsedVariableNames: () => ReadonlySet<string>;
|
|
738
724
|
}
|
|
739
725
|
}
|
|
740
|
-
/**
|
|
741
|
-
* Built-in engine plugin that provides CSS custom properties (variables) with smart pruning and autocomplete integration.
|
|
742
|
-
*
|
|
743
|
-
* @returns An `EnginePlugin` that registers variable definitions, manages a preflight for emitting `:root` / scoped variables, and prunes unused variables from the output.
|
|
744
|
-
*
|
|
745
|
-
* @remarks Reads `EngineConfig.variables` during `rawConfigConfigured` and attaches the `engine.variables` management interface during `configureEngine`. A preflight is registered that collects variable references from atomic styles and other preflights, transitively expands dependencies, and emits only used (or safe-listed) variables.
|
|
746
|
-
*
|
|
747
|
-
* @example
|
|
748
|
-
* ```ts
|
|
749
|
-
* createEngine({ plugins: [variables()] })
|
|
750
|
-
* ```
|
|
751
|
-
*/
|
|
752
|
-
declare function variables(): EnginePlugin;
|
|
753
726
|
interface ResolvedVariable {
|
|
754
727
|
name: string;
|
|
755
|
-
value
|
|
728
|
+
value?: InternalPropertyValue;
|
|
756
729
|
selector: string[];
|
|
757
730
|
pruneUnused: boolean;
|
|
758
|
-
|
|
731
|
+
suggest: {
|
|
759
732
|
asValueOf: string[];
|
|
760
733
|
asProperty: boolean;
|
|
761
734
|
};
|
|
735
|
+
description?: string;
|
|
736
|
+
external: boolean;
|
|
737
|
+
}
|
|
738
|
+
interface VariablesState {
|
|
739
|
+
definitions: VariablesDefinition[];
|
|
740
|
+
defaultPruneUnused: boolean;
|
|
741
|
+
safeSet: Set<string>;
|
|
742
|
+
resolved: ResolvedVariable[];
|
|
743
|
+
store: Map<string, ResolvedVariable[]>;
|
|
762
744
|
}
|
|
745
|
+
/** Built-in CSS variable subsystem with config-only semantic ingress. */
|
|
746
|
+
declare function variables(): EnginePlugin<VariablesState>;
|
|
763
747
|
/**
|
|
764
748
|
* Extracts all CSS variable names referenced via `var(--*)` calls in a string.
|
|
765
749
|
*
|
|
@@ -806,522 +790,212 @@ declare function normalizeVariableName(name: string): string;
|
|
|
806
790
|
*/
|
|
807
791
|
declare function extractUsedVarNamesFromPreflightResult(result: string | PreflightDefinition): string[];
|
|
808
792
|
//#endregion
|
|
809
|
-
//#region src/
|
|
810
|
-
/**
|
|
811
|
-
* Represents `null` or `undefined`, used throughout the engine to express optional absence.
|
|
812
|
-
*
|
|
813
|
-
* @remarks Prefer this alias over inlining `null | undefined` for consistency across the codebase.
|
|
814
|
-
*
|
|
815
|
-
* @example
|
|
816
|
-
* ```ts
|
|
817
|
-
* function process(value: string | Nullish) {
|
|
818
|
-
* if (value == null) return // handles both null and undefined
|
|
819
|
-
* }
|
|
820
|
-
* ```
|
|
821
|
-
*/
|
|
822
|
-
type Nullish = null | undefined;
|
|
823
|
-
/**
|
|
824
|
-
* Branded string type that preserves literal union autocompletion while still accepting arbitrary strings.
|
|
825
|
-
*
|
|
826
|
-
* @remarks TypeScript narrows `string` to only known literals when a union is used. Intersecting with `{}` keeps the union suggestions in IDE autocomplete without rejecting unknown strings at the type level.
|
|
827
|
-
*
|
|
828
|
-
* @example
|
|
829
|
-
* ```ts
|
|
830
|
-
* type Color = 'red' | 'blue' | UnionString
|
|
831
|
-
* const c: Color = 'red' // autocomplete suggests 'red' | 'blue'
|
|
832
|
-
* const d: Color = 'green' // still valid
|
|
833
|
-
* ```
|
|
834
|
-
*/
|
|
835
|
-
type UnionString = string & {};
|
|
836
|
-
/**
|
|
837
|
-
* A value that can be either a single item or an array of items.
|
|
838
|
-
*
|
|
839
|
-
* @typeParam T - The element type.
|
|
840
|
-
*
|
|
841
|
-
* @remarks Used pervasively in configuration surfaces so consumers can pass a single value or an array without explicit wrapping.
|
|
842
|
-
*
|
|
843
|
-
* @example
|
|
844
|
-
* ```ts
|
|
845
|
-
* function normalize<T>(input: Arrayable<T>): T[] {
|
|
846
|
-
* return [input].flat() as T[]
|
|
847
|
-
* }
|
|
848
|
-
* normalize('a') // ['a']
|
|
849
|
-
* normalize(['a','b']) // ['a','b']
|
|
850
|
-
* ```
|
|
851
|
-
*/
|
|
852
|
-
type Arrayable<T> = T | T[];
|
|
853
|
-
/**
|
|
854
|
-
* A value that may be synchronous or wrapped in a `Promise`.
|
|
855
|
-
*
|
|
856
|
-
* @typeParam T - The resolved value type.
|
|
857
|
-
*
|
|
858
|
-
* @remarks Hook callbacks and plugin functions use this so authors can return either synchronously or asynchronously without the engine caring which.
|
|
859
|
-
*
|
|
860
|
-
* @example
|
|
861
|
-
* ```ts
|
|
862
|
-
* async function run(fn: () => Awaitable<string>) {
|
|
863
|
-
* const result = await fn() // works whether fn is sync or async
|
|
864
|
-
* }
|
|
865
|
-
* ```
|
|
866
|
-
*/
|
|
867
|
-
type Awaitable<T> = T | Promise<T>;
|
|
868
|
-
/**
|
|
869
|
-
* Converts a union type into an intersection of all its members.
|
|
870
|
-
*
|
|
871
|
-
* @typeParam U - The union type to intersect.
|
|
872
|
-
*
|
|
873
|
-
* @remarks Leverages contra-variant inference on function parameter positions. Useful internally for merging augmented module declarations into a single combined type.
|
|
874
|
-
*
|
|
875
|
-
* @example
|
|
876
|
-
* ```ts
|
|
877
|
-
* type U = { a: 1 } | { b: 2 }
|
|
878
|
-
* type I = UnionToIntersection<U> // { a: 1 } & { b: 2 }
|
|
879
|
-
* ```
|
|
880
|
-
*/
|
|
881
|
-
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
|
|
882
|
-
/**
|
|
883
|
-
* Type-level strict equality check that resolves to `true` when `X` and `Y` are identical types.
|
|
884
|
-
*
|
|
885
|
-
* @typeParam X - First type to compare.
|
|
886
|
-
* @typeParam Y - Second type to compare.
|
|
887
|
-
*
|
|
888
|
-
* @remarks Uses the double-conditional-inference trick to detect structural and modifier differences that `extends` alone would miss (e.g. `readonly` vs mutable).
|
|
889
|
-
*
|
|
890
|
-
* @example
|
|
891
|
-
* ```ts
|
|
892
|
-
* type A = IsEqual<string, string> // true
|
|
893
|
-
* type B = IsEqual<string, number> // false
|
|
894
|
-
* ```
|
|
895
|
-
*/
|
|
896
|
-
type IsEqual<X, Y> = (<T>() => T extends X ? 1 : 2) extends (<T>() => T extends Y ? 1 : 2) ? true : false;
|
|
897
|
-
/**
|
|
898
|
-
* Evaluates to `true` when `T` is the `never` type, `false` otherwise.
|
|
899
|
-
*
|
|
900
|
-
* @typeParam T - The type to test.
|
|
901
|
-
*
|
|
902
|
-
* @remarks Wrapping `T` in a tuple prevents distributive conditional behavior that would otherwise collapse `never` before the check runs.
|
|
903
|
-
*
|
|
904
|
-
* @example
|
|
905
|
-
* ```ts
|
|
906
|
-
* type A = IsNever<never> // true
|
|
907
|
-
* type B = IsNever<string> // false
|
|
908
|
-
* ```
|
|
909
|
-
*/
|
|
910
|
-
type IsNever<T> = [T] extends [never] ? true : false;
|
|
911
|
-
/**
|
|
912
|
-
* Flattens an intersection type into a single object type for improved readability in IDE tooltips.
|
|
913
|
-
*
|
|
914
|
-
* @typeParam T - The intersection or object type to simplify.
|
|
915
|
-
*
|
|
916
|
-
* @remarks Mapped types re-enumerate all keys so the resulting hover preview shows a flat `{ ... }` shape instead of `A & B & C`.
|
|
917
|
-
*
|
|
918
|
-
* @example
|
|
919
|
-
* ```ts
|
|
920
|
-
* type Merged = Simplify<{ a: 1 } & { b: 2 }> // { a: 1; b: 2 }
|
|
921
|
-
* ```
|
|
922
|
-
*/
|
|
923
|
-
type Simplify<T> = { [K in keyof T]: T[K] } & {};
|
|
924
|
-
/**
|
|
925
|
-
* Converts a camelCase or PascalCase string literal type to kebab-case at the type level.
|
|
926
|
-
*
|
|
927
|
-
* @typeParam T - The string literal type to convert. CSS custom properties (`--*`) are returned as-is.
|
|
928
|
-
*
|
|
929
|
-
* @remarks Used to map JavaScript-style property names to their CSS kebab-case equivalents during style extraction and rendering.
|
|
930
|
-
*
|
|
931
|
-
* @example
|
|
932
|
-
* ```ts
|
|
933
|
-
* type A = ToKebab<'backgroundColor'> // 'background-color'
|
|
934
|
-
* type B = ToKebab<'--my-var'> // '--my-var'
|
|
935
|
-
* ```
|
|
936
|
-
*/
|
|
937
|
-
type ToKebab<T extends string> = T extends `--${string}` ? T : T extends `${infer A}${infer U}${infer Rest}` ? U extends Uppercase<U> ? U extends Lowercase<U> ? `${Lowercase<A>}${ToKebab<`${U}${Rest}`>}` : `${Lowercase<A>}-${ToKebab<`${Lowercase<U>}${Rest}`>}` : `${Lowercase<A>}${ToKebab<`${U}${Rest}`>}` : Lowercase<T>;
|
|
938
|
-
/**
|
|
939
|
-
* Converts a kebab-case string literal type to camelCase at the type level.
|
|
940
|
-
*
|
|
941
|
-
* @typeParam T - The string literal type to convert. CSS custom properties (`--*`) are returned as-is.
|
|
942
|
-
*
|
|
943
|
-
* @remarks The inverse of `ToKebab`. Used to reconcile CSS-native property names back to their JavaScript equivalents during autocomplete resolution.
|
|
944
|
-
*
|
|
945
|
-
* @example
|
|
946
|
-
* ```ts
|
|
947
|
-
* type A = FromKebab<'background-color'> // 'backgroundColor'
|
|
948
|
-
* type B = FromKebab<'--my-var'> // '--my-var'
|
|
949
|
-
* ```
|
|
950
|
-
*/
|
|
951
|
-
type FromKebab<T extends string> = T extends `--${string}` ? T : T extends `${infer Head}-${infer Tail}` ? `${Head}${FromKebab<Capitalize<Tail>>}` : T;
|
|
952
|
-
/**
|
|
953
|
-
* Safely extracts the value type at key `K` from object type `Obj`, returning `never` when `Obj` is `never` or `K` is not a key of `Obj`.
|
|
954
|
-
*
|
|
955
|
-
* @typeParam Obj - The source object type.
|
|
956
|
-
* @typeParam K - The key to look up.
|
|
957
|
-
*
|
|
958
|
-
* @remarks Wrapping `Obj` in a tuple prevents distributive collapse when `Obj` is `never`.
|
|
959
|
-
*
|
|
960
|
-
* @example
|
|
961
|
-
* ```ts
|
|
962
|
-
* type V = GetValue<{ a: number }, 'a'> // number
|
|
963
|
-
* type N = GetValue<{ a: number }, 'b'> // never
|
|
964
|
-
* ```
|
|
965
|
-
*/
|
|
966
|
-
type GetValue<Obj, K extends string> = [Obj] extends [never] ? never : K extends keyof Obj ? Obj[K] : never;
|
|
793
|
+
//#region src/atomic-style.d.ts
|
|
967
794
|
/**
|
|
968
|
-
*
|
|
969
|
-
*
|
|
970
|
-
* @typeParam T - The source type to look up.
|
|
971
|
-
* @typeParam Key - The key to look up in `T`.
|
|
972
|
-
* @typeParam I - The constraint that `T[Key]` must satisfy.
|
|
973
|
-
* @typeParam Fallback - The default type returned when `Key` is missing or `T[Key]` does not extend `I`.
|
|
795
|
+
* Mutable store holding all resolved atomic styles and their lookup indices for an engine instance.
|
|
796
|
+
* @internal
|
|
974
797
|
*
|
|
975
|
-
* @remarks
|
|
798
|
+
* @remarks The store is created once per engine and mutated as new styles are resolved via `engine.use()`. It maintains four related indices: content-hash to ID, ID to full atomic style, base-key to ID list (for order-sensitive reuse), and ID to insertion order.
|
|
976
799
|
*
|
|
977
800
|
* @example
|
|
978
801
|
* ```ts
|
|
979
|
-
*
|
|
980
|
-
*
|
|
802
|
+
* const store = createEngineStore()
|
|
803
|
+
* // store.atomicStyleIds: Map<serializedKey, 'pk-a'>
|
|
981
804
|
* ```
|
|
982
805
|
*/
|
|
983
|
-
|
|
806
|
+
interface EngineStore {
|
|
807
|
+
/** Map from serialized content keys to their assigned atomic style IDs. */
|
|
808
|
+
atomicStyleIds: Map<string, string>;
|
|
809
|
+
/** Map from atomic style ID to the full `AtomicStyle` object. */
|
|
810
|
+
atomicStyles: Map<string, AtomicStyle>;
|
|
811
|
+
/** Map from base content key to the list of atomic style IDs that share it (for order-sensitive styles). */
|
|
812
|
+
atomicStyleIdsByBaseKey: Map<string, string[]>;
|
|
813
|
+
/** Map from atomic style ID to its insertion order index, used for deterministic output ordering. */
|
|
814
|
+
atomicStyleOrder: Map<string, number>;
|
|
815
|
+
}
|
|
984
816
|
//#endregion
|
|
985
|
-
//#region src/
|
|
817
|
+
//#region src/extractor.d.ts
|
|
986
818
|
/**
|
|
987
|
-
*
|
|
819
|
+
* Function signature for the bound extraction function created by `createExtractFn`.
|
|
988
820
|
* @internal
|
|
989
821
|
*
|
|
990
|
-
* @
|
|
991
|
-
*
|
|
992
|
-
* @remarks Wraps `T` in a tuple to prevent distributive collapse on `never`, then narrows to `string` keys only. Used internally to derive autocomplete property names from augmented type maps.
|
|
993
|
-
*
|
|
994
|
-
* @example
|
|
995
|
-
* ```ts
|
|
996
|
-
* type Keys = AutocompleteKeys<{ foo: 1; bar: 2 }> // 'foo' | 'bar'
|
|
997
|
-
* type Empty = AutocompleteKeys<never> // never
|
|
998
|
-
* ```
|
|
999
|
-
*/
|
|
1000
|
-
type AutocompleteKeys<T> = [T] extends [never] ? never : Extract<keyof T, string>;
|
|
1001
|
-
/**
|
|
1002
|
-
* Configuration for pattern-based autocomplete suggestions that are expanded at code generation time.
|
|
1003
|
-
*
|
|
1004
|
-
* @remarks Patterns define template strings or records that the code-generation layer uses to produce expanded autocomplete entries. Unlike direct entries, patterns describe *how* to generate completions rather than listing them explicitly.
|
|
822
|
+
* @remarks Accepts a single style definition and returns the extracted content list. The plugin transform hooks and default selector are captured in the closure.
|
|
1005
823
|
*
|
|
1006
824
|
* @example
|
|
1007
825
|
* ```ts
|
|
1008
|
-
* const
|
|
1009
|
-
*
|
|
1010
|
-
* properties: { spacing: ['sm', 'md', 'lg'] },
|
|
1011
|
-
* }
|
|
826
|
+
* const extractFn: ExtractFn = createExtractFn({ ... })
|
|
827
|
+
* const contents = await extractFn({ color: 'red' })
|
|
1012
828
|
* ```
|
|
1013
829
|
*/
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
/**
|
|
1022
|
-
|
|
1023
|
-
*
|
|
1024
|
-
* @default undefined
|
|
1025
|
-
*/
|
|
1026
|
-
shortcuts?: Arrayable<string>;
|
|
1027
|
-
/**
|
|
1028
|
-
* Property-to-values mapping whose keys are property names and values are the allowed value patterns.
|
|
1029
|
-
*
|
|
1030
|
-
* @default undefined
|
|
1031
|
-
*/
|
|
1032
|
-
properties?: Record<string, Arrayable<string>>;
|
|
1033
|
-
/**
|
|
1034
|
-
* CSS property-to-values mapping whose keys are CSS property names and values are the allowed value patterns.
|
|
1035
|
-
*
|
|
1036
|
-
* @default undefined
|
|
1037
|
-
*/
|
|
1038
|
-
cssProperties?: Record<string, Arrayable<string>>;
|
|
830
|
+
type ExtractFn = (styleDefinition: InternalStyleDefinition) => Promise<ExtractedStyleContent[]>;
|
|
831
|
+
//#endregion
|
|
832
|
+
//#region src/pika.d.ts
|
|
833
|
+
/** Read-side engine-scoped registry for first-level Pika static authoring extensions. */
|
|
834
|
+
interface PikaManager {
|
|
835
|
+
/** Returns whether a finalized first-level static root is registered. */
|
|
836
|
+
hasStatic: (name: string) => boolean;
|
|
837
|
+
/** Returns the finalized implementation for a first-level static root. */
|
|
838
|
+
getStatic: (name: string) => unknown | undefined;
|
|
1039
839
|
}
|
|
1040
|
-
/**
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
840
|
+
/** Owner-bound initialization capability exposed only through one plugin context. */
|
|
841
|
+
interface PikaRegistrationCapability {
|
|
842
|
+
/** Registers one first-level static authoring extension during this plugin's active configureEngine hook. */
|
|
843
|
+
extendStatic: (name: string, implementation: unknown) => void;
|
|
844
|
+
}
|
|
845
|
+
//#endregion
|
|
846
|
+
//#region src/typegen/snapshot.d.ts
|
|
847
|
+
/** Path-free preview asset produced by deterministic Typegen finalization. */
|
|
848
|
+
interface TypegenPreviewAsset {
|
|
849
|
+
/** Opaque semantic asset identity used only to bind a later host href. */
|
|
850
|
+
readonly id: string;
|
|
851
|
+
/** Raw preview content. The host owns physical materialization/content addressing. */
|
|
852
|
+
readonly content: string;
|
|
853
|
+
/** Media type describing the raw content (for example `image/svg+xml`). */
|
|
854
|
+
readonly mediaType: string;
|
|
855
|
+
}
|
|
856
|
+
/** Path-free reference from member documentation to one preview asset artifact. */
|
|
857
|
+
interface TypegenPreviewImage {
|
|
858
|
+
readonly assetId: string;
|
|
859
|
+
/** Optional Markdown image alt text. */
|
|
860
|
+
readonly alt?: string;
|
|
861
|
+
}
|
|
862
|
+
/** Intentional semantic JSDoc tag owned by Typegen rather than arbitrary prose. */
|
|
863
|
+
interface TypegenJSDocTag {
|
|
864
|
+
/** Tag name without the leading `@` (for example `deprecated`). */
|
|
865
|
+
readonly name: string;
|
|
866
|
+
/** Optional lexical-safe tag text. */
|
|
867
|
+
readonly text?: string;
|
|
868
|
+
}
|
|
869
|
+
/** Path-free rich documentation vocabulary for generated Typegen members. */
|
|
870
|
+
interface TypegenDocumentation {
|
|
871
|
+
/** User/domain description rendered before preview content. */
|
|
872
|
+
readonly description?: string;
|
|
873
|
+
/** Resolved CSS semantics shown in the established PikaCSS fenced preview. */
|
|
874
|
+
readonly previewCss?: string;
|
|
875
|
+
/** Preview image references whose hrefs are deliberately host-owned. */
|
|
876
|
+
readonly previewImages?: readonly TypegenPreviewImage[];
|
|
877
|
+
/** Intentional Typegen-owned semantic JSDoc tags. */
|
|
878
|
+
readonly tags?: readonly TypegenJSDocTag[];
|
|
879
|
+
}
|
|
880
|
+
/** Managed Typegen attachment points contributed by one plugin. */
|
|
881
|
+
interface TypegenContribution {
|
|
882
|
+
/** Stable contribution identity. Must be non-empty and unique per Engine. */
|
|
883
|
+
readonly id: string;
|
|
884
|
+
/** Verbatim supporting TypeScript declarations. */
|
|
885
|
+
readonly declarations?: string;
|
|
886
|
+
/** First-level Pika static-extension type roots. */
|
|
887
|
+
readonly pika?: Readonly<Record<string, string>>;
|
|
1066
888
|
/**
|
|
1067
|
-
*
|
|
1068
|
-
*
|
|
1069
|
-
* @default undefined
|
|
889
|
+
* TypeScript type reference contributed to the nested selector surface.
|
|
890
|
+
* @default `undefined`
|
|
1070
891
|
*/
|
|
1071
|
-
|
|
892
|
+
readonly selectors?: string;
|
|
1072
893
|
/**
|
|
1073
|
-
*
|
|
1074
|
-
*
|
|
1075
|
-
* @default undefined
|
|
894
|
+
* TypeScript type reference contributed to the generated property surface.
|
|
895
|
+
* @default `undefined`
|
|
1076
896
|
*/
|
|
1077
|
-
|
|
897
|
+
readonly properties?: string;
|
|
1078
898
|
/**
|
|
1079
|
-
*
|
|
1080
|
-
*
|
|
1081
|
-
* @default undefined
|
|
899
|
+
* TypeScript type reference contributed to CSS property names and values.
|
|
900
|
+
* @default `undefined`
|
|
1082
901
|
*/
|
|
1083
|
-
|
|
902
|
+
readonly cssProperties?: string;
|
|
1084
903
|
/**
|
|
1085
|
-
*
|
|
1086
|
-
*
|
|
1087
|
-
* @default undefined
|
|
904
|
+
* TypeScript type reference contributed to CSS property value autocomplete.
|
|
905
|
+
* @default `undefined`
|
|
1088
906
|
*/
|
|
1089
|
-
|
|
907
|
+
readonly cssPropertyValues?: string;
|
|
1090
908
|
/**
|
|
1091
|
-
*
|
|
1092
|
-
*
|
|
1093
|
-
* @default undefined
|
|
909
|
+
* TypeScript type reference that narrows or constrains generated properties.
|
|
910
|
+
* @default `undefined`
|
|
1094
911
|
*/
|
|
1095
|
-
|
|
912
|
+
readonly propertyConstraints?: string;
|
|
1096
913
|
}
|
|
1097
|
-
/**
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
*
|
|
1102
|
-
* @example
|
|
1103
|
-
* ```ts
|
|
1104
|
-
* const config: AutocompleteConfig = {
|
|
1105
|
-
* selectors: ['hover', 'focus'],
|
|
1106
|
-
* properties: [['spacing', ['sm', 'md', 'lg']]],
|
|
1107
|
-
* }
|
|
1108
|
-
* ```
|
|
1109
|
-
*/
|
|
1110
|
-
interface AutocompleteConfig {
|
|
914
|
+
/** Immutable semantic contribution captured in a finalized Typegen snapshot. */
|
|
915
|
+
interface TypegenSnapshotContribution {
|
|
916
|
+
/** Stable contribution identity copied from the registered contribution. */
|
|
917
|
+
readonly id: string;
|
|
1111
918
|
/**
|
|
1112
|
-
*
|
|
1113
|
-
*
|
|
1114
|
-
* @default undefined
|
|
919
|
+
* Supporting TypeScript declarations captured for the finalized snapshot.
|
|
920
|
+
* @default `undefined`
|
|
1115
921
|
*/
|
|
1116
|
-
|
|
922
|
+
readonly declarations?: string;
|
|
1117
923
|
/**
|
|
1118
|
-
*
|
|
1119
|
-
*
|
|
1120
|
-
* @default undefined
|
|
924
|
+
* First-level Pika static-extension type roots captured for the snapshot.
|
|
925
|
+
* @default `undefined`
|
|
1121
926
|
*/
|
|
1122
|
-
|
|
927
|
+
readonly pika?: Readonly<Record<string, string>>;
|
|
1123
928
|
/**
|
|
1124
|
-
*
|
|
1125
|
-
*
|
|
1126
|
-
* @default undefined
|
|
929
|
+
* TypeScript type reference contributed to the nested selector surface.
|
|
930
|
+
* @default `undefined`
|
|
1127
931
|
*/
|
|
1128
|
-
|
|
932
|
+
readonly selectors?: string;
|
|
1129
933
|
/**
|
|
1130
|
-
*
|
|
1131
|
-
*
|
|
1132
|
-
* @default undefined
|
|
934
|
+
* TypeScript type reference contributed to the generated property surface.
|
|
935
|
+
* @default `undefined`
|
|
1133
936
|
*/
|
|
1134
|
-
|
|
937
|
+
readonly properties?: string;
|
|
1135
938
|
/**
|
|
1136
|
-
*
|
|
1137
|
-
*
|
|
1138
|
-
* @default undefined
|
|
939
|
+
* TypeScript type reference contributed to CSS property names and values.
|
|
940
|
+
* @default `undefined`
|
|
1139
941
|
*/
|
|
1140
|
-
|
|
942
|
+
readonly cssProperties?: string;
|
|
1141
943
|
/**
|
|
1142
|
-
*
|
|
1143
|
-
*
|
|
1144
|
-
* @default undefined
|
|
944
|
+
* TypeScript type reference contributed to CSS property value autocomplete.
|
|
945
|
+
* @default `undefined`
|
|
1145
946
|
*/
|
|
1146
|
-
|
|
947
|
+
readonly cssPropertyValues?: string;
|
|
1147
948
|
/**
|
|
1148
|
-
*
|
|
1149
|
-
*
|
|
1150
|
-
* @default undefined
|
|
949
|
+
* TypeScript type reference that narrows or constrains generated properties.
|
|
950
|
+
* @default `undefined`
|
|
1151
951
|
*/
|
|
1152
|
-
|
|
952
|
+
readonly propertyConstraints?: string;
|
|
1153
953
|
}
|
|
1154
|
-
/**
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
* @example
|
|
1161
|
-
* ```ts
|
|
1162
|
-
* const patterns: ResolvedAutocompletePatternsConfig = {
|
|
1163
|
-
* selectors: new Set(['hover']),
|
|
1164
|
-
* shortcuts: new Set(),
|
|
1165
|
-
* properties: new Map(),
|
|
1166
|
-
* cssProperties: new Map(),
|
|
1167
|
-
* }
|
|
1168
|
-
* ```
|
|
1169
|
-
*/
|
|
1170
|
-
interface ResolvedAutocompletePatternsConfig {
|
|
1171
|
-
/** Set of resolved selector autocomplete patterns. */
|
|
1172
|
-
selectors: Set<string>;
|
|
1173
|
-
/** Set of resolved shortcut autocomplete patterns. */
|
|
1174
|
-
shortcuts: Set<string>;
|
|
1175
|
-
/** Map of property names to their expanded autocomplete value patterns. */
|
|
1176
|
-
properties: Map<string, string[]>;
|
|
1177
|
-
/** Map of CSS property names to their expanded autocomplete value patterns. */
|
|
1178
|
-
cssProperties: Map<string, string[]>;
|
|
1179
|
-
}
|
|
1180
|
-
/**
|
|
1181
|
-
* Fully resolved autocomplete configuration used at runtime by the engine and integration layer.
|
|
1182
|
-
* @internal
|
|
1183
|
-
*
|
|
1184
|
-
* @remarks All user-facing arrayable and record values are normalized into `Set`/`Map` structures during engine config resolution. Plugins append entries via `engine.appendAutocomplete()` which mutates this structure in place.
|
|
1185
|
-
*
|
|
1186
|
-
* @example
|
|
1187
|
-
* ```ts
|
|
1188
|
-
* const ac: ResolvedAutocompleteConfig = {
|
|
1189
|
-
* selectors: new Set(['hover']),
|
|
1190
|
-
* shortcuts: new Set(),
|
|
1191
|
-
* extraProperties: new Set(['__layer']),
|
|
1192
|
-
* extraCssProperties: new Set(),
|
|
1193
|
-
* properties: new Map(),
|
|
1194
|
-
* cssProperties: new Map(),
|
|
1195
|
-
* patterns: { selectors: new Set(), shortcuts: new Set(), properties: new Map(), cssProperties: new Map() },
|
|
1196
|
-
* }
|
|
1197
|
-
* ```
|
|
1198
|
-
*/
|
|
1199
|
-
interface ResolvedAutocompleteConfig {
|
|
1200
|
-
/** Known selector names available for autocomplete. */
|
|
1201
|
-
selectors: Set<string>;
|
|
1202
|
-
/** Known shortcut names available for autocomplete. */
|
|
1203
|
-
shortcuts: Set<string>;
|
|
1204
|
-
/** Non-CSS property names injected by plugins (e.g. `__shortcut`, `__layer`, `__important`). */
|
|
1205
|
-
extraProperties: Set<string>;
|
|
1206
|
-
/** Extra CSS property names (including custom properties) injected by plugins. */
|
|
1207
|
-
extraCssProperties: Set<string>;
|
|
1208
|
-
/** Property-to-type mappings for TypeScript type generation. */
|
|
1209
|
-
properties: Map<string, string[]>;
|
|
1210
|
-
/** CSS property-to-value mappings for value-level autocomplete. */
|
|
1211
|
-
cssProperties: Map<string, string[]>;
|
|
1212
|
-
/** Resolved pattern-based autocomplete entries. */
|
|
1213
|
-
patterns: ResolvedAutocompletePatternsConfig;
|
|
954
|
+
/** Path-independent Typegen semantic state produced by Engine finalization. */
|
|
955
|
+
interface TypegenSnapshot {
|
|
956
|
+
/** Contributions captured and sorted when the Engine was finalized. */
|
|
957
|
+
readonly contributions: readonly TypegenSnapshotContribution[];
|
|
958
|
+
/** Path-free preview artifacts; host materialization binds these ids to hrefs later. */
|
|
959
|
+
readonly previewAssets: readonly TypegenPreviewAsset[];
|
|
1214
960
|
}
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
* Selector: 'hover' | 'focus'
|
|
1225
|
-
* Shortcut: 'btn' | 'card'
|
|
1226
|
-
* Layer: 'base' | 'components'
|
|
1227
|
-
* PropertyValue: { spacing: 'sm' | 'md' }
|
|
1228
|
-
* CSSPropertyValue: { color: 'primary' | 'secondary' }
|
|
1229
|
-
* }
|
|
1230
|
-
* ```
|
|
1231
|
-
*/
|
|
1232
|
-
interface _Autocomplete {
|
|
1233
|
-
/** Union of known selector names for IDE autocomplete. */
|
|
1234
|
-
Selector: UnionString;
|
|
1235
|
-
/** Union of known shortcut names for IDE autocomplete. */
|
|
1236
|
-
Shortcut: UnionString;
|
|
1237
|
-
/** Union of known layer names for IDE autocomplete. */
|
|
1238
|
-
Layer: UnionString;
|
|
1239
|
-
/** Record mapping extra property names to their accepted value types for IDE autocomplete. */
|
|
1240
|
-
PropertyValue: Record<string, unknown>;
|
|
1241
|
-
/** Record mapping CSS property names to their accepted value unions for IDE autocomplete. */
|
|
1242
|
-
CSSPropertyValue: Record<string, UnionString>;
|
|
961
|
+
//#endregion
|
|
962
|
+
//#region src/typegen/jsdoc.d.ts
|
|
963
|
+
/** Host binding used only while rendering final TypeScript source. */
|
|
964
|
+
interface TypegenJSDocRenderBindings {
|
|
965
|
+
/**
|
|
966
|
+
* Resolves one path-free semantic preview image to a Markdown href after the
|
|
967
|
+
* host has successfully materialized it. Returning nullish omits that image.
|
|
968
|
+
*/
|
|
969
|
+
readonly resolvePreviewImageHref?: (assetId: string) => string | null | undefined;
|
|
1243
970
|
}
|
|
1244
971
|
/**
|
|
1245
|
-
*
|
|
972
|
+
* Renders one lexical-safe JSDoc block from path-free semantic documentation.
|
|
1246
973
|
*
|
|
1247
|
-
* @
|
|
974
|
+
* @remarks
|
|
975
|
+
* The renderer preserves the historical `### PikaCSS Preview` fenced-CSS
|
|
976
|
+
* convention and U+200E safety workaround. Arbitrary descriptions are prevented
|
|
977
|
+
* from becoming semantic JSDoc `@tags`. Preview-image hrefs are supplied only at
|
|
978
|
+
* final render time, so semantic snapshots never contain host paths or URIs.
|
|
1248
979
|
*
|
|
1249
|
-
* @
|
|
980
|
+
* @param documentation - Path-free description, preview, and semantic tags to render.
|
|
981
|
+
* @param bindings - Host callbacks used to resolve semantic preview asset IDs to hrefs.
|
|
982
|
+
* @param indent - Prefix applied to every line of the generated JSDoc block.
|
|
1250
983
|
*
|
|
1251
|
-
* @example
|
|
1252
|
-
* ```ts
|
|
1253
|
-
* declare module '@pikacss/core' {
|
|
1254
|
-
* interface PikaAugment {
|
|
1255
|
-
* Autocomplete: DefineAutocomplete<{
|
|
1256
|
-
* Selector: 'hover' | 'focus'
|
|
1257
|
-
* Shortcut: never
|
|
1258
|
-
* Layer: 'base'
|
|
1259
|
-
* PropertyValue: never
|
|
1260
|
-
* CSSPropertyValue: never
|
|
1261
|
-
* }>
|
|
1262
|
-
* }
|
|
1263
|
-
* }
|
|
1264
|
-
* ```
|
|
1265
|
-
*/
|
|
1266
|
-
type DefineAutocomplete<A extends _Autocomplete> = A;
|
|
1267
|
-
/**
|
|
1268
|
-
* Default autocomplete map used when no plugin provides an augmentation, with all dimensions set to `never`.
|
|
1269
984
|
* @internal
|
|
1270
|
-
*
|
|
1271
|
-
* @remarks Serves as the fallback in `ResolvedAutocomplete` so the engine always has a valid autocomplete shape even without any plugin augmentations.
|
|
1272
|
-
*
|
|
1273
|
-
* @example
|
|
1274
|
-
* ```ts
|
|
1275
|
-
* // When PikaAugment has no Autocomplete key:
|
|
1276
|
-
* type Resolved = ResolvedAutocomplete // EmptyAutocomplete
|
|
1277
|
-
* ```
|
|
1278
985
|
*/
|
|
1279
|
-
|
|
1280
|
-
Selector: never;
|
|
1281
|
-
Shortcut: never;
|
|
1282
|
-
Layer: never;
|
|
1283
|
-
PropertyValue: never;
|
|
1284
|
-
CSSPropertyValue: never;
|
|
1285
|
-
}>;
|
|
986
|
+
declare function renderTypegenJSDoc(documentation: TypegenDocumentation, bindings?: TypegenJSDocRenderBindings, indent?: string): string[];
|
|
1286
987
|
//#endregion
|
|
1287
|
-
//#region src/
|
|
1288
|
-
/**
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
* // store.atomicStyleIds: Map<serializedKey, 'pk-a'>
|
|
1298
|
-
* ```
|
|
1299
|
-
*/
|
|
1300
|
-
interface EngineStore {
|
|
1301
|
-
/** Map from serialized content keys to their assigned atomic style IDs. */
|
|
1302
|
-
atomicStyleIds: Map<string, string>;
|
|
1303
|
-
/** Map from atomic style ID to the full `AtomicStyle` object. */
|
|
1304
|
-
atomicStyles: Map<string, AtomicStyle>;
|
|
1305
|
-
/** Map from base content key to the list of atomic style IDs that share it (for order-sensitive styles). */
|
|
1306
|
-
atomicStyleIdsByBaseKey: Map<string, string[]>;
|
|
1307
|
-
/** Map from atomic style ID to its insertion order index, used for deterministic output ordering. */
|
|
1308
|
-
atomicStyleOrder: Map<string, number>;
|
|
988
|
+
//#region src/typegen/registry.d.ts
|
|
989
|
+
/** Read-side engine-scoped Typegen manager. */
|
|
990
|
+
interface TypegenManager {
|
|
991
|
+
/** Finalized immutable semantic snapshot. */
|
|
992
|
+
readonly snapshot: TypegenSnapshot;
|
|
993
|
+
}
|
|
994
|
+
/** Owner-bound initialization capability exposed only through one plugin context. */
|
|
995
|
+
interface TypegenRegistrationCapability {
|
|
996
|
+
/** Registers one contribution during this plugin's active configureEngine hook. */
|
|
997
|
+
add: (contribution: TypegenContribution) => void;
|
|
1309
998
|
}
|
|
1310
|
-
//#endregion
|
|
1311
|
-
//#region src/extractor.d.ts
|
|
1312
|
-
/**
|
|
1313
|
-
* Function signature for the bound extraction function created by `createExtractFn`.
|
|
1314
|
-
* @internal
|
|
1315
|
-
*
|
|
1316
|
-
* @remarks Accepts a single style definition and returns the extracted content list. The plugin transform hooks and default selector are captured in the closure.
|
|
1317
|
-
*
|
|
1318
|
-
* @example
|
|
1319
|
-
* ```ts
|
|
1320
|
-
* const extractFn: ExtractFn = createExtractFn({ ... })
|
|
1321
|
-
* const contents = await extractFn({ color: 'red' })
|
|
1322
|
-
* ```
|
|
1323
|
-
*/
|
|
1324
|
-
type ExtractFn = (styleDefinition: InternalStyleDefinition) => Promise<ExtractedStyleContent[]>;
|
|
1325
999
|
//#endregion
|
|
1326
1000
|
//#region src/engine.d.ts
|
|
1327
1001
|
/**
|
|
@@ -1333,6 +1007,8 @@ type ExtractFn = (styleDefinition: InternalStyleDefinition) => Promise<Extracted
|
|
|
1333
1007
|
*
|
|
1334
1008
|
* @remarks Core plugins (`important`, `variables`, `keyframes`, `selectors`, `shortcuts`) are prepended automatically. The function resolves plugins, runs all configuration hooks in sequence, and returns the ready-to-use engine.
|
|
1335
1009
|
*
|
|
1010
|
+
* The caller-owned `config` graph is treated as immutable input (#117): the engine clones it into an engine-local working copy before any plugin configuration hook runs, so plugin hooks that mutate their config (`config.layers ??= {}` and friends) never write back into caller-owned objects, and the same config object can be reused across sequential or concurrent `createEngine()` calls without accumulating setup mutations. Ordinary config data (plain objects/arrays, `Map`/`Set` contents, `Date`, `RegExp`) is recursively isolated — module-augmented plugin fields included; functions and other opaque class instances keep their identity and are treated as immutable values; the `plugins` array is copied while plugin definition objects keep their identity (#116).
|
|
1011
|
+
*
|
|
1336
1012
|
* @example
|
|
1337
1013
|
* ```ts
|
|
1338
1014
|
* const engine = await createEngine({ prefix: 'pk-', plugins: [myPlugin()] })
|
|
@@ -1342,7 +1018,7 @@ declare function createEngine(config?: EngineConfig, options?: CreateEngineOptio
|
|
|
1342
1018
|
/**
|
|
1343
1019
|
* The PikaCSS engine: manages atomic style resolution, rendering, preflights, and plugin hooks.
|
|
1344
1020
|
*
|
|
1345
|
-
* @remarks Constructed via `createEngine()`. Holds the resolved configuration, the atomic style store, and exposes methods for processing style items (`use`), rendering CSS output (`renderPreflights`, `renderAtomicStyles`, `renderLayerOrderDeclaration`), and managing runtime extensions (`addPreflight`, `
|
|
1021
|
+
* @remarks Constructed via `createEngine()`. Holds the resolved configuration, the atomic style store, and exposes methods for processing style items (`use`), rendering CSS output (`renderPreflights`, `renderAtomicStyles`, `renderLayerOrderDeclaration`), and managing runtime extensions (`addPreflight`, `appendCssImport`).
|
|
1346
1022
|
*
|
|
1347
1023
|
* @example
|
|
1348
1024
|
* ```ts
|
|
@@ -1352,22 +1028,23 @@ declare function createEngine(config?: EngineConfig, options?: CreateEngineOptio
|
|
|
1352
1028
|
* ```
|
|
1353
1029
|
*/
|
|
1354
1030
|
declare class Engine {
|
|
1031
|
+
#private;
|
|
1355
1032
|
/** The fully resolved engine configuration. */
|
|
1356
1033
|
config: ResolvedEngineConfig;
|
|
1357
1034
|
/** Instance-scoped diagnostic handler supplied by the host. */
|
|
1358
1035
|
readonly onDiagnostic: DiagnosticHandler;
|
|
1359
1036
|
/** Reference to the instance-scoped plugin hook dispatcher. */
|
|
1360
1037
|
pluginHooks: ReturnType<typeof createEngineHooks>;
|
|
1038
|
+
/** Finalized/read-side first-level Pika static authoring extension registry. */
|
|
1039
|
+
readonly pika: PikaManager;
|
|
1040
|
+
/** Finalized/read-side Typegen semantic registry. */
|
|
1041
|
+
readonly typegen: TypegenManager;
|
|
1361
1042
|
/** The extraction function that decomposes style definitions into atomic style contents. */
|
|
1362
1043
|
extract: ExtractFn;
|
|
1363
1044
|
/** The engine's runtime store holding registered atomic styles and their ID mappings. */
|
|
1364
1045
|
store: EngineStore;
|
|
1365
|
-
/**
|
|
1366
|
-
|
|
1367
|
-
*
|
|
1368
|
-
* @remarks Plugins register paths via `addConfigDependency` during `configureEngine`. Integration layers (e.g. the unplugin) watch these files and re-create the engine when they change.
|
|
1369
|
-
*/
|
|
1370
|
-
configDependencies: Set<string>;
|
|
1046
|
+
/** Finalized external file and directory-membership dependencies for this engine. */
|
|
1047
|
+
get configDependencies(): readonly EngineConfigDependency[];
|
|
1371
1048
|
/**
|
|
1372
1049
|
* Creates an engine instance from a resolved configuration.
|
|
1373
1050
|
*
|
|
@@ -1380,7 +1057,7 @@ declare class Engine {
|
|
|
1380
1057
|
* const engine = new Engine(resolvedConfig)
|
|
1381
1058
|
* ```
|
|
1382
1059
|
*/
|
|
1383
|
-
constructor(config: ResolvedEngineConfig, onDiagnostic?: DiagnosticHandler, pluginHooks?: ReturnType<typeof createEngineHooks
|
|
1060
|
+
constructor(config: ResolvedEngineConfig, onDiagnostic?: DiagnosticHandler, pluginHooks?: ReturnType<typeof createEngineHooks>, atomicStyleIdStrategy?: AtomicStyleIdStrategy);
|
|
1384
1061
|
/**
|
|
1385
1062
|
* Reports a structured diagnostic to this engine instance's host handler.
|
|
1386
1063
|
*
|
|
@@ -1404,18 +1081,19 @@ declare class Engine {
|
|
|
1404
1081
|
*/
|
|
1405
1082
|
invokePreflight(fn: PreflightFn, isFormatted: boolean, ctx?: PreflightContext): Promise<string | PreflightDefinition>;
|
|
1406
1083
|
/**
|
|
1407
|
-
* Registers
|
|
1408
|
-
*
|
|
1409
|
-
* @param path - The file path (ideally absolute) the current config was derived from.
|
|
1084
|
+
* Registers a file dependency during Engine initialization.
|
|
1410
1085
|
*
|
|
1411
|
-
* @
|
|
1412
|
-
*
|
|
1413
|
-
* @example
|
|
1414
|
-
* ```ts
|
|
1415
|
-
* engine.addConfigDependency('/project/design.md')
|
|
1416
|
-
* ```
|
|
1086
|
+
* @param path - File path whose content/existence participates in Engine configuration semantics. Missing files are allowed.
|
|
1087
|
+
* @throws If registration is attempted after Engine finalization.
|
|
1417
1088
|
*/
|
|
1418
1089
|
addConfigDependency(path: string): void;
|
|
1090
|
+
/**
|
|
1091
|
+
* Registers a direct directory-membership dependency during Engine initialization.
|
|
1092
|
+
*
|
|
1093
|
+
* @param path - Directory path whose direct member create/delete/rename events invalidate Engine configuration semantics.
|
|
1094
|
+
* @throws If registration is attempted after Engine finalization.
|
|
1095
|
+
*/
|
|
1096
|
+
addConfigDirectoryMembershipDependency(path: string): void;
|
|
1419
1097
|
/**
|
|
1420
1098
|
* Fires the `preflightUpdated` hook to notify plugins that preflight content has changed.
|
|
1421
1099
|
*
|
|
@@ -1433,7 +1111,7 @@ declare class Engine {
|
|
|
1433
1111
|
*
|
|
1434
1112
|
* @param atomicStyle - The atomic style that was just added to the store.
|
|
1435
1113
|
*
|
|
1436
|
-
* @remarks Called automatically by `
|
|
1114
|
+
* @remarks Called automatically by `commitUse()` when a previously unseen atomic style is registered. This is a committed notification: the style's ID, cache keys, and store indices are already established, so mutating the payload is unsupported — plugins that need to transform styles must use the provisional hooks (`transformStyleItems`, `transformStyleDefinitions`, `transformSelectors`, `transformStyleContents`) instead (#114).
|
|
1437
1115
|
*
|
|
1438
1116
|
* @example
|
|
1439
1117
|
* ```ts
|
|
@@ -1442,63 +1120,80 @@ declare class Engine {
|
|
|
1442
1120
|
*/
|
|
1443
1121
|
notifyAtomicStyleAdded(atomicStyle: AtomicStyle): void;
|
|
1444
1122
|
/**
|
|
1445
|
-
*
|
|
1123
|
+
* Appends a CSS `@import` statement to the preflight output.
|
|
1446
1124
|
*
|
|
1125
|
+
* @param cssImport - The raw `@import` string (a trailing semicolon is appended if missing).
|
|
1447
1126
|
*
|
|
1448
|
-
* @remarks
|
|
1127
|
+
* @remarks Deduplicates imports. Fires `preflightUpdated` when a new import is added.
|
|
1449
1128
|
*
|
|
1450
1129
|
* @example
|
|
1451
1130
|
* ```ts
|
|
1452
|
-
* engine.
|
|
1131
|
+
* engine.appendCssImport('@import url("https://fonts.googleapis.com/css2?family=Inter")')
|
|
1453
1132
|
* ```
|
|
1454
1133
|
*/
|
|
1455
|
-
|
|
1134
|
+
appendCssImport(cssImport: string): void;
|
|
1456
1135
|
/**
|
|
1457
|
-
*
|
|
1136
|
+
* Registers a new preflight that will be rendered before atomic styles.
|
|
1458
1137
|
*
|
|
1459
|
-
* @param
|
|
1138
|
+
* @param preflight - A preflight definition: a function, a static string/object, or a wrapper with `layer`/`id` metadata.
|
|
1460
1139
|
*
|
|
1461
|
-
* @remarks
|
|
1140
|
+
* @remarks The preflight is resolved into a `ResolvedPreflight` (extracting optional `layer` and `id`) and appended to `config.preflights`. Fires `preflightUpdated` so plugins and the integration layer know to re-render.
|
|
1462
1141
|
*
|
|
1463
1142
|
* @example
|
|
1464
1143
|
* ```ts
|
|
1465
|
-
* engine.
|
|
1144
|
+
* engine.addPreflight({ layer: 'base', preflight: '*, *::before { box-sizing: border-box; }' })
|
|
1466
1145
|
* ```
|
|
1467
1146
|
*/
|
|
1468
|
-
|
|
1147
|
+
addPreflight(preflight: Preflight): void;
|
|
1469
1148
|
/**
|
|
1470
|
-
*
|
|
1149
|
+
* Provisionally resolves style items into a commit-ready plan without touching committed engine state.
|
|
1471
1150
|
*
|
|
1472
|
-
* @param
|
|
1151
|
+
* @param itemList - Style items to process: string references (shortcuts) and/or style definition objects.
|
|
1152
|
+
* @returns A promise of the {@link StyleUsePlan} to pass to `commitUse()`.
|
|
1473
1153
|
*
|
|
1474
|
-
* @remarks
|
|
1154
|
+
* @remarks
|
|
1155
|
+
* Runs the full provisional pipeline: `transformStyleItems`, extraction
|
|
1156
|
+
* (`transformStyleDefinitions`/`transformSelectors`), normalization, and the
|
|
1157
|
+
* normalized-content seam `transformStyleContents`. It allocates no atomic
|
|
1158
|
+
* style IDs, mutates no `EngineStore` state, and fires no committed
|
|
1159
|
+
* notifications — a rejection anywhere leaves the engine exactly as it was.
|
|
1160
|
+
* Plans deliberately carry no IDs: reuse-vs-fresh decisions read live store
|
|
1161
|
+
* state and are only valid inside `commitUse()` (#114).
|
|
1475
1162
|
*
|
|
1476
1163
|
* @example
|
|
1477
1164
|
* ```ts
|
|
1478
|
-
* engine.
|
|
1165
|
+
* const plan = await engine.prepareUse({ color: 'red' })
|
|
1166
|
+
* const ids = engine.commitUse(plan)
|
|
1479
1167
|
* ```
|
|
1480
1168
|
*/
|
|
1481
|
-
|
|
1169
|
+
prepareUse(...itemList: InternalStyleItem[]): Promise<StyleUsePlan>;
|
|
1482
1170
|
/**
|
|
1483
|
-
*
|
|
1171
|
+
* Commits a prepared plan: allocates/reuses atomic style IDs and registers new styles in the store.
|
|
1484
1172
|
*
|
|
1485
|
-
* @param
|
|
1173
|
+
* @param plan - A plan produced by `prepareUse()`.
|
|
1174
|
+
* @returns An array containing any unresolved string references first, followed by atomic style IDs in resolution order.
|
|
1486
1175
|
*
|
|
1487
|
-
* @remarks
|
|
1176
|
+
* @remarks
|
|
1177
|
+
* This is the short, mutation-critical section and MUST stay synchronous:
|
|
1178
|
+
* integration layers commit whole modules inside a revision/epoch-checked
|
|
1179
|
+
* synchronous block, so an `await` here would reopen the stale-commit race
|
|
1180
|
+
* (#114). `atomicStyleAdded` fires per newly registered style as a committed
|
|
1181
|
+
* notification; a throwing observer is reported through the diagnostic
|
|
1182
|
+
* context but never rolls back the already-committed registration.
|
|
1488
1183
|
*
|
|
1489
1184
|
* @example
|
|
1490
1185
|
* ```ts
|
|
1491
|
-
* engine.
|
|
1186
|
+
* const ids = engine.commitUse(await engine.prepareUse({ color: 'red' }))
|
|
1492
1187
|
* ```
|
|
1493
1188
|
*/
|
|
1494
|
-
|
|
1189
|
+
commitUse(plan: StyleUsePlan): string[];
|
|
1495
1190
|
/**
|
|
1496
1191
|
* Processes style items through the plugin pipeline and registers the resulting atomic styles in the store.
|
|
1497
1192
|
*
|
|
1498
1193
|
* @param itemList - Style items to process: string references (shortcuts) and/or style definition objects.
|
|
1499
1194
|
* @returns An array containing any unresolved string references first, followed by atomic style IDs in resolution order.
|
|
1500
1195
|
*
|
|
1501
|
-
* @remarks
|
|
1196
|
+
* @remarks Equivalent to `commitUse(await prepareUse(...itemList))` — the convenience path for direct consumers. Integration layers that need whole-module transactionality call the two phases separately (#114).
|
|
1502
1197
|
*
|
|
1503
1198
|
* @example
|
|
1504
1199
|
* ```ts
|
|
@@ -1529,12 +1224,11 @@ declare class Engine {
|
|
|
1529
1224
|
* Renders atomic styles into a CSS string, optionally filtered by ID and grouped by layer.
|
|
1530
1225
|
*
|
|
1531
1226
|
* @param isFormatted - Whether to produce human-readable CSS with newlines and indentation.
|
|
1532
|
-
* @param options - Optional filtering: `atomicStyleIds` to render a subset
|
|
1227
|
+
* @param options - Optional filtering: `atomicStyleIds` to render a subset.
|
|
1533
1228
|
* @param options.atomicStyleIds - Specific atomic style IDs to render instead of the full store.
|
|
1534
|
-
* @param options.isPreview - Whether to keep placeholder IDs instead of substituting real class names.
|
|
1535
1229
|
* @returns The rendered atomic-style CSS.
|
|
1536
1230
|
*
|
|
1537
|
-
* @remarks Styles are sorted by rendering weight (selector specificity depth), grouped into configured `@layer` blocks, and rendered.
|
|
1231
|
+
* @remarks Styles are sorted by rendering weight (selector specificity depth), grouped into configured `@layer` blocks, and rendered.
|
|
1538
1232
|
*
|
|
1539
1233
|
* @example
|
|
1540
1234
|
* ```ts
|
|
@@ -1543,7 +1237,6 @@ declare class Engine {
|
|
|
1543
1237
|
*/
|
|
1544
1238
|
renderAtomicStyles(isFormatted: boolean, options?: {
|
|
1545
1239
|
atomicStyleIds?: string[];
|
|
1546
|
-
isPreview?: boolean;
|
|
1547
1240
|
}): Promise<string>;
|
|
1548
1241
|
/**
|
|
1549
1242
|
* Renders the CSS `@layer` order declaration for all configured layers.
|
|
@@ -1575,6 +1268,23 @@ declare class Engine {
|
|
|
1575
1268
|
* ```
|
|
1576
1269
|
*/
|
|
1577
1270
|
declare function sortLayerNames(layers: Record<string, number>): string[];
|
|
1271
|
+
/**
|
|
1272
|
+
* The provisional result of `engine.prepareUse()`: fully transformed, extracted,
|
|
1273
|
+
* and normalized style contents plus unresolved string references, ready to be
|
|
1274
|
+
* committed via `engine.commitUse()`.
|
|
1275
|
+
*
|
|
1276
|
+
* @remarks
|
|
1277
|
+
* A plan deliberately carries no atomic style IDs and no base-key resolutions:
|
|
1278
|
+
* reuse-vs-fresh-ID decisions read live `EngineStore` state and are only valid
|
|
1279
|
+
* at the moment `commitUse()` runs. Discarding an uncommitted plan has no
|
|
1280
|
+
* effect on the engine (#114).
|
|
1281
|
+
*/
|
|
1282
|
+
interface StyleUsePlan {
|
|
1283
|
+
/** String references no plugin resolved; echoed back verbatim by `commitUse()`. */
|
|
1284
|
+
unknown: Set<string>;
|
|
1285
|
+
/** Deduplicated, normalized style contents in resolution order. */
|
|
1286
|
+
contents: StyleContent[];
|
|
1287
|
+
}
|
|
1578
1288
|
//#endregion
|
|
1579
1289
|
//#region src/plugin.d.ts
|
|
1580
1290
|
type DefineHooks<Hooks extends Record<string, [type: 'sync' | 'async', payload: unknown, returnValue?: unknown]>> = Hooks;
|
|
@@ -1586,35 +1296,86 @@ type EngineHooksDefinition = DefineHooks<{
|
|
|
1586
1296
|
transformSelectors: ['async', selectors: string[]];
|
|
1587
1297
|
transformStyleItems: ['async', styleItems: ResolvedStyleItem[]];
|
|
1588
1298
|
transformStyleDefinitions: ['async', styleDefinitions: ResolvedStyleDefinition[]];
|
|
1299
|
+
transformStyleContents: ['async', styleContents: StyleContent[]];
|
|
1589
1300
|
preflightUpdated: ['sync', void];
|
|
1590
1301
|
atomicStyleAdded: ['sync', AtomicStyle];
|
|
1591
|
-
autocompleteConfigUpdated: ['sync', void];
|
|
1592
1302
|
}>;
|
|
1303
|
+
/**
|
|
1304
|
+
* Owner-bound facade supplied only while one plugin configures an Engine.
|
|
1305
|
+
*
|
|
1306
|
+
* @remarks
|
|
1307
|
+
* The facade is scoped to one plugin definition and one awaited `configureEngine`
|
|
1308
|
+
* invocation. `pika` and `typegen` capabilities close when that invocation
|
|
1309
|
+
* settles. `runtime` is the underlying Engine for existing Engine APIs.
|
|
1310
|
+
*/
|
|
1311
|
+
interface EngineConfigurator<State = any> extends EnginePluginContext<State> {
|
|
1312
|
+
/** Underlying Engine being configured. */
|
|
1313
|
+
readonly runtime: Engine;
|
|
1314
|
+
/** Owner-bound Pika registration capability for this configureEngine invocation. */
|
|
1315
|
+
readonly pika: PikaRegistrationCapability;
|
|
1316
|
+
/** Owner-bound Typegen registration capability for this configureEngine invocation. */
|
|
1317
|
+
readonly typegen: TypegenRegistrationCapability;
|
|
1318
|
+
}
|
|
1593
1319
|
type HookParams<H extends [type: 'sync' | 'async', payload: any, returnValue?: any]> = H[1] extends void ? [] : [payload: H[1]];
|
|
1594
|
-
type PluginHookParams<H extends [type: 'sync' | 'async', payload: any, returnValue?: any]> = H[1] extends void ? [context
|
|
1320
|
+
type PluginHookParams<H extends [type: 'sync' | 'async', payload: any, returnValue?: any], State = any> = H[1] extends void ? [context: EnginePluginContext<State>] : [payload: H[1], context: EnginePluginContext<State>];
|
|
1595
1321
|
type HookReturnType<H extends [type: 'sync' | 'async', payload: any, returnValue?: any]> = H extends [any, any, infer R] ? H[0] extends 'async' ? Promise<R> : R : H[0] extends 'async' ? Promise<H[1]> : H[1];
|
|
1596
1322
|
type EngineHooks = { [K in keyof EngineHooksDefinition]: (plugins: EnginePlugin[], ...params: HookParams<EngineHooksDefinition[K]>) => HookReturnType<EngineHooksDefinition[K]> };
|
|
1597
1323
|
/**
|
|
1598
1324
|
* Creates an engine-local hook dispatcher bound to one diagnostic context.
|
|
1599
1325
|
*
|
|
1600
1326
|
* @internal
|
|
1327
|
+
* @remarks
|
|
1328
|
+
* Each dispatcher instance owns one plugin-context store: every plugin
|
|
1329
|
+
* definition gets exactly one `EnginePluginContext` (with `state` initialized
|
|
1330
|
+
* lazily via `createState()`) per dispatcher — i.e. per engine, since
|
|
1331
|
+
* `createEngine` creates one dispatcher per engine (#116). The same plugin
|
|
1332
|
+
* definition used with another dispatcher/engine gets a distinct context and
|
|
1333
|
+
* distinct state.
|
|
1601
1334
|
*/
|
|
1602
|
-
declare function createEngineHooks(context: EnginePluginContext): EngineHooks;
|
|
1603
|
-
type EnginePluginHooksOptions = { [K in keyof EngineHooksDefinition]?: EngineHooksDefinition[K][0] extends 'async' ? (...params: PluginHookParams<EngineHooksDefinition[K]>) => Awaitable<EngineHooksDefinition[K][1] | void> : (...params: PluginHookParams<EngineHooksDefinition[K]>) => EngineHooksDefinition[K][1] | void };
|
|
1604
|
-
/**
|
|
1605
|
-
|
|
1335
|
+
declare function createEngineHooks(context: Pick<EnginePluginContext, 'onDiagnostic'> & Partial<Pick<EnginePluginContext, 'host'>>): EngineHooks;
|
|
1336
|
+
type EnginePluginHooksOptions<State = any> = { [K in keyof EngineHooksDefinition]?: K extends 'configureEngine' ? (configurator: EngineConfigurator<State>) => Awaitable<void> : EngineHooksDefinition[K][0] extends 'async' ? (...params: PluginHookParams<EngineHooksDefinition[K], State>) => Awaitable<EngineHooksDefinition[K][1] | void> : (...params: PluginHookParams<EngineHooksDefinition[K], State>) => EngineHooksDefinition[K][1] | void };
|
|
1337
|
+
/**
|
|
1338
|
+
* Describes an engine plugin that can hook into the PikaCSS engine lifecycle.
|
|
1339
|
+
*
|
|
1340
|
+
* @remarks
|
|
1341
|
+
* A plugin object is a reusable **definition**, not a single-engine resource
|
|
1342
|
+
* (#116): the same object may be passed to any number of `createEngine()`
|
|
1343
|
+
* calls, sequentially or concurrently. Mutable per-engine data therefore must
|
|
1344
|
+
* never live in the plugin factory's closure — declare it via `createState`
|
|
1345
|
+
* and read/write it through hook `context.state` or `EngineConfigurator.state`, which the engine keeps isolated
|
|
1346
|
+
* per plugin/engine pair. Factory arguments that are never mutated may stay in
|
|
1347
|
+
* the closure as immutable definition configuration.
|
|
1348
|
+
*/
|
|
1349
|
+
interface EnginePlugin<State = any> extends EnginePluginHooksOptions<State> {
|
|
1606
1350
|
/** The unique human-readable name identifying this plugin in diagnostics. */
|
|
1607
1351
|
name: string;
|
|
1608
1352
|
/** Controls execution order relative to other plugins. */
|
|
1609
1353
|
order?: 'pre' | 'post';
|
|
1354
|
+
/**
|
|
1355
|
+
* Initializes this plugin's engine-local state.
|
|
1356
|
+
*
|
|
1357
|
+
* @returns The fresh state for one engine.
|
|
1358
|
+
*
|
|
1359
|
+
* @remarks
|
|
1360
|
+
* Invoked by the engine at most once per plugin definition **per engine**,
|
|
1361
|
+
* before the first hook of this plugin runs for that engine; every hook
|
|
1362
|
+
* invocation of that plugin/engine pair then receives the same object via
|
|
1363
|
+
* `context.state`. Another engine reusing the same definition gets a
|
|
1364
|
+
* distinct state object. Stateless plugins simply omit this.
|
|
1365
|
+
*/
|
|
1366
|
+
createState?: () => State;
|
|
1610
1367
|
}
|
|
1611
1368
|
/**
|
|
1612
1369
|
* Identity helper that provides type inference for an engine plugin definition.
|
|
1613
1370
|
*
|
|
1614
1371
|
* @param plugin - The plugin definition to return unchanged.
|
|
1615
1372
|
* @returns The same plugin instance.
|
|
1373
|
+
*
|
|
1374
|
+
* @remarks
|
|
1375
|
+
* When the plugin declares `createState`, the state type is inferred from its
|
|
1376
|
+
* return value and every hook's `context.state` is typed accordingly.
|
|
1616
1377
|
*/
|
|
1617
|
-
declare function defineEnginePlugin(plugin: EnginePlugin): EnginePlugin
|
|
1378
|
+
declare function defineEnginePlugin<State = void>(plugin: EnginePlugin<State>): EnginePlugin<State>;
|
|
1618
1379
|
//#endregion
|
|
1619
1380
|
//#region src/generated/csstype.d.ts
|
|
1620
1381
|
type UnionString$1 = string & {};
|
|
@@ -19583,7 +19344,9 @@ type AtRules = AtRules.Regular | AtRules.Nested;
|
|
|
19583
19344
|
type CSSPseudos$1 = "$::-moz-progress-bar" | "$::-moz-range-progress" | "$::-moz-range-thumb" | "$::-moz-range-track" | "$::-ms-browse" | "$::-ms-check" | "$::-ms-clear" | "$::-ms-expand" | "$::-ms-fill" | "$::-ms-fill-lower" | "$::-ms-fill-upper" | "$::-ms-reveal" | "$::-ms-thumb" | "$::-ms-ticks-after" | "$::-ms-ticks-before" | "$::-ms-tooltip" | "$::-ms-track" | "$::-ms-value" | "$::-webkit-progress-bar" | "$::-webkit-progress-inner-value" | "$::-webkit-progress-value" | "$::-webkit-slider-runnable-track" | "$::-webkit-slider-thumb" | "$::after" | "$::backdrop" | "$::before" | "$::checkmark" | "$::clear-icon" | "$::color-swatch" | "$::column" | "$::cue" | "$::cue()" | "$::cue-region" | "$::cue-region()" | "$::details-content" | "$::field-component" | "$::field-separator" | "$::field-text" | "$::file-selector-button" | "$::first-letter" | "$::first-line" | "$::grammar-error" | "$::highlight()" | "$::marker" | "$::nth-fragment()" | "$::part()" | "$::picker()" | "$::picker-icon" | "$::placeholder" | "$::reveal-icon" | "$::scroll-button()" | "$::scroll-marker" | "$::scroll-marker-group" | "$::search-text" | "$::selection" | "$::slider-fill" | "$::slider-thumb" | "$::slider-track" | "$::slotted()" | "$::spelling-error" | "$::step-control" | "$::step-down" | "$::step-up" | "$::target-text" | "$::view-transition" | "$::view-transition-group()" | "$::view-transition-group-children()" | "$::view-transition-image-pair()" | "$::view-transition-new()" | "$::view-transition-old()" | "$:active" | "$:active-view-transition" | "$:active-view-transition-type()" | "$:after" | "$:animated-image" | "$:any-link" | "$:autofill" | "$:before" | "$:blank" | "$:buffering" | "$:checked" | "$:current" | "$:current()" | "$:default" | "$:defined" | "$:dir()" | "$:disabled" | "$:empty" | "$:enabled" | "$:first" | "$:first-child" | "$:first-letter" | "$:first-line" | "$:first-of-page" | "$:first-of-type" | "$:focus" | "$:focus-visible" | "$:focus-within" | "$:fullscreen" | "$:future" | "$:has()" | "$:has-slotted" | "$:heading" | "$:heading()" | "$:high-value" | "$:host" | "$:host()" | "$:host-context()" | "$:hover" | "$:in-range" | "$:indeterminate" | "$:interest-source" | "$:interest-target" | "$:invalid" | "$:is()" | "$:lang()" | "$:last-child" | "$:last-of-page" | "$:last-of-type" | "$:left" | "$:link" | "$:link-to()" | "$:local-link" | "$:low-value" | "$:matches()" | "$:modal" | "$:muted" | "$:nav-source" | "$:not()" | "$:nth()" | "$:nth-child()" | "$:nth-col()" | "$:nth-last-child()" | "$:nth-last-col()" | "$:nth-last-of-type()" | "$:nth-of-page()" | "$:nth-of-type()" | "$:only-child" | "$:only-of-type" | "$:open" | "$:optimal-value" | "$:optional" | "$:out-of-range" | "$:past" | "$:paused" | "$:picture-in-picture" | "$:placeholder-shown" | "$:playing" | "$:popover-open" | "$:read-only" | "$:read-write" | "$:required" | "$:right" | "$:root" | "$:scope" | "$:seeking" | "$:snapped" | "$:snapped-block" | "$:snapped-inline" | "$:snapped-x" | "$:snapped-y" | "$:stalled" | "$:start-of-page" | "$:state()" | "$:target" | "$:target-after" | "$:target-before" | "$:target-current" | "$:target-within" | "$:unchecked" | "$:user-invalid" | "$:user-valid" | "$:valid" | "$:visited" | "$:volume-locked" | "$:where()" | "$:xr-overlay";
|
|
19584
19345
|
type AutocompleteLookup<TValueMap, TRelatedKeys extends string> = [TValueMap] extends [never] ? never : TRelatedKeys extends keyof TValueMap ? TValueMap[TRelatedKeys] : never;
|
|
19585
19346
|
type PropertyInputAtom<TValueMap, BaseValue, TRelatedKeys extends string> = UnionString$1 | BaseValue | AutocompleteLookup<TValueMap, TRelatedKeys | "*">;
|
|
19347
|
+
/** CSS property input value with optional Typegen autocomplete and fallback values. */
|
|
19586
19348
|
type PropertyInputValue<TValueMap, BaseValue, TRelatedKeys extends string = never> = PropertyInputAtom<TValueMap, BaseValue, TRelatedKeys> | [value: PropertyInputAtom<TValueMap, BaseValue, TRelatedKeys>, fallback: Array<PropertyInputAtom<TValueMap, BaseValue, TRelatedKeys>>] | null | undefined;
|
|
19349
|
+
/** Camel-case CSS property inputs used by the generated Typegen style definition. */
|
|
19587
19350
|
interface PropertiesInput<TValueMap = never, TLength = DefaultTLength, TTime = DefaultTTime> {
|
|
19588
19351
|
/**
|
|
19589
19352
|
* ❌ Baseline: Not widely available
|
|
@@ -27632,6 +27395,7 @@ interface PropertiesInput<TValueMap = never, TLength = DefaultTLength, TTime = D
|
|
|
27632
27395
|
*/
|
|
27633
27396
|
zoom?: PropertyInputValue<TValueMap, Property.Zoom, PropertyRelatedNames["zoom"]> | undefined;
|
|
27634
27397
|
}
|
|
27398
|
+
/** Kebab-case CSS property inputs used by the generated Typegen style definition. */
|
|
27635
27399
|
interface PropertiesHyphenInput<TValueMap = never, TLength = DefaultTLength, TTime = DefaultTTime> {
|
|
27636
27400
|
/**
|
|
27637
27401
|
*
|
|
@@ -36675,6 +36439,189 @@ declare namespace DataType {
|
|
|
36675
36439
|
type VisualBox = "border-box" | "content-box" | "padding-box";
|
|
36676
36440
|
}
|
|
36677
36441
|
//#endregion
|
|
36442
|
+
//#region src/types/utils.d.ts
|
|
36443
|
+
/**
|
|
36444
|
+
* Represents `null` or `undefined`, used throughout the engine to express optional absence.
|
|
36445
|
+
*
|
|
36446
|
+
* @remarks Prefer this alias over inlining `null | undefined` for consistency across the codebase.
|
|
36447
|
+
*
|
|
36448
|
+
* @example
|
|
36449
|
+
* ```ts
|
|
36450
|
+
* function process(value: string | Nullish) {
|
|
36451
|
+
* if (value == null) return // handles both null and undefined
|
|
36452
|
+
* }
|
|
36453
|
+
* ```
|
|
36454
|
+
*/
|
|
36455
|
+
type Nullish = null | undefined;
|
|
36456
|
+
/**
|
|
36457
|
+
* Branded string type that preserves literal union autocompletion while still accepting arbitrary strings.
|
|
36458
|
+
*
|
|
36459
|
+
* @remarks TypeScript narrows `string` to only known literals when a union is used. Intersecting with `{}` keeps the union suggestions in IDE autocomplete without rejecting unknown strings at the type level.
|
|
36460
|
+
*
|
|
36461
|
+
* @example
|
|
36462
|
+
* ```ts
|
|
36463
|
+
* type Color = 'red' | 'blue' | UnionString
|
|
36464
|
+
* const c: Color = 'red' // autocomplete suggests 'red' | 'blue'
|
|
36465
|
+
* const d: Color = 'green' // still valid
|
|
36466
|
+
* ```
|
|
36467
|
+
*/
|
|
36468
|
+
type UnionString = string & {};
|
|
36469
|
+
/**
|
|
36470
|
+
* A value that can be either a single item or an array of items.
|
|
36471
|
+
*
|
|
36472
|
+
* @typeParam T - The element type.
|
|
36473
|
+
*
|
|
36474
|
+
* @remarks Used pervasively in configuration surfaces so consumers can pass a single value or an array without explicit wrapping.
|
|
36475
|
+
*
|
|
36476
|
+
* @example
|
|
36477
|
+
* ```ts
|
|
36478
|
+
* function normalize<T>(input: Arrayable<T>): T[] {
|
|
36479
|
+
* return [input].flat() as T[]
|
|
36480
|
+
* }
|
|
36481
|
+
* normalize('a') // ['a']
|
|
36482
|
+
* normalize(['a','b']) // ['a','b']
|
|
36483
|
+
* ```
|
|
36484
|
+
*/
|
|
36485
|
+
type Arrayable<T> = T | T[];
|
|
36486
|
+
/**
|
|
36487
|
+
* A value that may be synchronous or wrapped in a `Promise`.
|
|
36488
|
+
*
|
|
36489
|
+
* @typeParam T - The resolved value type.
|
|
36490
|
+
*
|
|
36491
|
+
* @remarks Hook callbacks and plugin functions use this so authors can return either synchronously or asynchronously without the engine caring which.
|
|
36492
|
+
*
|
|
36493
|
+
* @example
|
|
36494
|
+
* ```ts
|
|
36495
|
+
* async function run(fn: () => Awaitable<string>) {
|
|
36496
|
+
* const result = await fn() // works whether fn is sync or async
|
|
36497
|
+
* }
|
|
36498
|
+
* ```
|
|
36499
|
+
*/
|
|
36500
|
+
type Awaitable<T> = T | Promise<T>;
|
|
36501
|
+
/**
|
|
36502
|
+
* Converts a union type into an intersection of all its members.
|
|
36503
|
+
*
|
|
36504
|
+
* @typeParam U - The union type to intersect.
|
|
36505
|
+
*
|
|
36506
|
+
* @remarks Leverages contra-variant inference on function parameter positions. Useful internally for merging augmented module declarations into a single combined type.
|
|
36507
|
+
*
|
|
36508
|
+
* @example
|
|
36509
|
+
* ```ts
|
|
36510
|
+
* type U = { a: 1 } | { b: 2 }
|
|
36511
|
+
* type I = UnionToIntersection<U> // { a: 1 } & { b: 2 }
|
|
36512
|
+
* ```
|
|
36513
|
+
*/
|
|
36514
|
+
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
|
|
36515
|
+
/**
|
|
36516
|
+
* Type-level strict equality check that resolves to `true` when `X` and `Y` are identical types.
|
|
36517
|
+
*
|
|
36518
|
+
* @typeParam X - First type to compare.
|
|
36519
|
+
* @typeParam Y - Second type to compare.
|
|
36520
|
+
*
|
|
36521
|
+
* @remarks Uses the double-conditional-inference trick to detect structural and modifier differences that `extends` alone would miss (e.g. `readonly` vs mutable).
|
|
36522
|
+
*
|
|
36523
|
+
* @example
|
|
36524
|
+
* ```ts
|
|
36525
|
+
* type A = IsEqual<string, string> // true
|
|
36526
|
+
* type B = IsEqual<string, number> // false
|
|
36527
|
+
* ```
|
|
36528
|
+
*/
|
|
36529
|
+
type IsEqual<X, Y> = (<T>() => T extends X ? 1 : 2) extends (<T>() => T extends Y ? 1 : 2) ? true : false;
|
|
36530
|
+
/**
|
|
36531
|
+
* Evaluates to `true` when `T` is the `never` type, `false` otherwise.
|
|
36532
|
+
*
|
|
36533
|
+
* @typeParam T - The type to test.
|
|
36534
|
+
*
|
|
36535
|
+
* @remarks Wrapping `T` in a tuple prevents distributive conditional behavior that would otherwise collapse `never` before the check runs.
|
|
36536
|
+
*
|
|
36537
|
+
* @example
|
|
36538
|
+
* ```ts
|
|
36539
|
+
* type A = IsNever<never> // true
|
|
36540
|
+
* type B = IsNever<string> // false
|
|
36541
|
+
* ```
|
|
36542
|
+
*/
|
|
36543
|
+
type IsNever<T> = [T] extends [never] ? true : false;
|
|
36544
|
+
/**
|
|
36545
|
+
* Flattens an intersection type into a single object type for improved readability in IDE tooltips.
|
|
36546
|
+
*
|
|
36547
|
+
* @typeParam T - The intersection or object type to simplify.
|
|
36548
|
+
*
|
|
36549
|
+
* @remarks Mapped types re-enumerate all keys so the resulting hover preview shows a flat `{ ... }` shape instead of `A & B & C`.
|
|
36550
|
+
*
|
|
36551
|
+
* @example
|
|
36552
|
+
* ```ts
|
|
36553
|
+
* type Merged = Simplify<{ a: 1 } & { b: 2 }> // { a: 1; b: 2 }
|
|
36554
|
+
* ```
|
|
36555
|
+
*/
|
|
36556
|
+
type Simplify<T> = { [K in keyof T]: T[K] } & {};
|
|
36557
|
+
/**
|
|
36558
|
+
* Converts a camelCase or PascalCase string literal type to kebab-case at the type level.
|
|
36559
|
+
*
|
|
36560
|
+
* @typeParam T - The string literal type to convert. CSS custom properties (`--*`) are returned as-is.
|
|
36561
|
+
*
|
|
36562
|
+
* @remarks Used to map JavaScript-style property names to their CSS kebab-case equivalents during style extraction and rendering.
|
|
36563
|
+
*
|
|
36564
|
+
* @example
|
|
36565
|
+
* ```ts
|
|
36566
|
+
* type A = ToKebab<'backgroundColor'> // 'background-color'
|
|
36567
|
+
* type B = ToKebab<'--my-var'> // '--my-var'
|
|
36568
|
+
* ```
|
|
36569
|
+
*/
|
|
36570
|
+
type ToKebab<T extends string> = T extends `--${string}` ? T : T extends `${infer A}${infer U}${infer Rest}` ? U extends Uppercase<U> ? U extends Lowercase<U> ? `${Lowercase<A>}${ToKebab<`${U}${Rest}`>}` : `${Lowercase<A>}-${ToKebab<`${Lowercase<U>}${Rest}`>}` : `${Lowercase<A>}${ToKebab<`${U}${Rest}`>}` : Lowercase<T>;
|
|
36571
|
+
/**
|
|
36572
|
+
* Converts a kebab-case string literal type to camelCase at the type level.
|
|
36573
|
+
*
|
|
36574
|
+
* @typeParam T - The string literal type to convert. CSS custom properties (`--*`) are returned as-is.
|
|
36575
|
+
*
|
|
36576
|
+
* @remarks The inverse of `ToKebab`. Used to reconcile CSS-native property names back to their JavaScript equivalents during autocomplete resolution.
|
|
36577
|
+
*
|
|
36578
|
+
* @example
|
|
36579
|
+
* ```ts
|
|
36580
|
+
* type A = FromKebab<'background-color'> // 'backgroundColor'
|
|
36581
|
+
* type B = FromKebab<'--my-var'> // '--my-var'
|
|
36582
|
+
* ```
|
|
36583
|
+
*/
|
|
36584
|
+
type FromKebab<T extends string> = T extends `--${string}` ? T : T extends `${infer Head}-${infer Tail}` ? `${Head}${FromKebab<Capitalize<Tail>>}` : T;
|
|
36585
|
+
/**
|
|
36586
|
+
* Safely extracts the value type at key `K` from object type `Obj`, returning `never` when `Obj` is `never` or `K` is not a key of `Obj`.
|
|
36587
|
+
*
|
|
36588
|
+
* @typeParam Obj - The source object type.
|
|
36589
|
+
* @typeParam K - The key to look up.
|
|
36590
|
+
*
|
|
36591
|
+
* @remarks Wrapping `Obj` in a tuple prevents distributive collapse when `Obj` is `never`.
|
|
36592
|
+
*
|
|
36593
|
+
* @example
|
|
36594
|
+
* ```ts
|
|
36595
|
+
* type V = GetValue<{ a: number }, 'a'> // number
|
|
36596
|
+
* type N = GetValue<{ a: number }, 'b'> // never
|
|
36597
|
+
* ```
|
|
36598
|
+
*/
|
|
36599
|
+
type GetValue<Obj, K extends string> = [Obj] extends [never] ? never : K extends keyof Obj ? Obj[K] : never;
|
|
36600
|
+
/**
|
|
36601
|
+
* Distributively reads one key from every member of an object union.
|
|
36602
|
+
*
|
|
36603
|
+
* @remarks Unlike {@link GetValue}, this helper intentionally distributes over
|
|
36604
|
+
* `Obj` so independent Typegen contributors add their values for the same key.
|
|
36605
|
+
*/
|
|
36606
|
+
type DistributiveGetValue<Obj, K extends PropertyKey> = Obj extends unknown ? K extends keyof Obj ? Obj[K] : never : never;
|
|
36607
|
+
/**
|
|
36608
|
+
* Conditionally resolves `T[Key]` when the key exists and its value extends `I`; otherwise falls back to `Fallback`.
|
|
36609
|
+
*
|
|
36610
|
+
* @typeParam T - The source type to look up.
|
|
36611
|
+
* @typeParam Key - The key to look up in `T`.
|
|
36612
|
+
* @typeParam I - The constraint that `T[Key]` must satisfy.
|
|
36613
|
+
* @typeParam Fallback - The default type returned when `Key` is missing or `T[Key]` does not extend `I`.
|
|
36614
|
+
*
|
|
36615
|
+
* @remarks Used extensively to resolve augmented types from `PikaAugment`, falling back to internal defaults when no augmentation is provided.
|
|
36616
|
+
*
|
|
36617
|
+
* @example
|
|
36618
|
+
* ```ts
|
|
36619
|
+
* type R = ResolveFrom<{ Foo: string }, 'Foo', string, 'default'> // string
|
|
36620
|
+
* type D = ResolveFrom<{}, 'Foo', string, 'default'> // 'default'
|
|
36621
|
+
* ```
|
|
36622
|
+
*/
|
|
36623
|
+
type ResolveFrom<T, Key extends string, I, Fallback extends I> = Key extends keyof T ? T[Key] extends I ? T[Key] : Fallback : Fallback;
|
|
36624
|
+
//#endregion
|
|
36678
36625
|
//#region src/types/public.d.ts
|
|
36679
36626
|
/**
|
|
36680
36627
|
* Mapping of CSS custom property names (starting with `--`) to their string values.
|
|
@@ -36728,29 +36675,15 @@ type CSSProperty = Extract<keyof CSSProperties, string>;
|
|
|
36728
36675
|
* ```
|
|
36729
36676
|
*/
|
|
36730
36677
|
type PropertyValue<T> = T | [value: T, fallback: T[]] | Nullish;
|
|
36731
|
-
type
|
|
36732
|
-
type
|
|
36733
|
-
type
|
|
36734
|
-
type Properties_CSS_Camel = PropertiesInput<ResolvedAutocompleteCSSPropertyValue>;
|
|
36735
|
-
type Properties_CSS_Hyphen = PropertiesHyphenInput<ResolvedAutocompleteCSSPropertyValue>;
|
|
36736
|
-
type Properties_CSS_Vars = { [K in `--${string}` & {}]?: PropertyValue<UnionString | _CssPropertiesValueWildcard> };
|
|
36737
|
-
type Properties_ExtraCSS = { [Key in ResolvedExtraCSSProperty]?: CSSPropertyInputValue<GetValue<CSSProperties, Key>, Key | ToKebab<Key> | FromKebab<Key>> };
|
|
36738
|
-
type Properties_Extra = { [Key in ResolvedExtraProperty]?: GetValue<ResolvedAutocompletePropertyValue, Key> };
|
|
36678
|
+
type Properties_CSS_Camel = PropertiesInput;
|
|
36679
|
+
type Properties_CSS_Hyphen = PropertiesHyphenInput;
|
|
36680
|
+
type Properties_CSS_Vars = { [K in `--${string}` & {}]?: PropertyValue<UnionString> };
|
|
36739
36681
|
/**
|
|
36740
|
-
* The
|
|
36741
|
-
*
|
|
36742
|
-
*
|
|
36743
|
-
*
|
|
36744
|
-
* @example
|
|
36745
|
-
* ```ts
|
|
36746
|
-
* const props: Properties = {
|
|
36747
|
-
* color: 'red',
|
|
36748
|
-
* 'font-size': '16px',
|
|
36749
|
-
* '--my-color': 'blue',
|
|
36750
|
-
* }
|
|
36751
|
-
* ```
|
|
36682
|
+
* The Core property map accepted before generated Typegen overlays domain/plugin
|
|
36683
|
+
* contributions. Generated documents compose directives and extension-owned
|
|
36684
|
+
* property/value surfaces on top of this baseline.
|
|
36752
36685
|
*/
|
|
36753
|
-
interface Properties extends Properties_CSS_Camel, Properties_CSS_Hyphen, Properties_CSS_Vars
|
|
36686
|
+
interface Properties extends Properties_CSS_Camel, Properties_CSS_Hyphen, Properties_CSS_Vars {}
|
|
36754
36687
|
type CSSPseudos = CSSPseudos$1;
|
|
36755
36688
|
/**
|
|
36756
36689
|
* Union of valid CSS selector strings for nested style definitions, including CSS at-rules and pseudo-selectors (prefixed with `$`).
|
|
@@ -36768,7 +36701,7 @@ type CSSSelector = AtRules.Nested | CSSPseudos;
|
|
|
36768
36701
|
* Union of all selector strings accepted in style definitions, including custom selectors from plugins, standard CSS selectors, and arbitrary strings.
|
|
36769
36702
|
* @internal
|
|
36770
36703
|
*
|
|
36771
|
-
* @remarks Combines `UnionString`
|
|
36704
|
+
* @remarks Combines open-ended `UnionString` authoring with built-in `CSSSelector` (at-rules + `$`-prefixed pseudos). Generated configured-selector members are layered on by Typegen rather than global augmentation.
|
|
36772
36705
|
*
|
|
36773
36706
|
* @example
|
|
36774
36707
|
* ```ts
|
|
@@ -36776,7 +36709,7 @@ type CSSSelector = AtRules.Nested | CSSPseudos;
|
|
|
36776
36709
|
* const custom: Selector = 'dark' // plugin-defined selector
|
|
36777
36710
|
* ```
|
|
36778
36711
|
*/
|
|
36779
|
-
type Selector$1 = UnionString |
|
|
36712
|
+
type Selector$1 = UnionString | CSSSelector;
|
|
36780
36713
|
/**
|
|
36781
36714
|
* A nested style definition where keys are selector strings and values are property values, property maps, nested definitions, or arrays of style items.
|
|
36782
36715
|
*
|
|
@@ -36816,34 +36749,27 @@ type StyleDefinition = Properties | StyleDefinitionMap;
|
|
|
36816
36749
|
* const itemDef: StyleItem = { color: 'red' } // inline style
|
|
36817
36750
|
* ```
|
|
36818
36751
|
*/
|
|
36819
|
-
type StyleItem = UnionString |
|
|
36752
|
+
type StyleItem = UnionString | StyleDefinition;
|
|
36820
36753
|
//#endregion
|
|
36821
36754
|
//#region src/types/shared.d.ts
|
|
36822
36755
|
/**
|
|
36823
|
-
*
|
|
36756
|
+
* Legacy generated-file augmentation bridge retained temporarily while Integration migrates to finalized Typegen documents.
|
|
36824
36757
|
*
|
|
36825
|
-
* @remarks
|
|
36758
|
+
* @remarks This is transitional plumbing, not a plugin authoring API. New authoring extensions use the Engine Typegen manager; the standalone Autocomplete dimension has been removed.
|
|
36826
36759
|
*
|
|
36827
|
-
* @example
|
|
36828
|
-
* ```ts
|
|
36829
|
-
* declare module '@pikacss/core' {
|
|
36830
|
-
* interface PikaAugment {
|
|
36831
|
-
* Autocomplete: DefineAutocomplete<{ Selector: 'dark' | 'light', Shortcut: never, Layer: never, PropertyValue: never, CSSPropertyValue: never }>
|
|
36832
|
-
* }
|
|
36833
|
-
* }
|
|
36834
|
-
* ```
|
|
36835
36760
|
*/
|
|
36836
36761
|
interface PikaAugment {}
|
|
36837
36762
|
/**
|
|
36838
|
-
*
|
|
36763
|
+
* Runtime normalization input accepted inside the engine.
|
|
36839
36764
|
* @internal
|
|
36840
36765
|
*
|
|
36841
|
-
* @remarks
|
|
36766
|
+
* @remarks This type is deliberately broader than the public `Properties` authoring contract. The extractor tolerates arbitrary JavaScript numbers at runtime and normalizes them to strings so callers that bypass or erase the public types do not make the engine fragile. Do not infer `pika()` value support from this alias: generated public CSS types keep `<number>`, `<integer>`, percentages, custom properties, and other numeric grammars string-backed. A numeric `0` is admitted only through generated length-like positions where unitless zero is unambiguous.
|
|
36842
36767
|
*
|
|
36843
36768
|
* @example
|
|
36844
36769
|
* ```ts
|
|
36845
36770
|
* const val: InternalPropertyValue = ['red', ['blue', 'green']]
|
|
36846
|
-
* const
|
|
36771
|
+
* const runtimeZero: InternalPropertyValue = 0
|
|
36772
|
+
* const runtimeNumber: InternalPropertyValue = 0.5 // tolerated internally; not a public pika() authoring value
|
|
36847
36773
|
* ```
|
|
36848
36774
|
*/
|
|
36849
36775
|
type InternalPropertyValue = PropertyValue<string | number>;
|
|
@@ -37000,79 +36926,6 @@ interface CSSStyleBlockBody {
|
|
|
37000
36926
|
type CSSStyleBlocks = Map<string, CSSStyleBlockBody>;
|
|
37001
36927
|
//#endregion
|
|
37002
36928
|
//#region src/types/resolved.d.ts
|
|
37003
|
-
/**
|
|
37004
|
-
* The effective autocomplete map resolved from `PikaAugment.Autocomplete`, falling back to `EmptyAutocomplete` when no plugin augments it.
|
|
37005
|
-
* @internal
|
|
37006
|
-
*
|
|
37007
|
-
* @remarks This is the source-of-truth autocomplete shape that all downstream resolved types (`ResolvedAutocompletePropertyValue`, `ResolvedSelector`, etc.) derive from.
|
|
37008
|
-
*
|
|
37009
|
-
* @example
|
|
37010
|
-
* ```ts
|
|
37011
|
-
* // With augmentation: resolves to the plugin-provided map
|
|
37012
|
-
* // Without augmentation: resolves to EmptyAutocomplete
|
|
37013
|
-
* type AC = ResolvedAutocomplete
|
|
37014
|
-
* ```
|
|
37015
|
-
*/
|
|
37016
|
-
type ResolvedAutocomplete = ResolveFrom<PikaAugment, 'Autocomplete', _Autocomplete, EmptyAutocomplete>;
|
|
37017
|
-
/**
|
|
37018
|
-
* The property-value record extracted from the resolved autocomplete map, mapping extra property names to their accepted value types.
|
|
37019
|
-
* @internal
|
|
37020
|
-
*
|
|
37021
|
-
* @remarks Used to derive the set of extra (non-CSS) properties and their value unions for type-safe `pika()` calls.
|
|
37022
|
-
*
|
|
37023
|
-
* @example
|
|
37024
|
-
* ```ts
|
|
37025
|
-
* type PV = ResolvedAutocompletePropertyValue // Record<string, unknown> or plugin-augmented map
|
|
37026
|
-
* ```
|
|
37027
|
-
*/
|
|
37028
|
-
type ResolvedAutocompletePropertyValue = ResolvedAutocomplete['PropertyValue'];
|
|
37029
|
-
/**
|
|
37030
|
-
* The CSS property-value record extracted from the resolved autocomplete map, mapping CSS property names to their accepted value unions.
|
|
37031
|
-
* @internal
|
|
37032
|
-
*
|
|
37033
|
-
* @remarks Used to extend the standard `CSSProperties` value types with plugin-contributed suggestions (e.g. design token names for `color`).
|
|
37034
|
-
*
|
|
37035
|
-
* @example
|
|
37036
|
-
* ```ts
|
|
37037
|
-
* type CPV = ResolvedAutocompleteCSSPropertyValue // Record<string, UnionString> or plugin-augmented map
|
|
37038
|
-
* ```
|
|
37039
|
-
*/
|
|
37040
|
-
type ResolvedAutocompleteCSSPropertyValue = ResolvedAutocomplete['CSSPropertyValue'];
|
|
37041
|
-
/**
|
|
37042
|
-
* Union of extra (non-CSS) property name strings derived from the resolved autocomplete property-value map.
|
|
37043
|
-
* @internal
|
|
37044
|
-
*
|
|
37045
|
-
* @remarks These property names (e.g. `__shortcut`, `__layer`, `__important`) are injected by core plugins into the `Properties` interface so they appear in `pika()` call autocomplete.
|
|
37046
|
-
*
|
|
37047
|
-
* @example
|
|
37048
|
-
* ```ts
|
|
37049
|
-
* type EP = ResolvedExtraProperty // '__shortcut' | '__layer' | ...
|
|
37050
|
-
* ```
|
|
37051
|
-
*/
|
|
37052
|
-
type ResolvedExtraProperty = AutocompleteKeys<ResolvedAutocompletePropertyValue>;
|
|
37053
|
-
/**
|
|
37054
|
-
* Union of extra CSS property name strings derived from the resolved autocomplete CSS property-value map.
|
|
37055
|
-
* @internal
|
|
37056
|
-
*
|
|
37057
|
-
* @remarks Includes custom properties and vendor-specific properties registered by plugins (e.g. CSS variable names from the variables plugin).
|
|
37058
|
-
*
|
|
37059
|
-
* @example
|
|
37060
|
-
* ```ts
|
|
37061
|
-
* type ECP = ResolvedExtraCSSProperty // '--my-color' | '--spacing-sm' | ...
|
|
37062
|
-
* ```
|
|
37063
|
-
*/
|
|
37064
|
-
type ResolvedExtraCSSProperty = AutocompleteKeys<ResolvedAutocompleteCSSPropertyValue>;
|
|
37065
|
-
/**
|
|
37066
|
-
* Union of known CSS `@layer` names, falling back to `UnionString` when no plugin augments the `Layer` dimension.
|
|
37067
|
-
*
|
|
37068
|
-
* @remarks When plugins define layer names via `DefineAutocomplete`, this type narrows to those names while still accepting arbitrary strings. Used in the `__layer` property autocomplete.
|
|
37069
|
-
*
|
|
37070
|
-
* @example
|
|
37071
|
-
* ```ts
|
|
37072
|
-
* type LN = ResolvedLayerName // 'base' | 'components' | ... or UnionString
|
|
37073
|
-
* ```
|
|
37074
|
-
*/
|
|
37075
|
-
type ResolvedLayerName = IsNever<ResolvedAutocomplete['Layer']> extends true ? UnionString : ResolvedAutocomplete['Layer'];
|
|
37076
36929
|
/**
|
|
37077
36930
|
* The effective selector string type resolved from `PikaAugment.Selector`, falling back to plain `string`.
|
|
37078
36931
|
* @internal
|
|
@@ -37101,14 +36954,14 @@ type ResolvedProperties = ResolveFrom<PikaAugment, 'Properties', any, InternalPr
|
|
|
37101
36954
|
* The subset of `ResolvedProperties` that contains only standard CSS properties, computed by excluding extra (non-CSS) property keys.
|
|
37102
36955
|
* @internal
|
|
37103
36956
|
*
|
|
37104
|
-
* @remarks
|
|
36957
|
+
* @remarks Core extension/directive authoring no longer flows through global autocomplete augmentation; generated Typegen owns those overlays.
|
|
37105
36958
|
*
|
|
37106
36959
|
* @example
|
|
37107
36960
|
* ```ts
|
|
37108
|
-
* type CP = ResolvedCSSProperties //
|
|
36961
|
+
* type CP = ResolvedCSSProperties // Effective CSS property surface
|
|
37109
36962
|
* ```
|
|
37110
36963
|
*/
|
|
37111
|
-
type ResolvedCSSProperties =
|
|
36964
|
+
type ResolvedCSSProperties = ResolvedProperties;
|
|
37112
36965
|
/**
|
|
37113
36966
|
* The effective `StyleDefinition` type resolved from `PikaAugment.StyleDefinition`, falling back to the internal default.
|
|
37114
36967
|
* @internal
|
|
@@ -37312,12 +37165,6 @@ interface EngineConfig {
|
|
|
37312
37165
|
* @default `'utilities'`
|
|
37313
37166
|
*/
|
|
37314
37167
|
defaultUtilitiesLayer?: string;
|
|
37315
|
-
/**
|
|
37316
|
-
* Autocomplete configuration for IDE integration and code generation type narrowing.
|
|
37317
|
-
*
|
|
37318
|
-
* @default `{}`
|
|
37319
|
-
*/
|
|
37320
|
-
autocomplete?: AutocompleteConfig;
|
|
37321
37168
|
}
|
|
37322
37169
|
/**
|
|
37323
37170
|
* Fully resolved engine configuration produced after plugin hooks have processed the raw config.
|
|
@@ -37344,8 +37191,6 @@ interface ResolvedEngineConfig {
|
|
|
37344
37191
|
preflights: ResolvedPreflight[];
|
|
37345
37192
|
/** Deduplicated and semicolon-terminated CSS `@import` statements. */
|
|
37346
37193
|
cssImports: string[];
|
|
37347
|
-
/** Resolved autocomplete configuration with `Set`/`Map` collections for efficient incremental appending. */
|
|
37348
|
-
autocomplete: ResolvedAutocompleteConfig;
|
|
37349
37194
|
/** CSS `@layer` name-to-order mapping used for ordering layer blocks in output. */
|
|
37350
37195
|
layers: Record<string, number>;
|
|
37351
37196
|
/** Name of the default `@layer` for preflight styles. */
|
|
@@ -37354,6 +37199,32 @@ interface ResolvedEngineConfig {
|
|
|
37354
37199
|
defaultUtilitiesLayer: string;
|
|
37355
37200
|
}
|
|
37356
37201
|
//#endregion
|
|
37202
|
+
//#region src/typegen/render.d.ts
|
|
37203
|
+
/** Output shape of the configured base Pika callable. */
|
|
37204
|
+
type TransformedFormat = 'string' | 'array';
|
|
37205
|
+
/** Host/project binding for one isolated Engine Typegen snapshot. */
|
|
37206
|
+
interface TypegenRenderUnit {
|
|
37207
|
+
/** Finalized semantic Typegen state to compose into the generated declaration namespace. */
|
|
37208
|
+
readonly snapshot: TypegenSnapshot;
|
|
37209
|
+
/** Globally visible configured Pika callable identifier. */
|
|
37210
|
+
readonly fnName: string;
|
|
37211
|
+
/** Runtime transform shape of the base callable. */
|
|
37212
|
+
readonly transformedFormat: TransformedFormat;
|
|
37213
|
+
/** Public package specifier from which Core authoring types are consumed. */
|
|
37214
|
+
readonly publicModule: string;
|
|
37215
|
+
/** Host-bound preview href resolution scoped to this isolated snapshot. */
|
|
37216
|
+
readonly hostBindings?: TypegenJSDocRenderBindings;
|
|
37217
|
+
/** Whether this host needs Vue template-instance globals for the callable. */
|
|
37218
|
+
readonly vueTemplateGlobals?: boolean;
|
|
37219
|
+
}
|
|
37220
|
+
/**
|
|
37221
|
+
* Renders one collision-safe TypeScript declaration document from isolated
|
|
37222
|
+
* finalized Engine Typegen snapshots and explicit project/host bindings.
|
|
37223
|
+
*
|
|
37224
|
+
* @param units - Isolated finalized snapshots and host bindings to render as one declaration document.
|
|
37225
|
+
*/
|
|
37226
|
+
declare function renderTypegenDocument(units: readonly TypegenRenderUnit[]): string;
|
|
37227
|
+
//#endregion
|
|
37357
37228
|
//#region src/utils.d.ts
|
|
37358
37229
|
/**
|
|
37359
37230
|
* Creates a scoped logger with configurable log-level functions and a toggleable debug mode.
|
|
@@ -37439,24 +37310,6 @@ declare function isPlainObjectRecord(value: unknown): value is Record<string, un
|
|
|
37439
37310
|
* ```
|
|
37440
37311
|
*/
|
|
37441
37312
|
declare function escapeRegExp(value: string): string;
|
|
37442
|
-
/**
|
|
37443
|
-
* Merges an `AutocompleteContribution` or `AutocompleteConfig` into the resolved autocomplete state, returning whether any entry changed.
|
|
37444
|
-
*
|
|
37445
|
-
* @param config - The resolved engine config (or a subset with the `autocomplete` field) to mutate.
|
|
37446
|
-
* @param contribution - The autocomplete entries to merge in.
|
|
37447
|
-
* @returns `true` if any selector, shortcut, property, CSS property, or pattern entry was added or extended.
|
|
37448
|
-
*
|
|
37449
|
-
* @remarks Called by `engine.appendAutocomplete()` and during initial config resolution. Each sub-field (selectors, shortcuts, etc.) is independently merged and the function returns `true` if any of them changed, which triggers an `autocompleteConfigUpdated` notification.
|
|
37450
|
-
*
|
|
37451
|
-
* @example
|
|
37452
|
-
* ```ts
|
|
37453
|
-
* const changed = appendAutocomplete(resolvedConfig, {
|
|
37454
|
-
* selectors: 'dark',
|
|
37455
|
-
* cssProperties: { color: 'primary' },
|
|
37456
|
-
* })
|
|
37457
|
-
* ```
|
|
37458
|
-
*/
|
|
37459
|
-
declare function appendAutocomplete(config: Pick<ResolvedEngineConfig, 'autocomplete'>, contribution: AutocompleteContribution | AutocompleteConfig): boolean;
|
|
37460
37313
|
/**
|
|
37461
37314
|
* Serializes a `CSSStyleBlocks` tree into a CSS string, optionally formatted with indentation and newlines.
|
|
37462
37315
|
*
|
|
@@ -37485,13 +37338,18 @@ declare function renderCSSStyleBlocks(blocks: CSSStyleBlocks, isFormatted: boole
|
|
|
37485
37338
|
* @param config - The engine configuration object.
|
|
37486
37339
|
* @returns The same configuration object, unchanged.
|
|
37487
37340
|
*
|
|
37488
|
-
* @remarks A compile-time-only helper with no runtime effect.
|
|
37341
|
+
* @remarks A compile-time-only helper with no runtime effect. Use it for low-level `EngineConfig` authoring or as a typed value nested under the canonical project `defineConfig({ engine: ... })` surface. It is not itself the default-export root for `pika.config.*`.
|
|
37489
37342
|
*
|
|
37490
37343
|
* @example
|
|
37491
37344
|
* ```ts
|
|
37492
|
-
*
|
|
37345
|
+
* import { defineEngineConfig } from '@pikacss/core'
|
|
37346
|
+
*
|
|
37347
|
+
* const engineConfig = defineEngineConfig({
|
|
37348
|
+
* prefix: 'pk-',
|
|
37349
|
+
* plugins: [],
|
|
37350
|
+
* })
|
|
37493
37351
|
* ```
|
|
37494
37352
|
*/
|
|
37495
37353
|
declare function defineEngineConfig<const T extends EngineConfig>(config: T): T;
|
|
37496
37354
|
//#endregion
|
|
37497
|
-
export { Arrayable, type
|
|
37355
|
+
export { Arrayable, type AtomicStyleIdContext, type AtomicStyleIdStrategy, Awaitable, type CSSProperty, type CSSSelector, type CSSStyleBlockBody, type CSSStyleBlocks, type CreateEngineOptions, type Diagnostic, type DiagnosticHandler, type DiagnosticLevel, DistributiveGetValue, DynamicSelector, DynamicShortcut, type Engine, type EngineConfig, type EngineConfigDependency, type EngineConfigurator, type EngineHostContext, type EnginePlugin, type EnginePluginContext, ExternalKeyframesDefinition, ExternalVariable, FromKebab, GetValue, ImportantConfig, IsEqual, IsNever, Keyframes, KeyframesConfig, KeyframesProgress, LocalKeyframesDefinition, LocalVariable, Nullish, type PikaAugment, type PikaManager, type PikaRegistrationCapability, type Preflight, type PreflightDefinition, type PreflightFn, type Properties, type PropertyValue, ResolveFrom, type ResolvedPreflight, Selector, SelectorsConfig, Shortcut, ShortcutPreviewCollector, ShortcutPreviewImage, ShortcutResolutionContext, ShortcutsConfig, Simplify, StaticSelector, StaticShortcut, type StyleDefinition, type StyleDefinitionMap, type StyleItem, type StyleUsePlan, ToKebab, type TransformedFormat, type PropertiesHyphenInput as TypegenCSSPropertiesHyphenInput, type PropertiesInput as TypegenCSSPropertiesInput, type PropertyInputValue as TypegenCSSPropertyInputValue, type TypegenContribution, type TypegenJSDocRenderBindings, type TypegenManager, type TypegenRegistrationCapability, type TypegenRenderUnit, type TypegenSnapshot, type TypegenSnapshotContribution, UnionString, UnionToIntersection, Variable, VariableSuggest, VariablesConfig, VariablesDefinition, createEngine, createLogger, defineEngineConfig, defineEnginePlugin, escapeRegExp, extractUsedVarNames, extractUsedVarNamesFromPreflightResult, important, isPlainObjectRecord, keyframes, log, normalizeVariableName, renderCSSStyleBlocks, renderTypegenDocument, renderTypegenJSDoc, resolveSelectorConfig, resolveShortcutConfig, selectors$1 as selectors, shortcuts, sortLayerNames, variables };
|