@pikacss/core 0.0.62 → 0.0.64
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 +734 -1021
- package/dist/index.mjs +1116 -558
- 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<void>;
|
|
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;
|
|
138
|
+
}
|
|
139
|
+
interface KeyframesState {
|
|
140
|
+
definitions: Keyframes[];
|
|
141
|
+
defaultPruneUnused: boolean;
|
|
142
|
+
store: Map<string, ResolvedKeyframesConfig>;
|
|
152
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. */
|
|
@@ -194,8 +187,33 @@ interface EngineHostContext {
|
|
|
194
187
|
* `config.root`, Nuxt's `rootDir`). Absent for standalone `createEngine()`
|
|
195
188
|
* callers that supply no host context.
|
|
196
189
|
*/
|
|
197
|
-
projectRoot?: string;
|
|
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;
|
|
198
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
|
+
}>;
|
|
199
217
|
/** Runtime-only options accepted by {@link createEngine}. */
|
|
200
218
|
interface CreateEngineOptions {
|
|
201
219
|
/**
|
|
@@ -203,14 +221,28 @@ interface CreateEngineOptions {
|
|
|
203
221
|
*
|
|
204
222
|
* @default A no-op handler.
|
|
205
223
|
*/
|
|
206
|
-
onDiagnostic?: DiagnosticHandler;
|
|
224
|
+
readonly onDiagnostic?: DiagnosticHandler;
|
|
207
225
|
/**
|
|
208
226
|
* Host semantic metadata for this engine (e.g. the effective project
|
|
209
227
|
* root). Exposed to plugins as `context.host`.
|
|
210
228
|
*
|
|
211
229
|
* @default An empty context.
|
|
212
230
|
*/
|
|
213
|
-
host?: EngineHostContext;
|
|
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;
|
|
214
246
|
}
|
|
215
247
|
/**
|
|
216
248
|
* Context passed to plugin hooks by the engine.
|
|
@@ -237,7 +269,7 @@ interface EnginePluginContext<State = void> {
|
|
|
237
269
|
* Host semantic metadata for this engine (#118). Read-only from a
|
|
238
270
|
* plugin's perspective; empty when no host context was supplied.
|
|
239
271
|
*/
|
|
240
|
-
host: EngineHostContext;
|
|
272
|
+
readonly host: EngineHostContext;
|
|
241
273
|
}
|
|
242
274
|
//#endregion
|
|
243
275
|
//#region src/resolver.d.ts
|
|
@@ -463,23 +495,7 @@ declare abstract class RecursiveResolver<T> extends AbstractResolver<T[]> {
|
|
|
463
495
|
*/
|
|
464
496
|
resolve(string: string, _visited?: Set<string>): Promise<T[]>;
|
|
465
497
|
}
|
|
466
|
-
/**
|
|
467
|
-
* Discriminated union describing a resolved rule configuration, either static or dynamic.
|
|
468
|
-
* @internal
|
|
469
|
-
*
|
|
470
|
-
* @typeParam T - The element type of the rule's resolved value array.
|
|
471
|
-
*
|
|
472
|
-
* @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.
|
|
473
|
-
*
|
|
474
|
-
* @example
|
|
475
|
-
* ```ts
|
|
476
|
-
* const config: ResolvedRuleConfig<string> = {
|
|
477
|
-
* type: 'static',
|
|
478
|
-
* rule: { key: 'hover', string: 'hover', resolved: ['$:hover'] },
|
|
479
|
-
* autocomplete: ['hover'],
|
|
480
|
-
* }
|
|
481
|
-
* ```
|
|
482
|
-
*/
|
|
498
|
+
/** Discriminated normalized rule used by selector/shortcut private registries. */
|
|
483
499
|
type ResolvedRuleConfig<T> = {
|
|
484
500
|
type: 'static';
|
|
485
501
|
rule: StaticRule<T[]>;
|
|
@@ -491,324 +507,243 @@ type ResolvedRuleConfig<T> = {
|
|
|
491
507
|
};
|
|
492
508
|
//#endregion
|
|
493
509
|
//#region src/plugins/selectors.d.ts
|
|
494
|
-
/**
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
* - **Tuple `[string, value]`**: a static rule mapping an exact selector name to one or more resolved CSS selectors.
|
|
500
|
-
* - **Tuple `[RegExp, fn, autocomplete?]`**: a dynamic rule matching a pattern and lazily computing resolved CSS selectors.
|
|
501
|
-
* - **Object `{ selector, value, autocomplete? }`**: an explicit form of either static or dynamic rule.
|
|
502
|
-
*
|
|
503
|
-
* 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).
|
|
504
|
-
*
|
|
505
|
-
* @example
|
|
506
|
-
* ```ts
|
|
507
|
-
* const rules: Selector[] = [
|
|
508
|
-
* ['hover', '$:hover'],
|
|
509
|
-
* [/^media-(\d+)$/, m => `@media (min-width: ${m[1]}px)`, 'media-${breakpoint}'],
|
|
510
|
-
* ]
|
|
511
|
-
* ```
|
|
512
|
-
*/
|
|
513
|
-
type Selector = string | [selector: RegExp, value: (matched: RegExpMatchArray) => Awaitable<Arrayable<UnionString | ResolvedSelector> | Nullish>, autocomplete?: Arrayable<string>] | [selector: string, value: Arrayable<UnionString | ResolvedSelector>] | {
|
|
514
|
-
selector: RegExp;
|
|
515
|
-
value: (matched: RegExpMatchArray) => Awaitable<Arrayable<UnionString | ResolvedSelector> | Nullish>;
|
|
516
|
-
autocomplete?: Arrayable<string>;
|
|
517
|
-
} | {
|
|
518
|
-
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. */
|
|
519
515
|
value: Arrayable<UnionString | ResolvedSelector>;
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
*/
|
|
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. */
|
|
533
544
|
interface SelectorsConfig {
|
|
534
|
-
/**
|
|
545
|
+
/** Static and dynamic selector definitions available to the engine. */
|
|
535
546
|
definitions: Selector[];
|
|
536
547
|
}
|
|
537
548
|
declare module '@pikacss/core' {
|
|
538
549
|
interface EngineConfig {
|
|
539
|
-
/**
|
|
540
|
-
* Selector rules configuration.
|
|
541
|
-
*
|
|
542
|
-
* @default undefined
|
|
543
|
-
*/
|
|
550
|
+
/** Selector definitions consumed once during Engine initialization. */
|
|
544
551
|
selectors?: SelectorsConfig;
|
|
545
552
|
}
|
|
546
|
-
interface Engine {
|
|
547
|
-
/** Runtime selector management: resolver instance and `add` method for registering selectors after engine creation. */
|
|
548
|
-
selectors: {
|
|
549
|
-
resolver: SelectorResolver;
|
|
550
|
-
add: (...list: Selector[]) => void;
|
|
551
|
-
};
|
|
552
|
-
}
|
|
553
553
|
}
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
*
|
|
561
|
-
* @example
|
|
562
|
-
* ```ts
|
|
563
|
-
* createEngine({ plugins: [selectors()] })
|
|
564
|
-
* ```
|
|
565
|
-
*/
|
|
566
|
-
declare function selectors$1(): EnginePlugin<void>;
|
|
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>;
|
|
567
560
|
declare class SelectorResolver extends RecursiveResolver<string> {}
|
|
568
|
-
/**
|
|
569
|
-
|
|
570
|
-
*
|
|
571
|
-
* @param config - The selector rule configuration to resolve.
|
|
572
|
-
* @returns A resolved static/dynamic rule config, a redirect string, or `undefined` if the shape is unrecognized.
|
|
573
|
-
*
|
|
574
|
-
* @remarks Delegates to the generic `resolveRuleConfig` with `'selector'` as the key name.
|
|
575
|
-
*
|
|
576
|
-
* @example
|
|
577
|
-
* ```ts
|
|
578
|
-
* const resolved = resolveSelectorConfig(['hover', '$:hover'])
|
|
579
|
-
* ```
|
|
580
|
-
*/
|
|
581
|
-
declare function resolveSelectorConfig(config: Selector): string | Nullish | ResolvedRuleConfig<string>;
|
|
561
|
+
/** @internal */
|
|
562
|
+
declare function resolveSelectorConfig(config: Selector): Nullish | ResolvedRuleConfig<string>;
|
|
582
563
|
//#endregion
|
|
583
564
|
//#region src/plugins/shortcuts.d.ts
|
|
584
|
-
/**
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
* @example
|
|
590
|
-
* ```ts
|
|
591
|
-
* const rules: Shortcut[] = [
|
|
592
|
-
* ['btn', [{ padding: '0.5rem 1rem' }, { borderRadius: '0.25rem' }]],
|
|
593
|
-
* [/^btn-(.+)$/, m => ({ backgroundColor: m[1] }), 'btn-${color}'],
|
|
594
|
-
* ]
|
|
595
|
-
* ```
|
|
596
|
-
*/
|
|
597
|
-
type Shortcut = string | [shortcut: RegExp, value: (matched: RegExpMatchArray) => Awaitable<Arrayable<ResolvedStyleItem> | Nullish>, autocomplete?: Arrayable<string>] | {
|
|
598
|
-
shortcut: RegExp;
|
|
599
|
-
value: (matched: RegExpMatchArray) => Awaitable<Arrayable<ResolvedStyleItem> | Nullish>;
|
|
600
|
-
autocomplete?: Arrayable<string>;
|
|
601
|
-
} | [shortcut: string, value: Arrayable<ResolvedStyleItem>] | {
|
|
602
|
-
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. */
|
|
603
570
|
value: Arrayable<ResolvedStyleItem>;
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
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. */
|
|
617
624
|
interface ShortcutsConfig {
|
|
618
|
-
/**
|
|
625
|
+
/** Static and dynamic shortcut definitions available to the engine. */
|
|
619
626
|
definitions: Shortcut[];
|
|
620
627
|
}
|
|
621
628
|
declare module '@pikacss/core' {
|
|
622
629
|
interface EngineConfig {
|
|
623
|
-
/**
|
|
624
|
-
* Shortcut rules configuration.
|
|
625
|
-
*
|
|
626
|
-
* @default undefined
|
|
627
|
-
*/
|
|
630
|
+
/** Shortcut definitions consumed once during Engine initialization. */
|
|
628
631
|
shortcuts?: ShortcutsConfig;
|
|
629
632
|
}
|
|
630
|
-
interface Engine {
|
|
631
|
-
/** Runtime shortcut management: resolver instance and `add` method for registering shortcuts after engine creation. */
|
|
632
|
-
shortcuts: {
|
|
633
|
-
resolver: ShortcutResolver;
|
|
634
|
-
add: (...list: Shortcut[]) => void;
|
|
635
|
-
};
|
|
636
|
-
}
|
|
637
633
|
}
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
*
|
|
645
|
-
* @example
|
|
646
|
-
* ```ts
|
|
647
|
-
* createEngine({ plugins: [shortcuts()] })
|
|
648
|
-
* ```
|
|
649
|
-
*/
|
|
650
|
-
declare function shortcuts(): EnginePlugin<void>;
|
|
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>;
|
|
651
640
|
declare class ShortcutResolver extends RecursiveResolver<InternalStyleItem> {}
|
|
641
|
+
/** @internal */
|
|
642
|
+
declare function resolveShortcutConfig(config: Shortcut): Nullish | ResolvedRuleConfig<StyleItem>;
|
|
652
643
|
//#endregion
|
|
653
644
|
//#region src/plugins/variables.d.ts
|
|
654
|
-
type ResolvedCSSProperty = keyof ResolvedCSSProperties;
|
|
655
|
-
/**
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
*
|
|
660
|
-
*
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
*/
|
|
665
|
-
|
|
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}`];
|
|
666
657
|
/**
|
|
667
|
-
*
|
|
668
|
-
*
|
|
669
|
-
* @default undefined (`'*'` when unset)
|
|
658
|
+
* Controls Typegen suggestions for this variable.
|
|
659
|
+
* @default `{ asProperty: true, asValueOf: false }`
|
|
670
660
|
*/
|
|
671
|
-
|
|
661
|
+
suggest?: VariableSuggest;
|
|
672
662
|
/**
|
|
673
|
-
*
|
|
674
|
-
*
|
|
675
|
-
* @default true
|
|
663
|
+
* Documentation rendered for the generated Typegen variable member.
|
|
664
|
+
* @default `undefined`
|
|
676
665
|
*/
|
|
677
|
-
|
|
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;
|
|
678
677
|
}
|
|
679
|
-
/**
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
*
|
|
684
|
-
* @example
|
|
685
|
-
* ```ts
|
|
686
|
-
* const v: VariableObject = {
|
|
687
|
-
* value: '#3b82f6',
|
|
688
|
-
* autocomplete: { asValueOf: '*' },
|
|
689
|
-
* pruneUnused: false,
|
|
690
|
-
* }
|
|
691
|
-
* ```
|
|
692
|
-
*/
|
|
693
|
-
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;
|
|
694
682
|
/**
|
|
695
|
-
*
|
|
696
|
-
*
|
|
697
|
-
* @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 }`
|
|
698
685
|
*/
|
|
699
|
-
|
|
686
|
+
suggest?: VariableSuggest;
|
|
700
687
|
/**
|
|
701
|
-
*
|
|
702
|
-
*
|
|
703
|
-
* @default undefined (`'*'` value suggestions when unset)
|
|
688
|
+
* Documentation rendered for the generated Typegen variable member.
|
|
689
|
+
* @default `undefined`
|
|
704
690
|
*/
|
|
705
|
-
|
|
691
|
+
description?: string;
|
|
706
692
|
/**
|
|
707
|
-
*
|
|
708
|
-
*
|
|
709
|
-
* @default true (inherits from `VariablesConfig.pruneUnused`)
|
|
693
|
+
* Discriminator excluding local variable definitions.
|
|
694
|
+
* @default `undefined`
|
|
710
695
|
*/
|
|
711
|
-
|
|
696
|
+
value?: never;
|
|
697
|
+
/**
|
|
698
|
+
* External variables are never pruned by PikaCSS.
|
|
699
|
+
* @default `undefined`
|
|
700
|
+
*/
|
|
701
|
+
pruneUnused?: never;
|
|
712
702
|
}
|
|
713
|
-
/**
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
* @remarks Use the short form for simple values. Use `VariableObject` when autocomplete control or pruning opt-out is needed.
|
|
717
|
-
*
|
|
718
|
-
* @example
|
|
719
|
-
* ```ts
|
|
720
|
-
* const simple: Variable = '#fff'
|
|
721
|
-
* const rich: Variable = { value: '#fff', autocomplete: { asValueOf: ['color'] } }
|
|
722
|
-
* ```
|
|
723
|
-
*/
|
|
724
|
-
type Variable = ResolvedCSSProperties[`--${string}`] | VariableObject;
|
|
725
|
-
/**
|
|
726
|
-
* A nested record mapping CSS variable names (`--*`) and optional selector scopes to variable definitions.
|
|
727
|
-
*
|
|
728
|
-
* @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.
|
|
729
|
-
*
|
|
730
|
-
* @example
|
|
731
|
-
* ```ts
|
|
732
|
-
* const def: VariablesDefinition = {
|
|
733
|
-
* '--color-primary': '#3b82f6',
|
|
734
|
-
* '.dark': { '--color-primary': '#60a5fa' },
|
|
735
|
-
* }
|
|
736
|
-
* ```
|
|
737
|
-
*/
|
|
703
|
+
/** Canonical object-only variable leaf. */
|
|
704
|
+
type Variable = LocalVariable | ExternalVariable;
|
|
705
|
+
/** CSS-like nested variable definition tree. Non-variable keys are selector scopes. */
|
|
738
706
|
type VariablesDefinition = { [key in UnionString | ResolvedSelector]?: Variable | VariablesDefinition };
|
|
739
|
-
/**
|
|
740
|
-
* Configuration object for the `variables` engine option.
|
|
741
|
-
*
|
|
742
|
-
* @remarks Passed via `EngineConfig.variables` to define CSS custom properties, control pruning, and specify a safe list.
|
|
743
|
-
*
|
|
744
|
-
* @example
|
|
745
|
-
* ```ts
|
|
746
|
-
* const config: VariablesConfig = {
|
|
747
|
-
* definitions: {
|
|
748
|
-
* '--color-primary': '#3b82f6',
|
|
749
|
-
* '--shadow-elevated': '0 12px 40px rgb(0 0 0 / 0.12)',
|
|
750
|
-
* },
|
|
751
|
-
* pruneUnused: true,
|
|
752
|
-
* safeList: ['--color-primary'],
|
|
753
|
-
* }
|
|
754
|
-
* ```
|
|
755
|
-
*/
|
|
707
|
+
/** Configuration for the built-in CSS variables subsystem. */
|
|
756
708
|
interface VariablesConfig {
|
|
757
|
-
/**
|
|
709
|
+
/** Variable definition trees. Later entries override earlier entries at the same selector/name path. */
|
|
758
710
|
definitions?: Arrayable<VariablesDefinition>;
|
|
759
|
-
/**
|
|
760
|
-
* Default pruning policy for variables that are not referenced by any atomic style or preflight.
|
|
761
|
-
*
|
|
762
|
-
* @default true
|
|
763
|
-
*/
|
|
711
|
+
/** Default pruning policy for local variables. @default true */
|
|
764
712
|
pruneUnused?: boolean;
|
|
765
|
-
/**
|
|
766
|
-
* Variable names that should always be emitted regardless of usage.
|
|
767
|
-
*
|
|
768
|
-
* @default []
|
|
769
|
-
*/
|
|
713
|
+
/** Variable names always emitted regardless of usage. */
|
|
770
714
|
safeList?: (`--${string}` & {})[];
|
|
771
715
|
}
|
|
772
716
|
declare module '@pikacss/core' {
|
|
773
717
|
interface EngineConfig {
|
|
774
|
-
/**
|
|
775
|
-
* CSS custom properties (variables) configuration.
|
|
776
|
-
*
|
|
777
|
-
* @default undefined
|
|
778
|
-
*/
|
|
718
|
+
/** CSS variable definitions consumed once during Engine initialization. */
|
|
779
719
|
variables?: VariablesConfig;
|
|
780
720
|
}
|
|
781
721
|
interface Engine {
|
|
782
|
-
/**
|
|
783
|
-
|
|
784
|
-
store: Map<string, ResolvedVariable[]>;
|
|
785
|
-
add: (variables: VariablesDefinition) => void;
|
|
786
|
-
};
|
|
722
|
+
/** Readonly semantic query of variable names referenced by current atomic styles, expanded transitively through configured variable values. */
|
|
723
|
+
getUsedVariableNames: () => ReadonlySet<string>;
|
|
787
724
|
}
|
|
788
725
|
}
|
|
789
|
-
/**
|
|
790
|
-
* Built-in engine plugin that provides CSS custom properties (variables) with smart pruning and autocomplete integration.
|
|
791
|
-
*
|
|
792
|
-
* @returns An `EnginePlugin` that registers variable definitions, manages a preflight for emitting `:root` / scoped variables, and prunes unused variables from the output.
|
|
793
|
-
*
|
|
794
|
-
* @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.
|
|
795
|
-
*
|
|
796
|
-
* @example
|
|
797
|
-
* ```ts
|
|
798
|
-
* createEngine({ plugins: [variables()] })
|
|
799
|
-
* ```
|
|
800
|
-
*/
|
|
801
|
-
declare function variables(): EnginePlugin<void>;
|
|
802
726
|
interface ResolvedVariable {
|
|
803
727
|
name: string;
|
|
804
|
-
value
|
|
728
|
+
value?: InternalPropertyValue;
|
|
805
729
|
selector: string[];
|
|
806
730
|
pruneUnused: boolean;
|
|
807
|
-
|
|
731
|
+
suggest: {
|
|
808
732
|
asValueOf: string[];
|
|
809
733
|
asProperty: boolean;
|
|
810
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[]>;
|
|
811
744
|
}
|
|
745
|
+
/** Built-in CSS variable subsystem with config-only semantic ingress. */
|
|
746
|
+
declare function variables(): EnginePlugin<VariablesState>;
|
|
812
747
|
/**
|
|
813
748
|
* Extracts all CSS variable names referenced via `var(--*)` calls in a string.
|
|
814
749
|
*
|
|
@@ -855,522 +790,212 @@ declare function normalizeVariableName(name: string): string;
|
|
|
855
790
|
*/
|
|
856
791
|
declare function extractUsedVarNamesFromPreflightResult(result: string | PreflightDefinition): string[];
|
|
857
792
|
//#endregion
|
|
858
|
-
//#region src/
|
|
859
|
-
/**
|
|
860
|
-
* Represents `null` or `undefined`, used throughout the engine to express optional absence.
|
|
861
|
-
*
|
|
862
|
-
* @remarks Prefer this alias over inlining `null | undefined` for consistency across the codebase.
|
|
863
|
-
*
|
|
864
|
-
* @example
|
|
865
|
-
* ```ts
|
|
866
|
-
* function process(value: string | Nullish) {
|
|
867
|
-
* if (value == null) return // handles both null and undefined
|
|
868
|
-
* }
|
|
869
|
-
* ```
|
|
870
|
-
*/
|
|
871
|
-
type Nullish = null | undefined;
|
|
872
|
-
/**
|
|
873
|
-
* Branded string type that preserves literal union autocompletion while still accepting arbitrary strings.
|
|
874
|
-
*
|
|
875
|
-
* @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.
|
|
876
|
-
*
|
|
877
|
-
* @example
|
|
878
|
-
* ```ts
|
|
879
|
-
* type Color = 'red' | 'blue' | UnionString
|
|
880
|
-
* const c: Color = 'red' // autocomplete suggests 'red' | 'blue'
|
|
881
|
-
* const d: Color = 'green' // still valid
|
|
882
|
-
* ```
|
|
883
|
-
*/
|
|
884
|
-
type UnionString = string & {};
|
|
885
|
-
/**
|
|
886
|
-
* A value that can be either a single item or an array of items.
|
|
887
|
-
*
|
|
888
|
-
* @typeParam T - The element type.
|
|
889
|
-
*
|
|
890
|
-
* @remarks Used pervasively in configuration surfaces so consumers can pass a single value or an array without explicit wrapping.
|
|
891
|
-
*
|
|
892
|
-
* @example
|
|
893
|
-
* ```ts
|
|
894
|
-
* function normalize<T>(input: Arrayable<T>): T[] {
|
|
895
|
-
* return [input].flat() as T[]
|
|
896
|
-
* }
|
|
897
|
-
* normalize('a') // ['a']
|
|
898
|
-
* normalize(['a','b']) // ['a','b']
|
|
899
|
-
* ```
|
|
900
|
-
*/
|
|
901
|
-
type Arrayable<T> = T | T[];
|
|
902
|
-
/**
|
|
903
|
-
* A value that may be synchronous or wrapped in a `Promise`.
|
|
904
|
-
*
|
|
905
|
-
* @typeParam T - The resolved value type.
|
|
906
|
-
*
|
|
907
|
-
* @remarks Hook callbacks and plugin functions use this so authors can return either synchronously or asynchronously without the engine caring which.
|
|
908
|
-
*
|
|
909
|
-
* @example
|
|
910
|
-
* ```ts
|
|
911
|
-
* async function run(fn: () => Awaitable<string>) {
|
|
912
|
-
* const result = await fn() // works whether fn is sync or async
|
|
913
|
-
* }
|
|
914
|
-
* ```
|
|
915
|
-
*/
|
|
916
|
-
type Awaitable<T> = T | Promise<T>;
|
|
917
|
-
/**
|
|
918
|
-
* Converts a union type into an intersection of all its members.
|
|
919
|
-
*
|
|
920
|
-
* @typeParam U - The union type to intersect.
|
|
921
|
-
*
|
|
922
|
-
* @remarks Leverages contra-variant inference on function parameter positions. Useful internally for merging augmented module declarations into a single combined type.
|
|
923
|
-
*
|
|
924
|
-
* @example
|
|
925
|
-
* ```ts
|
|
926
|
-
* type U = { a: 1 } | { b: 2 }
|
|
927
|
-
* type I = UnionToIntersection<U> // { a: 1 } & { b: 2 }
|
|
928
|
-
* ```
|
|
929
|
-
*/
|
|
930
|
-
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
|
|
931
|
-
/**
|
|
932
|
-
* Type-level strict equality check that resolves to `true` when `X` and `Y` are identical types.
|
|
933
|
-
*
|
|
934
|
-
* @typeParam X - First type to compare.
|
|
935
|
-
* @typeParam Y - Second type to compare.
|
|
936
|
-
*
|
|
937
|
-
* @remarks Uses the double-conditional-inference trick to detect structural and modifier differences that `extends` alone would miss (e.g. `readonly` vs mutable).
|
|
938
|
-
*
|
|
939
|
-
* @example
|
|
940
|
-
* ```ts
|
|
941
|
-
* type A = IsEqual<string, string> // true
|
|
942
|
-
* type B = IsEqual<string, number> // false
|
|
943
|
-
* ```
|
|
944
|
-
*/
|
|
945
|
-
type IsEqual<X, Y> = (<T>() => T extends X ? 1 : 2) extends (<T>() => T extends Y ? 1 : 2) ? true : false;
|
|
946
|
-
/**
|
|
947
|
-
* Evaluates to `true` when `T` is the `never` type, `false` otherwise.
|
|
948
|
-
*
|
|
949
|
-
* @typeParam T - The type to test.
|
|
950
|
-
*
|
|
951
|
-
* @remarks Wrapping `T` in a tuple prevents distributive conditional behavior that would otherwise collapse `never` before the check runs.
|
|
952
|
-
*
|
|
953
|
-
* @example
|
|
954
|
-
* ```ts
|
|
955
|
-
* type A = IsNever<never> // true
|
|
956
|
-
* type B = IsNever<string> // false
|
|
957
|
-
* ```
|
|
958
|
-
*/
|
|
959
|
-
type IsNever<T> = [T] extends [never] ? true : false;
|
|
960
|
-
/**
|
|
961
|
-
* Flattens an intersection type into a single object type for improved readability in IDE tooltips.
|
|
962
|
-
*
|
|
963
|
-
* @typeParam T - The intersection or object type to simplify.
|
|
964
|
-
*
|
|
965
|
-
* @remarks Mapped types re-enumerate all keys so the resulting hover preview shows a flat `{ ... }` shape instead of `A & B & C`.
|
|
966
|
-
*
|
|
967
|
-
* @example
|
|
968
|
-
* ```ts
|
|
969
|
-
* type Merged = Simplify<{ a: 1 } & { b: 2 }> // { a: 1; b: 2 }
|
|
970
|
-
* ```
|
|
971
|
-
*/
|
|
972
|
-
type Simplify<T> = { [K in keyof T]: T[K] } & {};
|
|
973
|
-
/**
|
|
974
|
-
* Converts a camelCase or PascalCase string literal type to kebab-case at the type level.
|
|
975
|
-
*
|
|
976
|
-
* @typeParam T - The string literal type to convert. CSS custom properties (`--*`) are returned as-is.
|
|
977
|
-
*
|
|
978
|
-
* @remarks Used to map JavaScript-style property names to their CSS kebab-case equivalents during style extraction and rendering.
|
|
979
|
-
*
|
|
980
|
-
* @example
|
|
981
|
-
* ```ts
|
|
982
|
-
* type A = ToKebab<'backgroundColor'> // 'background-color'
|
|
983
|
-
* type B = ToKebab<'--my-var'> // '--my-var'
|
|
984
|
-
* ```
|
|
985
|
-
*/
|
|
986
|
-
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>;
|
|
987
|
-
/**
|
|
988
|
-
* Converts a kebab-case string literal type to camelCase at the type level.
|
|
989
|
-
*
|
|
990
|
-
* @typeParam T - The string literal type to convert. CSS custom properties (`--*`) are returned as-is.
|
|
991
|
-
*
|
|
992
|
-
* @remarks The inverse of `ToKebab`. Used to reconcile CSS-native property names back to their JavaScript equivalents during autocomplete resolution.
|
|
993
|
-
*
|
|
994
|
-
* @example
|
|
995
|
-
* ```ts
|
|
996
|
-
* type A = FromKebab<'background-color'> // 'backgroundColor'
|
|
997
|
-
* type B = FromKebab<'--my-var'> // '--my-var'
|
|
998
|
-
* ```
|
|
999
|
-
*/
|
|
1000
|
-
type FromKebab<T extends string> = T extends `--${string}` ? T : T extends `${infer Head}-${infer Tail}` ? `${Head}${FromKebab<Capitalize<Tail>>}` : T;
|
|
1001
|
-
/**
|
|
1002
|
-
* 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`.
|
|
1003
|
-
*
|
|
1004
|
-
* @typeParam Obj - The source object type.
|
|
1005
|
-
* @typeParam K - The key to look up.
|
|
1006
|
-
*
|
|
1007
|
-
* @remarks Wrapping `Obj` in a tuple prevents distributive collapse when `Obj` is `never`.
|
|
1008
|
-
*
|
|
1009
|
-
* @example
|
|
1010
|
-
* ```ts
|
|
1011
|
-
* type V = GetValue<{ a: number }, 'a'> // number
|
|
1012
|
-
* type N = GetValue<{ a: number }, 'b'> // never
|
|
1013
|
-
* ```
|
|
1014
|
-
*/
|
|
1015
|
-
type GetValue<Obj, K extends string> = [Obj] extends [never] ? never : K extends keyof Obj ? Obj[K] : never;
|
|
793
|
+
//#region src/atomic-style.d.ts
|
|
1016
794
|
/**
|
|
1017
|
-
*
|
|
1018
|
-
*
|
|
1019
|
-
* @typeParam T - The source type to look up.
|
|
1020
|
-
* @typeParam Key - The key to look up in `T`.
|
|
1021
|
-
* @typeParam I - The constraint that `T[Key]` must satisfy.
|
|
1022
|
-
* @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
|
|
1023
797
|
*
|
|
1024
|
-
* @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.
|
|
1025
799
|
*
|
|
1026
800
|
* @example
|
|
1027
801
|
* ```ts
|
|
1028
|
-
*
|
|
1029
|
-
*
|
|
802
|
+
* const store = createEngineStore()
|
|
803
|
+
* // store.atomicStyleIds: Map<serializedKey, 'pk-a'>
|
|
1030
804
|
* ```
|
|
1031
805
|
*/
|
|
1032
|
-
|
|
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
|
+
}
|
|
1033
816
|
//#endregion
|
|
1034
|
-
//#region src/
|
|
817
|
+
//#region src/extractor.d.ts
|
|
1035
818
|
/**
|
|
1036
|
-
*
|
|
819
|
+
* Function signature for the bound extraction function created by `createExtractFn`.
|
|
1037
820
|
* @internal
|
|
1038
821
|
*
|
|
1039
|
-
* @
|
|
1040
|
-
*
|
|
1041
|
-
* @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.
|
|
1042
|
-
*
|
|
1043
|
-
* @example
|
|
1044
|
-
* ```ts
|
|
1045
|
-
* type Keys = AutocompleteKeys<{ foo: 1; bar: 2 }> // 'foo' | 'bar'
|
|
1046
|
-
* type Empty = AutocompleteKeys<never> // never
|
|
1047
|
-
* ```
|
|
1048
|
-
*/
|
|
1049
|
-
type AutocompleteKeys<T> = [T] extends [never] ? never : Extract<keyof T, string>;
|
|
1050
|
-
/**
|
|
1051
|
-
* Configuration for pattern-based autocomplete suggestions that are expanded at code generation time.
|
|
1052
|
-
*
|
|
1053
|
-
* @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.
|
|
1054
823
|
*
|
|
1055
824
|
* @example
|
|
1056
825
|
* ```ts
|
|
1057
|
-
* const
|
|
1058
|
-
*
|
|
1059
|
-
* properties: { spacing: ['sm', 'md', 'lg'] },
|
|
1060
|
-
* }
|
|
826
|
+
* const extractFn: ExtractFn = createExtractFn({ ... })
|
|
827
|
+
* const contents = await extractFn({ color: 'red' })
|
|
1061
828
|
* ```
|
|
1062
829
|
*/
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
/**
|
|
1071
|
-
|
|
1072
|
-
*
|
|
1073
|
-
* @default undefined
|
|
1074
|
-
*/
|
|
1075
|
-
shortcuts?: Arrayable<string>;
|
|
1076
|
-
/**
|
|
1077
|
-
* Property-to-values mapping whose keys are property names and values are the allowed value patterns.
|
|
1078
|
-
*
|
|
1079
|
-
* @default undefined
|
|
1080
|
-
*/
|
|
1081
|
-
properties?: Record<string, Arrayable<string>>;
|
|
1082
|
-
/**
|
|
1083
|
-
* CSS property-to-values mapping whose keys are CSS property names and values are the allowed value patterns.
|
|
1084
|
-
*
|
|
1085
|
-
* @default undefined
|
|
1086
|
-
*/
|
|
1087
|
-
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;
|
|
1088
839
|
}
|
|
1089
|
-
/**
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
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>>;
|
|
1103
888
|
/**
|
|
1104
|
-
*
|
|
1105
|
-
*
|
|
1106
|
-
* @default undefined
|
|
889
|
+
* TypeScript type reference contributed to the nested selector surface.
|
|
890
|
+
* @default `undefined`
|
|
1107
891
|
*/
|
|
1108
|
-
selectors?:
|
|
892
|
+
readonly selectors?: string;
|
|
1109
893
|
/**
|
|
1110
|
-
*
|
|
1111
|
-
*
|
|
1112
|
-
* @default undefined
|
|
894
|
+
* TypeScript type reference contributed to the generated property surface.
|
|
895
|
+
* @default `undefined`
|
|
1113
896
|
*/
|
|
1114
|
-
|
|
897
|
+
readonly properties?: string;
|
|
1115
898
|
/**
|
|
1116
|
-
*
|
|
1117
|
-
*
|
|
1118
|
-
* @default undefined
|
|
899
|
+
* TypeScript type reference contributed to CSS property names and values.
|
|
900
|
+
* @default `undefined`
|
|
1119
901
|
*/
|
|
1120
|
-
|
|
902
|
+
readonly cssProperties?: string;
|
|
1121
903
|
/**
|
|
1122
|
-
*
|
|
1123
|
-
*
|
|
1124
|
-
* @default undefined
|
|
904
|
+
* TypeScript type reference contributed to CSS property value autocomplete.
|
|
905
|
+
* @default `undefined`
|
|
1125
906
|
*/
|
|
1126
|
-
|
|
907
|
+
readonly cssPropertyValues?: string;
|
|
1127
908
|
/**
|
|
1128
|
-
*
|
|
1129
|
-
*
|
|
1130
|
-
* @default undefined
|
|
909
|
+
* TypeScript type reference that narrows or constrains generated properties.
|
|
910
|
+
* @default `undefined`
|
|
1131
911
|
*/
|
|
1132
|
-
|
|
1133
|
-
/**
|
|
1134
|
-
* Map of CSS property names to their accepted value suggestions.
|
|
1135
|
-
*
|
|
1136
|
-
* @default undefined
|
|
1137
|
-
*/
|
|
1138
|
-
cssProperties?: Record<string, Arrayable<string>>;
|
|
1139
|
-
/**
|
|
1140
|
-
* Pattern-based entries that define how to generate expanded autocomplete suggestions.
|
|
1141
|
-
*
|
|
1142
|
-
* @default undefined
|
|
1143
|
-
*/
|
|
1144
|
-
patterns?: AutocompletePatternsConfig;
|
|
912
|
+
readonly propertyConstraints?: string;
|
|
1145
913
|
}
|
|
1146
|
-
/**
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
*
|
|
1151
|
-
* @example
|
|
1152
|
-
* ```ts
|
|
1153
|
-
* const config: AutocompleteConfig = {
|
|
1154
|
-
* selectors: ['hover', 'focus'],
|
|
1155
|
-
* properties: [['spacing', ['sm', 'md', 'lg']]],
|
|
1156
|
-
* }
|
|
1157
|
-
* ```
|
|
1158
|
-
*/
|
|
1159
|
-
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;
|
|
1160
918
|
/**
|
|
1161
|
-
*
|
|
1162
|
-
*
|
|
1163
|
-
* @default undefined
|
|
919
|
+
* Supporting TypeScript declarations captured for the finalized snapshot.
|
|
920
|
+
* @default `undefined`
|
|
1164
921
|
*/
|
|
1165
|
-
|
|
922
|
+
readonly declarations?: string;
|
|
1166
923
|
/**
|
|
1167
|
-
*
|
|
1168
|
-
*
|
|
1169
|
-
* @default undefined
|
|
924
|
+
* First-level Pika static-extension type roots captured for the snapshot.
|
|
925
|
+
* @default `undefined`
|
|
1170
926
|
*/
|
|
1171
|
-
|
|
927
|
+
readonly pika?: Readonly<Record<string, string>>;
|
|
1172
928
|
/**
|
|
1173
|
-
*
|
|
1174
|
-
*
|
|
1175
|
-
* @default undefined
|
|
929
|
+
* TypeScript type reference contributed to the nested selector surface.
|
|
930
|
+
* @default `undefined`
|
|
1176
931
|
*/
|
|
1177
|
-
|
|
932
|
+
readonly selectors?: string;
|
|
1178
933
|
/**
|
|
1179
|
-
*
|
|
1180
|
-
*
|
|
1181
|
-
* @default undefined
|
|
934
|
+
* TypeScript type reference contributed to the generated property surface.
|
|
935
|
+
* @default `undefined`
|
|
1182
936
|
*/
|
|
1183
|
-
|
|
937
|
+
readonly properties?: string;
|
|
1184
938
|
/**
|
|
1185
|
-
*
|
|
1186
|
-
*
|
|
1187
|
-
* @default undefined
|
|
939
|
+
* TypeScript type reference contributed to CSS property names and values.
|
|
940
|
+
* @default `undefined`
|
|
1188
941
|
*/
|
|
1189
|
-
|
|
942
|
+
readonly cssProperties?: string;
|
|
1190
943
|
/**
|
|
1191
|
-
*
|
|
1192
|
-
*
|
|
1193
|
-
* @default undefined
|
|
944
|
+
* TypeScript type reference contributed to CSS property value autocomplete.
|
|
945
|
+
* @default `undefined`
|
|
1194
946
|
*/
|
|
1195
|
-
|
|
947
|
+
readonly cssPropertyValues?: string;
|
|
1196
948
|
/**
|
|
1197
|
-
*
|
|
1198
|
-
*
|
|
1199
|
-
* @default undefined
|
|
949
|
+
* TypeScript type reference that narrows or constrains generated properties.
|
|
950
|
+
* @default `undefined`
|
|
1200
951
|
*/
|
|
1201
|
-
|
|
952
|
+
readonly propertyConstraints?: string;
|
|
1202
953
|
}
|
|
1203
|
-
/**
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
* @example
|
|
1210
|
-
* ```ts
|
|
1211
|
-
* const patterns: ResolvedAutocompletePatternsConfig = {
|
|
1212
|
-
* selectors: new Set(['hover']),
|
|
1213
|
-
* shortcuts: new Set(),
|
|
1214
|
-
* properties: new Map(),
|
|
1215
|
-
* cssProperties: new Map(),
|
|
1216
|
-
* }
|
|
1217
|
-
* ```
|
|
1218
|
-
*/
|
|
1219
|
-
interface ResolvedAutocompletePatternsConfig {
|
|
1220
|
-
/** Set of resolved selector autocomplete patterns. */
|
|
1221
|
-
selectors: Set<string>;
|
|
1222
|
-
/** Set of resolved shortcut autocomplete patterns. */
|
|
1223
|
-
shortcuts: Set<string>;
|
|
1224
|
-
/** Map of property names to their expanded autocomplete value patterns. */
|
|
1225
|
-
properties: Map<string, string[]>;
|
|
1226
|
-
/** Map of CSS property names to their expanded autocomplete value patterns. */
|
|
1227
|
-
cssProperties: Map<string, string[]>;
|
|
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[];
|
|
1228
960
|
}
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
* selectors: new Set(['hover']),
|
|
1239
|
-
* shortcuts: new Set(),
|
|
1240
|
-
* extraProperties: new Set(['__layer']),
|
|
1241
|
-
* extraCssProperties: new Set(),
|
|
1242
|
-
* properties: new Map(),
|
|
1243
|
-
* cssProperties: new Map(),
|
|
1244
|
-
* patterns: { selectors: new Set(), shortcuts: new Set(), properties: new Map(), cssProperties: new Map() },
|
|
1245
|
-
* }
|
|
1246
|
-
* ```
|
|
1247
|
-
*/
|
|
1248
|
-
interface ResolvedAutocompleteConfig {
|
|
1249
|
-
/** Known selector names available for autocomplete. */
|
|
1250
|
-
selectors: Set<string>;
|
|
1251
|
-
/** Known shortcut names available for autocomplete. */
|
|
1252
|
-
shortcuts: Set<string>;
|
|
1253
|
-
/** Non-CSS property names injected by plugins (e.g. `__shortcut`, `__layer`, `__important`). */
|
|
1254
|
-
extraProperties: Set<string>;
|
|
1255
|
-
/** Extra CSS property names (including custom properties) injected by plugins. */
|
|
1256
|
-
extraCssProperties: Set<string>;
|
|
1257
|
-
/** Property-to-type mappings for TypeScript type generation. */
|
|
1258
|
-
properties: Map<string, string[]>;
|
|
1259
|
-
/** CSS property-to-value mappings for value-level autocomplete. */
|
|
1260
|
-
cssProperties: Map<string, string[]>;
|
|
1261
|
-
/** Resolved pattern-based autocomplete entries. */
|
|
1262
|
-
patterns: ResolvedAutocompletePatternsConfig;
|
|
1263
|
-
}
|
|
1264
|
-
/**
|
|
1265
|
-
* Shape contract for the autocomplete type map that plugins augment via module augmentation on `PikaAugment`.
|
|
1266
|
-
* @internal
|
|
1267
|
-
*
|
|
1268
|
-
* @remarks Each member corresponds to a dimension of the autocomplete surface. Plugin authors extend `PikaAugment` with a `DefineAutocomplete` entry whose members populate IDE completions.
|
|
1269
|
-
*
|
|
1270
|
-
* @example
|
|
1271
|
-
* ```ts
|
|
1272
|
-
* interface _Autocomplete {
|
|
1273
|
-
* Selector: 'hover' | 'focus'
|
|
1274
|
-
* Shortcut: 'btn' | 'card'
|
|
1275
|
-
* Layer: 'base' | 'components'
|
|
1276
|
-
* PropertyValue: { spacing: 'sm' | 'md' }
|
|
1277
|
-
* CSSPropertyValue: { color: 'primary' | 'secondary' }
|
|
1278
|
-
* }
|
|
1279
|
-
* ```
|
|
1280
|
-
*/
|
|
1281
|
-
interface _Autocomplete {
|
|
1282
|
-
/** Union of known selector names for IDE autocomplete. */
|
|
1283
|
-
Selector: UnionString;
|
|
1284
|
-
/** Union of known shortcut names for IDE autocomplete. */
|
|
1285
|
-
Shortcut: UnionString;
|
|
1286
|
-
/** Union of known layer names for IDE autocomplete. */
|
|
1287
|
-
Layer: UnionString;
|
|
1288
|
-
/** Record mapping extra property names to their accepted value types for IDE autocomplete. */
|
|
1289
|
-
PropertyValue: Record<string, unknown>;
|
|
1290
|
-
/** Record mapping CSS property names to their accepted value unions for IDE autocomplete. */
|
|
1291
|
-
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;
|
|
1292
970
|
}
|
|
1293
971
|
/**
|
|
1294
|
-
*
|
|
972
|
+
* Renders one lexical-safe JSDoc block from path-free semantic documentation.
|
|
1295
973
|
*
|
|
1296
|
-
* @
|
|
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.
|
|
1297
979
|
*
|
|
1298
|
-
* @
|
|
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.
|
|
1299
983
|
*
|
|
1300
|
-
* @example
|
|
1301
|
-
* ```ts
|
|
1302
|
-
* declare module '@pikacss/core' {
|
|
1303
|
-
* interface PikaAugment {
|
|
1304
|
-
* Autocomplete: DefineAutocomplete<{
|
|
1305
|
-
* Selector: 'hover' | 'focus'
|
|
1306
|
-
* Shortcut: never
|
|
1307
|
-
* Layer: 'base'
|
|
1308
|
-
* PropertyValue: never
|
|
1309
|
-
* CSSPropertyValue: never
|
|
1310
|
-
* }>
|
|
1311
|
-
* }
|
|
1312
|
-
* }
|
|
1313
|
-
* ```
|
|
1314
|
-
*/
|
|
1315
|
-
type DefineAutocomplete<A extends _Autocomplete> = A;
|
|
1316
|
-
/**
|
|
1317
|
-
* Default autocomplete map used when no plugin provides an augmentation, with all dimensions set to `never`.
|
|
1318
984
|
* @internal
|
|
1319
|
-
*
|
|
1320
|
-
* @remarks Serves as the fallback in `ResolvedAutocomplete` so the engine always has a valid autocomplete shape even without any plugin augmentations.
|
|
1321
|
-
*
|
|
1322
|
-
* @example
|
|
1323
|
-
* ```ts
|
|
1324
|
-
* // When PikaAugment has no Autocomplete key:
|
|
1325
|
-
* type Resolved = ResolvedAutocomplete // EmptyAutocomplete
|
|
1326
|
-
* ```
|
|
1327
985
|
*/
|
|
1328
|
-
|
|
1329
|
-
Selector: never;
|
|
1330
|
-
Shortcut: never;
|
|
1331
|
-
Layer: never;
|
|
1332
|
-
PropertyValue: never;
|
|
1333
|
-
CSSPropertyValue: never;
|
|
1334
|
-
}>;
|
|
986
|
+
declare function renderTypegenJSDoc(documentation: TypegenDocumentation, bindings?: TypegenJSDocRenderBindings, indent?: string): string[];
|
|
1335
987
|
//#endregion
|
|
1336
|
-
//#region src/
|
|
1337
|
-
/**
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
* // store.atomicStyleIds: Map<serializedKey, 'pk-a'>
|
|
1347
|
-
* ```
|
|
1348
|
-
*/
|
|
1349
|
-
interface EngineStore {
|
|
1350
|
-
/** Map from serialized content keys to their assigned atomic style IDs. */
|
|
1351
|
-
atomicStyleIds: Map<string, string>;
|
|
1352
|
-
/** Map from atomic style ID to the full `AtomicStyle` object. */
|
|
1353
|
-
atomicStyles: Map<string, AtomicStyle>;
|
|
1354
|
-
/** Map from base content key to the list of atomic style IDs that share it (for order-sensitive styles). */
|
|
1355
|
-
atomicStyleIdsByBaseKey: Map<string, string[]>;
|
|
1356
|
-
/** Map from atomic style ID to its insertion order index, used for deterministic output ordering. */
|
|
1357
|
-
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;
|
|
1358
998
|
}
|
|
1359
|
-
//#endregion
|
|
1360
|
-
//#region src/extractor.d.ts
|
|
1361
|
-
/**
|
|
1362
|
-
* Function signature for the bound extraction function created by `createExtractFn`.
|
|
1363
|
-
* @internal
|
|
1364
|
-
*
|
|
1365
|
-
* @remarks Accepts a single style definition and returns the extracted content list. The plugin transform hooks and default selector are captured in the closure.
|
|
1366
|
-
*
|
|
1367
|
-
* @example
|
|
1368
|
-
* ```ts
|
|
1369
|
-
* const extractFn: ExtractFn = createExtractFn({ ... })
|
|
1370
|
-
* const contents = await extractFn({ color: 'red' })
|
|
1371
|
-
* ```
|
|
1372
|
-
*/
|
|
1373
|
-
type ExtractFn = (styleDefinition: InternalStyleDefinition) => Promise<ExtractedStyleContent[]>;
|
|
1374
999
|
//#endregion
|
|
1375
1000
|
//#region src/engine.d.ts
|
|
1376
1001
|
/**
|
|
@@ -1393,7 +1018,7 @@ declare function createEngine(config?: EngineConfig, options?: CreateEngineOptio
|
|
|
1393
1018
|
/**
|
|
1394
1019
|
* The PikaCSS engine: manages atomic style resolution, rendering, preflights, and plugin hooks.
|
|
1395
1020
|
*
|
|
1396
|
-
* @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`).
|
|
1397
1022
|
*
|
|
1398
1023
|
* @example
|
|
1399
1024
|
* ```ts
|
|
@@ -1403,22 +1028,23 @@ declare function createEngine(config?: EngineConfig, options?: CreateEngineOptio
|
|
|
1403
1028
|
* ```
|
|
1404
1029
|
*/
|
|
1405
1030
|
declare class Engine {
|
|
1031
|
+
#private;
|
|
1406
1032
|
/** The fully resolved engine configuration. */
|
|
1407
1033
|
config: ResolvedEngineConfig;
|
|
1408
1034
|
/** Instance-scoped diagnostic handler supplied by the host. */
|
|
1409
1035
|
readonly onDiagnostic: DiagnosticHandler;
|
|
1410
1036
|
/** Reference to the instance-scoped plugin hook dispatcher. */
|
|
1411
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;
|
|
1412
1042
|
/** The extraction function that decomposes style definitions into atomic style contents. */
|
|
1413
1043
|
extract: ExtractFn;
|
|
1414
1044
|
/** The engine's runtime store holding registered atomic styles and their ID mappings. */
|
|
1415
1045
|
store: EngineStore;
|
|
1416
|
-
/**
|
|
1417
|
-
|
|
1418
|
-
*
|
|
1419
|
-
* @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.
|
|
1420
|
-
*/
|
|
1421
|
-
configDependencies: Set<string>;
|
|
1046
|
+
/** Finalized external file and directory-membership dependencies for this engine. */
|
|
1047
|
+
get configDependencies(): readonly EngineConfigDependency[];
|
|
1422
1048
|
/**
|
|
1423
1049
|
* Creates an engine instance from a resolved configuration.
|
|
1424
1050
|
*
|
|
@@ -1431,7 +1057,7 @@ declare class Engine {
|
|
|
1431
1057
|
* const engine = new Engine(resolvedConfig)
|
|
1432
1058
|
* ```
|
|
1433
1059
|
*/
|
|
1434
|
-
constructor(config: ResolvedEngineConfig, onDiagnostic?: DiagnosticHandler, pluginHooks?: ReturnType<typeof createEngineHooks
|
|
1060
|
+
constructor(config: ResolvedEngineConfig, onDiagnostic?: DiagnosticHandler, pluginHooks?: ReturnType<typeof createEngineHooks>, atomicStyleIdStrategy?: AtomicStyleIdStrategy);
|
|
1435
1061
|
/**
|
|
1436
1062
|
* Reports a structured diagnostic to this engine instance's host handler.
|
|
1437
1063
|
*
|
|
@@ -1455,18 +1081,19 @@ declare class Engine {
|
|
|
1455
1081
|
*/
|
|
1456
1082
|
invokePreflight(fn: PreflightFn, isFormatted: boolean, ctx?: PreflightContext): Promise<string | PreflightDefinition>;
|
|
1457
1083
|
/**
|
|
1458
|
-
* Registers
|
|
1459
|
-
*
|
|
1460
|
-
* @param path - The file path (ideally absolute) the current config was derived from.
|
|
1461
|
-
*
|
|
1462
|
-
* @remarks Call from a plugin after loading data from disk — typically in `configureEngine`, but registering during later hooks (e.g. while resolving inside `engine.use()`) is fully supported: each genuinely new path fires the `configDependencyAdded` committed notification so integration layers can extend an already-running watcher (#122). Integration layers watch registered paths and rebuild the engine when any of them changes.
|
|
1084
|
+
* Registers a file dependency during Engine initialization.
|
|
1463
1085
|
*
|
|
1464
|
-
* @
|
|
1465
|
-
*
|
|
1466
|
-
* engine.addConfigDependency('/project/design.md')
|
|
1467
|
-
* ```
|
|
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.
|
|
1468
1088
|
*/
|
|
1469
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;
|
|
1470
1097
|
/**
|
|
1471
1098
|
* Fires the `preflightUpdated` hook to notify plugins that preflight content has changed.
|
|
1472
1099
|
*
|
|
@@ -1492,31 +1119,6 @@ declare class Engine {
|
|
|
1492
1119
|
* ```
|
|
1493
1120
|
*/
|
|
1494
1121
|
notifyAtomicStyleAdded(atomicStyle: AtomicStyle): void;
|
|
1495
|
-
/**
|
|
1496
|
-
* Fires the `autocompleteConfigUpdated` hook to notify plugins that autocomplete entries changed.
|
|
1497
|
-
*
|
|
1498
|
-
*
|
|
1499
|
-
* @remarks Called automatically after `appendAutocomplete` when the contribution modifies the resolved autocomplete config.
|
|
1500
|
-
*
|
|
1501
|
-
* @example
|
|
1502
|
-
* ```ts
|
|
1503
|
-
* engine.notifyAutocompleteConfigUpdated()
|
|
1504
|
-
* ```
|
|
1505
|
-
*/
|
|
1506
|
-
notifyAutocompleteConfigUpdated(): void;
|
|
1507
|
-
/**
|
|
1508
|
-
* Merges an autocomplete contribution into the resolved autocomplete config.
|
|
1509
|
-
*
|
|
1510
|
-
* @param contribution - The autocomplete entries to append (selectors, properties, CSS properties, etc.).
|
|
1511
|
-
*
|
|
1512
|
-
* @remarks Delegates to the `appendAutocomplete` utility and fires `autocompleteConfigUpdated` if the config was actually modified.
|
|
1513
|
-
*
|
|
1514
|
-
* @example
|
|
1515
|
-
* ```ts
|
|
1516
|
-
* engine.appendAutocomplete({ selectors: 'hover', cssProperties: { color: 'red' } })
|
|
1517
|
-
* ```
|
|
1518
|
-
*/
|
|
1519
|
-
appendAutocomplete(contribution: AutocompleteContribution): void;
|
|
1520
1122
|
/**
|
|
1521
1123
|
* Appends a CSS `@import` statement to the preflight output.
|
|
1522
1124
|
*
|
|
@@ -1697,9 +1299,23 @@ type EngineHooksDefinition = DefineHooks<{
|
|
|
1697
1299
|
transformStyleContents: ['async', styleContents: StyleContent[]];
|
|
1698
1300
|
preflightUpdated: ['sync', void];
|
|
1699
1301
|
atomicStyleAdded: ['sync', AtomicStyle];
|
|
1700
|
-
autocompleteConfigUpdated: ['sync', void];
|
|
1701
|
-
configDependencyAdded: ['sync', path: string];
|
|
1702
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
|
+
}
|
|
1703
1319
|
type HookParams<H extends [type: 'sync' | 'async', payload: any, returnValue?: any]> = H[1] extends void ? [] : [payload: H[1]];
|
|
1704
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>];
|
|
1705
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];
|
|
@@ -1717,7 +1333,7 @@ type EngineHooks = { [K in keyof EngineHooksDefinition]: (plugins: EnginePlugin[
|
|
|
1717
1333
|
* distinct state.
|
|
1718
1334
|
*/
|
|
1719
1335
|
declare function createEngineHooks(context: Pick<EnginePluginContext, 'onDiagnostic'> & Partial<Pick<EnginePluginContext, 'host'>>): EngineHooks;
|
|
1720
|
-
type EnginePluginHooksOptions<State = any> = { [K in keyof EngineHooksDefinition]?: EngineHooksDefinition[K][0] extends 'async' ? (...params: PluginHookParams<EngineHooksDefinition[K], State>) => Awaitable<EngineHooksDefinition[K][1] | void> : (...params: PluginHookParams<EngineHooksDefinition[K], State>) => EngineHooksDefinition[K][1] | void };
|
|
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 };
|
|
1721
1337
|
/**
|
|
1722
1338
|
* Describes an engine plugin that can hook into the PikaCSS engine lifecycle.
|
|
1723
1339
|
*
|
|
@@ -1726,7 +1342,7 @@ type EnginePluginHooksOptions<State = any> = { [K in keyof EngineHooksDefinition
|
|
|
1726
1342
|
* (#116): the same object may be passed to any number of `createEngine()`
|
|
1727
1343
|
* calls, sequentially or concurrently. Mutable per-engine data therefore must
|
|
1728
1344
|
* never live in the plugin factory's closure — declare it via `createState`
|
|
1729
|
-
* and read/write it through `context.state`, which the engine keeps isolated
|
|
1345
|
+
* and read/write it through hook `context.state` or `EngineConfigurator.state`, which the engine keeps isolated
|
|
1730
1346
|
* per plugin/engine pair. Factory arguments that are never mutated may stay in
|
|
1731
1347
|
* the closure as immutable definition configuration.
|
|
1732
1348
|
*/
|
|
@@ -19728,7 +19344,9 @@ type AtRules = AtRules.Regular | AtRules.Nested;
|
|
|
19728
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";
|
|
19729
19345
|
type AutocompleteLookup<TValueMap, TRelatedKeys extends string> = [TValueMap] extends [never] ? never : TRelatedKeys extends keyof TValueMap ? TValueMap[TRelatedKeys] : never;
|
|
19730
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. */
|
|
19731
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. */
|
|
19732
19350
|
interface PropertiesInput<TValueMap = never, TLength = DefaultTLength, TTime = DefaultTTime> {
|
|
19733
19351
|
/**
|
|
19734
19352
|
* ❌ Baseline: Not widely available
|
|
@@ -27777,6 +27395,7 @@ interface PropertiesInput<TValueMap = never, TLength = DefaultTLength, TTime = D
|
|
|
27777
27395
|
*/
|
|
27778
27396
|
zoom?: PropertyInputValue<TValueMap, Property.Zoom, PropertyRelatedNames["zoom"]> | undefined;
|
|
27779
27397
|
}
|
|
27398
|
+
/** Kebab-case CSS property inputs used by the generated Typegen style definition. */
|
|
27780
27399
|
interface PropertiesHyphenInput<TValueMap = never, TLength = DefaultTLength, TTime = DefaultTTime> {
|
|
27781
27400
|
/**
|
|
27782
27401
|
*
|
|
@@ -36820,6 +36439,189 @@ declare namespace DataType {
|
|
|
36820
36439
|
type VisualBox = "border-box" | "content-box" | "padding-box";
|
|
36821
36440
|
}
|
|
36822
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
|
|
36823
36625
|
//#region src/types/public.d.ts
|
|
36824
36626
|
/**
|
|
36825
36627
|
* Mapping of CSS custom property names (starting with `--`) to their string values.
|
|
@@ -36873,29 +36675,15 @@ type CSSProperty = Extract<keyof CSSProperties, string>;
|
|
|
36873
36675
|
* ```
|
|
36874
36676
|
*/
|
|
36875
36677
|
type PropertyValue<T> = T | [value: T, fallback: T[]] | Nullish;
|
|
36876
|
-
type
|
|
36877
|
-
type
|
|
36878
|
-
type
|
|
36879
|
-
type Properties_CSS_Camel = PropertiesInput<ResolvedAutocompleteCSSPropertyValue>;
|
|
36880
|
-
type Properties_CSS_Hyphen = PropertiesHyphenInput<ResolvedAutocompleteCSSPropertyValue>;
|
|
36881
|
-
type Properties_CSS_Vars = { [K in `--${string}` & {}]?: PropertyValue<UnionString | _CssPropertiesValueWildcard> };
|
|
36882
|
-
type Properties_ExtraCSS = { [Key in ResolvedExtraCSSProperty]?: CSSPropertyInputValue<GetValue<CSSProperties, Key>, Key | ToKebab<Key> | FromKebab<Key>> };
|
|
36883
|
-
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> };
|
|
36884
36681
|
/**
|
|
36885
|
-
* The
|
|
36886
|
-
*
|
|
36887
|
-
*
|
|
36888
|
-
*
|
|
36889
|
-
* @example
|
|
36890
|
-
* ```ts
|
|
36891
|
-
* const props: Properties = {
|
|
36892
|
-
* color: 'red',
|
|
36893
|
-
* 'font-size': '16px',
|
|
36894
|
-
* '--my-color': 'blue',
|
|
36895
|
-
* }
|
|
36896
|
-
* ```
|
|
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.
|
|
36897
36685
|
*/
|
|
36898
|
-
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 {}
|
|
36899
36687
|
type CSSPseudos = CSSPseudos$1;
|
|
36900
36688
|
/**
|
|
36901
36689
|
* Union of valid CSS selector strings for nested style definitions, including CSS at-rules and pseudo-selectors (prefixed with `$`).
|
|
@@ -36913,7 +36701,7 @@ type CSSSelector = AtRules.Nested | CSSPseudos;
|
|
|
36913
36701
|
* Union of all selector strings accepted in style definitions, including custom selectors from plugins, standard CSS selectors, and arbitrary strings.
|
|
36914
36702
|
* @internal
|
|
36915
36703
|
*
|
|
36916
|
-
* @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.
|
|
36917
36705
|
*
|
|
36918
36706
|
* @example
|
|
36919
36707
|
* ```ts
|
|
@@ -36921,7 +36709,7 @@ type CSSSelector = AtRules.Nested | CSSPseudos;
|
|
|
36921
36709
|
* const custom: Selector = 'dark' // plugin-defined selector
|
|
36922
36710
|
* ```
|
|
36923
36711
|
*/
|
|
36924
|
-
type Selector$1 = UnionString |
|
|
36712
|
+
type Selector$1 = UnionString | CSSSelector;
|
|
36925
36713
|
/**
|
|
36926
36714
|
* A nested style definition where keys are selector strings and values are property values, property maps, nested definitions, or arrays of style items.
|
|
36927
36715
|
*
|
|
@@ -36961,34 +36749,27 @@ type StyleDefinition = Properties | StyleDefinitionMap;
|
|
|
36961
36749
|
* const itemDef: StyleItem = { color: 'red' } // inline style
|
|
36962
36750
|
* ```
|
|
36963
36751
|
*/
|
|
36964
|
-
type StyleItem = UnionString |
|
|
36752
|
+
type StyleItem = UnionString | StyleDefinition;
|
|
36965
36753
|
//#endregion
|
|
36966
36754
|
//#region src/types/shared.d.ts
|
|
36967
36755
|
/**
|
|
36968
|
-
*
|
|
36756
|
+
* Legacy generated-file augmentation bridge retained temporarily while Integration migrates to finalized Typegen documents.
|
|
36969
36757
|
*
|
|
36970
|
-
* @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.
|
|
36971
36759
|
*
|
|
36972
|
-
* @example
|
|
36973
|
-
* ```ts
|
|
36974
|
-
* declare module '@pikacss/core' {
|
|
36975
|
-
* interface PikaAugment {
|
|
36976
|
-
* Autocomplete: DefineAutocomplete<{ Selector: 'dark' | 'light', Shortcut: never, Layer: never, PropertyValue: never, CSSPropertyValue: never }>
|
|
36977
|
-
* }
|
|
36978
|
-
* }
|
|
36979
|
-
* ```
|
|
36980
36760
|
*/
|
|
36981
36761
|
interface PikaAugment {}
|
|
36982
36762
|
/**
|
|
36983
|
-
*
|
|
36763
|
+
* Runtime normalization input accepted inside the engine.
|
|
36984
36764
|
* @internal
|
|
36985
36765
|
*
|
|
36986
|
-
* @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.
|
|
36987
36767
|
*
|
|
36988
36768
|
* @example
|
|
36989
36769
|
* ```ts
|
|
36990
36770
|
* const val: InternalPropertyValue = ['red', ['blue', 'green']]
|
|
36991
|
-
* const
|
|
36771
|
+
* const runtimeZero: InternalPropertyValue = 0
|
|
36772
|
+
* const runtimeNumber: InternalPropertyValue = 0.5 // tolerated internally; not a public pika() authoring value
|
|
36992
36773
|
* ```
|
|
36993
36774
|
*/
|
|
36994
36775
|
type InternalPropertyValue = PropertyValue<string | number>;
|
|
@@ -37145,79 +36926,6 @@ interface CSSStyleBlockBody {
|
|
|
37145
36926
|
type CSSStyleBlocks = Map<string, CSSStyleBlockBody>;
|
|
37146
36927
|
//#endregion
|
|
37147
36928
|
//#region src/types/resolved.d.ts
|
|
37148
|
-
/**
|
|
37149
|
-
* The effective autocomplete map resolved from `PikaAugment.Autocomplete`, falling back to `EmptyAutocomplete` when no plugin augments it.
|
|
37150
|
-
* @internal
|
|
37151
|
-
*
|
|
37152
|
-
* @remarks This is the source-of-truth autocomplete shape that all downstream resolved types (`ResolvedAutocompletePropertyValue`, `ResolvedSelector`, etc.) derive from.
|
|
37153
|
-
*
|
|
37154
|
-
* @example
|
|
37155
|
-
* ```ts
|
|
37156
|
-
* // With augmentation: resolves to the plugin-provided map
|
|
37157
|
-
* // Without augmentation: resolves to EmptyAutocomplete
|
|
37158
|
-
* type AC = ResolvedAutocomplete
|
|
37159
|
-
* ```
|
|
37160
|
-
*/
|
|
37161
|
-
type ResolvedAutocomplete = ResolveFrom<PikaAugment, 'Autocomplete', _Autocomplete, EmptyAutocomplete>;
|
|
37162
|
-
/**
|
|
37163
|
-
* The property-value record extracted from the resolved autocomplete map, mapping extra property names to their accepted value types.
|
|
37164
|
-
* @internal
|
|
37165
|
-
*
|
|
37166
|
-
* @remarks Used to derive the set of extra (non-CSS) properties and their value unions for type-safe `pika()` calls.
|
|
37167
|
-
*
|
|
37168
|
-
* @example
|
|
37169
|
-
* ```ts
|
|
37170
|
-
* type PV = ResolvedAutocompletePropertyValue // Record<string, unknown> or plugin-augmented map
|
|
37171
|
-
* ```
|
|
37172
|
-
*/
|
|
37173
|
-
type ResolvedAutocompletePropertyValue = ResolvedAutocomplete['PropertyValue'];
|
|
37174
|
-
/**
|
|
37175
|
-
* The CSS property-value record extracted from the resolved autocomplete map, mapping CSS property names to their accepted value unions.
|
|
37176
|
-
* @internal
|
|
37177
|
-
*
|
|
37178
|
-
* @remarks Used to extend the standard `CSSProperties` value types with plugin-contributed suggestions (e.g. design token names for `color`).
|
|
37179
|
-
*
|
|
37180
|
-
* @example
|
|
37181
|
-
* ```ts
|
|
37182
|
-
* type CPV = ResolvedAutocompleteCSSPropertyValue // Record<string, UnionString> or plugin-augmented map
|
|
37183
|
-
* ```
|
|
37184
|
-
*/
|
|
37185
|
-
type ResolvedAutocompleteCSSPropertyValue = ResolvedAutocomplete['CSSPropertyValue'];
|
|
37186
|
-
/**
|
|
37187
|
-
* Union of extra (non-CSS) property name strings derived from the resolved autocomplete property-value map.
|
|
37188
|
-
* @internal
|
|
37189
|
-
*
|
|
37190
|
-
* @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.
|
|
37191
|
-
*
|
|
37192
|
-
* @example
|
|
37193
|
-
* ```ts
|
|
37194
|
-
* type EP = ResolvedExtraProperty // '__shortcut' | '__layer' | ...
|
|
37195
|
-
* ```
|
|
37196
|
-
*/
|
|
37197
|
-
type ResolvedExtraProperty = AutocompleteKeys<ResolvedAutocompletePropertyValue>;
|
|
37198
|
-
/**
|
|
37199
|
-
* Union of extra CSS property name strings derived from the resolved autocomplete CSS property-value map.
|
|
37200
|
-
* @internal
|
|
37201
|
-
*
|
|
37202
|
-
* @remarks Includes custom properties and vendor-specific properties registered by plugins (e.g. CSS variable names from the variables plugin).
|
|
37203
|
-
*
|
|
37204
|
-
* @example
|
|
37205
|
-
* ```ts
|
|
37206
|
-
* type ECP = ResolvedExtraCSSProperty // '--my-color' | '--spacing-sm' | ...
|
|
37207
|
-
* ```
|
|
37208
|
-
*/
|
|
37209
|
-
type ResolvedExtraCSSProperty = AutocompleteKeys<ResolvedAutocompleteCSSPropertyValue>;
|
|
37210
|
-
/**
|
|
37211
|
-
* Union of known CSS `@layer` names, falling back to `UnionString` when no plugin augments the `Layer` dimension.
|
|
37212
|
-
*
|
|
37213
|
-
* @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.
|
|
37214
|
-
*
|
|
37215
|
-
* @example
|
|
37216
|
-
* ```ts
|
|
37217
|
-
* type LN = ResolvedLayerName // 'base' | 'components' | ... or UnionString
|
|
37218
|
-
* ```
|
|
37219
|
-
*/
|
|
37220
|
-
type ResolvedLayerName = IsNever<ResolvedAutocomplete['Layer']> extends true ? UnionString : ResolvedAutocomplete['Layer'];
|
|
37221
36929
|
/**
|
|
37222
36930
|
* The effective selector string type resolved from `PikaAugment.Selector`, falling back to plain `string`.
|
|
37223
36931
|
* @internal
|
|
@@ -37246,14 +36954,14 @@ type ResolvedProperties = ResolveFrom<PikaAugment, 'Properties', any, InternalPr
|
|
|
37246
36954
|
* The subset of `ResolvedProperties` that contains only standard CSS properties, computed by excluding extra (non-CSS) property keys.
|
|
37247
36955
|
* @internal
|
|
37248
36956
|
*
|
|
37249
|
-
* @remarks
|
|
36957
|
+
* @remarks Core extension/directive authoring no longer flows through global autocomplete augmentation; generated Typegen owns those overlays.
|
|
37250
36958
|
*
|
|
37251
36959
|
* @example
|
|
37252
36960
|
* ```ts
|
|
37253
|
-
* type CP = ResolvedCSSProperties //
|
|
36961
|
+
* type CP = ResolvedCSSProperties // Effective CSS property surface
|
|
37254
36962
|
* ```
|
|
37255
36963
|
*/
|
|
37256
|
-
type ResolvedCSSProperties =
|
|
36964
|
+
type ResolvedCSSProperties = ResolvedProperties;
|
|
37257
36965
|
/**
|
|
37258
36966
|
* The effective `StyleDefinition` type resolved from `PikaAugment.StyleDefinition`, falling back to the internal default.
|
|
37259
36967
|
* @internal
|
|
@@ -37457,12 +37165,6 @@ interface EngineConfig {
|
|
|
37457
37165
|
* @default `'utilities'`
|
|
37458
37166
|
*/
|
|
37459
37167
|
defaultUtilitiesLayer?: string;
|
|
37460
|
-
/**
|
|
37461
|
-
* Autocomplete configuration for IDE integration and code generation type narrowing.
|
|
37462
|
-
*
|
|
37463
|
-
* @default `{}`
|
|
37464
|
-
*/
|
|
37465
|
-
autocomplete?: AutocompleteConfig;
|
|
37466
37168
|
}
|
|
37467
37169
|
/**
|
|
37468
37170
|
* Fully resolved engine configuration produced after plugin hooks have processed the raw config.
|
|
@@ -37489,8 +37191,6 @@ interface ResolvedEngineConfig {
|
|
|
37489
37191
|
preflights: ResolvedPreflight[];
|
|
37490
37192
|
/** Deduplicated and semicolon-terminated CSS `@import` statements. */
|
|
37491
37193
|
cssImports: string[];
|
|
37492
|
-
/** Resolved autocomplete configuration with `Set`/`Map` collections for efficient incremental appending. */
|
|
37493
|
-
autocomplete: ResolvedAutocompleteConfig;
|
|
37494
37194
|
/** CSS `@layer` name-to-order mapping used for ordering layer blocks in output. */
|
|
37495
37195
|
layers: Record<string, number>;
|
|
37496
37196
|
/** Name of the default `@layer` for preflight styles. */
|
|
@@ -37499,6 +37199,32 @@ interface ResolvedEngineConfig {
|
|
|
37499
37199
|
defaultUtilitiesLayer: string;
|
|
37500
37200
|
}
|
|
37501
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
|
|
37502
37228
|
//#region src/utils.d.ts
|
|
37503
37229
|
/**
|
|
37504
37230
|
* Creates a scoped logger with configurable log-level functions and a toggleable debug mode.
|
|
@@ -37584,24 +37310,6 @@ declare function isPlainObjectRecord(value: unknown): value is Record<string, un
|
|
|
37584
37310
|
* ```
|
|
37585
37311
|
*/
|
|
37586
37312
|
declare function escapeRegExp(value: string): string;
|
|
37587
|
-
/**
|
|
37588
|
-
* Merges an `AutocompleteContribution` or `AutocompleteConfig` into the resolved autocomplete state, returning whether any entry changed.
|
|
37589
|
-
*
|
|
37590
|
-
* @param config - The resolved engine config (or a subset with the `autocomplete` field) to mutate.
|
|
37591
|
-
* @param contribution - The autocomplete entries to merge in.
|
|
37592
|
-
* @returns `true` if any selector, shortcut, property, CSS property, or pattern entry was added or extended.
|
|
37593
|
-
*
|
|
37594
|
-
* @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.
|
|
37595
|
-
*
|
|
37596
|
-
* @example
|
|
37597
|
-
* ```ts
|
|
37598
|
-
* const changed = appendAutocomplete(resolvedConfig, {
|
|
37599
|
-
* selectors: 'dark',
|
|
37600
|
-
* cssProperties: { color: 'primary' },
|
|
37601
|
-
* })
|
|
37602
|
-
* ```
|
|
37603
|
-
*/
|
|
37604
|
-
declare function appendAutocomplete(config: Pick<ResolvedEngineConfig, 'autocomplete'>, contribution: AutocompleteContribution | AutocompleteConfig): boolean;
|
|
37605
37313
|
/**
|
|
37606
37314
|
* Serializes a `CSSStyleBlocks` tree into a CSS string, optionally formatted with indentation and newlines.
|
|
37607
37315
|
*
|
|
@@ -37630,13 +37338,18 @@ declare function renderCSSStyleBlocks(blocks: CSSStyleBlocks, isFormatted: boole
|
|
|
37630
37338
|
* @param config - The engine configuration object.
|
|
37631
37339
|
* @returns The same configuration object, unchanged.
|
|
37632
37340
|
*
|
|
37633
|
-
* @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.*`.
|
|
37634
37342
|
*
|
|
37635
37343
|
* @example
|
|
37636
37344
|
* ```ts
|
|
37637
|
-
*
|
|
37345
|
+
* import { defineEngineConfig } from '@pikacss/core'
|
|
37346
|
+
*
|
|
37347
|
+
* const engineConfig = defineEngineConfig({
|
|
37348
|
+
* prefix: 'pk-',
|
|
37349
|
+
* plugins: [],
|
|
37350
|
+
* })
|
|
37638
37351
|
* ```
|
|
37639
37352
|
*/
|
|
37640
37353
|
declare function defineEngineConfig<const T extends EngineConfig>(config: T): T;
|
|
37641
37354
|
//#endregion
|
|
37642
|
-
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 };
|