@unocss/autocomplete 0.55.1 → 0.55.3

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 CHANGED
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  const core = require('@unocss/core');
6
4
  const lruCache = require('lru-cache');
7
5
  const fzf = require('fzf');
@@ -216,6 +214,9 @@ function createAutocomplete(uno, options = {}) {
216
214
  templates,
217
215
  cache,
218
216
  reset,
217
+ /**
218
+ * Enumerate possible suggestions from 'aa' - 'zz'
219
+ */
219
220
  enumerate
220
221
  };
221
222
  async function enumerate() {
@@ -0,0 +1,48 @@
1
+ import { SuggestResult, AutoCompleteFunction, UnoGenerator } from '@unocss/core';
2
+ import { LRUCache } from 'lru-cache';
3
+
4
+ type AutoCompleteMatchType = 'prefix' | 'fuzzy';
5
+ interface AutocompleteOptions {
6
+ matchType?: AutoCompleteMatchType;
7
+ }
8
+ type AutocompleteTemplatePart = AutocompleteTemplateStatic | AutocompleteTemplateGroup | AutocompleteTemplateTheme;
9
+ interface AutocompleteTemplateStatic {
10
+ type: 'static';
11
+ value: string;
12
+ }
13
+ interface AutocompleteTemplateGroup {
14
+ type: 'group';
15
+ values: string[];
16
+ }
17
+ interface AutocompleteTemplateTheme {
18
+ type: 'theme';
19
+ objects: Record<string, unknown>[];
20
+ }
21
+ interface ParsedAutocompleteTemplate {
22
+ parts: AutocompleteTemplatePart[];
23
+ suggest(input: string, matchType?: AutoCompleteMatchType): string[] | undefined;
24
+ }
25
+ interface UnocssAutocomplete {
26
+ suggest: (input: string, allowsEmptyInput?: boolean) => Promise<string[]>;
27
+ suggestInFile: (content: string, cursor: number) => Promise<SuggestResult>;
28
+ templates: (string | AutoCompleteFunction)[];
29
+ cache: LRUCache<string, string[]>;
30
+ reset: () => void;
31
+ enumerate: () => Promise<Set<string>>;
32
+ }
33
+
34
+ declare function createAutocomplete(uno: UnoGenerator, options?: AutocompleteOptions): UnocssAutocomplete;
35
+
36
+ declare const shorthands: Record<string, string>;
37
+ declare const ignoredThemeKeys: string[];
38
+ declare function parseAutocomplete(template: string, theme?: any, extraShorthands?: Record<string, string>): ParsedAutocompleteTemplate;
39
+
40
+ declare function searchUsageBoundary(line: string, index: number): {
41
+ content: string;
42
+ start: number;
43
+ end: number;
44
+ };
45
+ declare function searchAttrKey(content: string, cursor: number): string | undefined;
46
+ declare function cartesian<T>(arr: T[][]): T[][];
47
+
48
+ export { type AutoCompleteMatchType, type AutocompleteOptions, type AutocompleteTemplateGroup, type AutocompleteTemplatePart, type AutocompleteTemplateStatic, type AutocompleteTemplateTheme, type ParsedAutocompleteTemplate, type UnocssAutocomplete, cartesian, createAutocomplete, ignoredThemeKeys, parseAutocomplete, searchAttrKey, searchUsageBoundary, shorthands };
@@ -0,0 +1,48 @@
1
+ import { SuggestResult, AutoCompleteFunction, UnoGenerator } from '@unocss/core';
2
+ import { LRUCache } from 'lru-cache';
3
+
4
+ type AutoCompleteMatchType = 'prefix' | 'fuzzy';
5
+ interface AutocompleteOptions {
6
+ matchType?: AutoCompleteMatchType;
7
+ }
8
+ type AutocompleteTemplatePart = AutocompleteTemplateStatic | AutocompleteTemplateGroup | AutocompleteTemplateTheme;
9
+ interface AutocompleteTemplateStatic {
10
+ type: 'static';
11
+ value: string;
12
+ }
13
+ interface AutocompleteTemplateGroup {
14
+ type: 'group';
15
+ values: string[];
16
+ }
17
+ interface AutocompleteTemplateTheme {
18
+ type: 'theme';
19
+ objects: Record<string, unknown>[];
20
+ }
21
+ interface ParsedAutocompleteTemplate {
22
+ parts: AutocompleteTemplatePart[];
23
+ suggest(input: string, matchType?: AutoCompleteMatchType): string[] | undefined;
24
+ }
25
+ interface UnocssAutocomplete {
26
+ suggest: (input: string, allowsEmptyInput?: boolean) => Promise<string[]>;
27
+ suggestInFile: (content: string, cursor: number) => Promise<SuggestResult>;
28
+ templates: (string | AutoCompleteFunction)[];
29
+ cache: LRUCache<string, string[]>;
30
+ reset: () => void;
31
+ enumerate: () => Promise<Set<string>>;
32
+ }
33
+
34
+ declare function createAutocomplete(uno: UnoGenerator, options?: AutocompleteOptions): UnocssAutocomplete;
35
+
36
+ declare const shorthands: Record<string, string>;
37
+ declare const ignoredThemeKeys: string[];
38
+ declare function parseAutocomplete(template: string, theme?: any, extraShorthands?: Record<string, string>): ParsedAutocompleteTemplate;
39
+
40
+ declare function searchUsageBoundary(line: string, index: number): {
41
+ content: string;
42
+ start: number;
43
+ end: number;
44
+ };
45
+ declare function searchAttrKey(content: string, cursor: number): string | undefined;
46
+ declare function cartesian<T>(arr: T[][]): T[][];
47
+
48
+ export { type AutoCompleteMatchType, type AutocompleteOptions, type AutocompleteTemplateGroup, type AutocompleteTemplatePart, type AutocompleteTemplateStatic, type AutocompleteTemplateTheme, type ParsedAutocompleteTemplate, type UnocssAutocomplete, cartesian, createAutocomplete, ignoredThemeKeys, parseAutocomplete, searchAttrKey, searchUsageBoundary, shorthands };
package/dist/index.d.ts CHANGED
@@ -45,4 +45,4 @@ declare function searchUsageBoundary(line: string, index: number): {
45
45
  declare function searchAttrKey(content: string, cursor: number): string | undefined;
46
46
  declare function cartesian<T>(arr: T[][]): T[][];
47
47
 
48
- export { AutoCompleteMatchType, AutocompleteOptions, AutocompleteTemplateGroup, AutocompleteTemplatePart, AutocompleteTemplateStatic, AutocompleteTemplateTheme, ParsedAutocompleteTemplate, UnocssAutocomplete, cartesian, createAutocomplete, ignoredThemeKeys, parseAutocomplete, searchAttrKey, searchUsageBoundary, shorthands };
48
+ export { type AutoCompleteMatchType, type AutocompleteOptions, type AutocompleteTemplateGroup, type AutocompleteTemplatePart, type AutocompleteTemplateStatic, type AutocompleteTemplateTheme, type ParsedAutocompleteTemplate, type UnocssAutocomplete, cartesian, createAutocomplete, ignoredThemeKeys, parseAutocomplete, searchAttrKey, searchUsageBoundary, shorthands };
package/dist/index.mjs CHANGED
@@ -212,6 +212,9 @@ function createAutocomplete(uno, options = {}) {
212
212
  templates,
213
213
  cache,
214
214
  reset,
215
+ /**
216
+ * Enumerate possible suggestions from 'aa' - 'zz'
217
+ */
215
218
  enumerate
216
219
  };
217
220
  async function enumerate() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unocss/autocomplete",
3
- "version": "0.55.1",
3
+ "version": "0.55.3",
4
4
  "description": "Autocomplete utils for UnoCSS",
5
5
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",
@@ -37,7 +37,7 @@
37
37
  "lru-cache": "^10.0.1"
38
38
  },
39
39
  "devDependencies": {
40
- "@unocss/core": "0.55.1"
40
+ "@unocss/core": "0.55.3"
41
41
  },
42
42
  "scripts": {
43
43
  "build": "unbuild",