@unocss/core 0.29.6 → 0.30.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +7 -3
- package/dist/index.d.ts +67 -6
- package/dist/index.mjs +7 -3
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -332,6 +332,10 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
332
332
|
config.theme || {}
|
|
333
333
|
].reduce((a, p) => mergeDeep(a, p), {}));
|
|
334
334
|
mergePresets("extendTheme").forEach((extendTheme) => extendTheme(theme));
|
|
335
|
+
const autocomplete = {
|
|
336
|
+
templates: uniq(sortedPresets.map((p) => toArray(p.autocomplete?.templates)).flat()),
|
|
337
|
+
extractors: sortedPresets.map((p) => toArray(p.autocomplete?.extractors)).flat().sort((a, b) => (a.order || 0) - (b.order || 0))
|
|
338
|
+
};
|
|
335
339
|
return {
|
|
336
340
|
mergeSelectors: true,
|
|
337
341
|
warn: true,
|
|
@@ -350,14 +354,14 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
350
354
|
preprocess: mergePresets("preprocess"),
|
|
351
355
|
postprocess: mergePresets("postprocess"),
|
|
352
356
|
preflights: mergePresets("preflights"),
|
|
353
|
-
autocomplete
|
|
357
|
+
autocomplete,
|
|
354
358
|
variants: mergePresets("variants").map(normalizeVariant),
|
|
355
359
|
shortcuts: resolveShortcuts(mergePresets("shortcuts")),
|
|
356
360
|
extractors
|
|
357
361
|
};
|
|
358
362
|
}
|
|
359
363
|
|
|
360
|
-
const version = "0.
|
|
364
|
+
const version = "0.30.2";
|
|
361
365
|
|
|
362
366
|
class UnoGenerator {
|
|
363
367
|
constructor(userConfig = {}, defaults = {}) {
|
|
@@ -443,7 +447,7 @@ class UnoGenerator {
|
|
|
443
447
|
}
|
|
444
448
|
this._cache.set(cacheKey, null);
|
|
445
449
|
}
|
|
446
|
-
async generate(input, {
|
|
450
|
+
async generate(input = "", {
|
|
447
451
|
id,
|
|
448
452
|
scope,
|
|
449
453
|
preflights = true,
|
package/dist/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ declare class UnoGenerator {
|
|
|
14
14
|
applyExtractors(code: string, id?: string, set?: Set<string>): Promise<Set<string>>;
|
|
15
15
|
makeContext(raw: string, applied: VariantMatchedResult): RuleContext<{}>;
|
|
16
16
|
parseToken(raw: string, alias?: string): Promise<StringifiedUtil[] | null | undefined>;
|
|
17
|
-
generate(input
|
|
17
|
+
generate(input?: string | Set<string>, { id, scope, preflights, safelist, minify, }?: GenerateOptions): Promise<GenerateResult>;
|
|
18
18
|
matchVariants(raw: string, current?: string): VariantMatchedResult;
|
|
19
19
|
applyVariants(parsed: ParsedUtil, variantHandlers?: VariantHandler[], raw?: string): UtilObject;
|
|
20
20
|
constructCustomCSS(context: Readonly<RuleContext>, body: CSSObject | CSSEntries, overrideSelector?: string): string;
|
|
@@ -356,12 +356,69 @@ interface ConfigBase<Theme extends {} = {}> {
|
|
|
356
356
|
*/
|
|
357
357
|
extendTheme?: Arrayable<ThemeExtender<Theme>>;
|
|
358
358
|
/**
|
|
359
|
-
*
|
|
360
|
-
*/
|
|
361
|
-
autocomplete?:
|
|
359
|
+
* Addtional options for auto complete
|
|
360
|
+
*/
|
|
361
|
+
autocomplete?: {
|
|
362
|
+
/**
|
|
363
|
+
* Custom functions / templates to provide autocomplete suggestions
|
|
364
|
+
*/
|
|
365
|
+
templates?: Arrayable<AutoCompleteFunction | AutoCompleteTemplate>;
|
|
366
|
+
/**
|
|
367
|
+
* Custom extractors to pickup possible classes and
|
|
368
|
+
* transform class-name style suggestions to the correct format
|
|
369
|
+
*/
|
|
370
|
+
extractors?: Arrayable<AutoCompleteExtractor>;
|
|
371
|
+
};
|
|
362
372
|
}
|
|
363
373
|
declare type AutoCompleteTemplate = string;
|
|
364
374
|
declare type AutoCompleteFunction = (input: string) => Awaitable<string[]>;
|
|
375
|
+
interface AutoCompleteExtractorContext {
|
|
376
|
+
content: string;
|
|
377
|
+
cursor: number;
|
|
378
|
+
}
|
|
379
|
+
interface Replacement {
|
|
380
|
+
/**
|
|
381
|
+
* The range of the original text
|
|
382
|
+
*/
|
|
383
|
+
start: number;
|
|
384
|
+
end: number;
|
|
385
|
+
/**
|
|
386
|
+
* The text used to replace
|
|
387
|
+
*/
|
|
388
|
+
replacement: string;
|
|
389
|
+
}
|
|
390
|
+
interface SuggestResult {
|
|
391
|
+
/**
|
|
392
|
+
* The generated suggestions
|
|
393
|
+
*
|
|
394
|
+
* `[original, formatted]`
|
|
395
|
+
*/
|
|
396
|
+
suggestions: [string, string][];
|
|
397
|
+
/**
|
|
398
|
+
* The function to convert the selected suggestion back.
|
|
399
|
+
* Needs to pass in the original one.
|
|
400
|
+
*/
|
|
401
|
+
resolveReplacement: (suggestion: string) => Replacement;
|
|
402
|
+
}
|
|
403
|
+
interface AutoCompleteExtractorResult {
|
|
404
|
+
/**
|
|
405
|
+
* The extracted string
|
|
406
|
+
*/
|
|
407
|
+
extracted: string;
|
|
408
|
+
/**
|
|
409
|
+
* The function to convert the selected suggestion back
|
|
410
|
+
*/
|
|
411
|
+
resolveReplacement: (suggestion: string) => Replacement;
|
|
412
|
+
/**
|
|
413
|
+
* The function to format suggestions
|
|
414
|
+
*/
|
|
415
|
+
transformSuggestions?: (suggestions: string[]) => string[];
|
|
416
|
+
}
|
|
417
|
+
interface AutoCompleteExtractor {
|
|
418
|
+
name: string;
|
|
419
|
+
extract: (context: AutoCompleteExtractorContext) => Awaitable<AutoCompleteExtractorResult | null>;
|
|
420
|
+
order?: number;
|
|
421
|
+
}
|
|
365
422
|
interface Preset<Theme extends {} = {}> extends ConfigBase<Theme> {
|
|
366
423
|
name: string;
|
|
367
424
|
enforce?: 'pre' | 'post';
|
|
@@ -481,7 +538,7 @@ interface UserConfig<Theme extends {} = {}> extends ConfigBase<Theme>, UserOnlyO
|
|
|
481
538
|
}
|
|
482
539
|
interface UserConfigDefaults<Theme extends {} = {}> extends ConfigBase<Theme>, UserOnlyOptions<Theme> {
|
|
483
540
|
}
|
|
484
|
-
interface ResolvedConfig extends Omit<RequiredByKey<UserConfig, 'mergeSelectors' | 'theme' | 'rules' | 'variants' | 'layers' | 'extractors' | 'blocklist' | 'safelist' | 'preflights' | 'sortLayers'>, 'rules' | 'shortcuts'> {
|
|
541
|
+
interface ResolvedConfig extends Omit<RequiredByKey<UserConfig, 'mergeSelectors' | 'theme' | 'rules' | 'variants' | 'layers' | 'extractors' | 'blocklist' | 'safelist' | 'preflights' | 'sortLayers'>, 'rules' | 'shortcuts' | 'autocomplete'> {
|
|
485
542
|
shortcuts: Shortcut[];
|
|
486
543
|
variants: VariantObject[];
|
|
487
544
|
preprocess: Preprocessor[];
|
|
@@ -489,6 +546,10 @@ interface ResolvedConfig extends Omit<RequiredByKey<UserConfig, 'mergeSelectors'
|
|
|
489
546
|
rulesSize: number;
|
|
490
547
|
rulesDynamic: (DynamicRule | undefined)[];
|
|
491
548
|
rulesStaticMap: Record<string, [number, CSSObject | CSSEntries, RuleMeta | undefined] | undefined>;
|
|
549
|
+
autocomplete: {
|
|
550
|
+
templates: (AutoCompleteFunction | AutoCompleteTemplate)[];
|
|
551
|
+
extractors: AutoCompleteExtractor[];
|
|
552
|
+
};
|
|
492
553
|
}
|
|
493
554
|
interface GenerateResult {
|
|
494
555
|
css: string;
|
|
@@ -559,4 +620,4 @@ declare const extractorSplit: Extractor;
|
|
|
559
620
|
|
|
560
621
|
declare const extractorSvelte: Extractor;
|
|
561
622
|
|
|
562
|
-
export { ArgumentType, Arrayable, AutoCompleteFunction, AutoCompleteTemplate, Awaitable, BetterMap, BlocklistRule, CONTROL_SHORTCUT_NO_MERGE, CSSColorValue, CSSEntries, CSSObject, CSSValues, ConfigBase, DeepPartial, DynamicMatcher, DynamicRule, DynamicShortcut, DynamicShortcutMatcher, Extractor, ExtractorContext, FilterPattern, FlatObjectTuple, GenerateOptions, GenerateResult, GeneratorOptions, ParsedColorValue, ParsedUtil, PartialByKeys, PluginOptions, Postprocessor, Preflight, PreflightContext, Preprocessor, Preset, PresetOptions, RGBAColorValue, RawUtil, RequiredByKey, ResolvedConfig, RestArgs, Rule, RuleContext, RuleMeta, Shift, Shortcut, SourceCodeTransformer, SourceMap, StaticRule, StaticShortcut, StaticShortcutMap, StringifiedUtil, ThemeExtender, TransformResult, TwoKeyMap, UnoGenerator, UnocssPluginContext, UserConfig, UserConfigDefaults, UserOnlyOptions, UserShortcuts, UtilObject, ValueHandler, ValueHandlerCallback, Variant, VariantContext, VariantFunction, VariantHandler, VariantMatchedResult, VariantObject, attributifyRE, clearIdenticalEntries, clone, createGenerator, createValueHandler, e, entriesToCss, escapeRegExp, escapeSelector, expandVariantGroup, extractorSplit, extractorSvelte, hasScopePlaceholder, isAttributifySelector, isObject, isRawUtil, isStaticRule, isStaticShortcut, isValidSelector, mergeDeep, mergeSet, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull, regexClassGroup, regexScopePlaceholder, toArray, uniq, validateFilterRE, warnOnce, withLayer };
|
|
623
|
+
export { ArgumentType, Arrayable, AutoCompleteExtractor, AutoCompleteExtractorContext, AutoCompleteExtractorResult, AutoCompleteFunction, AutoCompleteTemplate, Awaitable, BetterMap, BlocklistRule, CONTROL_SHORTCUT_NO_MERGE, CSSColorValue, CSSEntries, CSSObject, CSSValues, ConfigBase, DeepPartial, DynamicMatcher, DynamicRule, DynamicShortcut, DynamicShortcutMatcher, Extractor, ExtractorContext, FilterPattern, FlatObjectTuple, GenerateOptions, GenerateResult, GeneratorOptions, ParsedColorValue, ParsedUtil, PartialByKeys, PluginOptions, Postprocessor, Preflight, PreflightContext, Preprocessor, Preset, PresetOptions, RGBAColorValue, RawUtil, Replacement, RequiredByKey, ResolvedConfig, RestArgs, Rule, RuleContext, RuleMeta, Shift, Shortcut, SourceCodeTransformer, SourceMap, StaticRule, StaticShortcut, StaticShortcutMap, StringifiedUtil, SuggestResult, ThemeExtender, TransformResult, TwoKeyMap, UnoGenerator, UnocssPluginContext, UserConfig, UserConfigDefaults, UserOnlyOptions, UserShortcuts, UtilObject, ValueHandler, ValueHandlerCallback, Variant, VariantContext, VariantFunction, VariantHandler, VariantMatchedResult, VariantObject, attributifyRE, clearIdenticalEntries, clone, createGenerator, createValueHandler, e, entriesToCss, escapeRegExp, escapeSelector, expandVariantGroup, extractorSplit, extractorSvelte, hasScopePlaceholder, isAttributifySelector, isObject, isRawUtil, isStaticRule, isStaticShortcut, isValidSelector, mergeDeep, mergeSet, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull, regexClassGroup, regexScopePlaceholder, toArray, uniq, validateFilterRE, warnOnce, withLayer };
|
package/dist/index.mjs
CHANGED
|
@@ -328,6 +328,10 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
328
328
|
config.theme || {}
|
|
329
329
|
].reduce((a, p) => mergeDeep(a, p), {}));
|
|
330
330
|
mergePresets("extendTheme").forEach((extendTheme) => extendTheme(theme));
|
|
331
|
+
const autocomplete = {
|
|
332
|
+
templates: uniq(sortedPresets.map((p) => toArray(p.autocomplete?.templates)).flat()),
|
|
333
|
+
extractors: sortedPresets.map((p) => toArray(p.autocomplete?.extractors)).flat().sort((a, b) => (a.order || 0) - (b.order || 0))
|
|
334
|
+
};
|
|
331
335
|
return {
|
|
332
336
|
mergeSelectors: true,
|
|
333
337
|
warn: true,
|
|
@@ -346,14 +350,14 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
346
350
|
preprocess: mergePresets("preprocess"),
|
|
347
351
|
postprocess: mergePresets("postprocess"),
|
|
348
352
|
preflights: mergePresets("preflights"),
|
|
349
|
-
autocomplete
|
|
353
|
+
autocomplete,
|
|
350
354
|
variants: mergePresets("variants").map(normalizeVariant),
|
|
351
355
|
shortcuts: resolveShortcuts(mergePresets("shortcuts")),
|
|
352
356
|
extractors
|
|
353
357
|
};
|
|
354
358
|
}
|
|
355
359
|
|
|
356
|
-
const version = "0.
|
|
360
|
+
const version = "0.30.2";
|
|
357
361
|
|
|
358
362
|
class UnoGenerator {
|
|
359
363
|
constructor(userConfig = {}, defaults = {}) {
|
|
@@ -439,7 +443,7 @@ class UnoGenerator {
|
|
|
439
443
|
}
|
|
440
444
|
this._cache.set(cacheKey, null);
|
|
441
445
|
}
|
|
442
|
-
async generate(input, {
|
|
446
|
+
async generate(input = "", {
|
|
443
447
|
id,
|
|
444
448
|
scope,
|
|
445
449
|
preflights = true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.30.2",
|
|
4
4
|
"description": "The instant on-demand Atomic CSS engine.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"unocss",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"sideEffects": false,
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"magic-string": "^0.26.1",
|
|
41
|
-
"unconfig": "^0.3.
|
|
41
|
+
"unconfig": "^0.3.2"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"build": "unbuild",
|